NGL  6.5
The NCCA Graphics Library
ngl::Shader Class Reference

and encapsulation of an OpenGL Shader object with associations for source code, etc. Used in conjunction with the ShaderProgram class More...

#include <Shader.h>

+ Collaboration diagram for ngl::Shader:

Public Member Functions

 Shader (std::string _name, ShaderType _type) noexcept
 ctor More...
 
 ~Shader ()
 dtor, will clean up shader source and remove shader from GL More...
 
void compile () noexcept
 compile the current shader will check to see if source is attached and issue warning if not More...
 
void load (std::string _name) noexcept
 load in shader source and attach it to the shader object if source is already loaded it will re-load and re-attached More...
 
void loadFromString (const std::string &_string) noexcept
 
void toggleDebug () noexcept
 toggle the debug state More...
 
GLuint getShaderHandle () const noexcept
 get the shader handle for this shader More...
 
void incrementRefCount () noexcept
 increment the shader ref count so we can see how many program objects are using this shader More...
 
void decrementRefCount () noexcept
 decrement the reference counteer More...
 
int getRefCount () const noexcept
 return the number of ProgramObjects referencing this shader More...
 
const std::string getShaderSource () const noexcept
 the shader source More...
 

Private Attributes

std::string m_name
 the text name of this Shader used in the search for shader More...
 
std::string m_source
 the actual source code for this shader (used for debug and initial loading) More...
 
bool m_compiled
 flag to indicate if the shader has been compiled this will get channged on re-load of source to false More...
 
ShaderType m_shaderType
 what type of shader we are More...
 
GLuint m_shaderHandle
 the GL handle for this shader object used in linking etc More...
 
bool m_debugState
 flag to indicate the debug state More...
 
int m_refCount
 number of ProgramObjects referencing this shader More...
 

Detailed Description

and encapsulation of an OpenGL Shader object with associations for source code, etc. Used in conjunction with the ShaderProgram class

Author
Jonathan Macey
Version
1.0
Date
24/11/10

Definition at line 40 of file Shader.h.

Constructor & Destructor Documentation

ngl::Shader::Shader ( std::string  _name,
ShaderType  _type 
)
noexcept

ctor

Parameters
_namethe name of the program object
[in]_typethe type of shader we are building

Definition at line 52 of file Shader.cpp.

References ngl::COMPUTE, ngl::FRAGMENT, ngl::GEOMETRY, GL_COMPUTE_SHADER, GL_FRAGMENT_SHADER, GL_GEOMETRY_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER, GL_VERTEX_SHADER, glCreateShader, ngl::NONE, ngl::TESSCONTROL, ngl::TESSEVAL, and ngl::VERTEX.

ngl::Shader::~Shader ( )

dtor, will clean up shader source and remove shader from GL

Definition at line 74 of file Shader.cpp.

References glDeleteShader, m_name, and m_shaderHandle.

Member Function Documentation

void ngl::Shader::compile ( )
noexcept

compile the current shader will check to see if source is attached and issue warning if not

Definition at line 80 of file Shader.cpp.

References GL_COMPILE_STATUS, GL_FALSE, glCompileShader, glGetShaderiv, m_compiled, m_debugState, m_name, m_shaderHandle, m_source, and ngl::printInfoLog().

+ Here is the call graph for this function:

void ngl::Shader::decrementRefCount ( )
inlinenoexcept

decrement the reference counteer

Definition at line 82 of file Shader.h.

int ngl::Shader::getRefCount ( ) const
inlinenoexcept

return the number of ProgramObjects referencing this shader

Returns
the number of references

Definition at line 87 of file Shader.h.

GLuint ngl::Shader::getShaderHandle ( ) const
inlinenoexcept

get the shader handle for this shader

Returns
the hand for this shader

Definition at line 73 of file Shader.h.

const std::string ngl::Shader::getShaderSource ( ) const
inlinenoexcept

the shader source

Returns
the shader source

Definition at line 92 of file Shader.h.

void ngl::Shader::incrementRefCount ( )
inlinenoexcept

increment the shader ref count so we can see how many program objects are using this shader

Definition at line 78 of file Shader.h.

void ngl::Shader::load ( std::string  _name)
noexcept

load in shader source and attach it to the shader object if source is already loaded it will re-load and re-attached

Parameters
_namethe file name for the source we are loading

Definition at line 105 of file Shader.cpp.

References glShaderSource, m_compiled, m_debugState, m_shaderHandle, m_source, and ngl::printInfoLog().

+ Here is the call graph for this function:

void ngl::Shader::loadFromString ( const std::string _string)
noexcept

Definition at line 134 of file Shader.cpp.

References glShaderSource, m_compiled, m_debugState, m_shaderHandle, m_source, and ngl::printInfoLog().

+ Here is the call graph for this function:

void ngl::Shader::toggleDebug ( )
inlinenoexcept

toggle the debug state

Definition at line 68 of file Shader.h.

Member Data Documentation

bool ngl::Shader::m_compiled
private

flag to indicate if the shader has been compiled this will get channged on re-load of source to false

Definition at line 107 of file Shader.h.

bool ngl::Shader::m_debugState
private

flag to indicate the debug state

Definition at line 119 of file Shader.h.

std::string ngl::Shader::m_name
private

the text name of this Shader used in the search for shader

Definition at line 98 of file Shader.h.

int ngl::Shader::m_refCount
private

number of ProgramObjects referencing this shader

Definition at line 123 of file Shader.h.

GLuint ngl::Shader::m_shaderHandle
private

the GL handle for this shader object used in linking etc

Definition at line 115 of file Shader.h.

ShaderType ngl::Shader::m_shaderType
private

what type of shader we are

Definition at line 111 of file Shader.h.

std::string ngl::Shader::m_source
private

the actual source code for this shader (used for debug and initial loading)

Definition at line 102 of file Shader.h.


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