State.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2005 Dave Griffiths
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 
00017 #include "Renderer.h"
00018 #include "TexturePainter.h"
00019 #include "State.h"
00020 
00021 using namespace Fluxus;
00022 
00023 State::State() :
00024 Colour(1,1,1),
00025 Shinyness(1.0f),
00026 Opacity(1.0f),
00027 Parent(1),
00028 Hints(HINT_SOLID),
00029 LineWidth(1),
00030 PointWidth(1),
00031 SourceBlend(GL_SRC_ALPHA),
00032 DestinationBlend(GL_ONE_MINUS_SRC_ALPHA),
00033 WireColour(1,1,1),
00034 WireOpacity(1.0f),
00035 Shader(NULL)
00036 {
00037     for (int c=0; c<MAX_TEXTURES; c++)
00038     {
00039         Textures[c]=0;
00040     }
00041 }
00042 
00043 void State::Apply()
00044 {
00045     glMultMatrixf(Transform.arr());
00046     Colour.a=Ambient.a=Emissive.a=Specular.a=Opacity;
00047     WireColour.a=WireOpacity;
00048     glColor4f(Colour.r,Colour.g,Colour.b,Colour.a);
00049     glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,Ambient.arr());
00050     glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,Emissive.arr());
00051     glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Colour.arr());
00052     glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,Specular.arr());
00053     glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,&Shinyness);
00054     glLineWidth(LineWidth);
00055     glPointSize(PointWidth);
00056     glBlendFunc(SourceBlend,DestinationBlend);
00057 
00058     TexturePainter::Get()->SetCurrent(Textures,TextureStates);
00059 
00060     if (Shader)
00061     {
00062         Shader->Apply();
00063     }
00064     else
00065     {
00066         GLSLShader::Unapply();
00067     }
00068 }
00069 
00070 void State::Spew()
00071 {
00072     Trace::Stream<<"Colour: "<<Colour<<endl
00073         <<"Specular: "<<Specular<<endl
00074         <<"Ambient: "<<Ambient<<endl
00075         <<"Emissive: "<<Emissive<<endl
00076         <<"Shinyness: "<<Shinyness<<endl
00077         <<"Opacity: "<<Opacity<<endl
00078         <<"WireOpacity: "<<WireOpacity<<endl
00079         <<"Texture: "<<Textures[0]<<endl
00080         <<"Parent: "<<Parent<<endl
00081         <<"Hints: "<<Hints<<endl
00082         <<"LineWidth: "<<LineWidth<<endl
00083         <<"Transform: "<<Transform<<endl;
00084 }
00085 

Generated on Mon Feb 11 06:54:25 2008 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1