Depth Testing on MX31

I am not able to enable depth testing on my MX31 device. The same code, seems to work on windows. Here is my code:

	glBindTexture(GL_TEXTURE_2D, texture);

	if( GL_TRUE == glIsEnabled(GL_DEPTH_TEST) )
		fprintf(stdout, "DrawQuad -> DepthTest is enabled");
		glDrawArrays(GL_TRIANGLES, 0, 6);

What are the possible reasons why a glEnable(GL_DEPTH_TEST) would fail? Thanks in advance.

Ok… I got GL_DEPTH_TEST set successfully. I did this by adding a EGL_DEPTH_SIZE in my argument to eglChooseConfig… I have tried with values 1,2,24.

Unfortunately there is a side effect.

When GL_DEPTH_TEST was not setting, ie, when I was not giving EGL_DEPTH_SIZE in my eglChooseConfig , quads were drawing properly, although without proper depth testing.

But now, when I supply an EGL_DEPTH_SIZE, the quads dont draw at all. There is just a black screen.

This is on an MX31 device.
Whats going on here?
What are valid values for EGL_DEPTH_SIZE and how do they affect my application?

Please help!

Depth testing obviously needs a depth buffer, and to get a depth buffer you need to request one. Typical available depth buffer depths are 16 or 24 bits, so with requesting 16 you should be on the safe side.

Do you clear the depth buffer together with the color buffer? What are your vertex coordinates and transformation matrices?

The initialization code has:


The vertices of the background quad are:

int afVertices[] ={0,   480,   100,
	   0,     0,   100, 
	   800, 480,   100,
	   0,	  0,   100,
	   800, 480,   100,
	   800,   0,   100};

I do not clear the depth and color buffer at all. When and why should I do this?

First of all it’s always good to keep the semantic separation between modelview matrix and projection matrix. glOrthox creates a projection matrix and should thus be used with glMatrixMode(GL_PROJECTION) (and glLoadIdentity()).

Then you’re drawing your background quad exactly at the far clip distance with a non-identity transform. This is dangerous as even the smallest rounding error could cause your quad to be just behind the far clip plane and thus being completely clipped.
Why do you need a background quad?

I do not clear the depth and color buffer at all. When and why should I do this?

On many implementations you should clear the color and depth buffer at the start of every frame. This indicates that the old contents of those buffers can be discarded.
Also the depth test doesn’t work correctly if there are still values from previous frames in the depth buffer.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.