Results 1 to 5 of 5

Thread: Depth Testing on MX31

  1. #1

    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:

    Code :
       glEnable(GL_TEXTURE_2D); 
    	glEnable(GL_DEPTH_TEST);
    	glBindTexture(GL_TEXTURE_2D, texture);
     
    	glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
    	glTexParameterx( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    	glEnableClientState(GL_VERTEX_ARRAY);
    	glVertexPointer(3,GL_FIXED,0,afVertices);
    	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    	glTexCoordPointer(2,GL_FLOAT,0,afTexCoord);
    	if( GL_TRUE == glIsEnabled(GL_DEPTH_TEST) )
    	{
       //NEVER ENTERS THIS
    		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.

  2. #2
    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!

  3. #3
    Senior Member
    Join Date
    May 2006
    Posts
    353
    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?
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  4. #4
    The initialization code has:

    Code :
       glViewport(0,0,800,480);
    	glMatrixMode(GL_MODELVIEW);
    	glOrthox(0,800,0,480,100,-100);
    	glEnable(GL_DEPTH_TEST);

    The vertices of the background quad are:

    Code :
    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?

  5. #5
    Senior Member
    Join Date
    May 2006
    Posts
    353
    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.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

Similar Threads

  1. OpenVG and i.MX31
    By birger in forum OpenVG and VGU
    Replies: 1
    Last Post: 05-07-2008, 09:28 AM
  2. glDrawTexiOES z parameter on mx31
    By akhil in forum OpenGL ES general technical discussions
    Replies: 4
    Last Post: 09-26-2007, 11:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •