From f0278d0381ac57be161d7d4f136a9571b35eaf05 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 24 May 2013 22:02:52 -0500 Subject: Allow drawing sun in OpenGL1 renderer Removed #if 0 ... #endif around RB_DrawSun(). Merged improvements and changes from OpenGL2 renderer. --- src/renderergl1/tr_backend.c | 7 +++-- src/renderergl1/tr_local.h | 2 +- src/renderergl1/tr_sky.c | 65 +++++--------------------------------------- 3 files changed, 12 insertions(+), 62 deletions(-) diff --git a/src/renderergl1/tr_backend.c b/src/renderergl1/tr_backend.c index 432050b6..adc97169 100644 --- a/src/renderergl1/tr_backend.c +++ b/src/renderergl1/tr_backend.c @@ -669,9 +669,10 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { qglDepthRange (0, 1); } -#if 0 - RB_DrawSun(); -#endif + if (r_drawSun->integer) { + RB_DrawSun(0.1, tr.sunShader); + } + // darken down any stencil shadows RB_ShadowFinish(); diff --git a/src/renderergl1/tr_local.h b/src/renderergl1/tr_local.h index 9e253d8e..fc8da467 100644 --- a/src/renderergl1/tr_local.h +++ b/src/renderergl1/tr_local.h @@ -1329,7 +1329,7 @@ SKIES void R_BuildCloudData( shaderCommands_t *shader ); void R_InitSkyTexCoords( float cloudLayerHeight ); void R_DrawSkyBox( shaderCommands_t *shader ); -void RB_DrawSun( void ); +void RB_DrawSun( float scale, shader_t *shader ); void RB_ClipSkyPolygons( shaderCommands_t *shader ); /* diff --git a/src/renderergl1/tr_sky.c b/src/renderergl1/tr_sky.c index a68c1c51..561261a5 100644 --- a/src/renderergl1/tr_sky.c +++ b/src/renderergl1/tr_sky.c @@ -697,23 +697,21 @@ void R_InitSkyTexCoords( float heightCloud ) /* ** RB_DrawSun */ -void RB_DrawSun( void ) { +void RB_DrawSun( float scale, shader_t *shader ) { float size; float dist; vec3_t origin, vec1, vec2; - vec3_t temp; + byte sunColor[4] = { 255, 255, 255, 255 }; if ( !backEnd.skyRenderedThisView ) { return; } - if ( !r_drawSun->integer ) { - return; - } + qglLoadMatrixf( backEnd.viewParms.world.modelMatrix ); qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) - size = dist * 0.4; + size = dist * scale; VectorScale( tr.sunDirection, dist, origin ); PerpendicularVector( vec1, tr.sunDirection ); @@ -725,58 +723,9 @@ void RB_DrawSun( void ) { // farthest depth range qglDepthRange( 1.0, 1.0 ); - // FIXME: use quad stamp - RB_BeginSurface( tr.sunShader, tess.fogNum ); - VectorCopy( origin, temp ); - VectorSubtract( temp, vec1, temp ); - VectorSubtract( temp, vec2, temp ); - VectorCopy( temp, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = 255; - tess.vertexColors[tess.numVertexes][1] = 255; - tess.vertexColors[tess.numVertexes][2] = 255; - tess.numVertexes++; - - VectorCopy( origin, temp ); - VectorAdd( temp, vec1, temp ); - VectorSubtract( temp, vec2, temp ); - VectorCopy( temp, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = 255; - tess.vertexColors[tess.numVertexes][1] = 255; - tess.vertexColors[tess.numVertexes][2] = 255; - tess.numVertexes++; - - VectorCopy( origin, temp ); - VectorAdd( temp, vec1, temp ); - VectorAdd( temp, vec2, temp ); - VectorCopy( temp, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 1; - tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = 255; - tess.vertexColors[tess.numVertexes][1] = 255; - tess.vertexColors[tess.numVertexes][2] = 255; - tess.numVertexes++; - - VectorCopy( origin, temp ); - VectorSubtract( temp, vec1, temp ); - VectorAdd( temp, vec2, temp ); - VectorCopy( temp, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 1; - tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = 255; - tess.vertexColors[tess.numVertexes][1] = 255; - tess.vertexColors[tess.numVertexes][2] = 255; - tess.numVertexes++; - - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 1; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 3; + RB_BeginSurface( shader, 0 ); + + RB_AddQuadStamp(origin, vec1, vec2, sunColor); RB_EndSurface(); -- cgit