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 Shader(NULL)
00034 {
00035     for (int c=0; c<MAX_TEXTURES; c++)
00036     {
00037         Textures[c]=0;
00038     }
00039 }
00040 
00041 void State::Apply()
00042 {
00043     glMultMatrixf(Transform.arr());
00044     Colour.a=Ambient.a=Emissive.a=Specular.a=Opacity;
00045     glColor4f(Colour.r,Colour.g,Colour.b,Colour.a);
00046     glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,Ambient.arr());
00047     glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,Emissive.arr());
00048     glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,Colour.arr());
00049     glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,Specular.arr());
00050     glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,&Shinyness);
00051     glLineWidth(LineWidth);
00052     glPointSize(PointWidth);
00053     glBlendFunc(SourceBlend,DestinationBlend);
00054 
00055     TexturePainter::Get()->SetCurrent(Textures);
00056     
00057     if (Shader)
00058     {
00059         Shader->Apply();
00060     }
00061     else
00062     {
00063         GLSLShader::Unapply();
00064     }
00065 }
00066 
00067 void State::Spew()
00068 {
00069     Trace::Stream<<"Colour: "<<Colour<<endl
00070         <<"Specular: "<<Specular<<endl
00071         <<"Ambient: "<<Ambient<<endl
00072         <<"Emissive: "<<Emissive<<endl
00073         <<"Shinyness: "<<Shinyness<<endl
00074         <<"Opacity: "<<Opacity<<endl
00075         <<"Texture: "<<Textures[0]<<endl
00076         <<"Parent: "<<Parent<<endl
00077         <<"Hints: "<<Hints<<endl
00078         <<"LineWidth: "<<LineWidth<<endl
00079         <<"Transform: "<<Transform<<endl;
00080 }
00081     

Generated on Tue Sep 4 23:22:18 2007 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1