Skip to main content
GameDev.net gamedev.net
🔒 Locked

Framebuffer Objects with Stencil on Nvidia Drivers

Started by big4ared Oct 13, 2005 at 9:14 PM 0 replies 850+ views
Original Post
big4ared
big4ared
Hi, longtime listener, first time caller . . . I noticed that some of you have had trouble with getting stencil renderbuffers to work with FBOs on nvidia cards. Here's a solution: use GL_DEPTH_STENCIL_NV. I wrote the following code. Feel free to try it with your drivers version. I ran it with the newest beta drivers. As we all know, desperate times call for desperate measures: char pb[256]; glGenRenderbuffersEXT( 1, &ulStencilBuffer ); glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, ulStencilBuffer ); FILE* fout; fout = fopen( "fb_valid.txt", "w" ); int i; GLenum en; en = glGetError(); for( i = 0; i < 256*256; i++ ) { glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, i, lWidth, lHeight ); en = glGetError(); if( en == GL_NO_ERROR ) { fprintf( fout, "i: %x\n", i ); } } fclose( fout ); The output I got was i: 1 i: 2 i: 3 i: 4 i: 1902 <-- depth component i: 1907 <-- RGB, etc. i: 1908 i: 2a10 i: 804f i: 8050 i: 8051 i: 8052 i: 8053 i: 8054 i: 8055 i: 8056 i: 8057 i: 8058 i: 8059 i: 805a i: 805b i: 81a5 i: 81a6 i: 81a7 i: 84f9 <--- GL_DEPTH_STENCIL_NV i: 8814 <--- mmmmm, apples i: 8815 i: 881a i: 881b i: 88f0 <----- what is this value and below? Can't find them anywhere i: 8c40 i: 8c41 i: 8c42 i: 8c43 i: 8c44 i: 8c45 i: 8c46 i: 8c47 First, what's the deal with those 0x8cxx values? I can't find them in any header files. Second, GL_STENCIL_INDEXzz_EXT are nowhere to be found. Third, the only one that I could find was GL_DEPTH_STENCIL_NV, so let's ride that pony. I tried creating an FBO with a color, depth, and stencil, but that failed. It also didn't work generating stencil-only. BUT, it does work if you enable both depth and stencil on the same GL_DEPTH_STENCIL_NV texture. So here's what you do: 1. When creating a texture, do: glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_NV, ulWidth, ulHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); 2. When setting up the fbo, go with this for the same ulTexId: glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, ulTexId, 0 ); glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, ulTexId, 0 ); Best of luck. Maybe someday GL_STENCIL_INDEX8_EXT will work, but I won't bet on it.
Code-R
Code-R
thank you thank you thank you thank you.
period.
(rating++)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.