PDA

View Full Version : FBO and depth/stencil help



Olivier B.
05-14-2007, 03:31 AM
Hi,

I've made a research on previous topics but I don't find a solution to my problem. I put this code to init my depth/stencil texture :

// Depth stencil texture initialisation
glGenTextures(1, &tmpCG->idDepthStencil);
glBindTexture(GL_TEXTURE_RECTANGLE_NV, tmpCG->idDepthStencil);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_RECTANGLE_NV, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_DEPTH24_STENCIL8_EXT, gridInfo.resX, gridInfo.resZ, 0,
GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); After this code I attach this texture to 2 FBOs :


glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, targetType, idTex, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, targetType, idTex, 0); I check for OpenGL error -> no problem
I check my FBOs -> COMPLETE

In my render loop I put that before drawing in my FBO using a Shader


glClear(GL_STENCIL_BUFFER_BIT);

glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); My fragment program does'nt make anything particular (just put a color in gl_FragColor for debug). So, my stencil buffer must have 1 value in every pixels but using Image Debug I see that value is 0. I don't understand why its doesn't work.

PS : My graphics card is a NV Quadro 3450/4000 SDI with ForceWare 91.36

Nighthawk
05-14-2007, 08:00 AM
Hi,

FBOs do not support Stencil Attachments was the last thing i read:
http://www.gamedev.net/reference/articles/article2331.asp

Or has this been fixed in the meantime?

Olivier B.
05-14-2007, 08:11 AM
Thanks for your reply Nighthawk but normally with this extension packed_depth_stencil (http://oss.sgi.com/projects/ogl-sample/registry/EXT/packed_depth_stencil.txt)
you can achieve stencil test on FBO by using the same texture for depth and stencil buffers