tgMaterial.cpp
Go to the documentation of this file.
00001 
00002 #include <blort/TomGine/tgMaterial.h>
00003 
00004 #ifdef WIN32
00005 #include <GL/glew.h>
00006 #include <GL/gl.h>
00007 #include <GL/glu.h>
00008 #else
00009 #include <GL/gl.h>
00010 #include <GL/glu.h>
00011 #include <GL/glext.h>
00012 #endif
00013 
00014 using namespace TomGine;
00015 
00016 tgMaterial::tgMaterial(){
00017     ambient = vec4(0.5f, 0.5f, 0.5f, 1.0f);
00018     diffuse = vec4(0.5f, 0.5f, 0.5f, 1.0f);
00019     specular = vec4(0.5f, 0.5f, 0.5f, 1.0f);
00020     color = vec4(0.5f, 0.5f, 0.5f, 1.0f);
00021     shininess = 50.0f;
00022 }
00023 
00024 void tgMaterial::Apply(){
00025     glEnable(GL_LIGHTING);
00026     glMaterialfv(GL_FRONT,GL_AMBIENT,ambient);
00027     glMaterialfv(GL_FRONT,GL_DIFFUSE,diffuse);
00028     glMaterialfv(GL_FRONT,GL_SPECULAR,specular);
00029     glMaterialfv(GL_FRONT,GL_SHININESS,&shininess);
00030 }
00031 
00032 void tgMaterial::Color(float r, float g, float b, float a){
00033     color = vec4(r,g,b,a);
00034     ambient = vec4(r,g,b,a) * 0.5f;
00035     diffuse = vec4(0.2f,0.2f,0.2f,a) + vec4(r,g,b,0.0f) * 0.8f;
00036     specular = vec4(0.3f,0.3f,0.3f,a);
00037     shininess = 20.0f;// * float(rand())/RAND_MAX;
00038 }
00039 
00040 void tgMaterial::Random(){
00041     vec4 c;
00042     c.random();
00043     Color(c.x, c.y, c.z);
00044 }
00045 


blort
Author(s): Michael Zillich, Thomas Mörwald, Johann Prankl, Andreas Richtsfeld, Bence Magyar (ROS version)
autogenerated on Thu Jan 2 2014 11:38:26