void VGUI_SetupDrawingText( int *pColor ) { pglEnable( GL_BLEND ); pglEnable( GL_ALPHA_TEST ); pglAlphaFunc( GL_GREATER, 0.0f ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] ); }
static void ogl_EnableDepthBias(void) { ASSERT( _pGfx->gl_eCurrentAPI==GAT_OGL); _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglEnable( GL_POLYGON_OFFSET_POINT); pglEnable( GL_POLYGON_OFFSET_LINE); pglEnable( GL_POLYGON_OFFSET_FILL); pglPolygonOffset( -1.0f, -2.0f); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
static void ogl_EnableBlend(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 = TRUE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglEnable( GL_BLEND); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); // adjust dithering if( gap_iDithering==2) ogl_EnableDither(); else ogl_DisableDither(); }
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_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 ); }
/* =========== 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_DrawFog ============= */ void R_DrawFog( void ) { if( !RI.fogEnabled || RI.refdef.onlyClientDraw ) return; pglEnable( GL_FOG ); pglFogi( GL_FOG_MODE, GL_EXP ); pglFogf( GL_FOG_DENSITY, RI.fogDensity ); pglFogfv( GL_FOG_COLOR, RI.fogColor ); pglHint( GL_FOG_HINT, GL_NICEST ); }
/* ================= 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; }
/* ============= 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 ); }
SDL_bool blitter_opengl_resize(int w,int h) { Uint32 sdl_flags; sdl_flags = SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE | SDL_OPENGL | SDL_RESIZABLE; video_opengl = SDL_SetVideoMode(w, h, 16, sdl_flags); if ( video_opengl == NULL) return SDL_FALSE; pglEnable(GL_TEXTURE_2D); pglViewport(0, 0, w, h); return SDL_TRUE; }
/* ================= 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 ); } }
/* ================= 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 ); } }
static void ogl_EnableDepthTest(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 = TRUE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglEnable( GL_DEPTH_TEST); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
static void ogl_EnableClipPlane(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 = TRUE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglEnable( 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 ); }
static void ogl_EnableTexture(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] = TRUE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglEnable(GL_TEXTURE_2D); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
/* ================= 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; } }
// enable truform rendering static void ogl_EnableTruform(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 = TRUE; _sfStats.StartTimer(CStatForm::STI_GFXAPI); pglEnable( GL_PN_TRIANGLES_ATI); OGL_CHECKERROR; _sfStats.StopTimer(CStatForm::STI_GFXAPI); }
SDL_bool blitter_opengl_init() { Uint32 sdl_flags; Uint32 width = visible_area.w; Uint32 height = visible_area.h; if (load_glproc() == SDL_FALSE) return SDL_FALSE; sdl_flags = (fullscreen?SDL_FULLSCREEN:0)| SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE | SDL_OPENGL | SDL_RESIZABLE; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if ((effect[neffect].x_ratio!=2 || effect[neffect].y_ratio!=2) && (effect[neffect].x_ratio!=1 || effect[neffect].y_ratio!=1) ) { printf("Opengl support only effect with a ratio of 2x2 or 1x1\n"); return SDL_FALSE; } /* if (conf.res_x==304 && conf.res_y==224) { */ if (scale < 2) { width *=effect[neffect].x_ratio; height*=effect[neffect].y_ratio; } width *= scale; height *= scale; /* } else { width = conf.res_x; height=conf.res_y; } */ conf.res_x=width; conf.res_y=height; video_opengl = SDL_SetVideoMode(width, height, 16, sdl_flags); if ( video_opengl == NULL) return SDL_FALSE; pglClearColor(0, 0, 0, 0); pglClear(GL_COLOR_BUFFER_BIT); pglEnable(GL_TEXTURE_2D); pglViewport(0, 0, width, height); /* Linear Filter */ pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); /* pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); */ /* Texture Mode */ pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); if (neffect == 0) { /* Texture limits */ /* a = (240.0/304.0); b = (48.0/256.0); c = (240.0/256.0); */ #ifdef USE_GL2 tex_opengl= SDL_CreateRGBSurface(SDL_SWSURFACE, 512, 256, 16, 0xF800, 0x7E0, 0x1F, 0); #else pglPixelStorei(GL_UNPACK_ROW_LENGTH, 352); #endif } else { /* Texture limits */ a = ((256.0/(float)visible_area.w) - 1.0f)*effect[neffect].x_ratio/2.0; b = ((512.0/(float)visible_area.w) - 1.0f)*effect[neffect].x_ratio/2.0; c = (((float)visible_area.h/256.0))*effect[neffect].y_ratio/2.0; d = (((float)((visible_area.w<<1)-512)/256.0))*effect[neffect].y_ratio/2.0; screen = SDL_CreateRGBSurface(SDL_SWSURFACE, visible_area.w<<1, /*visible_area.h<<1*/512, 16, 0xF800, 0x7E0, 0x1F, 0); //printf("[opengl] create_screen %p\n",screen); #ifdef USE_GL2 tex_opengl= SDL_CreateRGBSurface(SDL_SWSURFACE, 1024, 512, 16, 0xF800, 0x7E0, 0x1F, 0); if (visible_area.w==320) { glrectef.x=0; glrectef.y=0; glrectef.w=320*2; glrectef.h=224*2; } else { glrectef.x=0; glrectef.y=0; glrectef.w=304*2; glrectef.h=224*2; } #else pglPixelStorei(GL_UNPACK_ROW_LENGTH, visible_area.w<<1); #endif } return SDL_TRUE; }
void DrawSurfaceDecals( msurface_t *fa ) { decal_t *p; cl_entity_t *e; if( !fa->pdecals ) return; e = RI.currententity; ASSERT( e != NULL ); if( e->curstate.rendermode == kRenderNormal || e->curstate.rendermode == kRenderTransAlpha ) { pglDepthMask( GL_FALSE ); pglEnable( GL_BLEND ); if( e->curstate.rendermode == kRenderTransAlpha ) pglDisable( GL_ALPHA_TEST ); } if( e->curstate.rendermode == kRenderTransColor ) pglEnable( GL_TEXTURE_2D ); if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd ) GL_Cull( GL_NONE ); pglEnable( GL_POLYGON_OFFSET_FILL ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); if( fa->flags & SURF_TRANSPARENT && glState.stencilEnabled ) { mtexinfo_t *tex = fa->texinfo; for( p = fa->pdecals; p; p = p->pnext ) { if( p->texture ) { float *o, *v; int i, numVerts; o = R_DecalSetupVerts( p, fa, p->texture, &numVerts ); pglEnable( GL_STENCIL_TEST ); pglStencilFunc( GL_ALWAYS, 1, 0xFFFFFFFF ); pglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); pglStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE ); pglBegin( GL_POLYGON ); for( i = 0, v = o; i < numVerts; i++, v += VERTEXSIZE ) { v[5] = ( DotProduct( v, tex->vecs[0] ) + tex->vecs[0][3] ) / tex->texture->width; v[6] = ( DotProduct( v, tex->vecs[1] ) + tex->vecs[1][3] ) / tex->texture->height; pglTexCoord2f( v[5], v[6] ); pglVertex3fv( v ); } pglEnd(); pglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); pglEnable( GL_ALPHA_TEST ); pglBegin( GL_POLYGON ); for( i = 0, v = o; i < numVerts; i++, v += VERTEXSIZE ) { pglTexCoord2f( v[5], v[6] ); pglVertex3fv( v ); } pglEnd(); pglDisable( GL_ALPHA_TEST ); pglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); pglStencilFunc( GL_EQUAL, 0, 0xFFFFFFFF ); pglStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); } } } for( p = fa->pdecals; p; p = p->pnext ) { if( p->texture ) { gltexture_t *glt = R_GetTexture( p->texture ); // normal HL decal with alpha-channel if( glt->flags & TF_HAS_ALPHA ) { // draw transparent decals with GL_MODULATE if( glt->fogParams[3] > DECAL_TRANSPARENT_THRESHOLD ) pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); else pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); } else { // color decal like detail texture. Base color is 127 127 127 pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); pglBlendFunc( GL_DST_COLOR, GL_SRC_COLOR ); } DrawSingleDecal( p, fa ); } } if( fa->flags & SURF_TRANSPARENT && glState.stencilEnabled ) pglDisable( GL_STENCIL_TEST ); if( e->curstate.rendermode == kRenderNormal || e->curstate.rendermode == kRenderTransAlpha ) { pglDepthMask( GL_TRUE ); pglDisable( GL_BLEND ); if( e->curstate.rendermode == kRenderTransAlpha ) pglEnable( GL_ALPHA_TEST ); } pglDisable( GL_POLYGON_OFFSET_FILL ); if( e->curstate.rendermode == kRenderTransTexture || e->curstate.rendermode == kRenderTransAdd ) GL_Cull( GL_FRONT ); if( e->curstate.rendermode == kRenderTransColor ) pglDisable( GL_TEXTURE_2D ); // restore blendfunc here if( e->curstate.rendermode == kRenderTransAdd || e->curstate.rendermode == kRenderGlow ) pglBlendFunc( GL_SRC_ALPHA, GL_ONE ); }
/* ============= 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_BloomBlend ================= */ void R_BloomBlend( const ref_params_t *fd ) { if( !r_bloom->value ) return; if( !BLOOM_SIZE ) R_Bloom_InitTextures(); if( screen_texture_width < BLOOM_SIZE || screen_texture_height < BLOOM_SIZE ) return; // set up full screen workspace 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, -10, 100 ); pglMatrixMode( GL_MODELVIEW ); pglLoadIdentity(); pglDisable( GL_DEPTH_TEST ); pglDisable( GL_ALPHA_TEST ); pglDepthMask( GL_FALSE ); pglDisable( GL_BLEND ); GL_Cull( 0 ); pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); // set up current sizes curView_x = fd->viewport[0]; curView_y = fd->viewport[1]; curView_width = fd->viewport[2]; curView_height = fd->viewport[3]; screenTex_tcw = ( (float)curView_width / (float)screen_texture_width ); screenTex_tch = ( (float)curView_height / (float)screen_texture_height ); if( curView_height > curView_width ) { sampleText_tcw = ( (float)curView_width / (float)curView_height ); sampleText_tch = 1.0f; } else { sampleText_tcw = 1.0f; sampleText_tch = ( (float)curView_height / (float)curView_width ); } sample_width = ( BLOOM_SIZE * sampleText_tcw ); sample_height = ( BLOOM_SIZE * sampleText_tch ); // copy the screen space we'll use to work into the backup texture GL_Bind( GL_TEXTURE0, r_bloombackuptexture ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, r_screenbackuptexture_width * sampleText_tcw, r_screenbackuptexture_height * sampleText_tch ); // create the bloom image R_Bloom_DownsampleView(); R_Bloom_GeneratexDiamonds(); pglDisable( GL_BLEND ); // restore the screen-backup to the screen GL_Bind( GL_TEXTURE0, r_bloombackuptexture ); pglColor4f( 1, 1, 1, 1 ); R_Bloom_Quad( 0, glState.height - (r_screenbackuptexture_height * sampleText_tch), r_screenbackuptexture_width * sampleText_tcw, r_screenbackuptexture_height * sampleText_tch, sampleText_tcw, sampleText_tch ); pglScissor( RI.scissor[0], RI.scissor[1], RI.scissor[2], RI.scissor[3] ); R_Bloom_DrawEffect(); 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 ); pglEnable( GL_DEPTH_TEST ); pglDepthMask( GL_TRUE ); pglDisable( GL_BLEND ); GL_Cull( GL_FRONT ); }
/* ================= R_ShadowPassDrawBrushModel ================= */ void R_ShadowPassDrawBrushModel( cl_entity_t *e, const plight_t *pl ) { Vector mins, maxs; model_t *clmodel; bool rotated; clmodel = e->model; if( e->angles != g_vecZero ) { for( int i = 0; i < 3; i++ ) { mins[i] = e->origin[i] - clmodel->radius; maxs[i] = e->origin[i] + clmodel->radius; } rotated = true; } else { mins = e->origin + clmodel->mins; maxs = e->origin + clmodel->maxs; rotated = false; } if( R_CullBox( mins, maxs, RI.clipFlags )) return; if( RI.params & ( RP_SKYPORTALVIEW|RP_PORTALVIEW|RP_SCREENVIEW )) { if( rotated ) { if( R_VisCullSphere( e->origin, clmodel->radius )) return; } else { if( R_VisCullBox( mins, maxs )) return; } } if( rotated ) R_RotateForEntity( e ); else R_TranslateForEntity( e ); if( rotated ) tr.modelorg = RI.objectMatrix.VectorITransform( RI.vieworg ); else tr.modelorg = RI.vieworg - e->origin; // accumulate lit surfaces msurface_t *psurf = &clmodel->surfaces[clmodel->firstmodelsurface]; for( int i = 0; i < clmodel->nummodelsurfaces; i++, psurf++ ) { float *v; int k; if( psurf->flags & (SURF_DRAWTILED|SURF_PORTAL|SURF_REFLECT)) continue; R_AddToGrassChain( psurf, pl->frustum, pl->clipflags, false ); if( R_CullSurfaceExt( psurf, pl->frustum, 0 )) continue; // draw depth-mask on transparent textures if( psurf->flags & SURF_TRANSPARENT ) { pglEnable( GL_ALPHA_TEST ); pglEnable( GL_TEXTURE_2D ); pglAlphaFunc( GL_GREATER, 0.0f ); GL_Bind( GL_TEXTURE0, psurf->texinfo->texture->gl_texturenum ); } pglBegin( GL_POLYGON ); for( k = 0, v = psurf->polys->verts[0]; k < psurf->polys->numverts; k++, v += VERTEXSIZE ) { if( psurf->flags & SURF_TRANSPARENT ) pglTexCoord2f( v[3], v[4] ); pglVertex3fv( v ); } pglEnd(); if( psurf->flags & SURF_TRANSPARENT ) { pglDisable( GL_ALPHA_TEST ); pglDisable( GL_TEXTURE_2D ); } } R_LoadIdentity(); // restore worldmatrix }
/* ================ VGUI_EnableTexture disable texturemode for fill rectangle ================ */ void VGUI_EnableTexture( qboolean enable ) { if( enable ) pglEnable( GL_TEXTURE_2D ); else pglDisable( GL_TEXTURE_2D ); }
/* ================= R_Bloom_GeneratexDiamonds ================= */ static void R_Bloom_GeneratexDiamonds( void ) { int i, j; float intensity; // set up sample size workspace pglScissor( 0, 0, sample_width, sample_height ); pglViewport( 0, 0, sample_width, sample_height ); pglMatrixMode( GL_PROJECTION ); pglLoadIdentity(); pglOrtho( 0, sample_width, sample_height, 0, -10, 100 ); pglMatrixMode( GL_MODELVIEW ); pglLoadIdentity(); // copy small scene into r_bloomeffecttexture GL_Bind( GL_TEXTURE0, r_bloomeffecttexture ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height ); // start modifying the small scene corner pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); pglEnable( GL_BLEND ); // darkening passes if( r_bloom_darken->value ) { pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglBlendFunc( GL_DST_COLOR, GL_ZERO ); for( i = 0; i < (int)r_bloom_darken->value; i++ ) R_Bloom_SamplePass( 0, 0 ); pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height ); } // bluring passes pglBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_COLOR ); if( r_bloom_diamond_size->value > 7.0f || r_bloom_diamond_size->value <= 3.0f ) { if( r_bloom_diamond_size->value != 8.0f ) CVAR_SET_FLOAT( "r_bloom_diamond_size", 8.0f ); for( i = 0; i < r_bloom_diamond_size->value; i++ ) { for( j = 0; j < r_bloom_diamond_size->value; j++ ) { intensity = r_bloom_intensity->value * 0.3f * Diamond8x[i][j]; if( intensity < 0.01f ) continue; pglColor4f( intensity, intensity, intensity, 1.0f ); R_Bloom_SamplePass( i-4, j-4 ); } } } else if( r_bloom_diamond_size->value > 5.0f ) { if( r_bloom_diamond_size->value != 6.0f ) CVAR_SET_FLOAT( "r_bloom_diamond_size", 6.0f ); for( i = 0; i < r_bloom_diamond_size->value; i++ ) { for( j = 0; j < r_bloom_diamond_size->value; j++ ) { intensity = r_bloom_intensity->value * 0.5f * Diamond6x[i][j]; if( intensity < 0.01f ) continue; pglColor4f( intensity, intensity, intensity, 1.0f ); R_Bloom_SamplePass( i-3, j-3 ); } } } else if( r_bloom_diamond_size->value > 3.0f ) { if( r_bloom_diamond_size->value != 4.0f ) CVAR_SET_FLOAT( "r_bloom_diamond_size", 4.0f ); for( i = 0; i < r_bloom_diamond_size->value; i++ ) { for( j = 0; j < r_bloom_diamond_size->value; j++ ) { intensity = r_bloom_intensity->value * 0.8f * Diamond4x[i][j]; if( intensity < 0.01f ) continue; pglColor4f( intensity, intensity, intensity, 1.0f ); R_Bloom_SamplePass( i-2, j-2 ); } } } pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height ); // restore full screen workspace 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, -10, 100 ); pglMatrixMode( GL_MODELVIEW ); pglLoadIdentity(); }
void GL_InitExtensions( void ) { // initialize gl extensions GL_CheckExtension( "OpenGL 1.1.0", opengl_110funcs, NULL, GL_OPENGL_110 ); // get our various GL strings glConfig.vendor_string = pglGetString( GL_VENDOR ); glConfig.renderer_string = pglGetString( GL_RENDERER ); glConfig.version_string = pglGetString( GL_VERSION ); glConfig.extensions_string = pglGetString( GL_EXTENSIONS ); MsgDev( D_INFO, "Video: %s\n", glConfig.renderer_string ); // initalize until base opengl functions loaded GL_CheckExtension( "glDrawRangeElements", drawrangeelementsfuncs, "gl_drawrangeelments", GL_DRAW_RANGEELEMENTS_EXT ); if( !GL_Support( GL_DRAW_RANGEELEMENTS_EXT )) GL_CheckExtension( "GL_EXT_draw_range_elements", drawrangeelementsextfuncs, "gl_drawrangeelments", GL_DRAW_RANGEELEMENTS_EXT ); // multitexture glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1; GL_CheckExtension( "GL_ARB_multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE ); if( GL_Support( GL_ARB_MULTITEXTURE )) { pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units ); GL_CheckExtension( "GL_ARB_texture_env_combine", NULL, "gl_texture_env_combine", GL_ENV_COMBINE_EXT ); if( !GL_Support( GL_ENV_COMBINE_EXT )) GL_CheckExtension( "GL_EXT_texture_env_combine", NULL, "gl_texture_env_combine", GL_ENV_COMBINE_EXT ); if( GL_Support( GL_ENV_COMBINE_EXT )) GL_CheckExtension( "GL_ARB_texture_env_dot3", NULL, "gl_texture_env_dot3", GL_DOT3_ARB_EXT ); } else { GL_CheckExtension( "GL_SGIS_multitexture", sgis_multitexturefuncs, "gl_sgis_multitexture", GL_ARB_MULTITEXTURE ); if( GL_Support( GL_ARB_MULTITEXTURE )) glConfig.max_texture_units = 2; } if( glConfig.max_texture_units == 1 ) GL_SetExtension( GL_ARB_MULTITEXTURE, false ); // 3d texture support GL_CheckExtension( "GL_EXT_texture3D", texture3dextfuncs, "gl_texture_3d", GL_TEXTURE_3D_EXT ); if( GL_Support( GL_TEXTURE_3D_EXT )) { pglGetIntegerv( GL_MAX_3D_TEXTURE_SIZE, &glConfig.max_3d_texture_size ); if( glConfig.max_3d_texture_size < 32 ) { GL_SetExtension( GL_TEXTURE_3D_EXT, false ); MsgDev( D_ERROR, "GL_EXT_texture3D reported bogus GL_MAX_3D_TEXTURE_SIZE, disabled\n" ); } } GL_CheckExtension( "GL_SGIS_generate_mipmap", NULL, "gl_sgis_generate_mipmaps", GL_SGIS_MIPMAPS_EXT ); // hardware cubemaps GL_CheckExtension( "GL_ARB_texture_cube_map", NULL, "gl_texture_cubemap", GL_TEXTURECUBEMAP_EXT ); if( GL_Support( GL_TEXTURECUBEMAP_EXT )) { pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size ); // check for seamless cubemaps too GL_CheckExtension( "GL_ARB_seamless_cube_map", NULL, "gl_seamless_cubemap", GL_ARB_SEAMLESS_CUBEMAP ); } // point particles extension GL_CheckExtension( "GL_EXT_point_parameters", pointparametersfunc, NULL, GL_EXT_POINTPARAMETERS ); GL_CheckExtension( "GL_ARB_texture_non_power_of_two", NULL, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT ); GL_CheckExtension( "GL_ARB_texture_compression", texturecompressionfuncs, "gl_dds_hardware_support", GL_TEXTURE_COMPRESSION_EXT ); GL_CheckExtension( "GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "gl_cva_support", GL_CUSTOM_VERTEX_ARRAY_EXT ); if( !GL_Support( GL_CUSTOM_VERTEX_ARRAY_EXT )) GL_CheckExtension( "GL_SGI_compiled_vertex_array", compiledvertexarrayfuncs, "gl_cva_support", GL_CUSTOM_VERTEX_ARRAY_EXT ); GL_CheckExtension( "GL_EXT_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT ); if( !GL_Support( GL_CLAMPTOEDGE_EXT )) GL_CheckExtension("GL_SGIS_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT ); glConfig.max_texture_anisotropy = 0.0f; GL_CheckExtension( "GL_EXT_texture_filter_anisotropic", NULL, "gl_ext_anisotropic_filter", GL_ANISOTROPY_EXT ); if( GL_Support( GL_ANISOTROPY_EXT )) pglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.max_texture_anisotropy ); GL_CheckExtension( "GL_EXT_texture_lod_bias", NULL, "gl_ext_texture_lodbias", GL_TEXTURE_LODBIAS ); if( GL_Support( GL_TEXTURE_LODBIAS )) pglGetFloatv( GL_MAX_TEXTURE_LOD_BIAS_EXT, &glConfig.max_texture_lodbias ); GL_CheckExtension( "GL_ARB_texture_border_clamp", NULL, "gl_ext_texborder_clamp", GL_CLAMP_TEXBORDER_EXT ); GL_CheckExtension( "GL_EXT_blend_minmax", blendequationfuncs, "gl_ext_customblend", GL_BLEND_MINMAX_EXT ); GL_CheckExtension( "GL_EXT_blend_subtract", blendequationfuncs, "gl_ext_customblend", GL_BLEND_SUBTRACT_EXT ); GL_CheckExtension( "glStencilOpSeparate", gl2separatestencilfuncs, "gl_separate_stencil", GL_SEPARATESTENCIL_EXT ); if( !GL_Support( GL_SEPARATESTENCIL_EXT )) GL_CheckExtension("GL_ATI_separate_stencil", atiseparatestencilfuncs, "gl_separate_stencil", GL_SEPARATESTENCIL_EXT ); GL_CheckExtension( "GL_EXT_stencil_two_side", stenciltwosidefuncs, "gl_stenciltwoside", GL_STENCILTWOSIDE_EXT ); GL_CheckExtension( "GL_ARB_vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", GL_ARB_VERTEX_BUFFER_OBJECT_EXT ); // we don't care if it's an extension or not, they are identical functions, so keep it simple in the rendering code if( pglDrawRangeElementsEXT == NULL ) pglDrawRangeElementsEXT = pglDrawRangeElements; GL_CheckExtension( "GL_ARB_texture_env_add", NULL, "gl_texture_env_add", GL_TEXTURE_ENV_ADD_EXT ); // vp and fp shaders GL_CheckExtension( "GL_ARB_shader_objects", shaderobjectsfuncs, "gl_shaderobjects", GL_SHADER_OBJECTS_EXT ); GL_CheckExtension( "GL_ARB_shading_language_100", NULL, "gl_glslprogram", GL_SHADER_GLSL100_EXT ); GL_CheckExtension( "GL_ARB_vertex_shader", vertexshaderfuncs, "gl_vertexshader", GL_VERTEX_SHADER_EXT ); GL_CheckExtension( "GL_ARB_fragment_shader", NULL, "gl_pixelshader", GL_FRAGMENT_SHADER_EXT ); GL_CheckExtension( "GL_ARB_depth_texture", NULL, "gl_depthtexture", GL_DEPTH_TEXTURE ); GL_CheckExtension( "GL_ARB_shadow", NULL, "gl_arb_shadow", GL_SHADOW_EXT ); GL_CheckExtension( "GL_ARB_texture_float", NULL, "gl_arb_texture_float", GL_ARB_TEXTURE_FLOAT_EXT ); GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_arb_depth_float", GL_ARB_DEPTH_FLOAT_EXT ); if( glw_state.extended ) GL_CheckExtension( "GL_ARB_debug_output", debugoutputfuncs, "gl_debug_output", GL_DEBUG_OUTPUT ); // occlusion queries GL_CheckExtension( "GL_ARB_occlusion_query", occlusionfunc, "gl_occlusion_queries", GL_OCCLUSION_QUERIES_EXT ); if( GL_Support( GL_SHADER_GLSL100_EXT )) { pglGetIntegerv( GL_MAX_TEXTURE_COORDS_ARB, &glConfig.max_texture_coords ); pglGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &glConfig.max_teximage_units ); } else { // just get from multitexturing glConfig.max_texture_coords = glConfig.max_teximage_units = glConfig.max_texture_units; } // rectangle textures support if( Q_strstr( glConfig.extensions_string, "GL_NV_texture_rectangle" )) { glConfig.texRectangle = GL_TEXTURE_RECTANGLE_NV; pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &glConfig.max_2d_rectangle_size ); } else if( Q_strstr( glConfig.extensions_string, "GL_EXT_texture_rectangle" )) { glConfig.texRectangle = GL_TEXTURE_RECTANGLE_EXT; pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &glConfig.max_2d_rectangle_size ); } else glConfig.texRectangle = glConfig.max_2d_rectangle_size = 0; // no rectangle glConfig.max_2d_texture_size = 0; pglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.max_2d_texture_size ); if( glConfig.max_2d_texture_size <= 0 ) glConfig.max_2d_texture_size = 256; Cvar_Get( "gl_max_texture_size", "0", CVAR_INIT, "opengl texture max dims" ); Cvar_Set( "gl_max_texture_size", va( "%i", glConfig.max_2d_texture_size )); pglGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &glConfig.max_vertex_uniforms ); pglGetIntegerv( GL_MAX_VERTEX_ATTRIBS_ARB, &glConfig.max_vertex_attribs ); // MCD has buffering issues #ifdef _WIN32 if(Q_strstr( glConfig.renderer_string, "gdi" )) Cvar_SetFloat( "gl_finish", 1 ); #endif #ifdef XASH_GLES Cvar_FullSet( "gl_allow_mirrors", "0", CVAR_READ_ONLY); // No support for GLES #endif Cvar_Set( "gl_anisotropy", va( "%f", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy ))); // software mipmap generator does wrong result with NPOT textures ... if( !GL_Support( GL_SGIS_MIPMAPS_EXT )) GL_SetExtension( GL_ARB_TEXTURE_NPOT_EXT, false ); if( GL_Support( GL_TEXTURE_COMPRESSION_EXT )) Image_AddCmdFlags( IL_DDS_HARDWARE ); // enable gldebug if allowed if( GL_Support( GL_DEBUG_OUTPUT )) { if( host.developer >= D_ERROR ) { MsgDev( D_NOTE, "Installing GL_DebugOutput...\n"); pglDebugMessageCallbackARB( GL_DebugOutput, NULL ); } // force everything to happen in the main thread instead of in a separate driver thread if( host.developer >= D_WARN ) pglEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB ); // enable all the low priority messages if( host.developer >= D_NOTE ) pglDebugMessageControlARB( GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, true ); } glw_state.initialized = true; tr.framecount = tr.visframecount = 1; }