/* ================ SV_DrawDebugTriangles Called from renderer for debug purposes ================ */ void SV_DrawDebugTriangles( void ) { #ifndef XASH_DEDICATED if( Host_IsDedicated() ) return; if( svgame.physFuncs.DrawNormalTriangles != NULL ) { // draw solid overlay svgame.physFuncs.DrawNormalTriangles (); } if( svgame.physFuncs.DrawDebugTriangles != NULL ) { // debug draws only pglDisable( GL_BLEND ); pglDepthMask( GL_FALSE ); pglDisable( GL_TEXTURE_2D ); // draw wireframe overlay svgame.physFuncs.DrawDebugTriangles (); pglEnable( GL_TEXTURE_2D ); pglDepthMask( GL_TRUE ); pglEnable( GL_BLEND ); } #endif }
PDGL_API void pdglDisable(int val) { if(pglDisable) { pglDisable(val); return; } pglDisable=pdglGetProcAddress("glDisable"); pglDisable(val); }
/* ============= R_ShadowPassSetupGL ============= */ static void R_ShadowPassSetupGL( const plight_t *pl ) { // matrices already computed RI.worldviewMatrix = pl->modelviewMatrix; RI.projectionMatrix = pl->projectionMatrix; RI.worldviewProjectionMatrix = RI.projectionMatrix.Concat( RI.worldviewMatrix ); GLfloat dest[16]; // tell engine about worldviewprojection matrix so TriWorldToScreen and TriScreenToWorld // will be working properly RI.worldviewProjectionMatrix.CopyToArray( dest ); SET_ENGINE_WORLDVIEW_MATRIX( dest ); pglScissor( RI.scissor[0], RI.scissor[1], RI.scissor[2], RI.scissor[3] ); pglViewport( RI.viewport[0], RI.viewport[1], RI.viewport[2], RI.viewport[3] ); pglMatrixMode( GL_PROJECTION ); GL_LoadMatrix( RI.projectionMatrix ); pglMatrixMode( GL_MODELVIEW ); GL_LoadMatrix( RI.worldviewMatrix ); GL_Cull( GL_FRONT ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); pglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); pglEnable( GL_POLYGON_OFFSET_FILL ); pglDisable( GL_TEXTURE_2D ); pglDepthMask( GL_TRUE ); pglPolygonOffset( 8, 30 ); pglEnable( GL_DEPTH_TEST ); pglDisable( GL_ALPHA_TEST ); pglDisable( GL_BLEND ); }
/* ================ SV_DrawDebugTriangles Called from renderer for debug purposes ================ */ void SV_DrawDebugTriangles( void ) { if( host.type != HOST_NORMAL ) return; if( svgame.physFuncs.DrawNormalTriangles != NULL ) { // draw solid overlay svgame.physFuncs.DrawNormalTriangles (); } if( svgame.physFuncs.DrawDebugTriangles != NULL ) { // debug draws only pglDisable( GL_BLEND ); pglDepthMask( GL_FALSE ); pglDisable( GL_TEXTURE_2D ); // draw wireframe overlay svgame.physFuncs.DrawDebugTriangles (); pglEnable( GL_TEXTURE_2D ); pglDepthMask( GL_TRUE ); pglEnable( GL_BLEND ); } }
void GAME_EXPORT GL_SetRenderMode( int mode ) { pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); switch( mode ) { case kRenderNormal: default: pglDisable( GL_BLEND ); pglDisable( GL_ALPHA_TEST ); break; case kRenderTransColor: case kRenderTransTexture: pglEnable( GL_BLEND ); pglDisable( GL_ALPHA_TEST ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); break; case kRenderTransAlpha: pglDisable( GL_BLEND ); pglEnable( GL_ALPHA_TEST ); break; case kRenderGlow: case kRenderTransAdd: pglEnable( GL_BLEND ); pglDisable( GL_ALPHA_TEST ); #if defined(XASH_BLEND_ES_WORKAROUND) // Problem with blending exists on every GLES configuration, not only on Android pglBlendFunc( GL_ONE, GL_ONE ); #else pglBlendFunc( GL_SRC_ALPHA, GL_ONE ); #endif break; } }
static void ogl_DisableDepthBias(void) { ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglDisable( GL_POLYGON_OFFSET_POINT); pglDisable( GL_POLYGON_OFFSET_LINE); pglDisable( GL_POLYGON_OFFSET_FILL); pglPolygonOffset( 0.0f, 0.0f); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
/* ============= R_SetupGL ============= */ static void R_SetupGL( void ) { if( RI.refdef.waterlevel >= 3 ) { float f; f = sin( cl.time * 0.4f * ( M_PI * 2.7f )); RI.refdef.fov_x += f; RI.refdef.fov_y -= f; } R_SetupModelviewMatrix( &RI.refdef, RI.worldviewMatrix ); R_SetupProjectionMatrix( &RI.refdef, RI.projectionMatrix ); // if( RI.params & RP_MIRRORVIEW ) RI.projectionMatrix[0][0] = -RI.projectionMatrix[0][0]; Matrix4x4_Concat( RI.worldviewProjectionMatrix, RI.projectionMatrix, RI.worldviewMatrix ); pglScissor( RI.scissor[0], RI.scissor[1], RI.scissor[2], RI.scissor[3] ); pglViewport( RI.viewport[0], RI.viewport[1], RI.viewport[2], RI.viewport[3] ); pglMatrixMode( GL_PROJECTION ); GL_LoadMatrix( RI.projectionMatrix ); pglMatrixMode( GL_MODELVIEW ); GL_LoadMatrix( RI.worldviewMatrix ); if( RI.params & RP_CLIPPLANE ) { GLdouble clip[4]; mplane_t *p = &RI.clipPlane; clip[0] = p->normal[0]; clip[1] = p->normal[1]; clip[2] = p->normal[2]; clip[3] = -p->dist; pglClipPlane( GL_CLIP_PLANE0, clip ); pglEnable( GL_CLIP_PLANE0 ); } if( RI.params & RP_FLIPFRONTFACE ) GL_FrontFace( !glState.frontFace ); GL_Cull( GL_FRONT ); pglDisable( GL_BLEND ); pglDisable( GL_ALPHA_TEST ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); }
/* =============== R_Set2DMode =============== */ void R_Set2DMode( qboolean enable ) { if( enable ) { if( glState.in2DMode ) return; // set 2D virtual screen size pglScissor( 0, 0, glState.width, glState.height ); pglViewport( 0, 0, glState.width, glState.height ); pglMatrixMode( GL_PROJECTION ); pglLoadIdentity(); pglOrtho( 0, glState.width, glState.height, 0, -99999, 99999 ); pglMatrixMode( GL_MODELVIEW ); pglLoadIdentity(); GL_Cull( 0 ); pglDepthMask( GL_FALSE ); pglDisable( GL_DEPTH_TEST ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); glState.in2DMode = true; RI.currententity = NULL; RI.currentmodel = NULL; } else { pglDepthMask( GL_TRUE ); pglEnable( GL_DEPTH_TEST ); pglMatrixMode( GL_MODELVIEW ); glState.in2DMode = false; } }
/* ============= R_ShadowPassEndGL ============= */ static void R_ShadowPassEndGL( void ) { pglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); pglDisable( GL_POLYGON_OFFSET_FILL ); pglEnable( GL_TEXTURE_2D ); pglPolygonOffset( -1, -2 ); }
static void ogl_DisableBlend(void) { // check consistency ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_BLEND); OGL_CHECKERROR; ASSERT( !bRes == !GFX_bBlending); #endif // cached? if( !GFX_bBlending && gap_bOptimizeStateChanges) return; GFX_bBlending = FALSE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglDisable(GL_BLEND); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); // adjust dithering if( gap_iDithering==0) ogl_DisableDither(); else ogl_EnableDither(); }
// set face culling static void ogl_CullFace( GfxFace eFace) { // check consistency and face ASSERT( eFace==GFX_FRONT || eFace==GFX_BACK || eFace==GFX_NONE); ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); #ifndef NDEBUG GLenum gleCull; BOOL bRes = pglIsEnabled(GL_CULL_FACE); pglGetIntegerv( GL_CULL_FACE_MODE, (GLint*)&gleCull); OGL_CHECKERROR; ASSERT( (bRes==GL_FALSE && GFX_eCullFace==GFX_NONE) || (bRes==GL_TRUE && gleCull==GL_FRONT && GFX_eCullFace==GFX_FRONT) || (bRes==GL_TRUE && gleCull==GL_BACK && GFX_eCullFace==GFX_BACK)); #endif // cached? if( GFX_eCullFace==eFace && gap_bOptimizeStateChanges) return; _sfStats.StartTimer(CStatForm::STI_GFXAPI); if( eFace==GFX_FRONT) { if( GFX_eCullFace==GFX_NONE) pglEnable(GL_CULL_FACE); pglCullFace(GL_FRONT); } else if( eFace==GFX_BACK) { if( GFX_eCullFace==GFX_NONE) pglEnable(GL_CULL_FACE); pglCullFace(GL_BACK); } else { pglDisable(GL_CULL_FACE); } OGL_CHECKERROR; GFX_eCullFace = eFace; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
void VGUI_SetupDrawingRect( int *pColor ) { pglEnable( GL_BLEND ); pglDisable( GL_ALPHA_TEST ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] ); }
/* ============= R_EndGL ============= */ static void R_EndGL( void ) { if( RI.params & RP_FLIPFRONTFACE ) GL_FrontFace( !glState.frontFace ); if( RI.params & RP_CLIPPLANE ) pglDisable( GL_CLIP_PLANE0 ); }
/* =========== SCR_DrawNetGraph =========== */ void SCR_DrawNetGraph( void ) { wrect_t rect; float avg_ping; int ping_count; int w, x, y; if( !host.developer ) return; if( cls.state != ca_active ) return; if( !net_graph->value ) return; if( net_scale->value <= 0 ) Cvar_SetFloat( "net_scale", 0.1f ); NetGraph_GetScreenPos( &rect, &w, &x, &y ); NetGraph_GetFrameData( &avg_ping, &ping_count ); NetGraph_DrawTextFields( x, y, w, rect, ping_count, avg_ping, packet_loss, packet_choke ); if( net_graph->value < 3 ) { pglEnable( GL_BLEND ); pglDisable( GL_TEXTURE_2D ); pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE ); pglBegin( GL_QUADS ); // draw all the fills as a long solid sequence of quads for speedup reasons // NOTE: fill colors without texture at this point NetGraph_DrawDataUsage( x, y, w ); NetGraph_DrawTimes( rect, x, w ); pglEnd(); pglColor4ub( 255, 255, 255, 255 ); pglEnable( GL_TEXTURE_2D ); pglDisable( GL_BLEND ); } }
/* ================= R_Bloom_DownsampleView ================= */ static void R_Bloom_DownsampleView( void ) { pglDisable( GL_BLEND ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); if( r_screendownsamplingtexture_size ) { // stepped downsample int midsample_width = ( r_screendownsamplingtexture_size * sampleText_tcw ); int midsample_height = ( r_screendownsamplingtexture_size * sampleText_tch ); // copy the screen and draw resized GL_Bind( GL_TEXTURE0, r_bloomscreentexture ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, curView_x, glState.height - ( curView_y + curView_height ), curView_width, curView_height ); R_Bloom_Quad( 0, glState.height - midsample_height, midsample_width, midsample_height, screenTex_tcw, screenTex_tch ); // now copy into downsampling (mid-sized) texture GL_Bind( GL_TEXTURE0, r_bloomdownsamplingtexture ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, midsample_width, midsample_height ); // now draw again in bloom size pglColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); R_Bloom_Quad( 0, glState.height - sample_height, sample_width, sample_height, sampleText_tcw, sampleText_tch ); // now blend the big screen texture into the bloom generation space (hoping it adds some blur) pglEnable( GL_BLEND ); pglBlendFunc( GL_ONE, GL_ONE ); pglColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); GL_Bind( GL_TEXTURE0, r_bloomscreentexture ); R_Bloom_Quad( 0, glState.height - sample_height, sample_width, sample_height, screenTex_tcw, screenTex_tch ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); pglDisable( GL_BLEND ); } else { // downsample simple GL_Bind( GL_TEXTURE0, r_bloomscreentexture ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, curView_x, glState.height - ( curView_y + curView_height ), curView_width, curView_height ); R_Bloom_Quad( 0, glState.height - sample_height, sample_width, sample_height, screenTex_tcw, screenTex_tch ); } }
/* ================= GL_Cull ================= */ void GL_Cull( GLenum cull ) { if( !cull ) { pglDisable( GL_CULL_FACE ); glState.faceCull = 0; return; } pglEnable( GL_CULL_FACE ); pglCullFace( cull ); glState.faceCull = cull; }
/* ================= GL_TextureTarget ================= */ void GL_TextureTarget( uint target ) { if( glState.activeTMU < 0 || glState.activeTMU >= GL_MaxTextureUnits( )) { MsgDev( D_ERROR, "GL_TextureTarget: bad tmu state %i\n", glState.activeTMU ); return; } if( glState.currentTextureTargets[glState.activeTMU] != target ) { if( glState.currentTextureTargets[glState.activeTMU] != GL_NONE ) pglDisable( glState.currentTextureTargets[glState.activeTMU] ); glState.currentTextureTargets[glState.activeTMU] = target; if( target != GL_NONE ) pglEnable( glState.currentTextureTargets[glState.activeTMU] ); } }
/* ================= GL_TexGen ================= */ void GL_TexGen( GLenum coord, GLenum mode ) { int tmu = min( glConfig.max_texture_coords, glState.activeTMU ); int bit, gen; switch( coord ) { case GL_S: bit = 1; gen = GL_TEXTURE_GEN_S; break; case GL_T: bit = 2; gen = GL_TEXTURE_GEN_T; break; case GL_R: bit = 4; gen = GL_TEXTURE_GEN_R; break; case GL_Q: bit = 8; gen = GL_TEXTURE_GEN_Q; break; default: return; } if( mode ) { if( !( glState.genSTEnabled[tmu] & bit )) { pglEnable( gen ); glState.genSTEnabled[tmu] |= bit; } pglTexGeni( coord, GL_TEXTURE_GEN_MODE, mode ); } else { if( glState.genSTEnabled[tmu] & bit ) { pglDisable( gen ); glState.genSTEnabled[tmu] &= ~bit; } } }
static void _makeFrameBlack( float opacity ) { if ( opacity < 0.0f || opacity > 1.0f ) opacity = 1.0f; if ( CL_IsInConsole( ) ) // No strobing on the console { pglEnable( GL_SCISSOR_TEST ); pglScissor( con_rect.x, ( -con_rect.y ) - ( con_rect.h * 1.25 ), con_rect.w, con_rect.h ); // Preview strobe setting on static pglClearColor( 0.0f, 0.0f, 0.0f, opacity ); pglClear( GL_COLOR_BUFFER_BIT ); pglDisable( GL_SCISSOR_TEST ); } else { pglClearColor( 0.0f, 0.0f, 0.0f, opacity ); pglClear( GL_COLOR_BUFFER_BIT ); } }
/* ============== GL_CleanUpTextureUnits ============== */ void GL_CleanUpTextureUnits( int last ) { int i; for( i = glState.activeTMU; i > (last - 1); i-- ) { // disable upper units if( glState.currentTextureTargets[i] != GL_NONE ) { pglDisable( glState.currentTextureTargets[i] ); glState.currentTextureTargets[i] = GL_NONE; glState.currentTextures[i] = -1; // unbind texture } GL_SetTexCoordArrayMode( GL_NONE ); GL_LoadIdentityTexMatrix(); GL_DisableAllTexGens(); GL_SelectTexture( i - 1 ); } }
static void ogl_DisableClipPlane(void) { // check consistency ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_CLIP_PLANE0); OGL_CHECKERROR; ASSERT( !bRes == !GFX_bClipPlane); #endif // cached? if( !GFX_bClipPlane && gap_bOptimizeStateChanges) return; GFX_bClipPlane = FALSE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglDisable(GL_CLIP_PLANE0); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
/* ================= R_Bloom_DrawEffect ================= */ static void R_Bloom_DrawEffect( void ) { GL_Bind( GL_TEXTURE0, r_bloomeffecttexture ); pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglColor4f( r_bloom_alpha->value, r_bloom_alpha->value, r_bloom_alpha->value, 1.0f ); pglBlendFunc( GL_ONE, GL_ONE ); pglEnable( GL_BLEND ); pglBegin( GL_QUADS ); pglTexCoord2f( 0, sampleText_tch ); pglVertex2f( curView_x, curView_y ); pglTexCoord2f( 0, 0 ); pglVertex2f( curView_x, curView_y+curView_height ); pglTexCoord2f( sampleText_tcw, 0 ); pglVertex2f( curView_x+curView_width, curView_y+curView_height ); pglTexCoord2f( sampleText_tcw, sampleText_tch ); pglVertex2f( curView_x+curView_width, curView_y ); pglEnd(); pglDisable( GL_BLEND ); }
/* ================= GL_SetTexCoordArrayMode ================= */ void GL_SetTexCoordArrayMode( GLenum mode ) { int tmu = min( glConfig.max_texture_coords, glState.activeTMU ); int bit, cmode = glState.texCoordArrayMode[tmu]; if( mode == GL_TEXTURE_COORD_ARRAY ) bit = 1; else if( mode == GL_TEXTURE_CUBE_MAP_ARB ) bit = 2; else bit = 0; if( cmode != bit ) { if( cmode == 1 ) pglDisableClientState( GL_TEXTURE_COORD_ARRAY ); else if( cmode == 2 ) pglDisable( GL_TEXTURE_CUBE_MAP_ARB ); if( bit == 1 ) pglEnableClientState( GL_TEXTURE_COORD_ARRAY ); else if( bit == 2 ) pglEnable( GL_TEXTURE_CUBE_MAP_ARB ); glState.texCoordArrayMode[tmu] = bit; } }
static void ogl_DisableDepthTest(void) { // check consistency ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_DEPTH_TEST); OGL_CHECKERROR; ASSERT( !bRes == !GFX_bDepthTest); #endif // cached? if( !GFX_bDepthTest && gap_bOptimizeStateChanges) return; GFX_bDepthTest = FALSE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglDisable(GL_DEPTH_TEST); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
static void ogl_DisableTexture(void) { // check consistency ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_TEXTURE_2D); OGL_CHECKERROR; ASSERT( !bRes == !GFX_abTexture[GFX_iActiveTexUnit]); #endif // cached? if( !GFX_abTexture[GFX_iActiveTexUnit] && gap_bOptimizeStateChanges) return; GFX_abTexture[GFX_iActiveTexUnit] = FALSE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglDisable(GL_TEXTURE_2D); pglDisableClientState(GL_TEXTURE_COORD_ARRAY); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
// disable truform rendering static void ogl_DisableTruform(void) { // skip if Truform isn't set if( truform_iLevel<1) return; // check consistency ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); #ifndef NDEBUG BOOL bRes; bRes = pglIsEnabled(GL_PN_TRIANGLES_ATI); OGL_CHECKERROR; ASSERT( !bRes == !GFX_bTruform); #endif if( !GFX_bTruform && gap_bOptimizeStateChanges) return; GFX_bTruform = FALSE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglDisable( GL_PN_TRIANGLES_ATI); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
/* ================ VGUI_EnableTexture disable texturemode for fill rectangle ================ */ void VGUI_EnableTexture( qboolean enable ) { if( enable ) pglEnable( GL_TEXTURE_2D ); else pglDisable( GL_TEXTURE_2D ); }
/* ============= R_SetupGL ============= */ static void R_SetupGL( void ) { if( r_underwater_distortion->value && RI.refdef.waterlevel >= 3 ) { float f; f = sin( cl.time * r_underwater_distortion->value * ( M_PI * 2.7f )); RI.refdef.fov_x += f; RI.refdef.fov_y -= f; } R_SetupModelviewMatrix( &RI.refdef, RI.worldviewMatrix ); R_SetupProjectionMatrix( &RI.refdef, RI.projectionMatrix ); // if( RI.params & RP_MIRRORVIEW ) RI.projectionMatrix[0][0] = -RI.projectionMatrix[0][0]; Matrix4x4_Concat( RI.worldviewProjectionMatrix, RI.projectionMatrix, RI.worldviewMatrix ); if( RP_NORMALPASS( )) { int x, x2, y, y2; // set up viewport (main, playersetup) x = floor( RI.viewport[0] * glState.width / glState.width ); x2 = ceil(( RI.viewport[0] + RI.viewport[2] ) * glState.width / glState.width ); y = floor( glState.height - RI.viewport[1] * glState.height / glState.height ); y2 = ceil( glState.height - ( RI.viewport[1] + RI.viewport[3] ) * glState.height / glState.height ); pglViewport( x, y2, x2 - x, y - y2 ); } else { // envpass, mirrorpass pglViewport( RI.viewport[0], RI.viewport[1], RI.viewport[2], RI.viewport[3] ); } pglMatrixMode( GL_PROJECTION ); GL_LoadMatrix( RI.projectionMatrix ); pglMatrixMode( GL_MODELVIEW ); GL_LoadMatrix( RI.worldviewMatrix ); if( RI.params & RP_CLIPPLANE ) { GLdouble clip[4]; mplane_t *p = &RI.clipPlane; clip[0] = p->normal[0]; clip[1] = p->normal[1]; clip[2] = p->normal[2]; clip[3] = -p->dist; pglClipPlane( GL_CLIP_PLANE0, clip ); pglEnable( GL_CLIP_PLANE0 ); } if( RI.params & RP_FLIPFRONTFACE ) GL_FrontFace( !glState.frontFace ); GL_Cull( GL_FRONT ); pglDisable( GL_BLEND ); pglDisable( GL_ALPHA_TEST ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); }
/* ============= R_DrawStretchRaw ============= */ void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty ) { byte *raw = NULL; gltexture_t *tex; if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT )) { int width = 1, height = 1; // check the dimensions width = NearestPOW( cols, true ); height = NearestPOW( rows, false ); if( cols != width || rows != height ) { raw = GL_ResampleTexture( data, cols, rows, width, height, false ); cols = width; rows = height; } } else { raw = (byte *)data; } if( cols > glConfig.max_2d_texture_size ) Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", cols ); if( rows > glConfig.max_2d_texture_size ) Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", rows ); pglDisable( GL_BLEND ); pglDisable( GL_ALPHA_TEST ); pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); tex = R_GetTexture( tr.cinTexture ); GL_Bind( GL_TEXTURE0, tr.cinTexture ); if( cols == tex->width && rows == tex->height ) { if( dirty ) { pglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_BGRA, GL_UNSIGNED_BYTE, raw ); } } else { tex->width = cols; tex->height = rows; if( dirty ) { pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, cols, rows, 0, GL_BGRA, GL_UNSIGNED_BYTE, raw ); } } pglBegin( GL_QUADS ); pglTexCoord2f( 0, 0 ); pglVertex2f( x, y ); pglTexCoord2f( 1, 0 ); pglVertex2f( x + w, y ); pglTexCoord2f( 1, 1 ); pglVertex2f( x + w, y + h ); pglTexCoord2f( 0, 1 ); pglVertex2f( x, y + h ); pglEnd(); }
/* ============= R_DrawEntitiesOnList ============= */ void R_DrawEntitiesOnList( void ) { int i; glState.drawTrans = false; // draw the solid submodels fog R_DrawFog (); // first draw solid entities for( i = 0; i < tr.num_solid_entities; i++ ) { if( RI.refdef.onlyClientDraw ) break; RI.currententity = tr.solid_entities[i]; RI.currentmodel = RI.currententity->model; ASSERT( RI.currententity != NULL ); ASSERT( RI.currententity->model != NULL ); switch( RI.currentmodel->type ) { case mod_brush: R_DrawBrushModel( RI.currententity ); break; case mod_studio: R_DrawStudioModel( RI.currententity ); break; case mod_sprite: R_DrawSpriteModel( RI.currententity ); break; default: break; } } if( !RI.refdef.onlyClientDraw ) { CL_DrawBeams( false ); } if( RI.drawWorld ) clgame.dllFuncs.pfnDrawNormalTriangles(); // NOTE: some mods with custom renderer may generate glErrors // so we clear it here while( pglGetError() != GL_NO_ERROR ); // don't fogging translucent surfaces if( !RI.fogCustom ) pglDisable( GL_FOG ); pglDepthMask( GL_FALSE ); glState.drawTrans = true; // then draw translucent entities for( i = 0; i < tr.num_trans_entities; i++ ) { if( RI.refdef.onlyClientDraw ) break; RI.currententity = tr.trans_entities[i]; RI.currentmodel = RI.currententity->model; ASSERT( RI.currententity != NULL ); ASSERT( RI.currententity->model != NULL ); switch( RI.currentmodel->type ) { case mod_brush: R_DrawBrushModel( RI.currententity ); break; case mod_studio: R_DrawStudioModel( RI.currententity ); break; case mod_sprite: R_DrawSpriteModel( RI.currententity ); break; default: break; } } if( RI.drawWorld ) clgame.dllFuncs.pfnDrawTransparentTriangles (); if( !RI.refdef.onlyClientDraw ) { CL_DrawBeams( true ); CL_DrawParticles(); } // NOTE: some mods with custom renderer may generate glErrors // so we clear it here while( pglGetError() != GL_NO_ERROR ); glState.drawTrans = false; pglDepthMask( GL_TRUE ); pglDisable( GL_BLEND ); // Trinity Render issues R_DrawViewModel(); CL_ExtraUpdate(); }