The following code isn’t producing the results I expect:
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