add TextureUnit param to SetTextureMode

This commit is contained in:
Glenn Maynard
2007-02-13 04:59:05 +00:00
parent 9e94e85a35
commit ebb7189b88
12 changed files with 60 additions and 63 deletions
+4 -4
View File
@@ -513,7 +513,7 @@ bool BitmapText::EarlyAbortDraw() const
void BitmapText::DrawPrimitives()
{
Actor::SetGlobalRenderStates(); // set Actor-specified render states
DISPLAY->SetTextureMode( TextureMode_Modulate );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate );
/* Draw if we're not fully transparent or the zbuffer is enabled */
if( m_pTempState->diffuse[0].a != 0 )
@@ -601,7 +601,7 @@ void BitmapText::DrawPrimitives()
/* render the glow pass */
if( m_pTempState->glow.a > 0.0001f )
{
DISPLAY->SetTextureMode( TextureMode_Glow );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow );
for( unsigned i=0; i<m_aVertices.size(); i++ )
m_aVertices[i].c = m_pTempState->glow;
@@ -773,7 +773,7 @@ void ColorBitmapText::SimpleAddLine( const RString &sAddition, const int iWidthP
void ColorBitmapText::DrawPrimitives( )
{
Actor::SetGlobalRenderStates(); // set Actor-specified render states
DISPLAY->SetTextureMode( TextureMode_Modulate );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate );
/* Draw if we're not fully transparent or the zbuffer is enabled */
if( m_pTempState->diffuse[0].a != 0 )
@@ -822,7 +822,7 @@ void ColorBitmapText::DrawPrimitives( )
/* render the glow pass */
if( m_pTempState->glow.a > 0.0001f )
{
DISPLAY->SetTextureMode( TextureMode_Glow );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow );
for( unsigned i=0; i<m_aVertices.size(); i++ )
m_aVertices[i].c = m_pTempState->glow;
+1 -1
View File
@@ -132,7 +132,7 @@ public:
// parameters have no effect.
Actor::SetTextureRenderStates();
DISPLAY->SetTextureMode( TextureMode_Modulate );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate );
DISPLAY->DrawQuadStrip( m_Slices, ARRAYLEN(m_Slices) );
}
+1 -1
View File
@@ -160,7 +160,7 @@ void GrooveRadar::GrooveRadarValueMap::DrawPrimitives()
const float fRadius = GetUnzoomedWidth()/2.0f*1.1f;
DISPLAY->ClearAllTextures();
DISPLAY->SetTextureMode( TextureMode_Modulate );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate );
RageSpriteVertex v[12]; // needed to draw 5 fan primitives and 10 strip primitives
if( !m_bValuesVisible )
+3 -3
View File
@@ -322,7 +322,7 @@ void Model::DrawPrimitives()
//////////////////////
if( m_pTempState->diffuse[0].a > 0 )
{
DISPLAY->SetTextureMode( TextureMode_Modulate );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate );
for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i )
{
@@ -367,7 +367,7 @@ void Model::DrawPrimitives()
DISPLAY->SetTexture( TextureUnit_2, mat.alpha.GetCurrentTexture() ? mat.alpha.GetCurrentTexture()->GetTexHandle() : 0 );
Actor::SetTextureRenderStates(); // set Actor-specified render states
DISPLAY->SetSphereEnvironmentMapping( mat.alpha.m_bSphereMapped );
DISPLAY->SetTextureMode( TextureMode_Add );
DISPLAY->SetTextureMode( TextureUnit_2, TextureMode_Add );
DISPLAY->SetTextureFiltering( true );
}
else
@@ -434,7 +434,7 @@ void Model::DrawPrimitives()
//////////////////////
if( m_pTempState->glow.a > 0.0001f )
{
DISPLAY->SetTextureMode( TextureMode_Glow );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow );
for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i )
{
+2 -2
View File
@@ -515,9 +515,9 @@ void NoteDisplay::DrawHoldBody( const TapNote& tn, int iCol, float fBeat, bool b
}
if( bGlow )
DISPLAY->SetTextureMode( TextureMode_Glow );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow );
else
DISPLAY->SetTextureMode( TextureMode_Modulate );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate );
const bool bWavyPartsNeedZBuffer = ArrowEffects::NeedZBuffer( m_pPlayerState );
DISPLAY->SetZTestMode( bWavyPartsNeedZBuffer?ZTEST_WRITE_ON_PASS:ZTEST_OFF );
+1 -1
View File
@@ -203,7 +203,7 @@ public:
virtual void ClearAllTextures() = 0;
virtual int GetNumTextureUnits() = 0;
virtual void SetTexture( TextureUnit tu, unsigned iTexture ) = 0;
virtual void SetTextureMode( TextureMode tm ) = 0;
virtual void SetTextureMode( TextureUnit tu, TextureMode tm ) = 0;
virtual void SetTextureWrapping( bool b ) = 0;
virtual int GetMaxTextureSize() const = 0;
virtual void SetTextureFiltering( bool b ) = 0;
+25 -25
View File
@@ -1131,34 +1131,34 @@ void RageDisplay_D3D::SetTexture( TextureUnit tu, unsigned iTexture )
g_currentTextureUnit = tu;
// g_DeviceCaps.MaxSimultaneousTextures = 1;
if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported
if( tu >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported
return;
if( iTexture == 0 )
{
g_pd3dDevice->SetTexture( g_currentTextureUnit, NULL );
g_pd3dDevice->SetTexture( tu, NULL );
// Intentionally commented out. Don't mess with texture stage state when just setting the texture.
// Model sets its texture modes before setting the final texture.
//g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_DISABLE );
//g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_DISABLE );
}
else
{
IDirect3DTexture8* pTex = (IDirect3DTexture8*) iTexture;
g_pd3dDevice->SetTexture( g_currentTextureUnit, pTex );
g_pd3dDevice->SetTexture( tu, pTex );
// Intentionally commented out. Don't mess with texture stage state when just setting the texture.
// Model sets its texture modes before setting the final texture.
//g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_MODULATE );
//g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_MODULATE );
// Set palette (if any)
SetPalette( iTexture );
}
}
void RageDisplay_D3D::SetTextureMode( TextureMode tm )
void RageDisplay_D3D::SetTextureMode( TextureUnit tu, TextureMode tm )
{
if( g_currentTextureUnit >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported
if( tu >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported
return;
switch( tm )
@@ -1167,28 +1167,28 @@ void RageDisplay_D3D::SetTextureMode( TextureMode tm )
// Use D3DTA_CURRENT instead of diffuse so that multitexturing works
// properly. For stage 0, D3DTA_CURRENT is the diffuse color.
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
break;
case TextureMode_Add:
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_ADD );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_ADD );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
break;
case TextureMode_Glow:
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( g_currentTextureUnit, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLORARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
g_pd3dDevice->SetTextureStageState( tu, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
break;
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ public:
void ClearAllTextures();
int GetNumTextureUnits();
void SetTexture( TextureUnit tu, unsigned iTexture );
void SetTextureMode( TextureMode tm );
void SetTextureMode( TextureUnit tu, TextureMode tm );
void SetTextureWrapping( bool b );
int GetMaxTextureSize() const;
void SetTextureFiltering( bool b);
+1 -1
View File
@@ -33,7 +33,7 @@ public:
void ClearAllTextures() { }
int GetNumTextureUnits() { return 1; }
void SetTexture( TextureUnit tu, unsigned iTexture ) { }
void SetTextureMode( TextureMode tm ) { }
void SetTextureMode( TextureUnit tu, TextureMode tm ) { }
void SetTextureWrapping( bool b ) { }
int GetMaxTextureSize() const { return 2048; }
void SetTextureFiltering( bool b) { }
+18 -21
View File
@@ -1358,6 +1358,18 @@ void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNu
glDisable( GL_POINT_SMOOTH );
}
static bool SetTextureUnit( TextureUnit tu )
{
// If multitexture isn't supported, ignore all textures except for 0.
if( GLExt.glActiveTextureARB == NULL )
return false;
if( (int) tu > g_iMaxTextureUnits )
return false;
GLExt.glActiveTextureARB( enum_add2(GL_TEXTURE0_ARB, tu) );
return true;
}
void RageDisplay_OGL::ClearAllTextures()
{
FOREACH_ENUM( TextureUnit, i )
@@ -1379,26 +1391,8 @@ int RageDisplay_OGL::GetNumTextureUnits()
void RageDisplay_OGL::SetTexture( TextureUnit tu, unsigned iTexture )
{
if( GLExt.glActiveTextureARB == NULL )
{
// multitexture isn't supported. Ignore all textures except for 0.
if( tu != 0 )
return;
}
else
{
switch( tu )
{
case 0:
GLExt.glActiveTextureARB(GL_TEXTURE0_ARB);
break;
case 1:
GLExt.glActiveTextureARB(GL_TEXTURE1_ARB);
break;
default:
ASSERT(0);
}
}
if( !SetTextureUnit( tu ) )
return;
if( iTexture )
{
@@ -1411,8 +1405,11 @@ void RageDisplay_OGL::SetTexture( TextureUnit tu, unsigned iTexture )
}
}
void RageDisplay_OGL::SetTextureMode( TextureMode tm )
void RageDisplay_OGL::SetTextureMode( TextureUnit tu, TextureMode tm )
{
if( !SetTextureUnit( tu ) )
return;
switch( tm )
{
case TextureMode_Modulate:
+1 -1
View File
@@ -43,7 +43,7 @@ public:
void ClearAllTextures();
int GetNumTextureUnits();
void SetTexture( TextureUnit tu, unsigned iTexture );
void SetTextureMode( TextureMode tm );
void SetTextureMode( TextureUnit tu, TextureMode tm );
void SetTextureWrapping( bool b );
int GetMaxTextureSize() const;
void SetTextureFiltering( bool b);
+2 -2
View File
@@ -503,7 +503,7 @@ void Sprite::DrawTexture( const TweenState *state )
state->diffuse[2].a > 0 ||
state->diffuse[3].a > 0 )
{
DISPLAY->SetTextureMode( TextureMode_Modulate );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Modulate );
//////////////////////
// render the shadow
@@ -532,7 +532,7 @@ void Sprite::DrawTexture( const TweenState *state )
//////////////////////
if( state->glow.a > 0.0001f )
{
DISPLAY->SetTextureMode( TextureMode_Glow );
DISPLAY->SetTextureMode( TextureUnit_1, TextureMode_Glow );
v[0].c = v[1].c = v[2].c = v[3].c = state->glow;
DISPLAY->DrawQuad( v );
}