PDA

View Full Version : EXT_stencil_two_side on ATI



Jan
10-02-2010, 01:45 AM
Hi there

Just tried my engine on an ATI card (Radeon 4xxx), and it seems not to support EXT_stencil_two_side.

Can anyone tell me, if there is some other extension on ATI, that provides the same functionality?

The driver supports OpenGL 3.3 (though i'm using a 2.1 context atm), and i was under the impression that stencil_two_side should have been made core at some point, so i am a bit surprised that the EXT-extension is not supported.

Thanks,
Jan.

Dan Bartlett
10-02-2010, 03:59 AM
I think it became part of core OpenGL in version 2.0, but in a different form; with the extension it is:


glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);

glActiveStencilFaceEXT(GL_BACK);
glStencilOp(GL_KEEP, // stencil test fail
GL_KEEP, // depth test fail
GL_DECR_WRAP_EXT); // depth test pass
glStencilMask(~0);
glStencilFunc(GL_ALWAYS, 0, ~0);

but in the core 2.0+:


glStencilOpSeparate(GL_BACK, GL_KEEP, // stencil test fail
GL_KEEP, // depth test fail
GL_DECR_WRAP_EXT); // depth test pass
glStencilMaskSeparate(GL_BACK, ~0);
glStencilFuncSeparate(GL_BACK, GL_ALWAYS, 0, ~0);


In http://www.opengl.org/registry/api/gl.spec it mentions a ARB_stencil_two_side extension, but I don't think this extension ever got added to the registry as a proper extension.

Groovounet
10-02-2010, 05:40 AM
Actually it's the ATI extension that have been promoted to core:
http://www.opengl.org/registry/specs/ATI/separate_stencil.txt
Just use the core feature, it works everywhere.

Dan Bartlett
10-02-2010, 01:32 PM
It's slightly different to that extension also, because that extension doesn't include glStencilMaskSeparate equivalent, and StencilFuncSeparateATI operates differently:


StencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);

vs


StencilFuncSeparate( GLenum face, GLenum func, GLint ref, GLuint mask );

In the ATI version, it's not possible to set ref + mask for each face separately.

The OpenGL registry http://www.opengl.org/registry/api/gl.spec lists StencilFuncSeparateATI as an alias for StencilFuncSeparate, but it's not safe to use as one, although it's easily done by mistake as they both have the same parameter layout.

Jan
10-03-2010, 02:43 AM
Great, thanks for the detailed information!