7 // Author: Antoine Chavasse <a.chavasse@gmail.com>, (C) 2005
9 // Copyright: See COPYING file that comes with this distribution
13 //#include "GL/glew.h"
15 using namespace sluggish
;
17 Material::Material() :
19 m_VertexColorChannel( e_NONE
)
23 bool Material::operator==( const Material
& _Mat
) const
25 // if( m_pTexture != _Mat.m_pTexture )
28 if( m_Ambient
!= _Mat
.m_Ambient
)
31 if( m_Diffuse
!= _Mat
.m_Diffuse
)
34 if( m_Specular
!= _Mat
.m_Specular
)
37 if( m_Emission
!= _Mat
.m_Emission
)
40 if( m_Shininess
!= _Mat
.m_Shininess
)
46 bool Material::operator<( const Material
& _Mat
) const
48 // TODO: texture comparison stuff
49 // if( m_pTexture ! _Mat.m_pTexture )
52 if( m_Ambient
< _Mat
.m_Ambient
)
55 if( m_Diffuse
< _Mat
.m_Diffuse
)
58 if( m_Specular
< _Mat
.m_Specular
)
61 if( m_Emission
< _Mat
.m_Emission
)
64 if( m_Shininess
< _Mat
.m_Shininess
)
70 void Material::setup() const
75 glMaterialfv( GL_FRONT
, GL_AMBIENT
, m_Ambient
.asArray() );
76 glMaterialfv( GL_FRONT
, GL_DIFFUSE
, m_Diffuse
.asArray() );
77 glMaterialfv( GL_FRONT
, GL_SPECULAR
, m_Specular
.asArray() );
78 glMaterialfv( GL_FRONT
, GL_EMISSION
, m_Emission
.asArray() );
79 glMaterialf( GL_FRONT
, GL_SHININESS
, m_Shininess
);
81 if( m_VertexColorChannel
== e_NONE
)
82 glDisable( GL_COLOR_MATERIAL
);
85 switch( m_VertexColorChannel
)
88 glColorMaterial( GL_FRONT
, GL_EMISSION
);
92 glColorMaterial( GL_FRONT
, GL_AMBIENT
);
96 glColorMaterial( GL_FRONT
, GL_DIFFUSE
);
100 glColorMaterial( GL_FRONT
, GL_SPECULAR
);
103 case e_AMBIENT_AND_DIFFUSE
:
104 glColorMaterial( GL_FRONT
, GL_AMBIENT_AND_DIFFUSE
);
111 glEnable( GL_COLOR_MATERIAL
);
115 /*if( m_pTexture.IsValid() )
118 glDisable( GL_TEXTURE_2D );*/