00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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