Commit fd598dfe authored by Richard Gobeille's avatar Richard Gobeille
Browse files

engine: GL state fixes

Fixes textures with fullbright pixels being drawn completely bright when texture filtering is enabled, and a couple other issues.
parent b188ee81
......@@ -7031,26 +7031,22 @@ static void renderDrawSprite(int32_t snum)
{
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
switch (videoGetRenderMode())
#ifdef USE_OPENGL
if (videoGetRenderMode() != REND_CLASSIC)
{
case REND_CLASSIC:
classicDrawSprite(snum);
return;
#ifdef USE_OPENGL
case REND_POLYMOST:
polymost_drawsprite(snum);
return;
# ifdef POLYMER
case REND_POLYMER:
buildgl_setEnabled(GL_ALPHA_TEST);
buildgl_setEnabled(GL_ALPHA_TEST);
buildgl_setEnabled(GL_BLEND);
polymer_drawsprite(snum);
buildgl_setDisabled(GL_BLEND);
buildgl_setDisabled(GL_ALPHA_TEST);
if (videoGetRenderMode() == REND_POLYMOST)
polymost_drawsprite(snum);
# ifdef POLYMER
else polymer_drawsprite(snum);
# endif
return;
# endif
#endif
}
#endif
classicDrawSprite(snum);
}
......@@ -7062,22 +7058,21 @@ static void renderDrawMaskedWall(int16_t damaskwallcnt)
MICROPROFILE_SCOPEI("Engine", EDUKE32_FUNCTION, MP_AUTO);
//============================================================================= //POLYMOST BEGINS
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST) { polymost_drawmaskwall(damaskwallcnt); return; }
# ifdef POLYMER
else if (videoGetRenderMode() == REND_POLYMER)
#ifdef USE_OPENGL
if (videoGetRenderMode() != REND_CLASSIC)
{
buildgl_setEnabled(GL_ALPHA_TEST);
buildgl_setEnabled(GL_BLEND);
polymer_drawmaskwall(damaskwallcnt);
buildgl_setDisabled(GL_BLEND);
buildgl_setDisabled(GL_ALPHA_TEST);
if (videoGetRenderMode() == REND_POLYMOST)
polymost_drawmaskwall(damaskwallcnt);
# ifdef POLYMER
else
{
buildgl_setEnabled(GL_ALPHA_TEST);
buildgl_setEnabled(GL_BLEND);
polymer_drawmaskwall(damaskwallcnt);
}
# endif
return;
}
#endif
#endif
//============================================================================= //POLYMOST ENDS
......@@ -9967,8 +9962,6 @@ killsprite:
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
{
buildgl_setDisabled(GL_BLEND);
buildgl_setEnabled(GL_ALPHA_TEST);
polymost_setClamp(1+2);
if (spritesortcnt < numSprites)
......@@ -10034,8 +10027,6 @@ killsprite:
renderDrawMaskedWall(i);
}
buildgl_setEnabled(GL_BLEND);
buildgl_setEnabled(GL_ALPHA_TEST);
glDepthMask(GL_FALSE);
}
#endif
......
......@@ -342,7 +342,7 @@ void gltexapplyprops(void)
bind_2d_texture(pth->glpic, filter);
if (r_fullbrights && pth->flags & PTH_HASFULLBRIGHT)
if (pth->flags & PTH_HASFULLBRIGHT)
bind_2d_texture(pth->ofb->glpic, filter);
}
}
......@@ -3673,12 +3673,12 @@ static void polymost_drawpoly(vec2f_t const* const dpxy, int32_t const n, int32_
polymost_setFogEnabled(false);
buildgl_setDepthFunc(GL_EQUAL);
buildgl_setEnabled(GL_ALPHA_TEST);
polymost_drawpoly(dpxy, n, method_);
buildgl_setDepthFunc(GL_LEQUAL);
buildgl_setDisabled(GL_ALPHA_TEST);
if (!nofog)
polymost_setFogEnabled(true);
......@@ -9755,7 +9755,6 @@ int32_t polymost_printtext256(int32_t xpos, int32_t ypos, int16_t col, int16_t b
polymostSet2dView(); // disables blending, texturing, and depth testing
buildgl_bindSamplerObject(0, 0);
buildgl_setDisabled(GL_ALPHA_TEST);
glDepthMask(GL_FALSE); // disable writing to the z-buffer
// glPushAttrib(GL_POLYGON_BIT|GL_ENABLE_BIT);
......@@ -9781,6 +9780,7 @@ int32_t polymost_printtext256(int32_t xpos, int32_t ypos, int16_t col, int16_t b
glEnd();
}
buildgl_setEnabled(GL_ALPHA_TEST);
buildgl_setEnabled(GL_BLEND);
glColor4ub(p.r,p.g,p.b,255);
......
......@@ -1081,14 +1081,6 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
mat[12] = -mat[12];
}
if (shadowHack)
{
buildgl_setDepthFunc(GL_LEQUAL); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
// glDepthRange(0.0, 0.9999);
}
// glPushAttrib(GL_POLYGON_BIT);
if ((grhalfxdown10x >= 0) ^ ((globalorientation&8) != 0) ^ ((globalorientation&4) != 0))
glFrontFace(GL_CW);
else
......@@ -1118,13 +1110,19 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
pc[3] *= 1.0f - spriteext[tspr->owner].alpha;
handle_blend(!!(tspr->cstat & CSTAT_SPRITE_TRANSLUCENT), tspr->blend, !!(tspr->cstat & CSTAT_SPRITE_TRANSLUCENT_INVERT));
if (!(tspr->cstat & CSTAT_SPRITE_TRANSLUCENT) || spriteext[tspr->owner].alpha > 0.f || pc[3] < 1.0f)
buildgl_setEnabled(GL_BLEND); // else buildgl_setDisabled(GL_BLEND);
}
else pc[3] = 1.f;
//------------
else
{
pc[3] = 1.f;
if (shadowHack)
handle_blend(0, 0, 0);
}
if (!(tspr->cstat & CSTAT_SPRITE_TRANSLUCENT) || spriteext[tspr->owner].alpha > 0.f || pc[3] < 1.0f)
buildgl_setEnabled(GL_BLEND);
else buildgl_setDisabled(GL_BLEND);
//transform to Build coords
float omat[16];
Bmemcpy(omat, mat, sizeof(omat));
......@@ -1194,8 +1192,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
glDrawElements(GL_TRIANGLES, m->qcnt*2*3, GL_UNSIGNED_INT, 0);
buildgl_bindBuffer(GL_ARRAY_BUFFER, 0);
buildgl_bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
//buildgl_bindBuffer(GL_ARRAY_BUFFER, 0);
//buildgl_bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
polymost_setClamp(prevClamp);
polymost_usePaletteIndexing(true);
......@@ -1204,12 +1202,6 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
//------------
buildgl_setDisabled(GL_CULL_FACE);
// glPopAttrib();
if (shadowHack)
{
buildgl_setDepthFunc(GL_LESS); //NEVER,LESS,(,L)EQUAL,GREATER,(NOT,G)EQUAL,ALWAYS
// glDepthRange(0.0, 0.99999);
}
glLoadIdentity();
globalnoeffect = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment