Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CelestiaGLProgram Class Reference

#include <shadermanager.h>

Collaboration diagram for CelestiaGLProgram:

Collaboration graph
List of all members.

Public Member Functions

 CelestiaGLProgram (GLProgram &_program, const ShaderProperties &)
void use () const
 ~CelestiaGLProgram ()

Public Attributes

Vec3ShaderParameter ambientColor
Vec3ShaderParameter eyePosition
Vec3ShaderParameter fragLightColor [MaxShaderLights]
Vec3ShaderParameter fragLightSpecColor [MaxShaderLights]
CelestiaGLProgramLight lights [MaxShaderLights]
FloatShaderParameter ringRadius
FloatShaderParameter ringWidth
CelestiaGLProgramShadow shadows [MaxShaderLights][MaxShaderShadows]
FloatShaderParameter shininess
FloatShaderParameter textureOffset

Private Member Functions

FloatShaderParameter floatParam (const std::string &)
void initParameters (const ShaderProperties &)
void initSamplers (const ShaderProperties &)
Vec3ShaderParameter vec3Param (const std::string &)
Vec4ShaderParameter vec4Param (const std::string &)

Private Attributes

GLProgramprogram

Constructor & Destructor Documentation

CelestiaGLProgram::CelestiaGLProgram GLProgram _program,
const ShaderProperties
 

Definition at line 159 of file shadermanager.cpp.

References initParameters(), and initSamplers().

00160                                                                     :
00161     program(&_program)
00162 {
00163     initParameters(props);
00164     initSamplers(props);
00165 };

CelestiaGLProgram::~CelestiaGLProgram  ) 
 

Definition at line 168 of file shadermanager.cpp.

References program.

00169 {
00170     delete program;
00171 }


Member Function Documentation

FloatShaderParameter CelestiaGLProgram::floatParam const std::string  )  [private]
 

Definition at line 175 of file shadermanager.cpp.

References GLProgram::getID(), and program.

Referenced by initParameters().

00176 {
00177     return FloatShaderParameter(program->getID(), paramName.c_str());
00178 }

void CelestiaGLProgram::initParameters const ShaderProperties  )  [private]
 

Definition at line 246 of file shadermanager.cpp.

References ambientColor, CelestiaGLProgramShadow::bias, CelestiaGLProgramLight::diffuse, CelestiaGLProgramLight::direction, eyePosition, floatParam(), fragLightColor, FragLightProperty(), fragLightSpecColor, CelestiaGLProgramLight::halfVector, IndexedParameter(), LightProperty(), lights, ringRadius, ringWidth, CelestiaGLProgramShadow::scale, shadows, shininess, CelestiaGLProgramLight::specular, CelestiaGLProgramShadow::texGenS, CelestiaGLProgramShadow::texGenT, textureOffset, vec3Param(), and vec4Param().

Referenced by CelestiaGLProgram().

00247 {
00248     for (unsigned int i = 0; i < props.nLights; i++)
00249     {
00250         lights[i].direction  = vec3Param(LightProperty(i, "direction"));
00251         lights[i].diffuse    = vec3Param(LightProperty(i, "diffuse"));
00252         lights[i].specular   = vec3Param(LightProperty(i, "specular"));
00253         lights[i].halfVector = vec3Param(LightProperty(i, "halfVector"));
00254 
00255         fragLightColor[i] = vec3Param(FragLightProperty(i, "color"));
00256         fragLightSpecColor[i] = vec3Param(FragLightProperty(i, "specColor"));
00257 
00258         for (unsigned int j = 0; j < props.getShadowCountForLight(i); j++)
00259         {
00260             shadows[i][j].texGenS =
00261                 vec4Param(IndexedParameter("shadowTexGenS", i, j));
00262             shadows[i][j].texGenT =
00263                 vec4Param(IndexedParameter("shadowTexGenT", i, j));
00264             shadows[i][j].scale =
00265                 floatParam(IndexedParameter("shadowScale", i, j));
00266             shadows[i][j].bias =
00267                 floatParam(IndexedParameter("shadowBias", i, j));
00268         }
00269     }
00270 
00271     if (props.lightModel == ShaderProperties::SpecularModel)
00272     {
00273         shininess            = floatParam("shininess");
00274     }
00275 
00276     if (props.lightModel == ShaderProperties::RingIllumModel)
00277     {
00278         // TODO: Eye position also required for specular lighting with
00279         // local viewer.
00280         eyePosition          = vec3Param("eyePosition");
00281     }
00282 
00283     ambientColor = vec3Param("ambientColor");
00284 
00285     if (props.texUsage & ShaderProperties::RingShadowTexture)
00286     {
00287         ringWidth            = floatParam("ringWidth");
00288         ringRadius           = floatParam("ringRadius");
00289     }
00290 
00291     textureOffset = floatParam("textureOffset");
00292 }

void CelestiaGLProgram::initSamplers const ShaderProperties  )  [private]
 

Definition at line 296 of file shadermanager.cpp.

References GLProgram::getID(), glx::glGetUniformLocationARB, glx::glUniform1iARB, program, and GLProgram::use().

Referenced by CelestiaGLProgram().

00297 {
00298     program->use();
00299 
00300     unsigned int nSamplers = 0;
00301     if (props.texUsage & ShaderProperties::DiffuseTexture)
00302     {
00303         int slot = glx::glGetUniformLocationARB(program->getID(), "diffTex");
00304         if (slot != -1)
00305             glx::glUniform1iARB(slot, nSamplers++);
00306     }
00307 
00308     if (props.texUsage & ShaderProperties::NormalTexture)
00309     {
00310         int slot = glx::glGetUniformLocationARB(program->getID(), "normTex");
00311         if (slot != -1)
00312             glx::glUniform1iARB(slot, nSamplers++);
00313     }
00314 
00315     if (props.texUsage & ShaderProperties::SpecularTexture)
00316     {
00317         int slot = glx::glGetUniformLocationARB(program->getID(), "specTex");
00318         if (slot != -1)
00319             glx::glUniform1iARB(slot, nSamplers++);
00320     }
00321 
00322     if (props.texUsage & ShaderProperties::NightTexture)
00323     {
00324         int slot = glx::glGetUniformLocationARB(program->getID(), "nightTex");
00325         if (slot != -1)
00326             glx::glUniform1iARB(slot, nSamplers++);
00327     }
00328 
00329     if (props.texUsage & ShaderProperties::RingShadowTexture)
00330     {
00331         int slot = glx::glGetUniformLocationARB(program->getID(), "ringTex");
00332         if (slot != -1)
00333             glx::glUniform1iARB(slot, nSamplers++);
00334     }
00335 }

void CelestiaGLProgram::use  )  const [inline]
 

Definition at line 78 of file shadermanager.h.

References program, and GLProgram::use().

Referenced by GLSL_RenderContext::makeCurrent(), renderClouds_GLSL(), renderRings_GLSL(), and renderSphere_GLSL().

00078 { program->use(); }

Vec3ShaderParameter CelestiaGLProgram::vec3Param const std::string  )  [private]
 

Definition at line 182 of file shadermanager.cpp.

References GLProgram::getID(), and program.

Referenced by initParameters().

00183 {
00184     return Vec3ShaderParameter(program->getID(), paramName.c_str());
00185 }

Vec4ShaderParameter CelestiaGLProgram::vec4Param const std::string  )  [private]
 

Definition at line 189 of file shadermanager.cpp.

References GLProgram::getID(), and program.

Referenced by initParameters().

00190 {
00191     return Vec4ShaderParameter(program->getID(), paramName.c_str());
00192 }


Member Data Documentation

Vec3ShaderParameter CelestiaGLProgram::ambientColor
 

Definition at line 86 of file shadermanager.h.

Referenced by initParameters(), GLSL_RenderContext::makeCurrent(), renderClouds_GLSL(), renderRings_GLSL(), and renderSphere_GLSL().

Vec3ShaderParameter CelestiaGLProgram::eyePosition
 

Definition at line 84 of file shadermanager.h.

Referenced by initParameters(), and renderRings_GLSL().

Vec3ShaderParameter CelestiaGLProgram::fragLightColor[MaxShaderLights]
 

Definition at line 82 of file shadermanager.h.

Referenced by initParameters().

Vec3ShaderParameter CelestiaGLProgram::fragLightSpecColor[MaxShaderLights]
 

Definition at line 83 of file shadermanager.h.

Referenced by initParameters().

CelestiaGLProgramLight CelestiaGLProgram::lights[MaxShaderLights]
 

Definition at line 81 of file shadermanager.h.

Referenced by initParameters().

GLProgram* CelestiaGLProgram::program [private]
 

Definition at line 103 of file shadermanager.h.

Referenced by floatParam(), initSamplers(), use(), vec3Param(), vec4Param(), and ~CelestiaGLProgram().

FloatShaderParameter CelestiaGLProgram::ringRadius
 

Definition at line 89 of file shadermanager.h.

Referenced by initParameters(), GLSL_RenderContext::makeCurrent(), renderClouds_GLSL(), and renderSphere_GLSL().

FloatShaderParameter CelestiaGLProgram::ringWidth
 

Definition at line 88 of file shadermanager.h.

Referenced by initParameters(), GLSL_RenderContext::makeCurrent(), renderClouds_GLSL(), and renderSphere_GLSL().

CelestiaGLProgramShadow CelestiaGLProgram::shadows[MaxShaderLights][MaxShaderShadows]
 

Definition at line 93 of file shadermanager.h.

Referenced by initParameters(), and renderRings_GLSL().

FloatShaderParameter CelestiaGLProgram::shininess
 

Definition at line 85 of file shadermanager.h.

Referenced by initParameters(), GLSL_RenderContext::makeCurrent(), and renderSphere_GLSL().

FloatShaderParameter CelestiaGLProgram::textureOffset
 

Definition at line 91 of file shadermanager.h.

Referenced by initParameters(), and renderClouds_GLSL().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:09 2006 for Celestia by  doxygen 1.4.1