#include "EPSG/Material.h"

/* System Includes */
#ifdef WIN32
	#include <Windows.h>
#endif

/* OpenGL Includes */
 #include <GL/GL.h>

EPSG::Material::Material()
{
	_ambient[0] = 1;
	_ambient[1] = 1;
	_ambient[2] = 1;
	_ambient[3] = 1;
	_diffuse[0] = 0;
	_diffuse[1] = 0;
	_diffuse[2] = 0;
	_diffuse[3] = 0;
	_specular[0] = 0;
	_specular[1] = 0;
	_specular[2] = 0;
	_specular[3] = 0;

	_shininess = 0.0f;
}

void EPSG::Material::load()
{
	//glPushAttrib( GL_LIGHTING_BIT );
	glPushClientAttrib( GL_LIGHTING_BIT );

	glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, _ambient );
	glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, _diffuse );
	glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, _specular );
	glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, _shininess );

}

void EPSG::Material::unload()
{
	//glPopAttrib();
	glPopClientAttrib();
}

void EPSG::Material::setAmbient( float r, float g, float b, float a )
{
	_ambient[0] = r;
	_ambient[1] = g;
	_ambient[2] = b;
	_ambient[3] = a;
}

void EPSG::Material::setDiffuse( float r, float g, float b, float a )
{
	_diffuse[0] = r;
	_diffuse[1] = g;
	_diffuse[2] = b;
	_diffuse[3] = a;
}

void EPSG::Material::setSpecular( float r, float g, float b, float a )
{
	_specular[0] = r;
	_specular[1] = g;
	_specular[2] = b;
	_specular[3] = a;
}

void EPSG::Material::setShininess( float shininess )
{
	_shininess = shininess;
}