Always use GL_Cull to change cull state

Manually changing cull state can cause later GL_Cull calls to not change
the cull state.
This commit is contained in:
Zack Middleton 2014-10-29 01:32:50 -05:00
parent 39cf21bf54
commit 1ba9e7a45e
5 changed files with 17 additions and 45 deletions

View file

@ -710,7 +710,7 @@ void RB_SetGL2D (void) {
GLS_SRCBLEND_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA |
GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
qglDisable( GL_CULL_FACE ); GL_Cull( CT_TWO_SIDED );
qglDisable( GL_CLIP_PLANE0 ); qglDisable( GL_CLIP_PLANE0 );
// set time for 2D shaders // set time for 2D shaders

View file

@ -211,7 +211,6 @@ void RB_ShadowTessEnd( void ) {
// draw the silhouette edges // draw the silhouette edges
GL_Bind( tr.whiteImage ); GL_Bind( tr.whiteImage );
qglEnable( GL_CULL_FACE );
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
qglColor3f( 0.2f, 0.2f, 0.2f ); qglColor3f( 0.2f, 0.2f, 0.2f );
@ -222,28 +221,15 @@ void RB_ShadowTessEnd( void ) {
qglEnable( GL_STENCIL_TEST ); qglEnable( GL_STENCIL_TEST );
qglStencilFunc( GL_ALWAYS, 1, 255 ); qglStencilFunc( GL_ALWAYS, 1, 255 );
// mirrors have the culling order reversed GL_Cull( CT_BACK_SIDED );
if ( backEnd.viewParms.isMirror ) { qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
qglCullFace( GL_FRONT );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
R_RenderShadowEdges(); R_RenderShadowEdges();
qglCullFace( GL_BACK ); GL_Cull( CT_FRONT_SIDED );
qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
R_RenderShadowEdges(); R_RenderShadowEdges();
} else {
qglCullFace( GL_BACK );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
R_RenderShadowEdges();
qglCullFace( GL_FRONT );
qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
R_RenderShadowEdges();
}
// reenable writing to the color buffer // reenable writing to the color buffer
@ -272,7 +258,7 @@ void RB_ShadowFinish( void ) {
qglStencilFunc( GL_NOTEQUAL, 0, 255 ); qglStencilFunc( GL_NOTEQUAL, 0, 255 );
qglDisable (GL_CLIP_PLANE0); qglDisable (GL_CLIP_PLANE0);
qglDisable (GL_CULL_FACE); GL_Cull( CT_TWO_SIDED );
GL_Bind( tr.whiteImage ); GL_Bind( tr.whiteImage );

View file

@ -818,7 +818,7 @@ void RB_SetGL2D (void) {
GLS_SRCBLEND_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA |
GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
qglDisable( GL_CULL_FACE ); GL_Cull( CT_TWO_SIDED );
qglDisable( GL_CLIP_PLANE0 ); qglDisable( GL_CLIP_PLANE0 );
// set time for 2D shaders // set time for 2D shaders

View file

@ -748,7 +748,7 @@ void FBO_BlitFromTexture(struct image_s *src, ivec4_t inSrcBox, vec2_t inSrcTexS
Mat4Ortho(0, width, height, 0, 0, 1, projection); Mat4Ortho(0, width, height, 0, 0, 1, projection);
qglDisable( GL_CULL_FACE ); GL_Cull( CT_TWO_SIDED );
GL_BindToTMU(src, TB_COLORMAP); GL_BindToTMU(src, TB_COLORMAP);

View file

@ -211,7 +211,6 @@ void RB_ShadowTessEnd( void ) {
// draw the silhouette edges // draw the silhouette edges
GL_Bind( tr.whiteImage ); GL_Bind( tr.whiteImage );
qglEnable( GL_CULL_FACE );
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
qglColor3f( 0.2f, 0.2f, 0.2f ); qglColor3f( 0.2f, 0.2f, 0.2f );
@ -222,28 +221,15 @@ void RB_ShadowTessEnd( void ) {
qglEnable( GL_STENCIL_TEST ); qglEnable( GL_STENCIL_TEST );
qglStencilFunc( GL_ALWAYS, 1, 255 ); qglStencilFunc( GL_ALWAYS, 1, 255 );
// mirrors have the culling order reversed GL_Cull( CT_BACK_SIDED );
if ( backEnd.viewParms.isMirror ) { qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
qglCullFace( GL_FRONT );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
R_RenderShadowEdges(); R_RenderShadowEdges();
qglCullFace( GL_BACK ); GL_Cull( CT_FRONT_SIDED );
qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
R_RenderShadowEdges(); R_RenderShadowEdges();
} else {
qglCullFace( GL_BACK );
qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
R_RenderShadowEdges();
qglCullFace( GL_FRONT );
qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
R_RenderShadowEdges();
}
// reenable writing to the color buffer // reenable writing to the color buffer
@ -272,7 +258,7 @@ void RB_ShadowFinish( void ) {
qglStencilFunc( GL_NOTEQUAL, 0, 255 ); qglStencilFunc( GL_NOTEQUAL, 0, 255 );
qglDisable (GL_CLIP_PLANE0); qglDisable (GL_CLIP_PLANE0);
qglDisable (GL_CULL_FACE); GL_Cull( CT_TWO_SIDED );
GL_Bind( tr.whiteImage ); GL_Bind( tr.whiteImage );