This document describes many such pitfalls and offers explanations or work-arounds.
glBitmap() and
glDrawPixels() calls will have no effect.
Solution; extend the viewport beyond the window bounds or use glBitmap() with an NULL bitmap and your desired delta X,Y movement from the current, valid raster position. Be sure to restore the viewport to a normal position before rendering other primitives.
The following function will set the raster position to an arbitrary window coordinate:
void window_pos( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
{
GLfloat fx, fy;
/* Push current matrix mode and viewport attributes */
glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
/* Setup projection parameters */
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
glDepthRange( z, z );
glViewport( (int) x - 1, (int) y - 1, 2, 2 );
/* set the raster (window) position */
fx = x - (int) x;
fy = y - (int) y;
glRasterPos4f( fx, fy, 0.0, w );
/* restore matrices, viewport and matrix mode */
glPopMatrix();
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glPopAttrib();
}
glXWaitX before the glViewport call to be
sure the X server has actually resized the window before
glViewport is called.
glClearIndexi(0) doesn't clear
the window to black.
glEnable(GL_DEPTH_TEST) and depth
testing still isn't happening be sure that you've requested a
visual (GLX) or pixel format (WGL) which has a depth buffer.
This is done by specifying the GLX_DEPTH_SIZE parameter to
glxChooseVisual() or specifying a non-zero
cDepthBits value in the PIXELFORMATDESCRIPTOR
structure passed to ChoosePixelFormat().