void R_DrawSkyBox (void) { #ifdef ENABLE_HYG_STARS R_DrawStars(); // jitstarviewer #else int i; if (fogenabled) // jitfog qgl.Disable(GL_FOG); if (skyrotate) { // check for no sky at all for (i = 0; i < 6; ++i) { if (skymins[0][i] < skymaxs[0][i] && skymins[1][i] < skymaxs[1][i]) break; } if (i == 6) return; // nothing visible } qgl.PushMatrix(); qgl.Translatef(r_origin[0], r_origin[1], r_origin[2]); qgl.Rotatef(r_newrefdef.time * skyrotate, skyaxis[0], skyaxis[1], skyaxis[2]); if (fogenabled && sky_images[0] == r_whitetexture) // jitfog { qgl.Color3fv(fogcolor); GLSTATE_ENABLE_BLEND GL_TexEnv(GL_MODULATE); } for (i = 0; i < 6; ++i) { if (skyrotate) { // hack, forces full sky to draw when rotating skymins[0][i] = -1; skymins[1][i] = -1; skymaxs[0][i] = 1; skymaxs[1][i] = 1; } if (skymins[0][i] >= skymaxs[0][i] || skymins[1][i] >= skymaxs[1][i]) continue; GL_Bind(sky_images[skytexorder[i]]->texnum); qgl.Begin(GL_QUADS); MakeSkyVec(skymins[0][i], skymins[1][i], i); MakeSkyVec(skymins[0][i], skymaxs[1][i], i); MakeSkyVec(skymaxs[0][i], skymaxs[1][i], i); MakeSkyVec(skymaxs[0][i], skymins[1][i], i); qgl.End(); } qgl.PopMatrix(); if (fogenabled) // jitfog { qgl.Color3f(1, 1, 1); GLSTATE_DISABLE_BLEND qgl.Enable(GL_FOG); } #endif }
static void FillCloudBox( int stage ) { int i; for ( i = 0; i < 6; i++ ) { int sky_mins_subd[ 2 ], sky_maxs_subd[ 2 ]; int s, t; float MIN_T; { MIN_T = -HALF_SKY_SUBDIVISIONS; // still don't want to draw the bottom, even if fullClouds if ( i == 5 ) { continue; } } sky_mins[ 0 ][ i ] = floor( sky_mins[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_mins[ 1 ][ i ] = floor( sky_mins[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[ 0 ][ i ] = ceil( sky_maxs[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[ 1 ][ i ] = ceil( sky_maxs[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; if ( ( sky_mins[ 0 ][ i ] >= sky_maxs[ 0 ][ i ] ) || ( sky_mins[ 1 ][ i ] >= sky_maxs[ 1 ][ i ] ) ) { continue; } sky_mins_subd[ 0 ] = Q_ftol( sky_mins[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS ); sky_mins_subd[ 1 ] = Q_ftol( sky_mins[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS ); sky_maxs_subd[ 0 ] = Q_ftol( sky_maxs[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS ); sky_maxs_subd[ 1 ] = Q_ftol( sky_maxs[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS ); if ( sky_mins_subd[ 0 ] < -HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 0 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_mins_subd[ 0 ] > HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 0 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_mins_subd[ 1 ] < MIN_T ) { sky_mins_subd[ 1 ] = MIN_T; } else if ( sky_mins_subd[ 1 ] > HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 1 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_maxs_subd[ 0 ] < -HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 0 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_maxs_subd[ 0 ] > HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 0 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_maxs_subd[ 1 ] < MIN_T ) { sky_maxs_subd[ 1 ] = MIN_T; } else if ( sky_maxs_subd[ 1 ] > HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 1 ] = HALF_SKY_SUBDIVISIONS; } // iterate through the subdivisions for ( t = sky_mins_subd[ 1 ] + HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[ 1 ] + HALF_SKY_SUBDIVISIONS; t++ ) { for ( s = sky_mins_subd[ 0 ] + HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[ 0 ] + HALF_SKY_SUBDIVISIONS; s++ ) { MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, i, nullptr, s_skyPoints[ t ][ s ] ); s_skyTexCoords[ t ][ s ][ 0 ] = s_cloudTexCoords[ i ][ t ][ s ][ 0 ]; s_skyTexCoords[ t ][ s ][ 1 ] = s_cloudTexCoords[ i ][ t ][ s ][ 1 ]; } } // only add indexes for first stage FillCloudySkySide( sky_mins_subd, sky_maxs_subd, ( bool )( stage == 0 ) ); } }
static void DrawSkyBox() { int i; sky_min = 0; sky_max = 1; Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) ); // set up for drawing tess.multiDrawPrimitives = 0; tess.numIndexes = 0; tess.numVertexes = 0; tess.attribsSet = 0; GL_State( GLS_DEFAULT ); Tess_MapVBOs( false ); for ( i = 0; i < 6; i++ ) { int sky_mins_subd[ 2 ], sky_maxs_subd[ 2 ]; int s, t; sky_mins[ 0 ][ i ] = floor( sky_mins[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_mins[ 1 ][ i ] = floor( sky_mins[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[ 0 ][ i ] = ceil( sky_maxs[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[ 1 ][ i ] = ceil( sky_maxs[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; if ( ( sky_mins[ 0 ][ i ] >= sky_maxs[ 0 ][ i ] ) || ( sky_mins[ 1 ][ i ] >= sky_maxs[ 1 ][ i ] ) ) { continue; } sky_mins_subd[ 0 ] = sky_mins[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS; sky_mins_subd[ 1 ] = sky_mins[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[ 0 ] = sky_maxs[ 0 ][ i ] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[ 1 ] = sky_maxs[ 1 ][ i ] * HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[ 0 ] < -HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 0 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_mins_subd[ 0 ] > HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 0 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_mins_subd[ 1 ] < -HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 1 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_mins_subd[ 1 ] > HALF_SKY_SUBDIVISIONS ) { sky_mins_subd[ 1 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_maxs_subd[ 0 ] < -HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 0 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_maxs_subd[ 0 ] > HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 0 ] = HALF_SKY_SUBDIVISIONS; } if ( sky_maxs_subd[ 1 ] < -HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 1 ] = -HALF_SKY_SUBDIVISIONS; } else if ( sky_maxs_subd[ 1 ] > HALF_SKY_SUBDIVISIONS ) { sky_maxs_subd[ 1 ] = HALF_SKY_SUBDIVISIONS; } // iterate through the subdivisions for ( t = sky_mins_subd[ 1 ] + HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[ 1 ] + HALF_SKY_SUBDIVISIONS; t++ ) { for ( s = sky_mins_subd[ 0 ] + HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[ 0 ] + HALF_SKY_SUBDIVISIONS; s++ ) { MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, i, s_skyTexCoords[ t ][ s ], s_skyPoints[ t ][ s ] ); } } // only add indexes for first stage FillCloudySkySide( sky_mins_subd, sky_maxs_subd, true ); } Tess_UpdateVBOs( ); GL_VertexAttribsState( tess.attribsSet ); Tess_DrawElements(); }
static void FillCloudBox( const shader_t *shader, int stage ) { int i; for ( i =0; i < 6; i++ ) { int sky_mins_subd[2], sky_maxs_subd[2]; int s, t; float MIN_T; if ( 1 ) // FIXME? shader->sky.fullClouds ) { MIN_T = -HALF_SKY_SUBDIVISIONS; // still don't want to draw the bottom, even if fullClouds if ( i == 5 ) continue; } else { switch( i ) { case 0: case 1: case 2: case 3: MIN_T = -1; break; case 5: // don't draw clouds beneath you continue; case 4: // top default: MIN_T = -HALF_SKY_SUBDIVISIONS; break; } } sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) || ( sky_mins[1][i] >= sky_maxs[1][i] ) ) { continue; } sky_mins_subd[0] = ri.ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); sky_mins_subd[1] = ri.ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); sky_maxs_subd[0] = ri.ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); sky_maxs_subd[1] = ri.ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[1] < MIN_T ) sky_mins_subd[1] = MIN_T; else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_maxs_subd[1] < MIN_T ) sky_maxs_subd[1] = MIN_T; else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; // // iterate through the subdivisions // for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) { for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) { MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, i, NULL, s_skyPoints[t][s] ); s_skyTexCoords[t][s][0] = s_cloudTexCoords[i][t][s][0]; s_skyTexCoords[t][s][1] = s_cloudTexCoords[i][t][s][1]; } } // only add indexes for first stage FillCloudySkySide( sky_mins_subd, sky_maxs_subd, ( stage == 0 ) ); } }
static void DrawSkyBox( shader_t *shader ) { int i; sky_min = 0; sky_max = 1; Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) ); for (i=0 ; i<6 ; i++) { int sky_mins_subd[2], sky_maxs_subd[2]; int s, t; sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) || ( sky_mins[1][i] >= sky_maxs[1][i] ) ) { continue; } sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS; sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS; else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS; else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; // // iterate through the subdivisions // for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) { for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) { MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, i, s_skyTexCoords[t][s], s_skyPoints[t][s] ); } } DrawSkySide( shader->sky.outerbox[sky_texorder[i]], sky_mins_subd, sky_maxs_subd ); } }
static void DrawSkyBox(shader_t *shader) { int i; sky_min = 0; sky_max = 1; Com_Memset(s_skyTexCoords, 0, sizeof(s_skyTexCoords)); // set up for drawing tess.multiDrawPrimitives = 0; tess.numIndexes = 0; tess.numVertexes = 0; #if defined(USE_D3D10) // TODO #else GL_State(GLS_DEFAULT); #endif for (i = 0; i < 6; i++) { int sky_mins_subd[2], sky_maxs_subd[2]; int s, t; sky_mins[0][i] = floor(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS) / HALF_SKY_SUBDIVISIONS; sky_mins[1][i] = floor(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS) / HALF_SKY_SUBDIVISIONS; sky_maxs[0][i] = ceil(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS) / HALF_SKY_SUBDIVISIONS; sky_maxs[1][i] = ceil(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS) / HALF_SKY_SUBDIVISIONS; if ((sky_mins[0][i] >= sky_maxs[0][i]) || (sky_mins[1][i] >= sky_maxs[1][i])) { continue; } sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS; sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS; sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS; if (sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS) { sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; } else if (sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS) { sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; } if (sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS) { sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS; } else if (sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS) { sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; } if (sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS) { sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; } else if (sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS) { sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; } if (sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS) { sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS; } else if (sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS) { sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; } // iterate through the subdivisions for (t = sky_mins_subd[1] + HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1] + HALF_SKY_SUBDIVISIONS; t++) { for (s = sky_mins_subd[0] + HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0] + HALF_SKY_SUBDIVISIONS; s++) { MakeSkyVec((s - HALF_SKY_SUBDIVISIONS) / (float)HALF_SKY_SUBDIVISIONS, (t - HALF_SKY_SUBDIVISIONS) / (float)HALF_SKY_SUBDIVISIONS, i, s_skyTexCoords[t][s], s_skyPoints[t][s]); } } //DrawSkySide(shader->sky.outerbox[sky_texorder[i]], sky_mins_subd, sky_maxs_subd); // only add indexes for first stage FillCloudySkySide(sky_mins_subd, sky_maxs_subd, qtrue); } Tess_DrawElements(); }