Ejemplo n.º 1
0
/*
==============
Tess_InstantQuad
==============
*/
void Tess_InstantQuad( vec4_t quadVerts[ 4 ] )
{
	GLimp_LogComment( "--- Tess_InstantQuad ---\n" );

	tess.multiDrawPrimitives = 0;
	tess.numVertexes = 0;
	tess.numIndexes = 0;
	tess.attribsSet = 0;

	Tess_MapVBOs( false );
	VectorCopy( quadVerts[ 0 ], tess.verts[ tess.numVertexes ].xyz );
	Vector4Set( tess.verts[ tess.numVertexes ].color, 255, 255, 255, 255 );
	tess.verts[ tess.numVertexes ].texCoords[ 0 ] = floatToHalf( 0.0f );
	tess.verts[ tess.numVertexes ].texCoords[ 1 ] = floatToHalf( 0.0f );
	tess.numVertexes++;

	VectorCopy( quadVerts[ 1 ], tess.verts[ tess.numVertexes ].xyz );
	Vector4Set( tess.verts[ tess.numVertexes ].color, 255, 255, 255, 255 );
	tess.verts[ tess.numVertexes ].texCoords[ 0 ] = floatToHalf( 1.0f );
	tess.verts[ tess.numVertexes ].texCoords[ 1 ] = floatToHalf( 0.0f );
	tess.numVertexes++;

	VectorCopy( quadVerts[ 2 ], tess.verts[ tess.numVertexes ].xyz );
	Vector4Set( tess.verts[ tess.numVertexes ].color, 255, 255, 255, 255 );
	tess.verts[ tess.numVertexes ].texCoords[ 0 ] = floatToHalf( 1.0f );
	tess.verts[ tess.numVertexes ].texCoords[ 1 ] = floatToHalf( 1.0f );
	tess.numVertexes++;

	VectorCopy( quadVerts[ 3 ], tess.verts[ tess.numVertexes ].xyz );
	Vector4Set( tess.verts[ tess.numVertexes ].color, 255, 255, 255, 255 );
	tess.verts[ tess.numVertexes ].texCoords[ 0 ] = floatToHalf( 0.0f );
	tess.verts[ tess.numVertexes ].texCoords[ 1 ] = floatToHalf( 1.0f );
	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;

	Tess_UpdateVBOs( );
	GL_VertexAttribsState( ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR );

	Tess_DrawElements();

	tess.multiDrawPrimitives = 0;
	tess.numVertexes = 0;
	tess.numIndexes = 0;
	tess.attribsSet = 0;
	GL_CheckErrors();
}
Ejemplo n.º 2
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();
}