Ok, so I have AllegroGL installed and working with GCC, I use
gcc in.cpp -mwindows -O2 -Wall -oout.exe -lagl -lalleg -luser32 -lgdi32 -lopengl32 -lglu32
To compile the examples, and they all work... but when I try to compile:
1 | #include <allegro.h> |
2 | #include <alleggl.h> |
3 | |
4 | volatile int Time = 0; |
5 | void TimerFunc() |
6 | { |
7 | Time++; |
8 | } |
9 | END_OF_FUNCTION(TimerFunc); |
10 | |
11 | void Init() |
12 | { |
13 | allegro_init(); |
14 | install_allegro_gl(); |
15 | install_keyboard(); |
16 | install_timer(); |
17 | |
18 | set_gfx_mode(GFX_OPENGL_WINDOWED, 640, 480, 0, 0); |
19 | |
20 | glClearColor(0.0, 0.0, 0.0, 0.0); |
21 | } |
22 | |
23 | int main() |
24 | { |
25 | Init(); |
26 | |
27 | float x = 0.0, y = 0.5; |
28 | |
29 | LOCK_VARIABLE(Time); |
30 | LOCK_FUNCTION(TimerFunc); |
31 | |
32 | install_int_ex(TimerFunc, BPS_TO_TIMER(60)); |
33 | |
34 | while(!key[KEY_ESC]) |
35 | { |
36 | while(Time > 0) |
37 | { |
38 | poll_keyboard(); |
39 | if(key[KEY_UP]) y += 0.01; |
40 | if(key[KEY_DOWN]) y -= 0.01; |
41 | if(key[KEY_RIGHT]) x += 0.01; |
42 | if(key[KEY_LEFT]) x -= 0.01; |
43 | |
44 | glClear(GL_COLOR_BUFFER_BIT); |
45 | glBegin(GL_LINES); |
46 | glColor3f(1.0, 0.0, 0.0); |
47 | glVertex2f(0.0, 0.0); |
48 | glVertex2f(x, y); |
49 | glColor3f(0.0, 1.0, 0.0); |
50 | glVertex2f(0.0, 0.0); |
51 | glVertex2f(-x, y); |
52 | glColor3f(0.0, 0.0, 1.0); |
53 | glVertex2f(0.0, 0.0); |
54 | glVertex2f(x, -y); |
55 | glColor3f(0.0, 1.0, 1.0); |
56 | glVertex2f(0.0, 0.0); |
57 | glVertex2f(-x, -y); |
58 | glEnd(); |
59 | glFlush(); |
60 | |
61 | Time--; |
62 | } |
63 | } |
64 | |
65 | return 0; |
66 | } |
67 | END_OF_MAIN(); |
I get an exe file that doesn't do anything except wait for me to press ESC -- I don't even get a blank window that pops up -- I tried
GFX_OPENGL_WINDOWED
GFX_OPENGL_FULLSCREEN
and just plain
GFX_OPENGL
none of them work :-(
Is there something the author screwed up on? -- none of the tutorials in his series (this is like #3) work for me -- they all just run and wait for me press esc or another key (some of the examples just exit on keypress) and then they quit.
The examples are here: Some old pixelate article?
Any ideas?
Edit: Here's another one that doesn't work: (No window even opens up or anything.)
1 | #include <allegro.h> |
2 | #include <alleggl.h> |
3 | |
4 | void Init() |
5 | { |
6 | allegro_init(); |
7 | install_allegro_gl(); |
8 | install_keyboard(); |
9 | |
10 | set_gfx_mode(GFX_OPENGL_WINDOWED, 640, 480, 0, 0); |
11 | |
12 | glClearColor(0.0, 0.0, 0.0, 0.0); |
13 | } |
14 | |
15 | int main() |
16 | { |
17 | Init(); |
18 | glClear(GL_COLOR_BUFFER_BIT); |
19 | readkey(); |
20 | |
21 | return 0; |
22 | } |
23 | END_OF_MAIN(); |
---------------------------------------
edit:
OK, so I dug into one of the example files, and changed the demo to do this:
1 | #include <allegro.h> |
2 | #include <alleggl.h> |
3 | |
4 | int Width = 640; |
5 | int Height = 480; |
6 | int BPP = 32; |
7 | int FullScreen = false; |
8 | |
9 | |
10 | volatile int Time = 0; |
11 | void TimerFunc() |
12 | { |
13 | Time++; |
14 | } |
15 | END_OF_FUNCTION(TimerFunc); |
16 | |
17 | int ChangeVideoMode(int width, int height, int bpp, int fullscreen) |
18 | { |
19 | allegro_gl_clear_settings(); |
20 | allegro_gl_set (AGL_COLOR_DEPTH, bpp); |
21 | allegro_gl_set (AGL_Z_DEPTH, 24); |
22 | allegro_gl_set (AGL_FULLSCREEN, fullscreen); |
23 | allegro_gl_set (AGL_DOUBLEBUFFER, 1); |
24 | |
25 | int suggest = AGL_COLOR_DEPTH | AGL_Z_DEPTH | AGL_DOUBLEBUFFER; |
26 | if (fullscreen) |
27 | { suggest |= AGL_FULLSCREEN; } |
28 | |
29 | allegro_gl_set (AGL_SUGGEST, suggest); |
30 | |
31 | int driver = GFX_OPENGL_WINDOWED; |
32 | if (fullscreen){driver = GFX_OPENGL_FULLSCREEN;} |
33 | |
34 | int r = set_gfx_mode(driver, width, height, 0, 0); |
35 | if (r) |
36 | { |
37 | allegro_message ("Error setting OpenGL graphics mode:\n%s\n" |
38 | "Allegro GL error : %s\n", |
39 | allegro_error, allegro_gl_error); |
40 | } |
41 | return r; |
42 | } |
43 | |
44 | |
45 | int Init() |
46 | { |
47 | allegro_init(); |
48 | install_allegro_gl(); |
49 | install_keyboard(); |
50 | install_timer(); |
51 | |
52 | if (ChangeVideoMode(Width, Height, BPP, FullScreen)) |
53 | { return 1; } |
54 | |
55 | glClearColor(0.0, 0.0, 0.0, 0.0); |
56 | |
57 | return 0; |
58 | } |
59 | |
60 | int main() |
61 | { |
62 | int r=Init(); |
63 | if (r){return r;} |
64 | |
65 | float x = 0.0, y = 0.5, z = -1; |
66 | float rot = 0; |
67 | |
68 | LOCK_VARIABLE(Time); |
69 | LOCK_FUNCTION(TimerFunc); |
70 | |
71 | install_int_ex(TimerFunc, BPS_TO_TIMER(60)); |
72 | |
73 | int Quitting=false; |
74 | while(!Quitting) |
75 | { |
76 | if (key[KEY_ESC]){Quitting=true;} |
77 | if (key[KEY_F10]) |
78 | { |
79 | FullScreen = !FullScreen; |
80 | if (ChangeVideoMode(Width, Height, BPP, FullScreen)) |
81 | { return 1; } |
82 | |
83 | while(key[KEY_F10]); |
84 | Time = 0; |
85 | } |
86 | |
87 | int skip=0; |
88 | int max_skip = 5; |
89 | |
90 | while(Time > 0) |
91 | { |
92 | if(key[KEY_UP]) y += 0.01; |
93 | if(key[KEY_DOWN]) y -= 0.01; |
94 | if(key[KEY_RIGHT]) x += 0.01; |
95 | if(key[KEY_LEFT]) x -= 0.01; |
96 | |
97 | if ((key[KEY_LSHIFT]) || (key[KEY_RSHIFT])) |
98 | { |
99 | if(key[KEY_MINUS_PAD]) z-=.01; |
100 | if(key[KEY_PLUS_PAD]) z+=.01; |
101 | } |
102 | else |
103 | { |
104 | if(key[KEY_MINUS_PAD]) rot-=1; |
105 | if(key[KEY_PLUS_PAD]) rot+=1; |
106 | } |
107 | |
108 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
109 | |
110 | glLoadIdentity(); |
111 | glRotatef(rot, 1, 0, 0); |
112 | |
113 | glBegin(GL_LINES); |
114 | glColor3f(1.0, 0.0, 0.0); |
115 | glVertex3f(0.0, 0.0, 0.0); |
116 | glVertex3f(x, y, z); |
117 | glColor3f(0.0, 1.0, 0.0); |
118 | glVertex3f(0.0, 0.0, 0.0); |
119 | glVertex3f(-x, y, z); |
120 | glColor3f(0.0, 0.0, 1.0); |
121 | glVertex3f(0.0, 0.0, 0.0); |
122 | glVertex3f(x, -y, z); |
123 | glColor3f(0.0, 1.0, 1.0); |
124 | glVertex3f(0.0, 0.0, 0.0); |
125 | glVertex3f(-x, -y, z); |
126 | glEnd(); |
127 | glFlush(); |
128 | allegro_gl_flip(); |
129 | |
130 | Time--; |
131 | skip++; |
132 | if (skip>=max_skip){Time=0;} |
133 | } |
134 | } |
135 | |
136 | return 0; |
137 | } |
138 | END_OF_MAIN(); |
it works now.