Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Getting GL_STENCIL_BITS returns 0

  1. #11
    Junior Member Newbie
    Join Date
    Mar 2017
    Posts
    28
    I tried your code john, and I'm getting a GL_INVALID_ENUM error. I tried `glGetError()` right after both the `glGetFramebufferAttachmentParameteriv`calls you have, and I'm getting the same errors there. It's the same thing in my own code.

    Does this say anything? From the docs, this error would only appear if the 1st or 3rd argument to that function is invalid, but I'm pretty sure the arguments are correct.

  2. #12
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,404
    Quote Originally Posted by DragonautX View Post
    Code :
    glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER,
    	GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &stencil_bits);
    You might try changing GL_STENCIL to GL_STENCIL_ATTACHMENT or GL_DEPTH_STENCIL_ATTACHMENT.

    If those work, it's a bug in the driver; GL_STENCIL is the correct parameter name for the default framebuffer; the other two are correct for a FBO.

  3. #13
    Junior Member Newbie
    Join Date
    Mar 2017
    Posts
    28
    I tried changing GL_STENCIL to the other two. It didn't work. Ya, I'm pretty sure this is a bug in my drivers.

    From mhagain's comment about pixel formats, I can't find anywhere that says you can set a pixel format in GLFW. But it gave me the idea to try to find a minimal win32 example of OpenGL where I could set the pixel format explicitly. I found a 'minimal.c' file here.

    I was able to copy-paste it. Had to switch arguments of `ReleaseDC()` for some reason, but after that, the program worked. Changed the second argument of `SetPixelFormat()` to a pixel format integer id 3, which I knew had 8 stencil bits (from the OpenGL Extension Viewer). Then I tried `glGetIntegerv`with GL_STENCIL_BITS in the `display()` function the and wrote the value to a file. Still was 0. If I was able to control the pixel format and still get a 0 stencil bits value, I'm pretty sure it's my laptop's drivers.

    (Also, my last post was a mistake. I ran the code on a "AMD Radeon HD 7570M/HD 7670M Graphics" graphics card instead of the Intel one. My laptop has switchable graphics. The AMD card produces a GL_INVALID_ENUM error, but the Intel card doesn't.)

    Anyways, thanks everyone for the help. I learned about glGetError() and pixel formats,. I got to try making a win32 opengl file work too. Never did that before, that was pretty cool.

Posting Permissions

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