本文整理汇总了C++中R_DrawElements函数的典型用法代码示例。如果您正苦于以下问题:C++ R_DrawElements函数的具体用法?C++ R_DrawElements怎么用?C++ R_DrawElements使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R_DrawElements函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RB_IterateStagesGeneric
/*
** RB_IterateStagesGeneric
*/
static void RB_IterateStagesGeneric( shaderCommands_t *input )
{
int stage;
for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
{
shaderStage_t *pStage = tess.xstages[stage];
if ( !pStage )
{
break;
}
ComputeColors( pStage );
ComputeTexCoords( pStage );
if ( !setArraysOnce )
{
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, input->svars.colors );
}
//
// do multitexture
//
if ( pStage->bundle[1].image[0] != 0 )
{
DrawMultitextured( input, stage );
}
else
{
if ( !setArraysOnce )
{
qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );
}
//
// set state
//
if ( pStage->bundle[0].vertexLightmap && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) && r_lightmap->integer )
{
GL_Bind( tr.whiteImage );
}
else
R_BindAnimatedImage( &pStage->bundle[0] );
GL_State( pStage->stateBits );
//
// draw
//
R_DrawElements( input->numIndexes, input->indexes );
}
// allow skipping out to show just lightmaps during development
if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap || pStage->bundle[0].vertexLightmap ) )
{
break;
}
}
}
示例2: DrawTris
/*
================
DrawTris
Draws triangle outlines for debugging
================
*/
static void DrawTris (shaderCommands_t *input) {
GL_Bind( tr.whiteImage );
qglColor3f (1,1,1);
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
qglDepthRange( 0, 0 );
qglDisableClientState (GL_COLOR_ARRAY);
qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
qglVertexPointer (3, GL_FLOAT, 16, input->xyz); // padded for SIMD
if (qglLockArraysEXT) {
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
#ifdef HAVE_GLES
qglDrawElements( GL_LINE_STRIP,
input->numIndexes,
GL_INDEX_TYPE,
input->indexes );
#else
R_DrawElements( input->numIndexes, input->indexes );
#endif
if (qglUnlockArraysEXT) {
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
qglDepthRange( 0, 1 );
}
示例3: DrawBBoxes
/*
================
DrawBBoxes
Draws bounding box outlines for debugging
================
*/
static void DrawBBoxes (shaderCommands_t *input) {
GL_Bind( tr.whiteImage );
// qglColor3f (1,1,1);
qglColor4f ( 0, 0, 0, 0.5f );
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
qglDepthRange( 0, 0 );
qglDisableClientState (GL_COLOR_ARRAY);
qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
qglVertexPointer (3, GL_FLOAT, 16, input->xyz); // padded for SIMD
if (qglLockArraysEXT) {
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
R_DrawElements( input->numIndexes, input->indexes );
if (qglUnlockArraysEXT) {
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
qglDepthRange( 0, 1 );
}
示例4: RB_FogPass
/*
===================
RB_FogPass
Blends a fog texture on top of everything else
===================
*/
static void RB_FogPass( void ) {
fog_t *fog;
int i;
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );
fog = tr.world->fogs + tess.fogNum;
for ( i = 0; i < tess.numVertexes; i++ ) {
* ( int * )&tess.svars.colors[i] = fog->colorInt;
}
RB_CalcFogTexCoords( ( float * ) tess.svars.texcoords[0] );
GL_Bind( tr.fogImage );
if ( tess.shader->fogPass == FP_EQUAL ) {
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL );
} else {
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
}
R_DrawElements( tess.numIndexes, tess.indexes );
}
示例5: DrawMultitextured
/*
===================
DrawMultitextured
output = t0 * t1 or t0 + t1
t0 = most upstream according to spec
t1 = most downstream according to spec
===================
*/
static void DrawMultitextured( shaderCommands_t *input, int stage ) {
shaderStage_t *pStage;
pStage = tess.xstages[stage];
// Ridah
if ( tess.shader->noFog && pStage->isFogged ) {
R_FogOn();
} else if ( tess.shader->noFog && !pStage->isFogged ) {
R_FogOff(); // turn it back off
} else { // make sure it's on
R_FogOn();
}
// done.
GL_State( pStage->stateBits );
// this is an ugly hack to work around a GeForce driver
// bug with multitexture and clip planes
#ifndef USE_OPENGLES
if ( backEnd.viewParms.isPortal ) {
qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
}
#endif
//
// base
//
GL_SelectTexture( 0 );
qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );
R_BindAnimatedImage( &pStage->bundle[0] );
//
// lightmap/secondary pass
//
GL_SelectTexture( 1 );
qglEnable( GL_TEXTURE_2D );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
if ( r_lightmap->integer ) {
GL_TexEnv( GL_REPLACE );
} else {
GL_TexEnv( tess.shader->multitextureEnv );
}
qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[1] );
R_BindAnimatedImage( &pStage->bundle[1] );
R_DrawElements( input->numIndexes, input->indexes );
//
// disable texturing on TEXTURE1, then select TEXTURE0
//
//qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
qglDisable( GL_TEXTURE_2D );
GL_SelectTexture( 0 );
}
示例6: DrawMultitextured
/*
===================
DrawMultitextured
output = t0 * t1 or t0 + t1
t0 = most upstream according to spec
t1 = most downstream according to spec
===================
*/
static void DrawMultitextured( shaderCommands_t *input, int stage ) {
shaderStage_t *pStage;
pStage = tess.xstages[stage];
GL_State( pStage->stateBits );
// this is an ugly hack to work around a GeForce driver
// bug with multitexture and clip planes
if ( backEnd.viewParms.isPortal ) {
// This is not yet available in the current platform. Removing:
//qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
}
//
// base
//
GX_SelectTexture( 0 );
// *********************** This call is not needed for the current implementation. Disabling:
//qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );
R_BindAnimatedImage( &pStage->bundle[0] );
//
// lightmap/secondary pass
//
GX_SelectTexture( 1 );
qgxEnableTexStage1();
// *********************** This call is not needed for the current implementation. Disabling:
//qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
if ( r_lightmap->integer ) {
GX_TexEnv( GX_REPLACE );
} else {
GX_TexEnv( tess.shader->multitextureEnv );
}
// *********************** This call is not needed for the current implementation. Disabling:
//qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[1] );
R_BindAnimatedImage( &pStage->bundle[1] );
R_DrawElements( input->numIndexes, input->indexes );
//
// disable texturing on TEXTURE1, then select TEXTURE0
//
//qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
qgxDisableTexStage1();
GX_SelectTexture( 0 );
}
示例7: RB_FogPass
/*
===================
RB_FogPass
Blends a fog texture on top of everything else
===================
*/
static void RB_FogPass(void)
{
fog_t *fog;
int i;
// no fog pass in snooper
if(tr.refdef.rdflags & RDF_SNOOPERVIEW || tess.shader->noFog || !r_wolffog->integer)
{
return;
}
// ydnar: no world, no fogging
if(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)
{
return;
}
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, tess.svars.colors);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, tess.svars.texcoords[0]);
fog = tr.world->fogs + tess.fogNum;
for(i = 0; i < tess.numVertexes; i++)
{
*(int *)&tess.svars.colors[i] = fog->shader->fogParms.colorInt;
}
RB_CalcFogTexCoords((float *)tess.svars.texcoords[0]);
GL_Bind(tr.fogImage);
if(tess.shader->fogPass == FP_EQUAL)
{
GL_State(GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL);
}
else
{
GL_State(GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA);
}
R_DrawElements(tess.numIndexes, tess.indexes);
}
示例8: RB_OutlinesPass
/*
===================
RB_OutlinesPass
Draws outlines on surfaces with shader.hasOutlines set
===================
*/
static void RB_OutlinesPass( void ) {
int outlines;
float outlinesAlpha;
outlines = r_outlines->value;
outlinesAlpha = r_outlinesAlpha->value;
if ( !tess.shader->hasOutlines )
return;
if ( !r_outlines->integer )
return;
GL_Bind( tr.whiteImage );
qglColor4f( 0, 0, 0, outlinesAlpha );
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
qglPolygonMode( GL_BACK, GL_LINE );
qglLineWidth( outlines + 1 );
qglCullFace( GL_BACK );
qglDisableClientState( GL_COLOR_ARRAY );
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
qglVertexPointer (3, GL_FLOAT, 16, tess.xyz); // padded for SIMD
if (qglLockArraysEXT) {
qglLockArraysEXT(0, tess.numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
R_DrawElements( tess.numIndexes, tess.indexes );
if (qglUnlockArraysEXT) {
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
// FIX: Must reset these manually or renderer will b0rk!
qglCullFace( GL_FRONT );
qglLineWidth( 1 );
}
示例9: DrawTris
/*
================
DrawTris
Draws triangle outlines for debugging
================
*/
static void DrawTris (shaderCommands_t *input) {
gxu_cur_vertex_format = GX_VTXFMT0;
qgxDisableTexture();
GX_Bind( tr.whiteImage );
gxu_cur_r = 255;
gxu_cur_g = 255;
gxu_cur_b = 255;
gxu_cur_a = 255;
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
c_islines = qtrue;
gxu_depth_min = 0.0;
gxu_depth_max = 0.0;
qgxSetViewport (gxu_viewport_x, gxu_viewport_y, gxu_viewport_width, gxu_viewport_height, gxu_depth_min, gxu_depth_max);
// These calls are not needed for the current implementation. Disabling:
/*
qglDisableClientState (GL_COLOR_ARRAY);
qglDisableClientState (GL_TEXTURE_COORD_ARRAY);
qglVertexPointer (3, GL_FLOAT, 16, input->xyz); // padded for SIMD
if (qglLockArraysEXT) {
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
*/
R_DrawElements( input->numIndexes, input->indexes );
// Neither are these. Disabling:
/*
if (qglUnlockArraysEXT) {
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
*/
gxu_depth_min = 0.0;
gxu_depth_max = 1.0;
qgxSetViewport (gxu_viewport_x, gxu_viewport_y, gxu_viewport_width, gxu_viewport_height, gxu_depth_min, gxu_depth_max);
c_islines = qfalse;
gxu_cur_vertex_format = GX_VTXFMT1;
qgxEnableTexture();
}
示例10: RB_InstantQuad2
/*
==============
RB_InstantQuad
based on Tess_InstantQuad from xreal
==============
*/
void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4])
{
GLimp_LogComment("--- RB_InstantQuad2 ---\n");
tess.numVertexes = 0;
tess.numIndexes = 0;
tess.firstIndex = 0;
VectorCopy4(quadVerts[0], tess.xyz[tess.numVertexes]);
VectorCopy2(texCoords[0], tess.texCoords[tess.numVertexes]);
tess.numVertexes++;
VectorCopy4(quadVerts[1], tess.xyz[tess.numVertexes]);
VectorCopy2(texCoords[1], tess.texCoords[tess.numVertexes]);
tess.numVertexes++;
VectorCopy4(quadVerts[2], tess.xyz[tess.numVertexes]);
VectorCopy2(texCoords[2], tess.texCoords[tess.numVertexes]);
tess.numVertexes++;
VectorCopy4(quadVerts[3], tess.xyz[tess.numVertexes]);
VectorCopy2(texCoords[3], tess.texCoords[tess.numVertexes]);
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_UpdateTessVao(ATTR_POSITION | ATTR_TEXCOORD);
R_DrawElements(tess.numIndexes, tess.firstIndex);
tess.numIndexes = 0;
tess.numVertexes = 0;
tess.firstIndex = 0;
}
示例11: RB_HazePass
/*
===================
RB_HazePass
Blends a fog texture on top of everything but the skybox
===================
*/
static void RB_HazePass( void ) {
int i;
unsigned int color[3], colorInt;
// TODO; Get color from worlspawn. Use black for now.
color[0] = 0;
color[1] = 0;
color[2] = 0;
colorInt = ColorBytes4( color[0] * tr.identityLight, color[1] * tr.identityLight, color[2] * tr.identityLight, 1.0 );
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY);
qglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );
//fog = tr.world->fogs + tess.fogNum;
for ( i = 0; i < tess.numVertexes; i++ ) {
* ( int * )&tess.svars.colors[i] = colorInt;
}
RB_CalcFogTexCoords( ( float * ) tess.svars.texcoords[0] );
GL_Bind( tr.fogImage );
if ( tess.shader->fogPass == FP_EQUAL ) {
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL );
} else {
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
}
R_DrawElements( tess.numIndexes, tess.indexes );
}
示例12: DynamicLightPass
//.........这里部分代码省略.........
radius = dl->radius;
radiusInverseCubed = dl->radiusInverseCubed;
intensity = dl->intensity;
floatColor[ 0 ] = dl->color[ 0 ] * 255.0f;
floatColor[ 1 ] = dl->color[ 1 ] * 255.0f;
floatColor[ 2 ] = dl->color[ 2 ] * 255.0f;
// directional lights have max intensity and washout remainder intensity
if ( dl->flags & REF_DIRECTED_DLIGHT ) {
remainder = intensity * 0.125;
} else {
remainder = 0.0f;
}
// illuminate vertexes
colors = tess.svars.colors[ 0 ];
for ( i = 0; i < tess.numVertexes; i++, colors += 4 )
{
backEnd.pc.c_dlightVertexes++;
// directional dlight, origin is a directional normal
if ( dl->flags & REF_DIRECTED_DLIGHT ) {
// twosided surfaces use absolute value of the calculated lighting
modulate = intensity * DotProduct( dl->origin, tess.normal[ i ].v );
if ( tess.shader->cullType == CT_TWO_SIDED ) {
modulate = fabs( modulate );
}
modulate += remainder;
}
// ball dlight
else
{
dir[ 0 ] = radius - fabs( origin[ 0 ] - tess.xyz[ i ].v[ 0 ] );
if ( dir[ 0 ] <= 0.0f ) {
continue;
}
dir[ 1 ] = radius - fabs( origin[ 1 ] - tess.xyz[ i ].v[ 1 ] );
if ( dir[ 1 ] <= 0.0f ) {
continue;
}
dir[ 2 ] = radius - fabs( origin[ 2 ] - tess.xyz[ i ].v[ 2 ] );
if ( dir[ 2 ] <= 0.0f ) {
continue;
}
modulate = intensity * dir[ 0 ] * dir[ 1 ] * dir[ 2 ] * radiusInverseCubed;
}
// optimizations
if ( modulate < ( 1.0f / 128.0f ) ) {
continue;
} else if ( modulate > 1.0f ) {
modulate = 1.0f;
}
// set color
color = myftol( floatColor[ 0 ] * modulate );
colors[ 0 ] = color > 255 ? 255 : color;
color = myftol( floatColor[ 1 ] * modulate );
colors[ 1 ] = color > 255 ? 255 : color;
color = myftol( floatColor[ 2 ] * modulate );
colors[ 2 ] = color > 255 ? 255 : color;
}
// build a list of triangles that need light
intColors = (int*) tess.svars.colors;
numIndexes = 0;
for ( i = 0; i < tess.numIndexes; i += 3 )
{
a = tess.indexes[ i ];
b = tess.indexes[ i + 1 ];
c = tess.indexes[ i + 2 ];
if ( !( intColors[ a ] | intColors[ b ] | intColors[ c ] ) ) {
continue;
}
hitIndexes[ numIndexes++ ] = a;
hitIndexes[ numIndexes++ ] = b;
hitIndexes[ numIndexes++ ] = c;
}
if ( numIndexes == 0 ) {
continue;
}
// debug code (fixme, there's a bug in this function!)
//% for( i = 0; i < numIndexes; i++ )
//% intColors[ hitIndexes[ i ] ] = 0x000000FF;
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );
R_FogOff();
GL_Bind( tr.whiteImage );
GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
R_DrawElements( numIndexes, hitIndexes );
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
R_FogOn();
}
}
示例13: DrawTris
/*
================
DrawTris
Draws triangle outlines for debugging
================
*/
static void DrawTris( shaderCommands_t *input ) {
char *s = r_trisColor->string;
vec4_t trisColor = { 1, 1, 1, 1 };
unsigned int stateBits = 0;
GL_Bind( tr.whiteImage );
if ( *s == '0' && ( *( s + 1 ) == 'x' || *( s + 1 ) == 'X' ) ) {
s += 2;
if ( Q_IsHexColorString( s ) ) {
trisColor[0] = ( (float)( gethex( *( s ) ) * 16 + gethex( *( s + 1 ) ) ) ) / 255.00;
trisColor[1] = ( (float)( gethex( *( s + 2 ) ) * 16 + gethex( *( s + 3 ) ) ) ) / 255.00;
trisColor[2] = ( (float)( gethex( *( s + 4 ) ) * 16 + gethex( *( s + 5 ) ) ) ) / 255.00;
if ( Q_HexColorStringHasAlpha( s ) ) {
trisColor[3] = ( (float)( gethex( *( s + 6 ) ) * 16 + gethex( *( s + 7 ) ) ) ) / 255.00;
}
}
} else {
int i;
char *token;
for ( i = 0 ; i < 4 ; i++ ) {
token = COM_Parse( &s );
if ( token ) {
trisColor[i] = atof( token );
} else {
trisColor[i] = 1.f;
}
}
if ( !trisColor[3] ) {
trisColor[3] = 1.f;
}
}
if ( trisColor[3] < 1.f ) {
stateBits |= ( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
}
qglColor4fv( trisColor );
// ydnar r_showtris 2
if ( r_showtris->integer == 2 ) {
stateBits |= ( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
GL_State( stateBits );
qglDepthRange( 0, 0 );
}
#ifdef CELSHADING_HACK
else if ( r_showtris->integer == 3 ) {
stateBits |= ( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE );
GL_State( stateBits );
qglEnable( GL_POLYGON_OFFSET_LINE );
qglPolygonOffset( 4.0, 0.5 );
qglLineWidth( 5.0 );
}
#endif
else
{
stateBits |= ( GLS_POLYMODE_LINE );
GL_State( stateBits );
qglEnable( GL_POLYGON_OFFSET_LINE );
qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value );
}
qglDisableClientState( GL_COLOR_ARRAY );
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
qglVertexPointer( 3, GL_FLOAT, 16, input->xyz ); // padded for SIMD
if ( qglLockArraysEXT ) {
qglLockArraysEXT( 0, input->numVertexes );
GLimp_LogComment( "glLockArraysEXT\n" );
}
R_DrawElements( input->numIndexes, input->indexes );
if ( qglUnlockArraysEXT ) {
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
qglDepthRange( 0, 1 );
qglDisable( GL_POLYGON_OFFSET_LINE );
}
示例14: RB_StageIteratorLightmappedMultitexture
void RB_StageIteratorLightmappedMultitexture( void ) {
shaderCommands_t *input;
input = &tess;
//
// log this call
//
if ( r_logFile->integer ) {
// don't just call LogComment, or we will get
// a call to va() every frame!
GLimp_LogComment( va( "--- RB_StageIteratorLightmappedMultitexture( %s ) ---\n", tess.shader->name ) );
}
// set GL fog
SetIteratorFog();
//
// set face culling appropriately
//
GL_Cull( input->shader->cullType );
//
// set color, pointers, and lock
//
GL_State( GLS_DEFAULT );
qglVertexPointer( 3, GL_FLOAT, 16, input->xyz );
#ifdef REPLACE_MODE
qglDisableClientState( GL_COLOR_ARRAY );
qglColor3f( 1, 1, 1 );
qglShadeModel( GL_FLAT );
#else
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.constantColor255 );
#endif
//
// select base stage
//
GL_SelectTexture( 0 );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
R_BindAnimatedImage( &tess.xstages[0]->bundle[0] );
qglTexCoordPointer( 2, GL_FLOAT, 8, tess.texCoords0 );
//
// configure second stage
//
GL_SelectTexture( 1 );
qglEnable( GL_TEXTURE_2D );
if ( r_lightmap->integer ) {
GL_TexEnv( GL_REPLACE );
} else {
GL_TexEnv( GL_MODULATE );
}
//----(SA) modified for snooper
if ( tess.xstages[0]->bundle[1].isLightmap && ( backEnd.refdef.rdflags & RDF_SNOOPERVIEW ) ) {
GL_Bind( tr.whiteImage );
} else {
R_BindAnimatedImage( &tess.xstages[0]->bundle[1] );
}
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 8, tess.texCoords1 );
//
// lock arrays
//
if ( qglLockArraysEXT ) {
qglLockArraysEXT( 0, input->numVertexes );
GLimp_LogComment( "glLockArraysEXT\n" );
}
R_DrawElements( input->numIndexes, input->indexes );
//
// disable texturing on TEXTURE1, then select TEXTURE0
//
qglDisable( GL_TEXTURE_2D );
qglDisableClientState( GL_TEXTURE_COORD_ARRAY );
GL_SelectTexture( 0 );
#ifdef REPLACE_MODE
GL_TexEnv( GL_MODULATE );
qglShadeModel( GL_SMOOTH );
#endif
//
// now do any dynamic lighting needed
//
//% if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE )
if ( tess.dlightBits && tess.shader->fogPass &&
!( tess.shader->surfaceFlags & ( SURF_NODLIGHT | SURF_SKY ) ) ) {
if ( r_dynamiclight->integer == 2 ) {
DynamicLightPass();
} else {
DynamicLightSinglePass();
}
//.........这里部分代码省略.........
示例15: RB_IterateStagesGeneric
//.........这里部分代码省略.........
if ( !pStage ) {
break;
}
ComputeColors( pStage );
ComputeTexCoords( pStage );
if ( !setArraysOnce ) {
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, input->svars.colors );
}
//
// do multitexture
//
if ( pStage->bundle[1].image[0] != 0 ) {
DrawMultitextured( input, stage );
} else
{
int fadeStart, fadeEnd;
if ( !setArraysOnce ) {
qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );
}
//
// set state
//
R_BindAnimatedImage( &pStage->bundle[0] );
// Ridah, per stage fogging (detail textures)
if ( tess.shader->noFog && pStage->isFogged ) {
R_FogOn();
} else if ( tess.shader->noFog && !pStage->isFogged ) {
R_FogOff(); // turn it back off
} else { // make sure it's on
R_FogOn();
}
// done.
//----(SA) fading model stuff
fadeStart = backEnd.currentEntity->e.fadeStartTime;
if ( fadeStart ) {
fadeEnd = backEnd.currentEntity->e.fadeEndTime;
if ( fadeStart > tr.refdef.time ) { // has not started to fade yet
GL_State( pStage->stateBits );
} else
{
int i;
unsigned int tempState;
float alphaval;
if ( fadeEnd < tr.refdef.time ) { // entity faded out completely
continue;
}
alphaval = (float)( fadeEnd - tr.refdef.time ) / (float)( fadeEnd - fadeStart );
tempState = pStage->stateBits;
// remove the current blend, and don't write to Z buffer
tempState &= ~( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS | GLS_DEPTHMASK_TRUE );
// set the blend to src_alpha, dst_one_minus_src_alpha
tempState |= ( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
GL_State( tempState );
GL_Cull( CT_FRONT_SIDED );
// modulate the alpha component of each vertex in the render list
for ( i = 0; i < tess.numVertexes; i++ ) {
tess.svars.colors[i][0] *= alphaval;
tess.svars.colors[i][1] *= alphaval;
tess.svars.colors[i][2] *= alphaval;
tess.svars.colors[i][3] *= alphaval;
}
}
}
//----(SA) end
// ydnar: lightmap stages should be GL_ONE GL_ZERO so they can be seen
else if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap ) ) {
unsigned int stateBits;
stateBits = ( pStage->stateBits & ~( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) |
( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
GL_State( stateBits );
} else {
GL_State( pStage->stateBits );
}
//
// draw
//
R_DrawElements( input->numIndexes, input->indexes );
}
// allow skipping out to show just lightmaps during development
if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap ) ) {
break;
}
}
}