/* * RB_BindImage */ void RB_BindImage( int tmu, const image_t *tex ) { GLuint texnum; assert( tex != NULL ); assert( tex->texnum != 0 ); if( tex->missing ) { tex = rsh.noTexture; } else if( !tex->loaded ) { // not yet loaded from disk tex = tex->flags & IT_CUBEMAP ? rsh.whiteCubemapTexture : rsh.whiteTexture; } else if( rsh.noTexture && ( r_nobind->integer && tex->texnum != 0 ) ) { // performance evaluation option tex = rsh.noTexture; } if( rb.gl.flushTextures ) { rb.gl.flushTextures = false; memset( rb.gl.currentTextures, 0, sizeof( rb.gl.currentTextures ) ); } texnum = tex->texnum; if( rb.gl.currentTextures[tmu] == texnum ) return; rb.gl.currentTextures[tmu] = texnum; RB_SelectTextureUnit( tmu ); qglBindTexture( R_TextureTarget( tex->flags, NULL ), tex->texnum ); rb.stats.c_totalBinds++; }
/* * RB_SetGLDefaults */ static void RB_SetGLDefaults( void ) { int i; qglClearColor( 1, 0, 0.5, 0.5 ); if( glConfig.stencilEnabled ) { qglStencilMask( ( GLuint ) ~0 ); qglStencilFunc( GL_EQUAL, 128, 0xFF ); qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); } // properly disable multitexturing at startup for( i = glConfig.maxTextureUnits-1; i >= 0; i-- ) { RB_SelectTextureUnit( i ); qglDisable( GL_TEXTURE_2D ); } qglEnable( GL_TEXTURE_2D ); qglDisable( GL_CULL_FACE ); qglFrontFace( GL_CCW ); qglEnable( GL_SCISSOR_TEST ); qglDisable( GL_BLEND ); qglDisable( GL_ALPHA_TEST ); qglDepthFunc( GL_LEQUAL ); qglDepthMask( GL_FALSE ); qglDisable( GL_POLYGON_OFFSET_FILL ); qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); qglEnable( GL_DEPTH_TEST ); qglShadeModel( GL_SMOOTH ); if( qglPolygonMode ) { qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } qglFrontFace( GL_CCW ); rb.gl.state = 0; rb.gl.frontFace = qfalse; rb.gl.currentTMU = -1; rb.gl.faceCull = 0; rb.gl.polygonOffset[0] = rb.gl.polygonOffset[1] = 0; memset( rb.gl.currentTextures, 0, sizeof( rb.gl.currentTextures ) ); }
/* * RB_BeginRegistration */ void RB_BeginRegistration( void ) { int i; RB_RegisterStreamVBOs(); RB_BindVBO( 0, 0 ); // unbind all texture targets on all TMUs for( i = MAX_TEXTURE_UNITS - 1; i >= 0; i-- ) { RB_SelectTextureUnit( i ); qglBindTexture( GL_TEXTURE_CUBE_MAP_ARB, 0 ); if( glConfig.ext.texture_array ) qglBindTexture( GL_TEXTURE_2D_ARRAY_EXT, 0 ); if( glConfig.ext.texture3D ) qglBindTexture( GL_TEXTURE_3D_EXT, 0 ); qglBindTexture( GL_TEXTURE_2D, 0 ); } RB_FlushTextureCache(); }
/* * RB_BindTexture */ void RB_BindTexture( int tmu, const image_t *tex ) { GLuint texnum; assert( tex != NULL ); if( r_nobind->integer && r_notexture && tex->texnum != 0 ) // performance evaluation option tex = r_notexture; RB_SelectTextureUnit( tmu ); texnum = tex->texnum; if( rb.gl.currentTextures[tmu] == texnum ) return; rb.gl.anyTexturesBound = 1; rb.gl.currentTextures[tmu] = texnum; if( tex->flags & IT_CUBEMAP ) qglBindTexture( GL_TEXTURE_CUBE_MAP_ARB, texnum ); else qglBindTexture( GL_TEXTURE_2D, texnum ); }