I have found a couple of possible bugs in the x11 versions of OpenGL/GLUT but wanted to get some feedback here before I send a bug report.
- GLUT_ALPHA is not available when calling glutInitDisplayMode
- a call to glClear(GL_STENCIL_BUFFER_BIT) while glDepthMask is set to GL_FALSE clears the depth buffer (see bottom for sample code)
Perhaps these are not really bugs and my understanding of OpenGL/GLUT/x11 is lacking. However, these issues do not exist for the aqua versions of OpenGL/GLUT so there is, at the very least, inconsistencies.
Does anybody else experience this? Am I misunderstanding something?
Cheers,
Glenn Tsang.
Sample Code:
you’ll need something like this:
glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
core test code:
<your image class> imgDepth(IMAGE_WIDTH, IMAGE_HEIGHT);
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glBegin(GL_TRIANGLES);
glVertex3f(0, 0, 0);
glVertex3f(1, 0, 0);
glVertex3f(0, 1, 0);
glEnd();
glReadPixels(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, GL_DEPTH_COMPONENT,
GL_UNSIGNED_BYTE, imgDepth.pixel);
imgDepth.Save(“test1.pgm”);
glDepthMask(GL_FALSE);
glClear(GL_STENCIL_BUFFER_BIT); // Clears depth buffer when depth mask false!
glDepthMask(GL_TRUE);
glReadPixels(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, GL_DEPTH_COMPONENT,
GL_UNSIGNED_BYTE, imgDepth.pixel);
imgDepth.Save("test2.pg