pouët.net

Go to bottom

Need help with FBO: Depth Texture makes the Color Texture become all blank!

category: code [glöplog]
 
So, heres the situation, my fbo works very well when i only render the color texture, but when i try to render both a depth texture the color texture, the color texture goes all white, so what should i do? Heres the code:

[core]
// Color Texture
glGenTextures(1,texture);
glBindTexture(GL_TEXTURE_2D,*texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, def.Width, def.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D,0);


// Depth Texture
glGenTextures(1,depth);
glBindTexture(GL_TEXTURE_2D, *depth);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, def.Width, def.Height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
glBindTexture(GL_TEXTURE_2D,0);


// Framebuffer
glGenFramebuffersEXT(1,fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,*fbo);

glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, *texture, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, *depth, 0); // <- WHEN I BIND THE DEPTH TEXTURE THE COLOR TEXTURE BECAMES BLANK, ALL WHITE! (also: The depth texture doen't work!)

glBindFramebufferEXT(GL_FRAMEBUFFER,0);

if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
MessageBox(0,"Looks like we are having problems with Post Processing...","Did it work?!",MB_OK);
[/code]

What should i do? Remembering everything works well without the function i pointed above in the code! And don't blame me for asking for help, already tried google, after 31 websites i gave up...

(ps: This is OPENGL 2.0, not 3.0)
fail [ code ] tag is fail...
And in your rendering loop, after glBindFramebuffer(), you do a glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);? Could be that you don't clear the depth so it doesn't render anything.
added on the 2012-06-22 22:25:52 by msqrt msqrt
did you configure your depth buffer?
do you have it enabled?
did you initiate your depth probably?
could you try different fbo for depth?
added on the 2012-06-22 22:29:02 by panic panic
Thank you msqrt, i was only cleaning the Color buffer, it's now working perfectly :D

Also: Thanks panic for those questions, next time something happens i will try asking myself to see if i can detect the error :D

login

Go to top