From 159ded433deda57e64033515fae116e98506352d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 5 Nov 2024 23:57:51 +0300 Subject: [PATCH] ref: gl: don't touch polygon offset when not drawing debug hulls as it breaks decals with VBO Also correctly restore polygon offset state so decals gets drawn even with VBO --- ref/gl/gl_rsurf.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ref/gl/gl_rsurf.c b/ref/gl/gl_rsurf.c index 06db6bd8..6d92ed56 100644 --- a/ref/gl/gl_rsurf.c +++ b/ref/gl/gl_rsurf.c @@ -1746,10 +1746,20 @@ void R_DrawBrushModel( cl_entity_t *e ) pglDisable( GL_BLEND ); pglDepthMask( GL_TRUE ); - pglPolygonOffset( 1.0f, 2.0f ); - pglEnable( GL_POLYGON_OFFSET_FILL ); - gEngfuncs.R_DrawModelHull( clmodel ); // draw before restore - pglDisable( GL_POLYGON_OFFSET_FILL ); + if( r_showhull->value > 0.0f ) + { + GLfloat factor, units; + + pglGetFloatv( GL_POLYGON_OFFSET_FACTOR, &factor ); + pglGetFloatv( GL_POLYGON_OFFSET_UNITS, &units ); + + pglPolygonOffset( 1.0f, 2.0f ); + pglEnable( GL_POLYGON_OFFSET_FILL ); + gEngfuncs.R_DrawModelHull( clmodel ); // draw before restore + pglDisable( GL_POLYGON_OFFSET_FILL ); + + pglPolygonOffset( factor, units ); + } R_LoadIdentity(); // restore worldmatrix }