chai3d::cShader Class Reference

This class implements a shader primitive. More...

#include <CShader.h>

Public Member Functions

 cShader (cShaderType a_type)
 Constructor of cShader. More...
 
virtual ~cShader ()
 Destructor of cShader. More...
 
bool loadSourceCode (const char *a_source)
 This method loads the shader content from a char array. More...
 
bool loadSourceCode (const std::string &a_source)
 This method loads the shader content from a string. More...
 
bool loadSourceFile (const std::string &a_fileName)
 This method loads the shader content from a file. More...
 
bool compile ()
 This method compiles a shader and display any problems if compilation fails. More...
 
bool isCompiled () const
 This method returns true if shader has been compiled successfully, false otherwise. More...
 
std::string getLog () const
 This method returns the log file generated from compilation. More...
 
GLuint getId () const
 This method returns the shader OpenGL ID. More...
 
std::string getSource ()
 This method returns the source code of the shader. More...
 
cShaderType getType () const
 This method returns the type of the shader. More...
 

Static Public Member Functions

static cShaderPtr create (cShaderType a_type)
 Shared cShader allocator. More...
 
static bool hasOpenGLShaders (cShaderType a_type)
 This method returns true if shaders are supported on this computer, false otherwise. More...
 

Protected Attributes

cShaderType m_type
 Shader type (C_VERTEX_SHADER, C_FRAGMENT_SHADER, or C_GEOMETRY_SHADER). More...
 
GLuint m_id
 Handle ID for the shader. More...
 
std::string m_source
 The shader source code (i.e. the GLSL code itself). More...
 
std::string m_log
 Log message following compilation. More...
 
bool m_compiled
 If true then shader was compiled successfully, false otherwise. More...
 

Detailed Description

This class implements the basic capabilities to load and control an OpenGL shader.

Constructor & Destructor Documentation

chai3d::cShader::cShader ( cShaderType  a_type)

Constructor of cShader.

virtual chai3d::cShader::~cShader ( )
inlinevirtual

Member Function Documentation

static cShaderPtr chai3d::cShader::create ( cShaderType  a_type)
inlinestatic
bool chai3d::cShader::loadSourceCode ( const char *  a_source)

This method loads the shader content from a char array.

Parameters
a_sourceSource code.
Returns
true if operation succeeds, false otherwise.
bool chai3d::cShader::loadSourceCode ( const std::string &  a_source)

This method loads the shader content from a string.

Parameters
a_sourceSource code.
Returns
true if operation succeeds, false otherwise.
bool chai3d::cShader::loadSourceFile ( const std::string &  a_fileName)

This method loads the shader content from a file.

Parameters
a_fileNameFilename containing source code.
Returns
true if operation succeeds, false otherwise.
bool chai3d::cShader::compile ( )

This method compile a shader and displays any problems if compilation fails.

Returns
true if operation succeeds, false otherwise.
bool chai3d::cShader::isCompiled ( ) const
inline
std::string chai3d::cShader::getLog ( ) const
inline
GLuint chai3d::cShader::getId ( ) const
inline
std::string chai3d::cShader::getSource ( )
inline
cShaderType chai3d::cShader::getType ( ) const
inline
static bool chai3d::cShader::hasOpenGLShaders ( cShaderType  a_type)
static

Member Data Documentation

cShaderType chai3d::cShader::m_type
protected
GLuint chai3d::cShader::m_id
protected
std::string chai3d::cShader::m_source
protected
std::string chai3d::cShader::m_log
protected
bool chai3d::cShader::m_compiled
protected

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