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.

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.

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.
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 (GLuint 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 48 of file glc_shader.h.


Constructor & Destructor Documentation

GLC_Shader::GLC_Shader (  ) 

Default constructor.

Definition at line 36 of file glc_shader.cpp.

References m_ProgramShaderId, and m_ShaderProgramHash.

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

Construct shader with specifie vertex and fragment.

Definition at line 46 of file glc_shader.cpp.

References m_ProgramShaderId, m_ShaderProgramHash, and setVertexAndFragmentShader().

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

Shader destructor.

Definition at line 78 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 97 of file glc_shader.cpp.

References m_ShaderProgramHash.

bool GLC_Shader::canBeDeleted (  )  const

Return true if the shader can be deleted.

Definition at line 87 of file glc_shader.cpp.

References m_CurrentShadingGroupId, and m_ProgramShaderId.

void GLC_Shader::createAndCompileProgrammShader (  ) 

Compile and attach shaders to a program shader.

Throw GLC_Exception if vertex and fragment shader are not been set

Definition at line 179 of file glc_shader.cpp.

References m_FragmentShader, m_ProgramShader, and m_VertexShader.

Referenced by GLC_Shader().

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 112 of file glc_shader.cpp.

References m_CurrentShadingGroupId, and m_ShaderProgramHash.

Referenced by GLC_Material::glExecute().

void GLC_Shader::deleteShader (  ) 

Delete the shader.

Definition at line 192 of file glc_shader.cpp.

References m_CurrentShadingGroupId, m_ProgramShaderId, m_ShaderProgramHash, and m_ShadingGroupStack.

Referenced by ~GLC_Shader().

bool GLC_Shader::hasActiveShader (  )  [static]

Return true if there is an active shader.

Definition at line 107 of file glc_shader.cpp.

References m_CurrentShadingGroupId.

Referenced by GLC_Material::glExecute().

GLuint GLC_Shader::id (  )  const [inline]

Return the program shader id.

Definition at line 74 of file glc_shader.h.

bool GLC_Shader::isUsable (  )  const [inline]

Return true if the shader is usable.

Definition at line 78 of file glc_shader.h.

Referenced by replaceShader().

QString GLC_Shader::name (  )  const [inline]

Return the shader's name.

Definition at line 85 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 123 of file glc_shader.h.

QGLShaderProgram* GLC_Shader::programShaderHandle (  )  [inline]

Return an handle to the QGLProgramShader of this shader.

Definition at line 89 of file glc_shader.h.

Referenced by GLC_Material::glExecute().

void GLC_Shader::replaceShader ( const GLC_Shader sourceShader  ) 

Replace this shader by a copy of another shader.

Definition at line 234 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 130 of file glc_shader.h.

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

Set Vertex and fragment shaders.

Definition at line 221 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 92 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 102 of file glc_shader.cpp.

References m_ShaderProgramHash.

void GLC_Shader::unuse (  )  [static]

unuse programm shader

Definition at line 159 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 ( GLuint  ShadingGroupId  )  [static]

Use specified program shader.

Return true if the given shading group id is usable

Definition at line 137 of file glc_shader.cpp.

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

void GLC_Shader::use (  ) 

Use this shader program.

Throw GLC_Exception if the program is not usable

Definition at line 121 of file glc_shader.cpp.

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

Referenced by GLC_3DViewCollection::glDraw().


Member Data Documentation

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

The current shading goup ID.

Definition at line 167 of file glc_shader.h.

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

QGLShader GLC_Shader::m_FragmentShader [private]

Fragment shader.

Definition at line 176 of file glc_shader.h.

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

QString GLC_Shader::m_Name [private]

The Shader's name.

Definition at line 185 of file glc_shader.h.

Referenced by setVertexAndFragmentShader().

QGLShaderProgram GLC_Shader::m_ProgramShader [private]

The programShader.

Definition at line 179 of file glc_shader.h.

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

Programm shader ID.

Definition at line 182 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 170 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 164 of file glc_shader.h.

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

QGLShader GLC_Shader::m_VertexShader [private]

Vertex shader.

Definition at line 173 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