I've been working on my first OpenGL project, I decided to implement it through Allegro 5.0.1 for the compiler MinGW 4.7.0. Currently I'm using TDM-GCC 4.7.1.
Well, the project consists on a simple 3D drawing library that is more like a wrapper for OpenGL.
The code I use to initialize OpenGL is.
flags = ALLEGRO_WINDOWED | ALLEGRO_OPENGL_3_0 | ALLEGRO_OPENGL; //allegro flags
Then to setup the projection matrix.
And the last one is for renderin, right now it's called every time after or before drawing.
I created a function for testing, it shows a textured quad on the given position and also can handle some rotation.
The problem is that when I try to apply depth testing the polygons still overlap. I could you tell me the right way to set it?
The depth buffer has to be requested before creating a display. Simply put this before al_create_display:
al_set_new_display_option(ALLEGRO_DEPTH_SIZE, 16, ALLEGRO_SUGGEST);
Thanks Elias, could you tell me when is it right to call glEnable(GL_DEPTH_TEST)? Because I want to know the "right" way.
Just once in the beginning. Unless you need to draw some things without depth test, then you will have to call glEnable/glDisable every time you need it enabled/disabled for drawing.