|
Allegro 5 Audio Playing Vorbis errors. |
Lone_Templar
Member #15,396
November 2013
|
I recently tried following CodingMadeEasy's tutorials, and after getting to the sound effect tutorial, this is what I have. 1#include<allegro5\allegro.h>
2#include<allegro5\allegro_native_dialog.h>
3#include<allegro5\allegro_image.h>
4#include<allegro5\allegro_audio.h>
5#include<allegro5\allegro_acodec.h>
6
7#define ScreenWidth 800
8#define ScreenHeight 600
9
10int main()
11{
12 ALLEGRO_DISPLAY *display;
13
14 enum Direction { DOWN, LEFT, RIGHT, UP };
15
16 const float FPS = 60.0;
17
18 if(!al_init())
19 al_show_native_message_box(display, "Error", "File Error", "Could not Initialize Allegro", NULL, ALLEGRO_MESSAGEBOX_ERROR);
20
21 display = al_create_display(ScreenWidth, ScreenHeight);
22
23 if(!display)
24 al_show_native_message_box(display, "Error", "Unknown Error!", "Could not create Allegro Display", NULL, ALLEGRO_MESSAGEBOX_ERROR);
25
26 al_set_window_position(display, 200, 200);
27
28 bool done = false, draw = true, active = false;
29 float x = 10, y = 10, moveSpeed = 5;
30 int dir = DOWN, sourceX = 32, sourceY = 0;
31
32 al_install_keyboard();
33 al_install_audio();
34 al_init_acodec_addon();
35 al_init_image_addon();
36
37 ALLEGRO_BITMAP *player = al_load_bitmap("monsterk.png");
38
39 ALLEGRO_KEYBOARD_STATE keyState;
40
41 ALLEGRO_SAMPLE *sample = al_load_sample( "you_got_it_1.wav ");
42
43 al_reserve_samples(1);
44
45 ALLEGRO_TIMER *timer = al_create_timer(1.0 / FPS);
46 ALLEGRO_EVENT_QUEUE *event_queue = al_create_event_queue();
47 al_register_event_source(event_queue, al_get_timer_event_source(timer));
48 al_register_event_source(event_queue, al_get_display_event_source(display));
49 al_register_event_source(event_queue, al_get_keyboard_event_source());
50
51 al_start_timer(timer);
52
53 while(!done)
54 {
55 ALLEGRO_EVENT events;
56 al_wait_for_event(event_queue, &events);
57 al_get_keyboard_state(&keyState);
58
59 if(events.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
60 {
61 done = true;
62 }
63 else if (events.type == ALLEGRO_EVENT_TIMER)
64 {
65 active = true;
66 if(al_key_down(&keyState, ALLEGRO_KEY_DOWN))
67 {
68 y += moveSpeed;
69 dir = DOWN;
70 al_play_sample(sample, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
71 }
72 else if(al_key_down(&keyState, ALLEGRO_KEY_UP))
73 {
74 y -= moveSpeed;
75 dir = UP;
76 }
77 else if(al_key_down(&keyState, ALLEGRO_KEY_RIGHT))
78 {
79 x += moveSpeed;
80 dir = RIGHT;
81 }
82 else if(al_key_down(&keyState, ALLEGRO_KEY_LEFT))
83 {
84 x -= moveSpeed;
85 dir = LEFT;
86 }
87 else
88 active = false;
89
90 if(active)
91 sourceX += al_get_bitmap_width(player) / 3;
92 else
93 sourceX = 32;
94
95 if(sourceX >= al_get_bitmap_width(player))
96 sourceX = 0;
97
98 sourceY = dir;
99
100 draw = true;
101 }
102
103 if(draw)
104 {
105 al_draw_bitmap_region(player, sourceX, sourceY * al_get_bitmap_height(player) / 3.9, 32, 32,
106 x, y, NULL);
107 al_flip_display();
108 al_clear_to_color(al_map_rgb(0, 0, 0));
109 }
110 }
111 al_destroy_display(display);
112 al_destroy_timer(timer);
113 al_destroy_sample(sample);
114 al_destroy_bitmap(player);
115 al_destroy_event_queue(event_queue);
116
117 return 0;
118}
I get 50 errors from this code. All of them begin with 'vorbis_'. Why do these errors appear, and how do I resolve them? I use CodeBlocks. I also tried the code from the allegro wiki audio tutorial, with the same results. Sorry in advance for any newb errors in the code. Hehe. |
pkrcel
Member #14,001
February 2012
|
Post your errors please. It is unlikely that Google shares your distaste for capitalism. - Derezo |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Gonna make a wild guess and say you used ogg but you didn't link ogg and vorbis during the linking stage. Also, post your errors. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Lone_Templar
Member #15,396
November 2013
|
Sorry about that. Here. C:\MinGW\lib\libvorbisfile-1.3.2-static-md.a(vorbisfile.o):vorbisfile.c|| undefined reference to `vorbis_packet_blocksize'| Sorry for the wall of text. |
pkrcel
Member #14,001
February 2012
|
Edgar was right, you didn't tell the linker to link vorbis. EDIT: that meaning libvorbis since you're using GCC, you should add the library under linker's options It is unlikely that Google shares your distaste for capitalism. - Derezo |
Lone_Templar
Member #15,396
November 2013
|
So how do I do that? EDIT: Ok, saw your edit. But it appears that I have linked it? I have static linked all the files that were stated on the CodeBlocks Allegro tutorial. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Somehow you're mixing versions of libvorbis. They're getting in each other's way. Your versions of libvorbis are different than the ones the precompiled binary libvorbis is using. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Lone_Templar
Member #15,396
November 2013
|
Ah, you're right. I checked the tutorial one more time, and linked the ONLY the shown files, I got lazy and just linked any files that had 'static' written in it. But I now get the following errors: C:\MinGW\lib\liballegro_dialog-5.0.10-static-mt.a(win_dialog.o):win_dialog.c|| undefined reference to `GetSaveFileNameA@4'| I have a feeling that I made a similar mistake. I didn't get these errors before, when I had linked every static link file. EDIT: WHY DO I HAVE A LACK OF CORRECT READING OF ENGLISH... I put the libraries in the wrong order. |
|