本文整理汇总了C++中R_BindAnimatedImage函数的典型用法代码示例。如果您正苦于以下问题:C++ R_BindAnimatedImage函数的具体用法?C++ R_BindAnimatedImage怎么用?C++ R_BindAnimatedImage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R_BindAnimatedImage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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 );
}
示例3: 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;
}
}
}
示例4: ProjectDlightTexture_scalar
//.........这里部分代码省略.........
} else if ( texCoords[0] > 1.0f ) {
clip |= 2;
}
if ( texCoords[1] < 0.0f ) {
clip |= 4;
} else if ( texCoords[1] > 1.0f ) {
clip |= 8;
}
texCoords[0] = texCoords[0];
texCoords[1] = texCoords[1];
// modulate the strength based on the height and color
if ( dist[2] > radius ) {
clip |= 16;
modulate = 0.0f;
} else if ( dist[2] < -radius ) {
clip |= 32;
modulate = 0.0f;
} else {
dist[2] = Q_fabs(dist[2]);
if ( dist[2] < radius * 0.5f ) {
modulate = 1.0f;
} else {
modulate = 2.0f * (radius - dist[2]) * scale;
}
}
}
clipBits[i] = clip;
colors[0] = ri.ftol(floatColor[0] * modulate);
colors[1] = ri.ftol(floatColor[1] * modulate);
colors[2] = ri.ftol(floatColor[2] * modulate);
colors[3] = 255;
}
// build a list of triangles that need light
numIndexes = 0;
for ( i = 0 ; i < tess.numIndexes ; i += 3 ) {
int a, b, c;
a = tess.indexes[i];
b = tess.indexes[i+1];
c = tess.indexes[i+2];
if ( clipBits[a] & clipBits[b] & clipBits[c] ) {
continue; // not lighted
}
hitIndexes[numIndexes] = a;
hitIndexes[numIndexes+1] = b;
hitIndexes[numIndexes+2] = c;
numIndexes += 3;
}
if ( !numIndexes ) {
continue;
}
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );
//----(SA) creating dlight shader to allow for special blends or alternate dlight texture
{
shader_t *dls = dl->dlshader;
if ( dls ) {
for ( i = 0; i < dls->numUnfoggedPasses; i++ )
{
shaderStage_t *stage = dls->stages[i];
R_BindAnimatedImage( &dls->stages[i]->bundle[0] );
GL_State( stage->stateBits | GLS_DEPTHFUNC_EQUAL );
R_DrawElements( numIndexes, hitIndexes );
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
}
} else
{
R_FogOff();
GL_Bind( tr.dlightImage );
// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light
// where they aren't rendered
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;
// Ridah, overdraw lights several times, rather than sending
// multiple lights through
for ( i = 0; i < dl->overdraw; i++ ) {
R_DrawElements( numIndexes, hitIndexes );
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
}
R_FogOn();
}
}
}
}
示例5: ProjectDlightTexture_altivec
//.........这里部分代码省略.........
} else if ( texCoords1 > 1.0f ) {
clip |= 8;
}
texCoords[0] = texCoords0;
texCoords[1] = texCoords1;
// modulate the strength based on the height and color
if ( dist2 > radius ) {
clip |= 16;
modulate = 0.0f;
} else if ( dist2 < -radius ) {
clip |= 32;
modulate = 0.0f;
} else {
dist2 = Q_fabs(dist2);
if ( dist2 < radius * 0.5f ) {
modulate = 1.0f;
} else {
modulate = 2.0f * (radius - dist2) * scale;
}
}
}
clipBits[i] = clip;
modulateVec = vec_ld(0,(float *)&modulate);
modulateVec = vec_perm(modulateVec,modulateVec,modulatePerm);
colorVec = vec_madd(floatColorVec0,modulateVec,zero);
colorInt = vec_cts(colorVec,0); // RGBx
colorShort = vec_pack(colorInt,colorInt); // RGBxRGBx
colorChar = vec_packsu(colorShort,colorShort); // RGBxRGBxRGBxRGBx
colorChar = vec_sel(colorChar,vSel,vSel); // RGBARGBARGBARGBA replace alpha with 255
vec_ste((vector unsigned int)colorChar,0,(unsigned int *)colors); // store color
}
// build a list of triangles that need light
numIndexes = 0;
for ( i = 0 ; i < tess.numIndexes ; i += 3 ) {
int a, b, c;
a = tess.indexes[i];
b = tess.indexes[i+1];
c = tess.indexes[i+2];
if ( clipBits[a] & clipBits[b] & clipBits[c] ) {
continue; // not lighted
}
hitIndexes[numIndexes] = a;
hitIndexes[numIndexes+1] = b;
hitIndexes[numIndexes+2] = c;
numIndexes += 3;
}
if ( !numIndexes ) {
continue;
}
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );
//----(SA) creating dlight shader to allow for special blends or alternate dlight texture
{
shader_t *dls = dl->dlshader;
if ( dls ) {
for ( i = 0; i < dls->numUnfoggedPasses; i++ )
{
shaderStage_t *stage = dls->stages[i];
R_BindAnimatedImage( &dls->stages[i]->bundle[0] );
GL_State( stage->stateBits | GLS_DEPTHFUNC_EQUAL );
R_DrawElements( numIndexes, hitIndexes );
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
}
} else
{
R_FogOff();
GL_Bind( tr.dlightImage );
// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light
// where they aren't rendered
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;
// Ridah, overdraw lights several times, rather than sending
// multiple lights through
for ( i = 0; i < dl->overdraw; i++ ) {
R_DrawElements( numIndexes, hitIndexes );
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
}
R_FogOn();
}
}
}
}
示例6: RB_StageIteratorVertexLitTexture
/*
** RB_StageIteratorVertexLitTexture
*/
void RB_StageIteratorVertexLitTexture( void )
{
shaderCommands_t *input;
shader_t *shader;
input = &tess;
shader = input->shader;
//
// compute colors
//
RB_CalcDiffuseColor( ( unsigned char * ) tess.svars.colors );
//
// 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_StageIteratorVertexLitTexturedUnfogged( %s ) ---\n", tess.shader->name) );
}
//
// set face culling appropriately
//
GL_Cull( shader->cullType );
//
// set arrays and lock
//
qglEnableClientState( GL_COLOR_ARRAY);
qglEnableClientState( GL_TEXTURE_COORD_ARRAY);
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.svars.colors );
qglTexCoordPointer( 2, GL_FLOAT, 16, tess.texCoords[0][0] );
qglVertexPointer (3, GL_FLOAT, 16, input->xyz);
if ( qglLockArraysEXT )
{
qglLockArraysEXT(0, input->numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
//
// call special shade routine
//
R_BindAnimatedImage( &tess.xstages[0]->bundle[0] );
GL_State( tess.xstages[0]->stateBits );
R_DrawElements( input->numIndexes, input->indexes );
//
// now do any dynamic lighting needed
//
if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE ) {
ProjectDlightTexture();
}
//
// now do fog
//
if ( tess.fogNum && tess.shader->fogPass ) {
RB_FogPass();
}
//
// unlock arrays
//
if (qglUnlockArraysEXT)
{
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
}
示例7: 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();
}
//.........这里部分代码省略.........
示例8: ProjectDlightTexture2
//.........这里部分代码省略.........
dStage = NULL;
if (tess.shader && qglActiveTextureARB)
{
int i = 0;
while (i < tess.shader->numUnfoggedPasses)
{
const int blendBits = (GLS_SRCBLEND_BITS+GLS_DSTBLEND_BITS);
if (((tess.shader->stages[i].bundle[0].image && !tess.shader->stages[i].bundle[0].isLightmap && !tess.shader->stages[i].bundle[0].numTexMods && tess.shader->stages[i].bundle[0].tcGen != TCGEN_ENVIRONMENT_MAPPED && tess.shader->stages[i].bundle[0].tcGen != TCGEN_FOG) ||
(tess.shader->stages[i].bundle[1].image && !tess.shader->stages[i].bundle[1].isLightmap && !tess.shader->stages[i].bundle[1].numTexMods && tess.shader->stages[i].bundle[1].tcGen != TCGEN_ENVIRONMENT_MAPPED && tess.shader->stages[i].bundle[1].tcGen != TCGEN_FOG)) &&
(tess.shader->stages[i].stateBits & blendBits) == 0 )
{ //only use non-lightmap opaque stages
dStage = &tess.shader->stages[i];
break;
}
i++;
}
}
if (!needResetVerts)
{
needResetVerts=1;
if (qglUnlockArraysEXT)
{
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
}
qglVertexPointer (3, GL_FLOAT, 16, vertCoordsArray); // padded for SIMD
if (dStage)
{
GL_SelectTexture( 0 );
GL_State(0);
qglTexCoordPointer( 2, GL_FLOAT, 0, oldTexCoordsArray[0] );
if (dStage->bundle[0].image && !dStage->bundle[0].isLightmap && !dStage->bundle[0].numTexMods && dStage->bundle[0].tcGen != TCGEN_ENVIRONMENT_MAPPED && dStage->bundle[0].tcGen != TCGEN_FOG)
{
R_BindAnimatedImage( &dStage->bundle[0] );
}
else
{
R_BindAnimatedImage( &dStage->bundle[1] );
}
GL_SelectTexture( 1 );
qglEnable( GL_TEXTURE_2D );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );
GL_Bind( tr.dlightImage );
GL_TexEnv( GL_MODULATE );
GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL);// | GLS_ATEST_GT_0);
R_DrawElements( numIndexes, hitIndexes );
qglDisable( GL_TEXTURE_2D );
GL_SelectTexture(0);
}
else
{
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );
GL_Bind( tr.dlightImage );
// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light
// where they aren't rendered
if ( dl->additive ) {
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
}
else {
GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
}
R_DrawElements( numIndexes, hitIndexes );
}
if (fogging)
{
qglEnable(GL_FOG);
}
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
}
if (needResetVerts)
{
qglVertexPointer (3, GL_FLOAT, 16, tess.xyz); // padded for SIMD
if (qglLockArraysEXT)
{
qglLockArraysEXT(0, tess.numVertexes);
GLimp_LogComment( "glLockArraysEXT\n" );
}
}
}
示例9: RB_IterateStagesGeneric
//.........这里部分代码省略.........
{
FogColorChange = false;
qglFogfv(GL_FOG_COLOR, fog->parms.color);
}
}
if (!input->fading)
{ //this means ignore this, while we do a fade-out
ComputeColors( pStage, forceRGBGen );
}
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 )
{
DrawMultitextured( input, stage );
}
else
{
static bool lStencilled = false;
if ( !setArraysOnce )
{
qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );
}
//
// set state
//
if ( (tess.shader == tr.distortionShader) ||
(backEnd.currentEntity && (backEnd.currentEntity->e.renderfx & RF_DISTORTION)) )
{ //special distortion effect -rww
//tr.screenImage should have been set for this specific entity before we got in here.
GL_Bind( tr.screenImage );
GL_Cull(CT_TWO_SIDED);
}
else if ( pStage->bundle[0].vertexLightmap && ( r_vertexLight->integer && !r_uiFullScreen->integer ) && r_lightmap->integer )
{
GL_Bind( tr.whiteImage );
}
else
R_BindAnimatedImage( &pStage->bundle[0] );
if (tess.shader == tr.distortionShader &&
glConfig.stencilBits >= 4)
{ //draw it to the stencil buffer!
tr_stencilled = true;
lStencilled = true;
qglEnable(GL_STENCIL_TEST);
qglStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
qglStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
//don't depthmask, don't blend.. don't do anything
GL_State(0);
}
else if (backEnd.currentEntity && (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA))
{
ForceAlpha((unsigned char *) tess.svars.colors, backEnd.currentEntity->e.shaderRGBA[3]);
if (backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH)
{ //depth write, so faces through the model will be stomped over by nearer ones. this works because
//we draw RF_FORCE_ENT_ALPHA stuff after everything else, including standard alpha surfs.
GL_State(GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE);
}
else
{
GL_State(GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA);
}
}
else
{
GL_State( stateBits );
}
//
// draw
//
R_DrawElements( input->numIndexes, input->indexes );
if (lStencilled)
{ //re-enable the color buffer, disable stencil test
lStencilled = false;
qglDisable(GL_STENCIL_TEST);
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
}
}
if (FogColorChange)
{
qglFogfv(GL_FOG_COLOR, fog->parms.color);
}
}
示例10: ProjectDlightTexture
//.........这里部分代码省略.........
// }
vec3_t va,vb,vc,vx;
VectorSubtract( origin, tess.xyz[a], va );
VectorSubtract( tess.xyz[a], tess.xyz[b], vb );
VectorSubtract( tess.xyz[a], tess.xyz[c], vc );
CrossProduct(vb,vc,vx);
if (DotProduct( vx, va ) > 0) continue;
hitIndexes[numIndexes] = a;
hitIndexes[numIndexes + 1] = b;
hitIndexes[numIndexes + 2] = c;
numIndexes += 3;
}
if ( !numIndexes ) {
continue;
}
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );
//----(SA) creating dlight shader to allow for special blends or alternate dlight texture
{
shader_t *dls = dl->dlshader;
if ( dls ) {
// if (!qglActiveTextureARB || dls->numUnfoggedPasses < 2) {
for ( i = 0; i < dls->numUnfoggedPasses; i++ )
{
shaderStage_t *stage = dls->stages[i];
R_BindAnimatedImage( &dls->stages[i]->bundle[0] );
GL_State( stage->stateBits | GLS_DEPTHFUNC_EQUAL );
R_DrawElements( numIndexes, hitIndexes );
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
}
/*
} else { // optimize for multitexture
for(i=0;i<dls->numUnfoggedPasses;)
{
shaderStage_t *stage = dls->stages[i];
GL_State(stage->stateBits | GLS_DEPTHFUNC_EQUAL);
// setup each TMU
for (tmu=0; tmu<glConfig.maxActiveTextures && i<dls->numUnfoggedPasses; tmu++, i++) {
GL_SelectTexture( tmu );
if (tmu) {
qglEnable( GL_TEXTURE_2D );
}
R_BindAnimatedImage( &dls->stages[i]->bundle[0] );
}
// draw the elements
R_DrawElements( numIndexes, hitIndexes );
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
}
示例11: RB_GLSL_IterateStagesGeneric
//.........这里部分代码省略.........
R_GLSL_SetUniform_ModelViewMatrix(program, glState.currentModelViewMatrix);
/* model view projection matrix */
if (program->u_ModelViewProjectionMatrix > -1)
R_GLSL_SetUniform_ModelViewProjectionMatrix(program, glState.currentModelViewProjectionMatrix);
/* projection matrix */
if (program->u_ProjectionMatrix > -1)
R_GLSL_SetUniform_ProjectionMatrix(program, glState.currentProjectionMatrix);
/* texture coordinates 0 */
if (program->u_TCGen0 > -1)
R_GLSL_SetUniform_TCGen0(program, pStage->bundle[0].tcGen);
/* texture coordinates 1 */
if (program->u_TCGen1 > -1)
R_GLSL_SetUniform_TCGen1(program, pStage->bundle[1].tcGen);
/* tex env */
if (program->u_TexEnv > -1) {
if (r_lightmap->integer)
R_GLSL_SetUniform_TexEnv(program, GL_REPLACE);
else
R_GLSL_SetUniform_TexEnv(program, input->shader->multitextureEnv);
}
/* texture unit 0 */
if (program->u_Texture0 > -1 && pStage->bundle[0].image[0]) {
GL_SelectTexture(0);
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]);
}
/* texture unit 1 */
if (program->u_Texture1 > -1 && pStage->bundle[1].image[0]) {
GL_SelectTexture(1);
qglEnable(GL_TEXTURE_2D);
R_BindAnimatedImage(&pStage->bundle[1]);
}
/* texture unit 2 */
if (program->u_Texture2 > -1 && pStage->bundle[2].image[0]) {
GL_SelectTexture(2);
qglEnable(GL_TEXTURE_2D);
R_BindAnimatedImage(&pStage->bundle[2]);
}
/* texture unit 3 */
if (program->u_Texture3 > -1 && pStage->bundle[3].image[0]) {
GL_SelectTexture(3);
qglEnable(GL_TEXTURE_2D);
R_BindAnimatedImage(&pStage->bundle[3]);
}
/* texture unit 4 */
if (program->u_Texture4 > -1 && pStage->bundle[4].image[0]) {
GL_SelectTexture(4);
qglEnable(GL_TEXTURE_2D);
R_BindAnimatedImage(&pStage->bundle[4]);
}
/* texture unit 5 */
if (program->u_Texture5 > -1 && pStage->bundle[5].image[0]) {
示例12: R_BindAnimatedImage
void CQuickSpriteSystem::Flush(void)
{
if (mNextVert==0)
{
return;
}
//
// render the main pass
//
R_BindAnimatedImage( mTexBundle );
GL_State(mGLStateBits);
//
// set arrays and lock
//
qglTexCoordPointer( 2, GL_FLOAT, 0, mTextureCoords );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY);
qglEnableClientState( GL_COLOR_ARRAY);
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, mColors );
qglVertexPointer (3, GL_FLOAT, 16, mVerts);
if ( qglLockArraysEXT )
{
qglLockArraysEXT(0, mNextVert);
GLimp_LogComment( "glLockArraysEXT\n" );
}
qglDrawArrays(GL_QUADS, 0, mNextVert);
backEnd.pc.c_vertexes += mNextVert;
backEnd.pc.c_indexes += mNextVert;
backEnd.pc.c_totalIndexes += mNextVert;
if (mUseFog)
{
//
// render the fog pass
//
GL_Bind( tr.fogImage );
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL );
//
// set arrays and lock
//
qglTexCoordPointer( 2, GL_FLOAT, 0, mFogTextureCoords);
// qglEnableClientState( GL_TEXTURE_COORD_ARRAY); // Done above
qglDisableClientState( GL_COLOR_ARRAY );
qglColor4ubv((GLubyte *)&mFogColor);
// qglVertexPointer (3, GL_FLOAT, 16, mVerts); // Done above
qglDrawArrays(GL_QUADS, 0, mNextVert);
// Second pass from fog
backEnd.pc.c_totalIndexes += mNextVert;
}
//
// unlock arrays
//
if (qglUnlockArraysEXT)
{
qglUnlockArraysEXT();
GLimp_LogComment( "glUnlockArraysEXT\n" );
}
mNextVert=0;
}
示例13: 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
{
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
//.........这里部分代码省略.........
示例14: ProjectDlightTexture
//.........这里部分代码省略.........
continue;
}
//don't have fog enabled when we redraw with alpha test, or it will double over
//and screw the tri up -rww
if (r_drawfog->value == 2 &&
tr.world &&
(tess.fogNum == tr.world->globalFog || tess.fogNum == tr.world->numfogs))
{
fogging = qglIsEnabled(GL_FOG);
if (fogging)
{
qglDisable(GL_FOG);
}
}
else
{
fogging = 0;
}
dStage = NULL;
if (tess.shader && qglActiveTextureARB)
{
int i = 0;
while (i < tess.shader->numUnfoggedPasses)
{
const int blendBits = (GLS_SRCBLEND_BITS+GLS_DSTBLEND_BITS);
if (((tess.shader->stages[i].bundle[0].image && !tess.shader->stages[i].bundle[0].isLightmap && !tess.shader->stages[i].bundle[0].numTexMods) ||
(tess.shader->stages[i].bundle[1].image && !tess.shader->stages[i].bundle[1].isLightmap && !tess.shader->stages[i].bundle[1].numTexMods)) &&
(tess.shader->stages[i].stateBits & blendBits) == 0 )
{ //only use non-lightmap opaque stages
dStage = &tess.shader->stages[i];
break;
}
i++;
}
}
if (dStage)
{
GL_SelectTexture( 0 );
GL_State(0);
qglTexCoordPointer( 2, GL_FLOAT, 0, tess.svars.texcoords[0] );
if (dStage->bundle[0].image && !dStage->bundle[0].isLightmap && !dStage->bundle[0].numTexMods)
{
R_BindAnimatedImage( &dStage->bundle[0] );
}
else
{
R_BindAnimatedImage( &dStage->bundle[1] );
}
GL_SelectTexture( 1 );
qglEnable( GL_TEXTURE_2D );
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );
GL_Bind( tr.dlightImage );
GL_TexEnv( GL_MODULATE );
GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL);// | GLS_ATEST_GT_0);
R_DrawElements( numIndexes, hitIndexes );
qglDisable( GL_TEXTURE_2D );
GL_SelectTexture(0);
}
else
{
qglEnableClientState( GL_TEXTURE_COORD_ARRAY );
qglTexCoordPointer( 2, GL_FLOAT, 0, texCoordsArray[0] );
qglEnableClientState( GL_COLOR_ARRAY );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, colorArray );
GL_Bind( tr.dlightImage );
// include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light
// where they aren't rendered
if ( dl->additive ) {
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
}
else {
GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
}
R_DrawElements( numIndexes, hitIndexes );
}
if (fogging)
{
qglEnable(GL_FOG);
}
backEnd.pc.c_totalIndexes += numIndexes;
backEnd.pc.c_dlightIndexes += numIndexes;
}
}
示例15: RB_IterateStagesGeneric
/*
** RB_IterateStagesGeneric
*/
static void RB_IterateStagesGeneric( shaderCommands_t *input )
{
int stage;
int loc;
GLenum prog;
char texname[MAX_QPATH];
shaderStage_t *pStage;
/*if ( input->shader->GLSL ) {
prog = getShaderProgram(input->shader->GLSLName);
if(prog == -1) return;
for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ )
{
pStage = tess.xstages[stage];
if(pStage) {
ComputeColors( pStage );
ComputeTexCoords( pStage );
if ( !setArraysOnce )
{
qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );
qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, input->svars.colors );
}
if(pStage->bundle[0].image) {
qglActiveTextureARB(GL_TEXTURE0_ARB + stage);
qglBindTexture (GL_TEXTURE_2D, pStage->bundle[0].image[0]->texnum);
Com_sprintf(texname,sizeof(texname),"texture_%i\n", stage);
loc = qglGetUniformLocationARB(prog, texname);
qglUniform1iARB(loc, stage);
}
}
}
pStage = tess.xstages[0];
GL_State( pStage->stateBits );
R_DrawElements( input->numIndexes, input->indexes );
return;
}*/
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 )
{
//Lightmaps and such
DrawMultitextured( input, stage );
}
else
{
if ( !setArraysOnce )
{
qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] );
}
//LOL WTF, I don't need to do this!
/*if(pStage->clamp) {
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
}*/
//
// 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 );
//
//.........这里部分代码省略.........