Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Clearing alpha channel + depth buffer

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 thecoast47   Members   

255
Like
0Likes
Like

Posted 30 November 2011 - 01:57 AM

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.

#2 gdmarkou   Members   

333
Like
1Likes
Like

Posted 30 November 2011 - 03:02 AM

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






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.