OpenGL forward compatible context initialization
Tim Spain

Salutations!

I'm new to Allegro and am trying to use it to create an OpenGL 3+ context. Which works, using the code below:

#SelectExpand
1#include <GL/gl.h> 2#include <allegro5/allegro.h> 3#include <stdio.h> 4#include <stdlib.h> 5 6int main (int argc, char** argv) 7{ 8 if (!al_init()) 9 exit(1); 10 11 al_set_new_display_flags( ALLEGRO_WINDOWED | 12 ALLEGRO_OPENGL | 13 ALLEGRO_NOFRAME ); 14 15 ALLEGRO_DISPLAY* dpy = al_create_display(1, 1); 16 al_set_new_display_flags(0); 17 18 al_set_new_display_flags( ALLEGRO_WINDOWED 19 | ALLEGRO_OPENGL_3_0 20 /*| ALLEGRO_OPENGL_FORWARD_COMPATIBLE*/ ); 21 22 ALLEGRO_DISPLAY* dpy3 = al_create_display(800, 600); 23 24 al_destroy_display(dpy); 25 26 printf("OpenGL version: %s\n", glGetString(GL_VERSION) ); 27 printf("GLSL version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION) ); 28 29 al_destroy_display(dpy3); 30 31 return 0; 32}

This compiles, links and returns:

OpenGL version: 3.0.0 NVIDIA 256.44
GLSL   version: 1.30 NVIDIA via Cg compiler

However, when I try to initialize a forward compatible context by uncommenting ALLEGRO_OPENGL_FORWARD_COMPATIBLE, the program crashes with the output

opengl3.3.exe: /home/tim/ccpp/allegro-4.9.21/src/opengl/extensions.c:153: print_extensions: Assertion `extension' failed.
Aborted

where the assertion is checking for an empty string of OpenGL extensions.

So:

  1. What am I doing wrong? What is the correct way to request a forward compatible context?

  2. Or is it Allegro that is doing something wrong?

Also, I have two other questions that I wouldn't mind an answer to:

  1. Is it necessary to do both the two al_create_display()s? On my installation it crashes if I do not first create the OpenGL 2 context. Is this the expected behaviour for allegro?

  2. How do I request a OpenGL version of, for example, 3.3? The glxinfo output claims to be capable of that.

Speaking of which, I am using Allegro 4.9.21 (from sourceforge 2010-08-17), built with GCC 4.3.3 on Ubuntu 9.4 (Jaunty) with the Nvidia 256.44 drivers.

Any and all answers are greatly appreciated!

Peter Wang

The assertion will be because Allegro internally calls glGetString(GL_EXTENSIONS); which is deprecated in OpenGL 3. So you aren't doing anything wrong, it's a bug. You shouldn't need to create two displays either.

We'll need to think about the API for requesting later OpenGL versions as well.

You're probably the first to try OpenGL 3 support...

Tim Spain

Thanks for the prompt reply, Peter.

It is good to know that I am not doing it wrong... :)

Thread #604906. Printed from Allegro.cc