PDA

View Full Version : Depth testing in OpenGL 3.3



JoshKlint
10-19-2010, 09:01 AM
Did anything change to get depth testing to work in GL 3.3? Do I have to specify the depth output in the fragment shader?

I have this code for creating the graphics context:

int iAttributes[] =
{
WGL_DRAW_TO_WINDOW_ARB,GL_TRUE,
WGL_SUPPORT_OPENGL_ARB,GL_TRUE,
WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB,
WGL_COLOR_BITS_ARB,24,
WGL_ALPHA_BITS_ARB,8,
WGL_DEPTH_BITS_ARB,24,
WGL_STENCIL_BITS_ARB,8,
WGL_DOUBLE_BUFFER_ARB,GL_TRUE,
WGL_SAMPLE_BUFFERS_ARB,GL_FALSE,
0,0
};
wglChoosePixelFormatARB(hdc,iAttributes,fAttribute s,1,&ipixelformat,&countformats);
And before I render 3D objects I do this;

glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
The projection matrix is calculated using a range of (0.1,100). I also tried adding a call to glDepthRange(near,far), to no avail.

So I am not sure why my triangles are just appearing in order. No depth testing appears to be occurring.

--EDIT--

glDepthRange() DID fix the problem, but stupid Microsoft Visual Studio got the build out of sync and was running old code. I'll leave this up for the benefit of anyone who does a search for this problem.