| 1 | #include <allegro.h> |
| 2 | #include <alleggl.h> |
| 3 | |
| 4 | |
| 5 | void Init() |
| 6 | { |
| 7 | allegro_init(); |
| 8 | install_allegro_gl(); |
| 9 | install_keyboard(); |
| 10 | |
| 11 | set_gfx_mode(GFX_OPENGL_WINDOWED, 640, 480, 0, 0); |
| 12 | |
| 13 | glClearColor(0.0, 0.0, 0.0, 0.0); |
| 14 | } |
| 15 | |
| 16 | int main() |
| 17 | { |
| 18 | Init(); |
| 19 | glClear(GL_COLOR_BUFFER_BIT); |
| 20 | readkey(); |
| 21 | |
| 22 | return 0; |
| 23 | } |
| 24 | END_OF_MAIN(); |
The code is supposed to make a blank window but the window doesn't show up. 
P.S. I installed the latest dev-paks for Allegro and AllegroGL.
Heh I bet I know what tutorial you're getting that from. You need to call the allegro_gl_flip() function (no parameters) to flip the buffer onto the screen.
I added flip after the "glClear" in main()
now it comes up with an error
AppName: allegro gl.exe AppVer: 0.0.0.0 ModName: allegro gl.exe
ModVer: 0.0.0.0 Offset: 00002fc5
edit: I tried compiling another example:
| 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(); |
And the window still won't show up. I think it has something to do with the dev-paks I installed >.< Ima try to compile the libraries from scratch.
Oh well, I wasn't sure if just the flip would work. This should:
| 1 | #include <allegro.h> |
| 2 | #include <alleggl.h> |
| 3 | |
| 4 | |
| 5 | void Init() |
| 6 | { |
| 7 | allegro_init(); |
| 8 | install_allegro_gl(); |
| 9 | install_keyboard(); |
| 10 | |
| 11 | allegro_gl_clear_settings(); |
| 12 | allegro_gl_set(AGL_COLOR_DEPTH, 16); |
| 13 | allegro_gl_set(AGL_Z_DEPTH, 8); |
| 14 | allegro_gl_set(AGL_WINDOWED, TRUE); |
| 15 | allegro_gl_set(AGL_DOUBLEBUFFER, 1); |
| 16 | allegro_gl_set(AGL_RENDERMETHOD, 1); |
| 17 | allegro_gl_set(AGL_SUGGEST, AGL_COLOR_DEPTH | |
| 18 | AGL_DOUBLEBUFFER | AGL_RENDERMETHOD | |
| 19 | AGL_Z_DEPTH | AGL_WINDOWED); |
| 20 | |
| 21 | set_gfx_mode(GFX_OPENGL, 640, 480, 0, 0); |
| 22 | |
| 23 | glClearColor(0.0, 0.0, 0.0, 0.0); |
| 24 | } |
| 25 | |
| 26 | int main() |
| 27 | { |
| 28 | Init(); |
| 29 | glClear(GL_COLOR_BUFFER_BIT); |
| 30 | allegro_gl_flip(); |
| 31 | while (!key[KEY_ESC]); |
| 32 | |
| 33 | return 0; |
| 34 | } |
| 35 | END_OF_MAIN(); |
bows ty
It works now.