Jump to content
  • Advertisement
Sign in to follow this  

Selective GL_DEPTH_TEST question

This topic is 3996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have a depth buffer question: In my code I render the follwing list:
m_List = glGenLists(1);
glNewList(m_List, GL_COMPILE);

    glPushMatrix();

    glDisable(GL_DEPTH_TEST);

    glBindTexture(GL_TEXTURE_2D, m_unTextures[9]);
    glEnable(GL_TEXTURE_2D);
			
    glEnable(GL_BLEND);
    glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);

    glCallList(List2);

    glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
    glBindTexture(GL_TEXTURE_2D, m_unTextures[10]);

    glCallList(List3);

    glEnable(GL_DEPTH_TEST);
    
    glDisable(GL_BLEND);
    glDisable(GL_TEXTURE_2D);

    glPopMatrix();
  
endlist()

The code masks a part of the texture and shows another part. And becasue of the disabling of the depth test all sides of the textured lists are viewable. But because of the disabling of the depth test when I render a textured quad ontop of the m_list list it blends with the texture of the quad. My question is: is there a way that I can use the disabling of the depth test for m_List but when I place an object over m_List it is rendered behind the object?

Share this post


Link to post
Share on other sites
Advertisement
You have to draw your "normal" geometry first. Then sort all faces you want to draw that way back to front, disable the depth mask ( glDepthMask(GL_FALSE) ) and render the sortet faces. So you get the effect you want.

Share this post


Link to post
Share on other sites
Thanks for the reply, Ingrader.

So, if I nderstand correctly I have to do the following pseudo-code:


void RenderScene()
{
// Draw all objects that do have or require depth test.
DrawAllNormalObjects();

// Sort all objects that do require dept test
// from back to front.
SortAllOtherObjects();

glDepthMask(GL_FALSE);

// Render the sorted faces with depth test disabled
DrawAllOtherObjects();
}




Do I need to enable the depth mask again at any time?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!