Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: GL_RENDERBUFFER_STENCIL_SIZE returns 0

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    5

    GL_RENDERBUFFER_STENCIL_SIZE returns 0

    The following code isn't producing the results I expect:

    Code :
      GLuint renderbuffer;
      glGenRenderbuffers(1, &renderbuffer);
      glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
      glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 1, 1);
     
      GLint stencilSize;
      glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_STENCIL_SIZE, &stencilSize);

    The stencil size is reported to be 0. I've checked glGetError() all along the way and no errors are being reported so it's not like it's an unsupported format. And glGetRenderbufferParameteriv with GL_RENDERBUFFER_INTERNAL_FORMAT is returning GL_STENCIL_INDEX8, so the format is being set. Color and depth formats work as expected.

    This happens on my GeForce GTX 670, Windows 7 x64, both with drivers 301.42 and 304.79-BETA, both with and without WGL_CONTEXT_ES2_PROFILE_BIT_EXT.

    It doesn't happen on my iOS simulator (I'm developing for both Windows and iOS right now to ensure I'm not using implementation-specific features). The iOS simulator reports the expected size of 8.

    Am I doing something wrong or is this a bug?

    EDIT:
    The same problem seems to occur with GL_STENCIL_INDEX1, GL_STENCIL_INDEX4, and GL_STENCIL_INDEX16, but not GL_DEPTH24_STENCIL8
    Last edited by jbates; 07-20-2012 at 06:44 PM. Reason: Added more cases which produce supposed bug

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Am I doing something wrong or is this a bug?
    Yes, to both.

    Never use GL_STENCIL_INDEX8. For anything. If you need a stencil buffer, use GL_DEPTH24_STENCIL8. Yes, according to the spec, you should be able to make GL_STENCIL_INDEX8 work. But you're less likely to encounter a driver bug if you just do the right thing and use what works.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    5

    Thanks for the speedy reply. I had a feeling stencil buffers not packed with a depth buffer weren't recommended. I wasn't actually planning on using it. I'm currently writing a wrapper library with unit tests and GL_STENCIL_INDEX8 was just the format I chose to test my getRenderbufferStencilSize() function.

    I was actually considering making my wrapper only include functionality from OpenGL ES 2.0 core, but maybe now I'll include at least GL_OES_packed_depth_stencil too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •