GL_ATI_separate_stencil support

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2557 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-09-13 05:57:56 +00:00
parent 416bc70c87
commit 85c97d0454
2 changed files with 38 additions and 12 deletions
+32 -11
View File
@@ -4,7 +4,7 @@
#include "cube.h"
#include "bot/bot.h"
bool hasTE = false, hasMT = false, hasMDA = false, hasDRE = false, hasstencil = false, hasST2 = false, hasSTW = false;
bool hasTE = false, hasMT = false, hasMDA = false, hasDRE = false, hasstencil = false, hasST2 = false, hasSTW = false, hasSTS = false;
// GL_ARB_multitexture
PFNGLACTIVETEXTUREARBPROC glActiveTexture_ = NULL;
@@ -22,6 +22,10 @@ PFNGLDRAWRANGEELEMENTSEXTPROC glDrawRangeElements_ = NULL;
// GL_EXT_stencil_two_side
PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFace_ = NULL;
// GL_ATI_separate_stencil
PFNGLSTENCILOPSEPARATEATIPROC glStencilOpSeparate_ = NULL;
PFNGLSTENCILFUNCSEPARATEATIPROC glStencilFuncSeparate_ = NULL;
void *getprocaddress(const char *name)
{
return SDL_GL_GetProcAddress(name);
@@ -74,9 +78,16 @@ void gl_checkextensions()
hasST2 = true;
}
if(strstr(exts, "GL_ATI_separate_stencil"))
{
glStencilOpSeparate_ = (PFNGLSTENCILOPSEPARATEATIPROC) getprocaddress("glStencilOpSeparateATI");
glStencilFuncSeparate_ = (PFNGLSTENCILFUNCSEPARATEATIPROC)getprocaddress("glStencilFuncSeparateATI");
hasSTS = true;
}
if(strstr(exts, "GL_EXT_stencil_wrap")) hasSTW = true;
if(!hasST2 || !hasSTW)
if((!hasST2 && !hasSTS) || !hasSTW)
{
// only enable stencil shadows by default if card is efficient at rendering them
stencilshadow = 0;
@@ -833,18 +844,28 @@ void drawstencilshadows()
stenciling = 1;
if(hasST2 && hasSTW)
if((hasST2 || hasSTS) && hasSTW)
{
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
glDisable(GL_CULL_FACE);
glActiveStencilFace_(GL_BACK);
glStencilFunc(GL_ALWAYS, 0, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
if(hasST2)
{
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
glActiveStencilFace_(GL_FRONT);
glStencilFunc(GL_ALWAYS, 0, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
glActiveStencilFace_(GL_BACK);
glStencilFunc(GL_ALWAYS, 0, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
glActiveStencilFace_(GL_FRONT);
glStencilFunc(GL_ALWAYS, 0, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
}
else
{
glStencilFuncSeparate_(GL_ALWAYS, GL_ALWAYS, 0, ~0U);
glStencilOpSeparate_(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
glStencilOpSeparate_(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
}
startmodelbatches();
renderentities();
@@ -852,8 +873,8 @@ void drawstencilshadows()
renderbounceents();
endmodelbatches();
if(hasST2) glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
glEnable(GL_CULL_FACE);
glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
}
else
{