Hello, I have been trying to search around the internet for info or tutorials on OpenGL 3.0, but every tutorial I've found requires extra libraries. I figured that with Allegro 5, I can completely skip GLUT altogether. Unfortunately, I haven't been able to get even a simple blue window to pop up.
Could anybody help me out with this?
initGL() needs to be called after the display is successfully created.
I tried it and had to comment out the "#include <GL/gl3.h>" line to get it to compile, and got this error:
/home/prog/allegro-5.0.5/src/opengl/extensions.c:190: print_extensions: Assertion `extension' failed. Aborted
glxinfo said this:
GLX version: 1.4 OpenGL version string: 3.3.0 NVIDIA 270.41.19
All the relevant examples supplied with the library work properly.
I tried putting initGL() after the display initialization, but it still made no difference. The screen is still black
Oh, looks like you forgot to use ALLEGRO_OPENGL when creating the display. To use a forward compatible OpenGL 3 display, you have to pass, e.g.:
al_set_new_display_flags(ALLEGRO_OPENGL_3_0 | ALLEGRO_OPENGL_FORWARD_COMPATIBLE | ALLEGRO_OPENGL);
If you're on Windows, it will still use the DirectX backend if you don't request to use an OpenGL one. Without ALLEGRO_OPENGL, the other two options are ignored.
Thanks for the feedback so far.
Arthur, I used the gl3.h header from the OpenGL Registry (versus the regular gl.h), although I don't know if there are any extra steps I needed to take after including it.
Arron, after I included the ALLEGRO_OPENGL flag, the program now crashes when creating a window. I have an Nvidia gtx260, so I know it's OpenGL 3.x compatible, but I have no idea why it crashes now.
I'll keep playing with the program though. Maybe there's just an extra line I haven't included just yet.
EDIT:
I GOT IT!!!
The problem was where I had the line al_get_new_display_flag() placed after the display initialized. I instead had to change it to al_get_display_flag(display). I feel so stupid right now.
I also had to remove the flag ALLEGRO_OPENGL_FORWARD_COMPATIBLE to get it running.
Anyway here's the final initialization code (just in case anyone else runs into these problems):