I just compile Allegro 4.2.1 and AllegroGL 0.4.1 with mingw32 3.4.2. I'm using MSVC8 so I built them with the "fix msvc8" command. I built a debug version as well. Instead of generating agl.lib and agld.lib, it generated agl_s.lib and agld_s.lib. (static?) Anyway, I linked to those libraries and I tried running this example provided with AllegroGL.
| 1 | #include <allegro.h> |
| 2 | #include <alleggl.h> |
| 3 | |
| 4 | int main() { |
| 5 | |
| 6 | /* Initialize both Allegro and AllegroGL */ |
| 7 | allegro_init(); |
| 8 | install_allegro_gl(); |
| 9 | |
| 10 | /* Tell Allegro we want to use the keyboard */ |
| 11 | install_keyboard(); |
| 12 | |
| 13 | /* Suggest a good screen mode for OpenGL */ |
| 14 | allegro_gl_set(AGL_Z_DEPTH, 8); |
| 15 | allegro_gl_set(AGL_COLOR_DEPTH, 16); |
| 16 | allegro_gl_set(AGL_SUGGEST, AGL_Z_DEPTH | AGL_COLOR_DEPTH); |
| 17 | |
| 18 | /* Set the graphics mode */ |
| 19 | set_gfx_mode(GFX_OPENGL_WINDOWED, 640, 480, 0, 0); |
| 20 | |
| 21 | /* Clear the screen */ |
| 22 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 23 | |
| 24 | /* Set up the view frustum */ |
| 25 | glMatrixMode(GL_MODELVIEW); |
| 26 | glLoadIdentity(); |
| 27 | glFrustum(-1.0, 1.0, -1.0, 1.0, 1, 60.0); |
| 28 | |
| 29 | /* Draw a quad using OpenGL */ |
| 30 | glBegin(GL_QUADS); |
| 31 | glColor3ub(255, 255, 255); |
| 32 | glVertex3f(-1, -1, -2); |
| 33 | glVertex3f( 1, -1, -2); |
| 34 | glVertex3f( 1, 1, -2); |
| 35 | glVertex3f(-1, 1, -2); |
| 36 | glEnd(); |
| 37 | |
| 38 | /* Flip the backbuffer on screen */ |
| 39 | allegro_gl_flip(); |
| 40 | |
| 41 | /* Wait for the user to press a key */ |
| 42 | readkey(); |
| 43 | |
| 44 | /* Finished. */ |
| 45 | return 0; |
| 46 | } |
| 47 | END_OF_MAIN() |
The application crashed when calling allegro_gl_flip(); I stepped into it and it goes there
void allegro_gl_flip(void) { __allegro_gl_driver->flip(); }
where __allegro_gl_driver is NULL.
Any ideas?
Thanks!
Check all return values of functions that can fail. One of them is failing, but you're assuming they don't.
As you said, this call fails.
install_allegro_gl();
It actually fails right from the start.
int install_allegro_gl(void) { if (!system_driver) return -1; // ...
Why is that?
Do you have the latest OpenGL drivers installed on your machine?
I think I have OpenGL driver Version 6.14.10.6347 that comes with my graphic card drivers. I don't think it is the latest but it should not be that old either. Should I get the latest?
Can you give us some details on your graphic card? Some gfx cards have no or poor OpenGL drivers. It is normally always a good idea to update to the latest drivers to improve poor ones..
Sophat: I'd say that allegro_init(); also failed.
I have a All-In-Wonder Radeon 9800 128MB.
Milan : Why would you say that ?
By the way, I can run the examples built with AllegroGL.
Because "system_driver" is a allegro variable initialized at allegro_init().
Strange that examples work.
Have you had any older version of allegrogl installed before? Maybe something is left and there are conflicts... just guessing.
It is the first time I've built AllegroGL myself.
Also when I stepped into allegro_init();
"system_driver" was definitely and allegro_init() returns 0.
From my watch window :
system_driver 0x100d0de0 _system_directx {id=1146626080 name=0x100eb698 "" desc=0x100eb698 "" ...} SYSTEM_DRIVER *
I am getting very confuse.
Thanks for any inputs.
Hm, I used to see that when symbols from DLL where not imported correctly... But I can't see anything wrong here.
You can try building AllegroGL using MSVC8 project files. It's in projects/ directory.
edit: You are using Allegro as a DLL, right?
Solved. You were right. I remove alld.lib from the dependencies.
Thanks a lot for your help and patience