Skip to content

Commit

Permalink
Client|Map Renderer: Explicitly revert all GL state changes made in D…
Browse files Browse the repository at this point in the history
…rawList::draw()
  • Loading branch information
danij-deng committed Nov 8, 2013
1 parent 8c16bab commit 0950aef
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
58 changes: 58 additions & 0 deletions doomsday/client/src/render/drawlist.cpp
Expand Up @@ -689,6 +689,60 @@ DENG2_PIMPL(DrawList)
{
default: break;

case DM_ALL:
if(spec.unit(TU_INTER).hasTexture())
{
GL_SelectTexUnits(1);
GL_ModulateTexture(1);
}
break;

case DM_BLENDED:
if(spec.unit(TU_INTER).hasTexture())
{
GL_SelectTexUnits(1);
GL_ModulateTexture(1);
}
break;

case DM_BLENDED_MOD_TEXTURE:
case DM_MOD_TEXTURE:
case DM_MOD_TEXTURE_MANY_LIGHTS:
if(spec.unit(TU_INTER).hasTexture())
{
GL_SelectTexUnits(1);
GL_ModulateTexture(1);
}
else if(mode != DM_BLENDED_MOD_TEXTURE)
{
GL_ModulateTexture(1);
}
break;

case DM_UNBLENDED_MOD_TEXTURE_AND_DETAIL:
if(!spec.unit(TU_INTER).hasTexture())
{
if(spec.unit(TU_PRIMARY_DETAIL).hasTexture())
{
GL_SelectTexUnits(1);
GL_ModulateTexture(1);
}
else
{
GL_ModulateTexture(1);
}
}
break;

case DM_UNBLENDED_TEXTURE_AND_DETAIL:
if(!spec.unit(TU_INTER).hasTexture() &&
spec.unit(TU_PRIMARY_DETAIL).hasTexture())
{
GL_SelectTexUnits(1);
GL_ModulateTexture(1);
}
break;

case DM_SHADOW:
if(!spec.unit(TU_PRIMARY).hasTexture())
{
Expand All @@ -702,6 +756,10 @@ DENG2_PIMPL(DrawList)
case DM_ALL_SHINY:
case DM_MASKED_SHINY:
GL_BlendMode(BM_NORMAL);
if(mode == DM_MASKED_SHINY && spec.unit(TU_INTER).hasTexture())
{
GL_SelectTexUnits(1);
}
break;
}
}
Expand Down
8 changes: 3 additions & 5 deletions doomsday/client/src/render/rend_main.cpp
Expand Up @@ -3399,17 +3399,15 @@ static void drawAllLists()

renderTextures = oldRenderTextures;

// Return to the normal GL state.
GL_SelectTexUnits(1);
GL_ModulateTexture(1);
glDisable(GL_TEXTURE_2D);

// The draw lists do not modify these states -ds
glEnable(GL_BLEND);
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
glEnable(GL_BLEND);
GL_BlendMode(BM_NORMAL);
if(usingFog)
{
glEnable(GL_FOG);
Expand Down

0 comments on commit 0950aef

Please sign in to comment.