Instead of their own bool, store enabled features in the features variable as a flag.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent bbb4762b77
commit c6b714299a

@ -31,11 +31,11 @@ namespace NL3D
CShaderDesc(){ CShaderDesc(){
for( int i = 0; i < MAX_TEXTURES; i++ ) for( int i = 0; i < MAX_TEXTURES; i++ )
texEnvMode[ i ] = 0; texEnvMode[ i ] = 0;
features = None;
shaderType = 0; shaderType = 0;
program = NULL; program = NULL;
vbFlags = 0; vbFlags = 0;
nlightmaps = 0; nlightmaps = 0;
alphaTest = false;
alphaTestTreshold = 0.5f; alphaTestTreshold = 0.5f;
} }
@ -53,10 +53,10 @@ namespace NL3D
if( nlightmaps != o.nlightmaps ) if( nlightmaps != o.nlightmaps )
return false; return false;
if( alphaTest != o.alphaTest ) if( features != o.features )
return false; return false;
if( alphaTest ) if( ( features & AlphaTest ) != 0 )
{ {
if( alphaTestTreshold > o.alphaTestTreshold + 0.0001f ) if( alphaTestTreshold > o.alphaTestTreshold + 0.0001f )
return false; return false;
@ -77,17 +77,31 @@ namespace NL3D
void setShaderType( uint32 type ){ shaderType = type; } void setShaderType( uint32 type ){ shaderType = type; }
void setProgram( IProgramObject *p ){ program = p; } void setProgram( IProgramObject *p ){ program = p; }
void setNLightMaps( uint32 n ){ nlightmaps = n; } void setNLightMaps( uint32 n ){ nlightmaps = n; }
void setAlphaTest( bool b ){ alphaTest = b; }
void setAlphaTest( bool b ){
if( b )
features |= AlphaTest;
else
features &= ~AlphaTest;
}
void setAlphaTestThreshold( float t ){ alphaTestTreshold = t; } void setAlphaTestThreshold( float t ){ alphaTestTreshold = t; }
IProgramObject* getProgram() const{ return program; } IProgramObject* getProgram() const{ return program; }
private: private:
enum TShaderFeatures
{
None = 0,
AlphaTest = 1
};
uint32 features;
uint32 texEnvMode[ MAX_TEXTURES ]; uint32 texEnvMode[ MAX_TEXTURES ];
uint32 vbFlags; uint32 vbFlags;
uint32 shaderType; uint32 shaderType;
uint32 nlightmaps; uint32 nlightmaps;
bool alphaTest;
float alphaTestTreshold; float alphaTestTreshold;
IProgramObject *program; IProgramObject *program;

Loading…
Cancel
Save