|
Having problems setting up Allegro. |
PamperBoy
Member #15,477
January 2014
|
Hi as the title says, im having trouble setting up allegro. I used code from a tutorial to check if allegro worked on my pc. As you can see he has made an error box if it didnt work. So it says "Error Could not initialize allegro 5". I copy-pasted all the files in the correct folders Does anyone know how to fix this? ____________________________________________________________________________ 1#include<allegro5/allegro.h>
2#include<allegro5/allegro_native_dialog.h>
3#include<allegro5/allegro_primitives.h>
4
5#define ScreenWidth 800
6#define ScreenHeight 600
7
8int main()
9{
10 ALLEGRO_DISPLAY *display;
11
12 if(al_init())
13 {
14 al_show_native_message_box(NULL, NULL, "Error", "Could not initialize Allegro 5", NULL, ALLEGRO_MESSAGEBOX_ERROR);
15 return -1;
16 }
17 display = al_create_display(ScreenWidth, ScreenHeight);
18
19 if(!display)
20 {
21 al_show_native_message_box(NULL, NULL, "Error", "Could not create Allegro 5 display", NULL, ALLEGRO_MESSAGEBOX_ERROR);
22 return -1;
23 }
24
25 // Drawing *not important for you guys*
26 al_set_new_display_flags(ALLEGRO_NOFRAME);
27 al_set_window_position(display, 200, 100);
28 al_set_window_title(display, "CodingMadeEasy");
29
30 ALLEGRO_COLOR electricBlue = al_map_rgb(44, 117, 255);
31
32 float points[8] = { 0, 0, 400, 100, 50, 200, ScreenWidth, ScreenHeight };
33
34 al_draw_triangle(10, 10, 20, 10, 25, 50, al_map_rgb(255, 0, 0), 1.0);
35 //al_draw_filled_triangle(10, 10, 20, 10, 25, 50, al_map_rgb(255, 0, 0), 1.0);
36
37 al_draw_rounded_rectangle(10, 10, 100, 100, 5, 5, al_map_rgb(0, 255, 0), 3);
38 //al_draw_filled_rounded_rectangle(10, 10, 100, 100, 5, 5, al_map_rgb(0, 255, 0), 3);
39
40 al_draw_rectangle(400, 400, 450, 500, al_map_rgb(255, 98, 100), 9.0);
41 //al_draw_filled_rectangle(400, 400, 450, 500, al_map_rgb(255, 98, 100), 9.0);
42
43 al_draw_circle(ScreenWidth / 2, ScreenHeight / 2, 10, al_map_rgb(255, 255, 0), 3.0);
44 //al_draw_filled_circle(ScreenWidth / 2, ScreenHeight / 2, 10, al_map_rgb(255, 255, 0), 3.0);
45
46 al_draw_ellipse(ScreenWidth / 2, ScreenHeight - 100, 10, 5, al_map_rgb(255, 0, 255), 4.0);
47 //al_draw_filled_ellipse(ScreenWidth / 2, ScreenHeight - 100, 10, 5, al_map_rgb(255, 0, 255), 4.0);
48
49 al_draw_arc(10, ScreenHeight - 100, 10, 0, 4.0, al_map_rgb(255, 0, 0), 2.0);
50
51 al_draw_line(100, 500, 300, 500, electricBlue, 6.0);
52
53 al_draw_pixel(500, 500, electricBlue);
54
55 al_draw_spline(points, electricBlue, 1.0);
56
57 al_flip_display();
58 al_rest(5.0);
59 al_destroy_display(display);
60
61 return 0;
62}
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
PamperBoy said:
al_show_native_message_box(NULL, NULL, "Error", "Could not initialize Allegro 5", NULL, ALLEGRO_MESSAGEBOX_ERROR); return -1; }
al_init is a wrapper for al_install_system, and al_install_system returns true if it was successful. So it is working, but your check condition is backwards. 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 |
PamperBoy
Member #15,477
January 2014
|
How do you mean backwards? Somehow it's working on his screen. (also im a beginner) can you tell me what to do? sry |
l j
Member #10,584
January 2009
|
PamperBoy
Member #15,477
January 2014
|
aah thx! But now i get this!:-/ 'Game.exe': Loaded 'D:\Game Assignment\Game\Debug\Game.exe', Symbols loaded. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
PamperBoy said: Cannot find or open the PDB file You can safely ignore this. It just means it couldn't find any debugging symbols for that library. Quote: Exit code 3 Not sure what this is from. The code you posted above never returns 3 for a value. Do you have other code you're compiling that you didn't show us? PamperBoy said:
display = al_create_display(ScreenWidth, ScreenHeight); if(!display) { al_show_native_message_box(NULL, NULL, "Error", "Could not create Allegro 5 display", NULL, ALLEGRO_MESSAGEBOX_ERROR); return -1; } // Drawing *not important for you guys*
You need to call al_set_new_display_flags before you create your display. Or it won't affect anything. 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 |
|