Reduce state changes and fix translucent maskwall depth buffer issue

git-svn-id: https://svn.eduke32.com/eduke32@7619 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/build/src/polymost.cpp
This commit is contained in:
pogokeen 2019-04-30 11:12:16 +00:00 committed by Christoph Oelckers
parent be86eb779b
commit d2ebc8a29c
2 changed files with 28 additions and 24 deletions

View file

@ -5833,9 +5833,6 @@ static void renderDrawSprite(int32_t snum)
#ifdef USE_OPENGL
case REND_POLYMOST:
polymost_drawsprite(snum);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
// glDepthRange(0.0, 1.0); //<- this is more widely supported than glPolygonOffset
return;
# ifdef POLYMER
case REND_POLYMER:
@ -8558,6 +8555,9 @@ killsprite:
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
{
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
for (i = spritesortcnt; i < numSprites; ++i)
{
if (tspriteptr[i] != NULL)
@ -8581,6 +8581,10 @@ killsprite:
else
renderDrawMaskedWall(--maskwallcnt);
}
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
}
#endif
@ -8716,10 +8720,6 @@ killsprite:
renderDrawMaskedWall(maskwallcnt);
}
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
glDepthMask(GL_FALSE);
#endif
while (spritesortcnt)
{
--spritesortcnt;

View file

@ -2398,26 +2398,13 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
static int32_t skyzbufferhack_pass = 0;
if (!waloff[globalpicnum])
{
glEnable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
}
else if (!(method & DAMETH_MASKPROPS) && fullbright_pass < 2)
{
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
}
else
if (method & DAMETH_MASKPROPS || fullbright_pass == 2)
{
float const al = alphahackarray[globalpicnum] != 0 ? alphahackarray[globalpicnum] * (1.f/255.f) :
(pth->hicr && pth->hicr->alphacut >= 0.f ? pth->hicr->alphacut : 0.f);
glAlphaFunc(GL_GREATER, al);
handle_blend((method & DAMETH_MASKPROPS) > DAMETH_MASK, drawpoly_blend, (method & DAMETH_MASKPROPS) == DAMETH_TRANS2);
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
}
float pc[4];
@ -2633,8 +2620,6 @@ do
glMatrixMode(GL_MODELVIEW);
}
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (videoGetRenderMode() != REND_POLYMOST)
return;
@ -2670,7 +2655,9 @@ do
vec3d_t const bxtex = xtex, bytex = ytex, botex = otex;
xtex = xtex2, ytex = ytex2, otex = otex2;
skyzbufferhack_pass++;
glColorMask(false, false, false, false);
polymost_drawpoly(dpxy, n, DAMETH_MASK);
glColorMask(true, true, true, true);
xtex = bxtex, ytex = bytex, otex = botex;
skyzbufferhack_pass--;
}
@ -5540,6 +5527,12 @@ void polymost_drawmaskwall(int32_t damaskwallcnt)
if ((uint32_t)globalpicnum >= MAXTILES)
globalpicnum = 0;
if (!waloff[globalpicnum])
{
glEnable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
}
globalorientation = (int32_t)wal->cstat;
DO_TILE_ANIM(globalpicnum, (int16_t)thewall[z]+16384);
@ -5730,6 +5723,13 @@ void polymost_drawmaskwall(int32_t damaskwallcnt)
polymost_updaterotmat();
polymost_drawpoly(dpxy, n, method);
polymost_identityrotmat();
if (!waloff[globalpicnum])
{
// restore this to normal
glDisable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
}
}
typedef struct
@ -6745,7 +6745,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
#if defined(POLYMER)
# ifdef USE_GLEXT
@ -6904,6 +6905,9 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (!nofog) polymost_setFogEnabled(true);
}
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);
#ifdef POLYMER
if (videoGetRenderMode() == REND_POLYMER)
{