Jump to content
  • Advertisement
Sign in to follow this  
thecoast47

Clearing alpha channel + depth buffer

This topic is 2576 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 can anyone tell me how to add geometry to the depth buffer but at the same time leave the framebuffer untouched?
Right now Im doing this:

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_NEVER);
for(int K = 0; K < ConvexHull_list.size();K++){
ConvexHull * CH = ConvexHull_list[K];
CH->Render();
}
glDisable(GL_DEPTH_TEST);


Also,how do I reset the alpha channel(to 0) in the framebuffer without disturbing the rest of the values in the framebuffer?
I was going to render a quad with glColor4f(0,0,0,0);
But I dont think doing that by itself clears only the alpha values in the framebuffer.

Share this post


Link to post
Share on other sites
Advertisement
You are looking for glColorMask

Drawing to depth buffer only.
Your code should look like :

glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); //disable write to color-buffer
glDepthMask(GL_TRUE);

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL); // or whatever

//render everything

glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); //enable write to color buffer



For resetting the alpha channel only :

glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); //only write to alpha
glDisable (GL_DEPTH_TEST);
glDepthMask(GL_FALSE);

//Render a full-screen quad with alpha=whatever you want

Share this post


Link to post
Share on other sites
Hidden
Al alternative might be to put a glDrawPixels call into a display list; make sure that you use the same format and layout as your color buffer has and it should go quite fast.

Share this post


Link to post
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!