Sign in to follow this  

FBO+DEPTH_STENCIL+81.xx = trouble?

This topic is 4301 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

Hello, I'm trying to setup a FBO with a texture2d color, depth and stencil attachments. This is the source code I use for FBO setup:
GLuint fb, rtt, depth_stencil_rb;
glGenFramebuffersEXT(1,&fb);
glGenTextures(1,&rtt);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fb);
glBindTexture(GL_TEXTURE_2D,rtt); 

glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,t->GetWidth(),t->GetHeight(),0,GL_RGBA,GL_UNSIGNED_BYTE,NULL);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
		glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,rtt,0);

glGenRenderbuffersEXT(1,&depth_stencil_rb); 
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT,depth_stencil_rb); 
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,0x84F9/*GL_DEPTH_STENCIL_EXT*/,t->GetWidth(),t->GetHeight());
 
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT,depth_stencil_rb);	
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_STENCIL_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT,depth_stencil_rb); 

glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);		glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
This code seems to work because it passes the checkFBOStatus test. However, when I'm trying to use the stencil, it doesn't seems to work properly. I try to readback the contents in the depth_stencil buffer with:
 glReadPixels(0,0,t->GetWidth(),t->GetHeight(),0x84F9/*GL_DEPTH_STENCIL_EXT*/,0x84FA/*GL_UNSIGNED_INT_24_8_EXT*/, pixels);
after setting the stencil value with:
 glClearStencil(8);
glClear(GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
But it I allways get the same data in the pixels array: 0, don't matter to what value I clean the depth_stencil buffer. Is there any problem in my code? Any one of you have some source code of a depth_stencil FBO working? (or only a stencil FBO at least). Thanks in advance.

Share this post


Link to post
Share on other sites

This topic is 4301 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this