GLC_Shader Class Reference

GLC_Shader : OpenGL shader abstraction. More...

#include <glc_shader.h>

List of all members.

Public Member Functions

Constructor / Destructor

 GLC_Shader ()
 Default constructor.
 GLC_Shader (QFile &, QFile &)
 Construct shader with specifie vertex and fragment.
 GLC_Shader (const GLC_Shader &)
 Copy constructor.
 ~GLC_Shader ()
 Shader destructor.
Set Functions

void setVertexAndFragmentShader (QFile &, QFile &)
 Set Vertex and fragment shaders.
void replaceShader (const GLC_Shader &)
 Replace this shader by a copy of another shader.
GLC_Shaderoperator= (const GLC_Shader &shader)
 Assignement operator which use replace shader method.
void setName (const QString &name)
 Set the Shader Name.
int modelViewLocationId () const
 Return the modelView location id.
int mvpLocationId () const
 Return the modelView Projection matrix id.
int invModelViewLocationId () const
 Return the inverse modelView location id.
int enableLightingId () const
 Return the enable lighting location id.
int lightsEnableStateId () const
 Return the lights enable state id.
int lightPositionId (GLenum lightId) const
 Return the light position id of the given light id.
int lightAmbientColorId (GLenum lightId) const
 Return the light ambient color id of the given light id.
int lightDiffuseColorId (GLenum lightId) const
 Return the light diffuse color id of the given light id.
int lightSpecularColorId (GLenum lightId) const
 Return the light specular color id of the given light id.
int lightSpotDirectionId (GLenum lightId) const
 Return the light spot direction id of the given light id.
int lightAttebuationFactorsId (GLenum lightId) const
 Return the light attenuation factors id of the given light id.
int lightSpotExponentId (GLenum lightId) const
 Return the light spot exponent id of the given light id.
int lightSpotCutoffId (GLenum lightId) const
 Return the light spot cutoff id of the given light id.
int lightComputeDistanceAttenuationId (GLenum lightId) const
 Return the light compute distance attenuation id of the given light id.

Private Member Functions

void initLightsUniformId ()
 Init light uniform id.

Private Attributes

QGLShader m_VertexShader
 Vertex shader.
QGLShader m_FragmentShader
 Fragment shader.
QGLShaderProgram m_ProgramShader
 The programShader.
GLC_uint m_ProgramShaderId
 Programm shader ID.
QString m_Name
 The Shader's name.
int m_PositionAttributeId
 The position attribute id.
int m_TextcoordAttributeId
 The Texture coordinate attribute id.
int m_ColorAttributeId
 The color attribute id.
int m_NormalAttributeId
 The Normal attribute id.
int m_ModelViewLocationId
 The modelView location matrix id.
int m_MvpLocationId
 The modelView Projection matrix id.
int m_InvModelViewLocationId
 The inverse modelView location id.
int m_EnableLightingId
 The enable lighting id.
int m_LightsEnableStateId
 Lights enable states id.
QMap< GLenum, int > m_LightsPositionId
 Lights positions id.
QMap< GLenum, int > m_LightsAmbientColorId
 Lights ambient color id.
QMap< GLenum, int > m_LightsDiffuseColorId
 Lights diffuse color id.
QMap< GLenum, int > m_LightsSpecularColorId
 Lights specular color id.
QMap< GLenum, int > m_LightsSpotDirectionId
 Lights spot direction id.
QMap< GLenum, int > m_LightsAttenuationFactorsId
 Lights attenuation factors id.
QMap< GLenum, int > m_LightsSpotExponentId
 Lights spot exponent id.
QMap< GLenum, int > m_LightsSpotCutoffAngleId
 Lights spot cutoff angle id.
QMap< GLenum, int > m_LightsComputeDistanceAttenuationId
 Lights compute distance attenuation.

Static Private Attributes

static QStack< GLC_uintm_ShadingGroupStack
 The shading group Stack.
static GLC_uint m_CurrentShadingGroupId = 0
 The current shading goup ID.
static QHash< GLC_uint,
GLC_Shader * > 
m_ShaderProgramHash
 Map between shading group id and program shader.

Get Functions



GLuint id () const
 Return the program shader id.
bool isUsable () const
 Return true if the shader is usable.
bool canBeDeleted () const
 Return true if the shader can be deleted.
QString name () const
 Return the shader's name.
QGLShaderProgram * programShaderHandle ()
 Return an handle to the QGLProgramShader of this shader.
int positionAttributeId () const
 Return the position attribute id.
int textureAttributeId () const
 Return the texture coordinate attribute id.
int colorAttributeId () const
 Return the color attribute id.
int normalAttributeId () const
 Return the normal attribute id.
static int shaderCount ()
 Return the number of shader.
static bool asShader (GLC_uint shadingGroupId)
 Return true if the given shading group id as a shader.
static GLC_ShadershaderHandle (GLC_uint shadingGroupId)
 Return handle to the shader associated to the given group id.
static bool hasActiveShader ()
 Return true if there is an active shader.
static GLC_ShadercurrentShaderHandle ()
 Return handle to the current active shader.

OpenGL Functions



void use ()
 Use this shader program.
void createAndCompileProgrammShader ()
 Compile and attach shaders to a program shader.
void deleteShader ()
 Delete the shader.
static bool use (GLC_uint ShadingGroupId)
 Use specified program shader.
static void unuse ()
 unuse programm shader

Detailed Description

GLC_Shader : OpenGL shader abstraction.

An GLC_Shader encapsulate vertex, fragment shader and programm
GLC_Shader provide functionnality to load, compile and execute GLSL vertex and fragment shader.

Definition at line 49 of file glc_shader.h.


Constructor & Destructor Documentation

GLC_Shader::GLC_Shader (  ) 

Default constructor.

Definition at line 38 of file glc_shader.cpp.

References initLightsUniformId(), m_ProgramShaderId, and m_ShaderProgramHash.

GLC_Shader::GLC_Shader ( QFile &  vertex,
QFile &  fragment 
)

Construct shader with specifie vertex and fragment.

Definition at line 67 of file glc_shader.cpp.

References initLightsUniformId(), m_ProgramShaderId, m_ShaderProgramHash, and setVertexAndFragmentShader().

GLC_Shader::GLC_Shader ( const GLC_Shader shader  ) 
GLC_Shader::~GLC_Shader (  ) 

Shader destructor.

Definition at line 137 of file glc_shader.cpp.

References deleteShader().


Member Function Documentation

bool GLC_Shader::asShader ( GLC_uint  shadingGroupId  )  [static]

Return true if the given shading group id as a shader.

Definition at line 156 of file glc_shader.cpp.

References m_ShaderProgramHash.

bool GLC_Shader::canBeDeleted (  )  const

Return true if the shader can be deleted.

Definition at line 146 of file glc_shader.cpp.

References m_CurrentShadingGroupId, and m_ProgramShaderId.

int GLC_Shader::colorAttributeId (  )  const [inline]

Return the color attribute id.

Definition at line 102 of file glc_shader.h.

void GLC_Shader::createAndCompileProgrammShader (  ) 
GLC_Shader * GLC_Shader::currentShaderHandle (  )  [static]

Return handle to the current active shader.

Return NULL if there is no current active shader

Definition at line 171 of file glc_shader.cpp.

References m_CurrentShadingGroupId, and m_ShaderProgramHash.

Referenced by GLC_Material::glExecute(), GLC_UniformShaderData::setLightingState(), and GLC_UniformShaderData::setModelViewProjectionMatrix().

void GLC_Shader::deleteShader (  ) 

Delete the shader.

Definition at line 301 of file glc_shader.cpp.

References m_CurrentShadingGroupId, m_ProgramShaderId, m_ShaderProgramHash, and m_ShadingGroupStack.

Referenced by ~GLC_Shader().

int GLC_Shader::enableLightingId (  )  const [inline]

Return the enable lighting location id.

Definition at line 163 of file glc_shader.h.

Referenced by GLC_UniformShaderData::setLightingState().

bool GLC_Shader::hasActiveShader (  )  [static]
GLuint GLC_Shader::id (  )  const [inline]

Return the program shader id.

Definition at line 75 of file glc_shader.h.

void GLC_Shader::initLightsUniformId (  )  [private]
int GLC_Shader::invModelViewLocationId (  )  const [inline]

Return the inverse modelView location id.

Definition at line 159 of file glc_shader.h.

Referenced by GLC_UniformShaderData::setModelViewProjectionMatrix().

bool GLC_Shader::isUsable (  )  const [inline]

Return true if the shader is usable.

Definition at line 79 of file glc_shader.h.

Referenced by replaceShader().

int GLC_Shader::lightAmbientColorId ( GLenum  lightId  )  const [inline]

Return the light ambient color id of the given light id.

Definition at line 175 of file glc_shader.h.

int GLC_Shader::lightAttebuationFactorsId ( GLenum  lightId  )  const [inline]

Return the light attenuation factors id of the given light id.

Definition at line 191 of file glc_shader.h.

int GLC_Shader::lightComputeDistanceAttenuationId ( GLenum  lightId  )  const [inline]

Return the light compute distance attenuation id of the given light id.

Definition at line 203 of file glc_shader.h.

int GLC_Shader::lightDiffuseColorId ( GLenum  lightId  )  const [inline]

Return the light diffuse color id of the given light id.

Definition at line 179 of file glc_shader.h.

int GLC_Shader::lightPositionId ( GLenum  lightId  )  const [inline]

Return the light position id of the given light id.

Definition at line 171 of file glc_shader.h.

int GLC_Shader::lightsEnableStateId (  )  const [inline]

Return the lights enable state id.

Definition at line 167 of file glc_shader.h.

int GLC_Shader::lightSpecularColorId ( GLenum  lightId  )  const [inline]

Return the light specular color id of the given light id.

Definition at line 183 of file glc_shader.h.

int GLC_Shader::lightSpotCutoffId ( GLenum  lightId  )  const [inline]

Return the light spot cutoff id of the given light id.

Definition at line 199 of file glc_shader.h.

int GLC_Shader::lightSpotDirectionId ( GLenum  lightId  )  const [inline]

Return the light spot direction id of the given light id.

Definition at line 187 of file glc_shader.h.

int GLC_Shader::lightSpotExponentId ( GLenum  lightId  )  const [inline]

Return the light spot exponent id of the given light id.

Definition at line 195 of file glc_shader.h.

int GLC_Shader::modelViewLocationId (  )  const [inline]

Return the modelView location id.

Definition at line 151 of file glc_shader.h.

Referenced by GLC_UniformShaderData::setModelViewProjectionMatrix().

int GLC_Shader::mvpLocationId (  )  const [inline]

Return the modelView Projection matrix id.

Definition at line 155 of file glc_shader.h.

Referenced by GLC_UniformShaderData::setModelViewProjectionMatrix().

QString GLC_Shader::name (  )  const [inline]

Return the shader's name.

Definition at line 86 of file glc_shader.h.

int GLC_Shader::normalAttributeId (  )  const [inline]

Return the normal attribute id.

Definition at line 106 of file glc_shader.h.

GLC_Shader& GLC_Shader::operator= ( const GLC_Shader shader  )  [inline]

Assignement operator which use replace shader method.

Definition at line 140 of file glc_shader.h.

int GLC_Shader::positionAttributeId (  )  const [inline]

Return the position attribute id.

Definition at line 94 of file glc_shader.h.

QGLShaderProgram* GLC_Shader::programShaderHandle (  )  [inline]

Return an handle to the QGLProgramShader of this shader.

Definition at line 90 of file glc_shader.h.

Referenced by GLC_Material::glExecute(), GLC_UniformShaderData::setLightingState(), and GLC_UniformShaderData::setModelViewProjectionMatrix().

void GLC_Shader::replaceShader ( const GLC_Shader sourceShader  ) 

Replace this shader by a copy of another shader.

Definition at line 343 of file glc_shader.cpp.

References isUsable(), m_FragmentShader, m_ProgramShader, and m_VertexShader.

void GLC_Shader::setName ( const QString &  name  )  [inline]

Set the Shader Name.

Definition at line 147 of file glc_shader.h.

void GLC_Shader::setVertexAndFragmentShader ( QFile &  vertexFile,
QFile &  fragmentFile 
)

Set Vertex and fragment shaders.

Definition at line 330 of file glc_shader.cpp.

References m_FragmentShader, m_Name, and m_VertexShader.

Referenced by GLC_Shader(), and GLC_SelectionMaterial::setShaders().

int GLC_Shader::shaderCount (  )  [static]

Return the number of shader.

Definition at line 151 of file glc_shader.cpp.

References m_ShaderProgramHash.

GLC_Shader * GLC_Shader::shaderHandle ( GLC_uint  shadingGroupId  )  [static]

Return handle to the shader associated to the given group id.

Return NULL if the given shading group as no associated shader

Definition at line 161 of file glc_shader.cpp.

References m_ShaderProgramHash.

int GLC_Shader::textureAttributeId (  )  const [inline]

Return the texture coordinate attribute id.

Definition at line 98 of file glc_shader.h.

void GLC_Shader::unuse (  )  [static]

unuse programm shader

Definition at line 221 of file glc_shader.cpp.

References GLC_State::isInSelectionMode(), m_CurrentShadingGroupId, m_ShaderProgramHash, and m_ShadingGroupStack.

Referenced by GLC_3DViewCollection::glDraw().

bool GLC_Shader::use ( GLC_uint  ShadingGroupId  )  [static]

Use specified program shader.

Return true if the given shading group id is usable

Definition at line 197 of file glc_shader.cpp.

References GLC_Context::current(), GLC_State::isInSelectionMode(), m_CurrentShadingGroupId, m_ShaderProgramHash, m_ShadingGroupStack, and GLC_Context::updateUniformVariables().

void GLC_Shader::use (  ) 

Member Data Documentation

The color attribute id.

Definition at line 273 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

GLuint GLC_Shader::m_CurrentShadingGroupId = 0 [static, private]

The current shading goup ID.

Definition at line 246 of file glc_shader.h.

Referenced by canBeDeleted(), currentShaderHandle(), deleteShader(), hasActiveShader(), unuse(), and use().

The enable lighting id.

Definition at line 288 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

QGLShader GLC_Shader::m_FragmentShader [private]

Fragment shader.

Definition at line 255 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), GLC_Shader(), replaceShader(), and setVertexAndFragmentShader().

The inverse modelView location id.

Definition at line 285 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

QMap<GLenum, int> GLC_Shader::m_LightsAmbientColorId [private]

Lights ambient color id.

Definition at line 297 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

QMap<GLenum, int> GLC_Shader::m_LightsAttenuationFactorsId [private]

Lights attenuation factors id.

Definition at line 309 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

Lights compute distance attenuation.

Definition at line 318 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

QMap<GLenum, int> GLC_Shader::m_LightsDiffuseColorId [private]

Lights diffuse color id.

Definition at line 300 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

Lights enable states id.

Definition at line 291 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

QMap<GLenum, int> GLC_Shader::m_LightsPositionId [private]

Lights positions id.

Definition at line 294 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

QMap<GLenum, int> GLC_Shader::m_LightsSpecularColorId [private]

Lights specular color id.

Definition at line 303 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

QMap<GLenum, int> GLC_Shader::m_LightsSpotCutoffAngleId [private]

Lights spot cutoff angle id.

Definition at line 315 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

QMap<GLenum, int> GLC_Shader::m_LightsSpotDirectionId [private]

Lights spot direction id.

Definition at line 306 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

QMap<GLenum, int> GLC_Shader::m_LightsSpotExponentId [private]

Lights spot exponent id.

Definition at line 312 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), and initLightsUniformId().

The modelView location matrix id.

Definition at line 279 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

The modelView Projection matrix id.

Definition at line 282 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

QString GLC_Shader::m_Name [private]

The Shader's name.

Definition at line 264 of file glc_shader.h.

Referenced by setVertexAndFragmentShader().

The Normal attribute id.

Definition at line 276 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

The position attribute id.

Definition at line 267 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

QGLShaderProgram GLC_Shader::m_ProgramShader [private]

The programShader.

Definition at line 258 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), replaceShader(), and use().

Programm shader ID.

Definition at line 261 of file glc_shader.h.

Referenced by canBeDeleted(), deleteShader(), GLC_Shader(), and use().

QHash< GLC_uint, GLC_Shader * > GLC_Shader::m_ShaderProgramHash [static, private]

Map between shading group id and program shader.

Definition at line 249 of file glc_shader.h.

Referenced by asShader(), currentShaderHandle(), deleteShader(), GLC_Shader(), shaderCount(), shaderHandle(), unuse(), and use().

QStack< GLC_uint > GLC_Shader::m_ShadingGroupStack [static, private]

The shading group Stack.

Definition at line 243 of file glc_shader.h.

Referenced by deleteShader(), unuse(), and use().

The Texture coordinate attribute id.

Definition at line 270 of file glc_shader.h.

Referenced by createAndCompileProgrammShader().

QGLShader GLC_Shader::m_VertexShader [private]

Vertex shader.

Definition at line 252 of file glc_shader.h.

Referenced by createAndCompileProgrammShader(), GLC_Shader(), replaceShader(), and setVertexAndFragmentShader().


The documentation for this class was generated from the following files:

SourceForge.net Logo

©2005-2011 Laurent Ribon