Lua bindings: signal start working again.
[fail.git] / scenegraph / material.cpp
blob7f5b2b52e4f03cb8258d7afe26a860ccacf9bbd2
1 //
2 // rendermgr
3 //
4 // Description:
5 //
6 //
7 // Author: Antoine Chavasse <a.chavasse@gmail.com>, (C) 2005
8 //
9 // Copyright: See COPYING file that comes with this distribution
12 #include "material.h"
13 //#include "GL/glew.h"
15 using namespace sluggish;
17 Material::Material() :
18 m_Shininess( 0.5f ),
19 m_VertexColorChannel( e_NONE )
23 bool Material::operator==( const Material& _Mat ) const
25 // if( m_pTexture != _Mat.m_pTexture )
26 // return false;
28 if( m_Ambient != _Mat.m_Ambient )
29 return false;
31 if( m_Diffuse != _Mat.m_Diffuse )
32 return false;
34 if( m_Specular != _Mat.m_Specular )
35 return false;
37 if( m_Emission != _Mat.m_Emission )
38 return false;
40 if( m_Shininess != _Mat.m_Shininess )
41 return false;
43 return true;
46 bool Material::operator<( const Material& _Mat ) const
48 // TODO: texture comparison stuff
49 // if( m_pTexture ! _Mat.m_pTexture )
50 // return false;
52 if( m_Ambient < _Mat.m_Ambient )
53 return false;
55 if( m_Diffuse < _Mat.m_Diffuse )
56 return false;
58 if( m_Specular < _Mat.m_Specular )
59 return false;
61 if( m_Emission < _Mat.m_Emission )
62 return false;
64 if( m_Shininess < _Mat.m_Shininess )
65 return false;
67 return false;
70 void Material::setup() const
72 // TODO: animatable
73 //eval();
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 );
83 else
85 switch( m_VertexColorChannel )
87 case e_EMISSION:
88 glColorMaterial( GL_FRONT, GL_EMISSION );
89 break;
91 case e_AMBIENT:
92 glColorMaterial( GL_FRONT, GL_AMBIENT );
93 break;
95 case e_DIFFUSE:
96 glColorMaterial( GL_FRONT, GL_DIFFUSE );
97 break;
99 case e_SPECULAR:
100 glColorMaterial( GL_FRONT, GL_SPECULAR );
101 break;
103 case e_AMBIENT_AND_DIFFUSE:
104 glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
105 break;
107 default:
108 break;
111 glEnable( GL_COLOR_MATERIAL );
114 // TODO: texture
115 /*if( m_pTexture.IsValid() )
116 m_pTexture->Setup();
117 else
118 glDisable( GL_TEXTURE_2D );*/