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 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