From fd557166333d7d336d3b8f25113ef1bf655e3ca9 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 3 Apr 2026 01:23:55 +0500 Subject: [PATCH] ref: gl: change backface culling only if it wasn't disabled by mod developer beforehand --- ref/gl/gl_studio.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/ref/gl/gl_studio.c b/ref/gl/gl_studio.c index 152219ea..c5a2b05e 100644 --- a/ref/gl/gl_studio.c +++ b/ref/gl/gl_studio.c @@ -2340,15 +2340,24 @@ static void R_StudioDrawPoints( void ) pstudionorms = (vec3_t *)((byte *)m_pStudioHeader + m_pSubModel->normindex); // backface culling for left-handed weapons - if( R_AllowFlipViewModel( RI.currententity )) + // + // there is a bug in GoldSrc that sets backface culling to GL_FRONT + // but doesn't check OpenGL state. This allows mod developers to disable + // backface culling through TriAPI call + // + // see https://github.com/FWGS/xash3d-fwgs/issues/2517 + if( glState.faceCull != GL_NONE ) { - tr.fFlipViewModel = true; - GL_Cull( GL_NONE ); - } - else - { - tr.fFlipViewModel = false; - GL_Cull( GL_FRONT ); + if( R_AllowFlipViewModel( RI.currententity )) + { + tr.fFlipViewModel = true; + GL_Cull( GL_NONE ); + } + else + { + tr.fFlipViewModel = false; + GL_Cull( GL_FRONT ); + } } for( j = 0; j < m_pSubModel->nummesh; j++ )