Allow drawing sun in OpenGL1 renderer

Removed #if 0 ... #endif around RB_DrawSun().
Merged improvements and changes from OpenGL2 renderer.
This commit is contained in:
Zack Middleton 2013-05-24 22:02:52 -05:00
parent ab4c602374
commit 0c3ec34db9
3 changed files with 11 additions and 61 deletions

View file

@ -668,9 +668,10 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
qglDepthRange (0, 1); qglDepthRange (0, 1);
} }
#if 0 if (r_drawSun->integer) {
RB_DrawSun(); RB_DrawSun(0.1, tr.sunShader);
#endif }
// darken down any stencil shadows // darken down any stencil shadows
RB_ShadowFinish(); RB_ShadowFinish();

View file

@ -1326,7 +1326,7 @@ SKIES
void R_BuildCloudData( shaderCommands_t *shader ); void R_BuildCloudData( shaderCommands_t *shader );
void R_InitSkyTexCoords( float cloudLayerHeight ); void R_InitSkyTexCoords( float cloudLayerHeight );
void R_DrawSkyBox( shaderCommands_t *shader ); void R_DrawSkyBox( shaderCommands_t *shader );
void RB_DrawSun( void ); void RB_DrawSun( float scale, shader_t *shader );
void RB_ClipSkyPolygons( shaderCommands_t *shader ); void RB_ClipSkyPolygons( shaderCommands_t *shader );
/* /*

View file

@ -696,23 +696,21 @@ void R_InitSkyTexCoords( float heightCloud )
/* /*
** RB_DrawSun ** RB_DrawSun
*/ */
void RB_DrawSun( void ) { void RB_DrawSun( float scale, shader_t *shader ) {
float size; float size;
float dist; float dist;
vec3_t origin, vec1, vec2; vec3_t origin, vec1, vec2;
vec3_t temp; byte sunColor[4] = { 255, 255, 255, 255 };
if ( !backEnd.skyRenderedThisView ) { if ( !backEnd.skyRenderedThisView ) {
return; return;
} }
if ( !r_drawSun->integer ) {
return;
}
qglLoadMatrixf( backEnd.viewParms.world.modelMatrix ); qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); 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) dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
size = dist * 0.4; size = dist * scale;
VectorScale( tr.sunDirection, dist, origin ); VectorScale( tr.sunDirection, dist, origin );
PerpendicularVector( vec1, tr.sunDirection ); PerpendicularVector( vec1, tr.sunDirection );
@ -724,58 +722,9 @@ void RB_DrawSun( void ) {
// farthest depth range // farthest depth range
qglDepthRange( 1.0, 1.0 ); qglDepthRange( 1.0, 1.0 );
// FIXME: use quad stamp RB_BeginSurface( shader, 0 );
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 ); RB_AddQuadStamp(origin, vec1, vec2, sunColor);
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_EndSurface(); RB_EndSurface();