Witam jak w temacie. Visual nie widzi mojego pliku z muzyką pomimo tego że znajduje się on w folderze z projektem. Czy błąd leży gdzieś w kodzie? Oto najwazniejsza część odpowiadająca za muzykę.
#include<iostream>
#include<allegro5\allegro_native_dialog.h>
#include<allegro5\allegro_primitives.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include"header.h"
int main(){
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_SAMPLE *mainmusic= NULL;
bool done= false;
bool redraw = true;
bool gameover = false;
if(!al_init()) return -1;
al_get_display_mode(al_get_num_display_modes()-1,&disp_mode);
if(!(display=al_create_display(disp_mode.width,disp_mode.height))){
al_show_native_message_box(NULL,NULL,NULL,"BLAD AL_CREATE_DISPLAY",NULL,ALLEGRO_MESSAGEBOX_ERROR);
return -2;
}
al_init_image_addon();
al_init_primitives_addon();
al_install_keyboard();
al_install_audio();
al_init_acodec_addon();
al_reserve_samples(1);
if(!al_install_audio()){
fprintf(stderr, "failed to initialize audio!\n");
system("pause");
return -1;
}
if(!al_init_acodec_addon()){
fprintf(stderr, "failed to initialize audio codecs!\n");
system("pause");
return -1;}
ALLEGRO_TIMER *timer=al_create_timer(1.0/60);
ALLEGRO_EVENT_QUEUE *ev_queue=al_create_event_queue();
al_register_event_source(ev_queue,al_get_keyboard_event_source());
al_register_event_source(ev_queue,al_get_timer_event_source(timer));
al_register_event_source(ev_queue,al_get_display_event_source(display));
mainmusic=al_load_sample( "Spacemusic.ogg" );
if (!mainmusic){
printf( "Audio clip sample not loaded!\n" ); // ta petla wskazuje blad
return -1;}
al_start_timer(timer);
while(!done){
ALLEGRO_EVENT event;
al_wait_for_event(ev_queue,&event);
if(event.type==ALLEGRO_EVENT_TIMER){
}
}
if(redraw && al_is_event_queue_empty(ev_queue)){
redraw=false;
if(!gameover){
al_play_sample(mainmusic, 1.0, 0.0,1.0,ALLEGRO_PLAYMODE_LOOP,NULL);
al_clear_to_color(al_map_rgb(0,0,0));
}
else
{
}
al_flip_display();
al_clear_to_color(al_map_rgb(0,0,0));
}
}
al_destroy_sample(mainmusic);
al_destroy_display(display);
return 0;