[AllegroGL] allegro_gl_flip() error

Started by
7 comments, last by CursedTyrant 17 years, 9 months ago
allegro_gl_flip() just doesn't work for me (it generates a standard Windows XP error). I have Allegro 4.20 and AllegroGL 0.4.0 RC4. Whenever I comment it out, I get a new taskbar item, but no window appears anyway. allegro_gl_flip() crashes every time, be it a window or fullscreen.
Advertisement
Please post some code.
I don't think the problem is there because of the called function.
Taken from a tutorial at http://echellon.hybd.net/issues/6/articles/agl-a/agl04.html
#include <allegro.h>#include <alleggl.h>void Init(){    allegro_init();    install_allegro_gl();    install_keyboard();    allegro_gl_set(AGL_DOUBLEBUFFER, true);    allegro_gl_set(AGL_SUGGEST, AGL_DOUBLEBUFFER);        set_gfx_mode(GFX_OPENGL_WINDOWED, 640, 480, 0, 0);         glClearColor(0.0, 0.0, 0.0, 0.0);}int main(){    Init();        glClear(GL_COLOR_BUFFER_BIT);    glBegin(GL_TRIANGLES);        glColor3f(1.0, 1.0, 0.5);        glVertex2f(0.0, 0.1);        glVertex2f(0.0, 0.6);        glVertex2f(-0.5, 0.1);    glEnd();        glBegin(GL_QUADS);        glColor3f(0.0, 0.0, 0.4);        glVertex2f(0.0, 0.6);        glVertex2f(0.0, 0.0);        glVertex2f(0.1, 0.0);        glVertex2f(0.1, 0.6);    glEnd();        glBegin(GL_POLYGON);        glColor3f(0.0, 0.0, 0.8);        glVertex2f(-0.5, -0.2);        glVertex2f(0.0, -0.3);        glVertex2f(0.5, -0.2);        glVertex2f(0.6, 0.0);        glVertex2f(-0.6, 0.0);    glEnd();    glFlush();    allegro_gl_flip();                readkey();       return 0;}END_OF_MAIN();

Either the tutorial is wrong (unlikely), or the problem *does* lie in that particular function (or some bizarre conflict between Allegro and AllegroGL). I compiled Allegro and AllegGL myself, and Allegro works just fine.
Did you build AllegroGL against the same version of Allegro? If, for instance, you are using AllegroGL compiled against Allegro 4.2.0, it may not work with Allegro 4.2.1.
Yes, I compiled Allegro and then AllegroGL. I did not compile anything else in the meantime.
You should besides the clearing of the color buffer also clear the depth buffer when rendering 3d objects.
Just put glClear(GL_DEPTH_BUFFER_BIT); before any glBegin call.

EDIT: And you should check the return value of set_gfx_mode()
Ok, I had to put set_color_depth() before set_gfx_mode()... I wasn't aware it had to be done in AllegGL, and I've got no idea why isn't it included in the tutorial, but I'm just glad it's working properly.
I am glad it works for you now, but I have another suggestion. I never saw set_color_depth() in a AllegroGL application. It is normally done with

allegro_gl_set(AGL_COLOR_DEPTH, 16);
allegro_gl_set(AGL_SUGGEST, AGL_COLOR_DEPTH);

in your case

allegro_gl_set(AGL_DOUBLEBUFFER, true);
allegro_gl_set(AGL_COLOR_DEPTH, 16);
allegro_gl_set(AGL_SUGGEST, AGL_DOUBLEBUFFER | AGL_COLOR_DEPTH);

Does this construct work for you?
Yes, it works fine. Thanks for the tip.

This topic is closed to new replies.

Advertisement