#164 depth test problem

open
nobody
None
5
2006-07-05
2006-07-05
paengi
No

I had depth problem when i tried to render two
polygons.

The distance of two polygons is short.
The order of two polygons was reversed when they was
rendered along z-axis.

Here is the code and image that should reproduces
this issues.

///////////////////////////////////////////////////

InitOGLES()
{
......

const EGLint configAttribs[] =
{
EGL_DEPTH_SIZE, 16,
EGL_SURFACE_TYPE,
EGL_WINDOW_BIT,
EGL_NONE
};

......

//Enable the depth test in order to see the
cube correctly
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);
glDepthRangef(0.0f, 1.0f);
glClearDepthf(1.0f);

glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);

glShadeModel(GL_FLAT);
......
}

Render()
{
unsigned char index[] = {2, 1, 3, 0};
GLfloat vertices[] = { -5,-5,0, -5,5,0,
5,5,0, 5,-5,0 };

glLoadIdentity();

glRotatef(m_RotationX, 1.0f, 0, 0);
glRotatef(m_RotationZ, 0.0f, 0.0f, 1.0f);
glTranslatef(0.0f, 0.0f, OffsetZ);

glEnableClientState(GL_VERTEX_ARRAY);

glVertexPointer(3, GL_FLOAT, 0, vertices);

glColor4f(1.0f, 0.0f, 0.0f, 0.0f);

glDrawElements(GL_TRIANGLE_STRIP, 4,
GL_UNSIGNED_BYTE, index);

vertices[2] = vertices[5] = vertices[8] =
vertices[11] = -0.01f;

glColor4f(0.0f, 1.0f, 0.0f, 0.0f);
glDrawElements(GL_TRIANGLE_STRIP, 4,
GL_UNSIGNED_BYTE, index);

glDisableClientState(GL_VERTEX_ARRAY);
}

///////////////////////////////////////////////////

Discussion

  • paengi
    paengi
    2006-07-05

    depth bug image

     
    Attachments
  • Logged In: YES
    user_id=618887

    I cannot see what your projection matrix is, but are you sure that a negative z
    coordinate is what you want?

    - HM

     
  • paengi
    paengi
    2006-07-07

    Logged In: YES
    user_id=1550259

    First of all, Thank you for your response.

    Here is .h file. I attach the file.

     
  • paengi
    paengi
    2006-07-07

    Logged In: YES
    user_id=1550259

    First of all, Thank you for your response.

    Here is .h file. I attach the file.

     
  • paengi
    paengi
    2006-07-07

    Sample Code

     
    Attachments
  • Logged In: NO

    We also find the same problem. It is the problem of
    Rasterization.