Search code examples
c++openglvbostencil-buffer

OpenGL Stencil Buffer, how well supported are they?


  • How commonly supported is the Stencil Buffer right now by hardware in OpenGL?

  • Is it better/worse supported than shaders?

  • If the hardware doesn't support it, will it be emulated in software?

I haven't been able to find any hard data on the subject unfortunately... I want to assume that since stenciling is an old technology, it'd have ubiquitous support. However, being an old technology, it could just as easily be getting phased out of newer GPU hardware in favour of fragment shaders.

In my scenario, I'd be using an 8-bit stencil buffer in combination with a 24-bit depth buffer, used with VBOs (if that affects anything). If I use the stencil buffer, it won't be possible for those without stencil support to be able to play the game I'm making, thus the worry. If they can at least emulate the stenciling effect in software, while it wouldn't be ideal, it would be enough to put my fears to rest.


Solution

  • Stencil buffers are still in the OpenGL 4.4 spec. They're described in section 9.1 and stencil tests are section 17.3.5.

    You're guaranteed stencil buffers. Whether they're done on the GPU or in software is an implementation detail. Any machine that can run the version of OpenGL you're targeting should be able to handle stencil testing on the CPU without breaking a sweat.