fallback for missing stencil wrap

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2625 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-09-15 11:46:37 +00:00
parent 4cb66ee2f1
commit bca2137d6d
4 changed files with 21 additions and 11 deletions
+1
View File
@@ -391,6 +391,7 @@ extern int isoccluded(float vx, float vy, float cx, float cy, float csize);
// main
extern SDL_Surface *screen;
extern int colorbits, depthbits, stencilbits;
extern time_t now_utc;
extern struct tm *systemtime();
+3 -2
View File
@@ -873,7 +873,8 @@ void gl_drawframe(int w, int h, float changelod, float curfps)
}
}
glClear((outsidemap(camera1) ? GL_COLOR_BUFFER_BIT : 0) | GL_DEPTH_BUFFER_BIT | (hasstencil && stencilshadow ? GL_STENCIL_BUFFER_BIT : 0));
if(stencilshadow && hasstencil && stencilbits >= 8) glClearStencil((hasSTS || hasST2) && !hasSTW ? 128 : 0);
glClear((outsidemap(camera1) ? GL_COLOR_BUFFER_BIT : 0) | GL_DEPTH_BUFFER_BIT | (stencilshadow && hasstencil && stencilbits >= 8 ? GL_STENCIL_BUFFER_BIT : 0));
glEnable(GL_TEXTURE_2D);
@@ -922,7 +923,7 @@ void gl_drawframe(int w, int h, float changelod, float curfps)
renderbounceents();
endmodelbatches();
if(stencilshadow && hasstencil) drawstencilshadows();
if(stencilshadow && hasstencil && stencilbits >= 8) drawstencilshadows();
// Added by Rick: Need todo here because of drawing the waypoints
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+2 -2
View File
@@ -282,7 +282,7 @@ void endmodelbatches(bool flush)
}
renderbatchedmodel(b.m, bm);
}
if(dynshadow && b.m->hasshadows() && (!reflecting || refracting) && (!stencilshadow || !hasstencil))
if(dynshadow && b.m->hasshadows() && (!reflecting || refracting) && (!stencilshadow || !hasstencil || stencilbits < 8))
{
glColor4f(0, 0, 0, dynshadow/100.0f);
loopvj(b.batched)
@@ -377,7 +377,7 @@ void rendermodel(const char *mdl, int anim, int tex, float rad, const vec &o, fl
if(!OUTBORD(x, y))
{
sqr *s = S(x, y);
if(!(anim&ANIM_TRANSLUCENT) && dynshadow && m->hasshadows() && (!reflecting || refracting) && (!stencilshadow || !hasstencil))
if(!(anim&ANIM_TRANSLUCENT) && dynshadow && m->hasshadows() && (!reflecting || refracting) && (!stencilshadow || !hasstencil || stencilbits < 8))
{
vec center(o.x, o.y, s->floor);
if(s->type==FHF) center.z -= s->vdelta/4.0f;
+15 -7
View File
@@ -330,7 +330,7 @@ void drawstencilshadows()
shadowx1 = shadowy1 = 1;
memset(shadowtiles, 0, sizeof(shadowtiles));
if((hasST2 || hasSTS) && hasSTW)
if(hasST2 || hasSTS)
{
glDisable(GL_CULL_FACE);
@@ -340,17 +340,17 @@ void drawstencilshadows()
glActiveStencilFace_(GL_BACK);
glStencilFunc(GL_ALWAYS, 0, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
glStencilOp(GL_KEEP, GL_KEEP, hasSTW ? GL_INCR_WRAP_EXT : GL_INCR);
glActiveStencilFace_(GL_FRONT);
glStencilFunc(GL_ALWAYS, 0, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
glStencilOp(GL_KEEP, GL_KEEP, hasSTW ? GL_DECR_WRAP_EXT : GL_DECR);
}
else
{
glStencilFuncSeparate_(GL_ALWAYS, GL_ALWAYS, 0, ~0U);
glStencilOpSeparate_(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
glStencilOpSeparate_(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
glStencilOpSeparate_(GL_BACK, GL_KEEP, GL_KEEP, hasSTW ? GL_INCR_WRAP_EXT : GL_INCR);
glStencilOpSeparate_(GL_FRONT, GL_KEEP, GL_KEEP, hasSTW ? GL_DECR_WRAP_EXT : GL_DECR);
}
startmodelbatches();
@@ -393,8 +393,16 @@ void drawstencilshadows()
{
glDisable(GL_DEPTH_TEST);
glStencilFunc(GL_NOTEQUAL, 0, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
if((hasST2 || hasSTS) && !hasSTW)
{
glStencilFunc(GL_NOTEQUAL, 128, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
}
else
{
glStencilFunc(GL_NOTEQUAL, 0, ~0U);
glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
}
glEnable(GL_BLEND);
glBlendFunc(GL_ZERO, GL_SRC_COLOR);