From 40cfbc9a8246ab2ea6b2f05f5043de70eb5ad980 Mon Sep 17 00:00:00 2001 From: SmileTheory Date: Thu, 12 Mar 2015 21:44:06 -0700 Subject: [PATCH] OpenGL2: Fix culling again. --- code/renderergl2/tr_backend.c | 17 ++--------------- code/renderergl2/tr_shade.c | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/code/renderergl2/tr_backend.c b/code/renderergl2/tr_backend.c index e74f8f24..c8c7200f 100644 --- a/code/renderergl2/tr_backend.c +++ b/code/renderergl2/tr_backend.c @@ -127,25 +127,12 @@ void GL_Cull( int cullType ) { } else { - qboolean cullFront; + qboolean cullFront = (cullType == CT_FRONT_SIDED); if ( glState.faceCulling == CT_TWO_SIDED ) - { qglEnable( GL_CULL_FACE ); - } - cullFront = (cullType == CT_FRONT_SIDED); - if ( backEnd.viewParms.isMirror ) - { - cullFront = !cullFront; - } - - if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) - { - cullFront = !cullFront; - } - - if (glState.faceCullFront != cullFront) + if ( glState.faceCullFront != cullFront ) qglCullFace( cullFront ? GL_FRONT : GL_BACK ); glState.faceCullFront = cullFront; diff --git a/code/renderergl2/tr_shade.c b/code/renderergl2/tr_shade.c index 70b4353e..0a652fbb 100644 --- a/code/renderergl2/tr_shade.c +++ b/code/renderergl2/tr_shade.c @@ -1505,20 +1505,28 @@ void RB_StageIteratorGeneric( void ) // // set face culling appropriately // - if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + if (input->shader->cullType == CT_TWO_SIDED) { - //GL_Cull( CT_TWO_SIDED ); - - if (input->shader->cullType == CT_TWO_SIDED) - GL_Cull( CT_TWO_SIDED ); - else if (input->shader->cullType == CT_FRONT_SIDED) - GL_Cull( CT_BACK_SIDED ); - else - GL_Cull( CT_FRONT_SIDED ); - + GL_Cull( CT_TWO_SIDED ); } else - GL_Cull( input->shader->cullType ); + { + qboolean cullFront = (input->shader->cullType == CT_FRONT_SIDED); + + if ( backEnd.viewParms.flags & VPF_DEPTHSHADOW ) + cullFront = !cullFront; + + if ( backEnd.viewParms.isMirror ) + cullFront = !cullFront; + + if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) + cullFront = !cullFront; + + if (cullFront) + GL_Cull( CT_FRONT_SIDED ); + else + GL_Cull( CT_BACK_SIDED ); + } // set polygon offset if necessary if ( input->shader->polygonOffset )