1
0
Fork 0
forked from fte/fteqw

Fix EF_ADDITIVE

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3527 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2010-04-09 10:49:04 +00:00
parent 7f82215a40
commit e07f5976b5

View file

@ -1,6 +1,5 @@
#include "quakedef.h" #include "quakedef.h"
//#define STATEFIXME
//#define FORCESTATE //#define FORCESTATE
@ -644,12 +643,11 @@ static void RevertToKnownState(void)
qglColor3f(1,1,1); qglColor3f(1,1,1);
shaderstate.shaderbits &= ~(SBITS_MISC_DEPTHEQUALONLY|SBITS_MISC_DEPTHCLOSERONLY|SBITS_MISC_NODEPTHTEST); shaderstate.shaderbits &= ~(SBITS_MISC_DEPTHEQUALONLY|SBITS_MISC_DEPTHCLOSERONLY);
shaderstate.shaderbits |= SBITS_MISC_DEPTHWRITE; shaderstate.shaderbits |= SBITS_MISC_DEPTHWRITE;
qglDepthFunc(GL_LEQUAL); qglDepthFunc(GL_LEQUAL);
qglDepthMask(GL_TRUE); qglDepthMask(GL_TRUE);
qglEnable(GL_DEPTH_TEST);
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
} }
@ -1713,9 +1711,9 @@ static void BE_SendPassBlendAndDepth(unsigned int sbits)
if (shaderstate.flags) if (shaderstate.flags)
{ {
if (shaderstate.flags & BEF_FORCEADDITIVE) if (shaderstate.flags & BEF_FORCEADDITIVE)
sbits = (sbits & ~SBITS_ATEST_BITS) | (SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ONE); sbits = (sbits & ~(SBITS_MISC_DEPTHWRITE|SBITS_BLEND_BITS|SBITS_ATEST_BITS)) | (SBITS_SRCBLEND_ONE | SBITS_DSTBLEND_ONE);
else if (shaderstate.flags & BEF_FORCETRANSPARENT) /*if transparency is forced, clear alpha test bits*/ else if (shaderstate.flags & BEF_FORCETRANSPARENT) /*if transparency is forced, clear alpha test bits*/
sbits = (sbits & ~SBITS_ATEST_BITS) | (SBITS_SRCBLEND_SRC_ALPHA | SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA); sbits = (sbits & ~(SBITS_MISC_DEPTHWRITE|SBITS_BLEND_BITS|SBITS_ATEST_BITS)) | (SBITS_SRCBLEND_SRC_ALPHA | SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA);
if (shaderstate.flags & BEF_FORCENODEPTH) /*EF_NODEPTHTEST dp extension*/ if (shaderstate.flags & BEF_FORCENODEPTH) /*EF_NODEPTHTEST dp extension*/
sbits |= SBITS_MISC_NODEPTHTEST; sbits |= SBITS_MISC_NODEPTHTEST;
@ -1731,10 +1729,6 @@ static void BE_SendPassBlendAndDepth(unsigned int sbits)
delta = sbits^shaderstate.shaderbits; delta = sbits^shaderstate.shaderbits;
#ifdef STATEFIXME
#pragma message("Hack to work around the fact that other bits of code change this state")
delta |= SBITS_MISC_NODEPTHTEST|SBITS_MISC_DEPTHEQUALONLY;
#endif
#ifdef FORCESTATE #ifdef FORCESTATE
delta |= ~0; delta |= ~0;
#endif #endif
@ -1751,6 +1745,7 @@ static void BE_SendPassBlendAndDepth(unsigned int sbits)
switch(sbits & SBITS_SRCBLEND_BITS) switch(sbits & SBITS_SRCBLEND_BITS)
{ {
case SBITS_SRCBLEND_ZERO: src = GL_ZERO; break; case SBITS_SRCBLEND_ZERO: src = GL_ZERO; break;
default:
case SBITS_SRCBLEND_ONE: src = GL_ONE; break; case SBITS_SRCBLEND_ONE: src = GL_ONE; break;
case SBITS_SRCBLEND_DST_COLOR: src = GL_DST_COLOR; break; case SBITS_SRCBLEND_DST_COLOR: src = GL_DST_COLOR; break;
case SBITS_SRCBLEND_ONE_MINUS_DST_COLOR: src = GL_ONE_MINUS_DST_COLOR; break; case SBITS_SRCBLEND_ONE_MINUS_DST_COLOR: src = GL_ONE_MINUS_DST_COLOR; break;
@ -1759,11 +1754,11 @@ static void BE_SendPassBlendAndDepth(unsigned int sbits)
case SBITS_SRCBLEND_DST_ALPHA: src = GL_DST_ALPHA; break; case SBITS_SRCBLEND_DST_ALPHA: src = GL_DST_ALPHA; break;
case SBITS_SRCBLEND_ONE_MINUS_DST_ALPHA: src = GL_ONE_MINUS_DST_ALPHA; break; case SBITS_SRCBLEND_ONE_MINUS_DST_ALPHA: src = GL_ONE_MINUS_DST_ALPHA; break;
case SBITS_SRCBLEND_ALPHA_SATURATE: src = GL_SRC_ALPHA_SATURATE; break; case SBITS_SRCBLEND_ALPHA_SATURATE: src = GL_SRC_ALPHA_SATURATE; break;
default: Sys_Error("Invalid shaderbits\n");
} }
switch(sbits & SBITS_DSTBLEND_BITS) switch(sbits & SBITS_DSTBLEND_BITS)
{ {
case SBITS_DSTBLEND_ZERO: dst = GL_ZERO; break; case SBITS_DSTBLEND_ZERO: dst = GL_ZERO; break;
default:
case SBITS_DSTBLEND_ONE: dst = GL_ONE; break; case SBITS_DSTBLEND_ONE: dst = GL_ONE; break;
case SBITS_DSTBLEND_SRC_COLOR: dst = GL_SRC_COLOR; break; case SBITS_DSTBLEND_SRC_COLOR: dst = GL_SRC_COLOR; break;
case SBITS_DSTBLEND_ONE_MINUS_SRC_COLOR: dst = GL_ONE_MINUS_SRC_COLOR; break; case SBITS_DSTBLEND_ONE_MINUS_SRC_COLOR: dst = GL_ONE_MINUS_SRC_COLOR; break;
@ -1771,7 +1766,6 @@ static void BE_SendPassBlendAndDepth(unsigned int sbits)
case SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA: dst = GL_ONE_MINUS_SRC_ALPHA; break; case SBITS_DSTBLEND_ONE_MINUS_SRC_ALPHA: dst = GL_ONE_MINUS_SRC_ALPHA; break;
case SBITS_DSTBLEND_DST_ALPHA: dst = GL_DST_ALPHA; break; case SBITS_DSTBLEND_DST_ALPHA: dst = GL_DST_ALPHA; break;
case SBITS_DSTBLEND_ONE_MINUS_DST_ALPHA: dst = GL_ONE_MINUS_DST_ALPHA; break; case SBITS_DSTBLEND_ONE_MINUS_DST_ALPHA: dst = GL_ONE_MINUS_DST_ALPHA; break;
default: Sys_Error("Invalid shaderbits\n");
} }
qglEnable(GL_BLEND); qglEnable(GL_BLEND);
qglBlendFunc(src, dst); qglBlendFunc(src, dst);
@ -1929,6 +1923,7 @@ static void DrawPass(const shaderpass_t *pass, const mesh_t *meshlist)
GL_TexEnv(pass[i].blendmode); GL_TexEnv(pass[i].blendmode);
break; break;
} }
//fallthrough
default: default:
case GL_MODULATE: case GL_MODULATE:
GL_TexEnv(GL_MODULATE); GL_TexEnv(GL_MODULATE);