scg3  0.6
scg::ShaderCore Class Reference

A core to set a shader program to be applied to subsequent nodes. More...

#include "ShaderCore.h"

Inheritance diagram for scg::ShaderCore:
[legend]
Collaboration diagram for scg::ShaderCore:
[legend]

Public Member Functions

 ShaderCore (GLuint program, const std::vector< ShaderID > &shaderIDs)
 
virtual ~ShaderCore ()
 
void clear ()
 
void init () const
 
GLuint getProgram () const
 
GLint getUniformLoc (const std::string &name) const
 
void setUniform1i (const std::string &name, GLint value) const
 
void setUniform1iv (const std::string &name, GLsizei count, const GLint *value) const
 
void setUniform1f (const std::string &name, GLfloat value) const
 
void setUniform1fv (const std::string &name, GLsizei count, const GLfloat *value) const
 
void setUniform2fv (const std::string &name, GLsizei count, const GLfloat *value) const
 
void setUniform3fv (const std::string &name, GLsizei count, const GLfloat *value) const
 
void setUniform4fv (const std::string &name, GLsizei count, const GLfloat *value) const
 
void setUniformMatrix2fv (const std::string &name, GLsizei count, const GLfloat *value) const
 
void setUniformMatrix3fv (const std::string &name, GLsizei count, const GLfloat *value) const
 
void setUniformMatrix4fv (const std::string &name, GLsizei count, const GLfloat *value) const
 
virtual void render (RenderState *renderState)
 
virtual void renderPost (RenderState *renderState)
 
- Public Member Functions inherited from scg::Core
 Core ()
 
virtual ~Core ()=0
 

Static Public Member Functions

static ShaderCoreSP create (GLuint program, const std::vector< ShaderID > &shaderIDs)
 

Protected Member Functions

void checkCompileError_ (const ShaderID &shaderID) const
 
void checkLinkError_ (GLuint program) const
 

Protected Attributes

GLuint program_
 
std::vector< ShaderIDshaderIDs_
 
ShaderCoreshaderCoreOld_
 
std::unordered_map< std::string, GLint > uniformLocMap_
 

Detailed Description

A core to set a shader program to be applied to subsequent nodes.

A few member functions are defined in the header file to allow inlining. Method chaining (via returning this pointers) is not supported to ensure maximum performance.

Definition at line 69 of file ShaderCore.h.

Constructor & Destructor Documentation

◆ ShaderCore()

scg::ShaderCore::ShaderCore ( GLuint  program,
const std::vector< ShaderID > &  shaderIDs 
)

Constructor with given program and shaders.

◆ ~ShaderCore()

virtual scg::ShaderCore::~ShaderCore ( )
virtual

Destructor.

Member Function Documentation

◆ checkCompileError_()

void scg::ShaderCore::checkCompileError_ ( const ShaderID shaderID) const
protected

Check for compile errors and print error messages.

◆ checkLinkError_()

void scg::ShaderCore::checkLinkError_ ( GLuint  program) const
protected

Check for link errors and print error messages.

◆ clear()

void scg::ShaderCore::clear ( )

Delete shaders and program.

◆ create()

static ShaderCoreSP scg::ShaderCore::create ( GLuint  program,
const std::vector< ShaderID > &  shaderIDs 
)
static

Create shared pointer.

◆ getProgram()

GLuint scg::ShaderCore::getProgram ( ) const

Get shader program.

◆ getUniformLoc()

GLint scg::ShaderCore::getUniformLoc ( const std::string &  name) const
inline

Get location of uniform variable.

Definition at line 108 of file ShaderCore.h.

◆ init()

void scg::ShaderCore::init ( ) const

Initialize shader core, i.e., compile shaders and link program, to be called by ShaderCoreFactory or by application after binding custom attribute and fragment data locations.

◆ render()

virtual void scg::ShaderCore::render ( RenderState renderState)
virtual

Render shader, i.e., bind shader program.

Implements scg::Core.

◆ renderPost()

virtual void scg::ShaderCore::renderPost ( RenderState renderState)
virtual

Render shader after traversing sub-tree, i.e., restore previous shader program.

Reimplemented from scg::Core.

◆ setUniform1f()

void scg::ShaderCore::setUniform1f ( const std::string &  name,
GLfloat  value 
) const
inline

Set uniform variable.

Definition at line 141 of file ShaderCore.h.

◆ setUniform1fv()

void scg::ShaderCore::setUniform1fv ( const std::string &  name,
GLsizei  count,
const GLfloat *  value 
) const
inline

Set uniform variable.

Definition at line 151 of file ShaderCore.h.

◆ setUniform1i()

void scg::ShaderCore::setUniform1i ( const std::string &  name,
GLint  value 
) const
inline

Set uniform variable.

Definition at line 121 of file ShaderCore.h.

◆ setUniform1iv()

void scg::ShaderCore::setUniform1iv ( const std::string &  name,
GLsizei  count,
const GLint *  value 
) const
inline

Set uniform variable.

Definition at line 131 of file ShaderCore.h.

◆ setUniform2fv()

void scg::ShaderCore::setUniform2fv ( const std::string &  name,
GLsizei  count,
const GLfloat *  value 
) const
inline

Set uniform variable.

Definition at line 161 of file ShaderCore.h.

◆ setUniform3fv()

void scg::ShaderCore::setUniform3fv ( const std::string &  name,
GLsizei  count,
const GLfloat *  value 
) const
inline

Set uniform variable.

Definition at line 171 of file ShaderCore.h.

◆ setUniform4fv()

void scg::ShaderCore::setUniform4fv ( const std::string &  name,
GLsizei  count,
const GLfloat *  value 
) const
inline

Set uniform variable.

Definition at line 181 of file ShaderCore.h.

◆ setUniformMatrix2fv()

void scg::ShaderCore::setUniformMatrix2fv ( const std::string &  name,
GLsizei  count,
const GLfloat *  value 
) const
inline

Set uniform variable.

Definition at line 191 of file ShaderCore.h.

◆ setUniformMatrix3fv()

void scg::ShaderCore::setUniformMatrix3fv ( const std::string &  name,
GLsizei  count,
const GLfloat *  value 
) const
inline

Set uniform variable.

Definition at line 201 of file ShaderCore.h.

◆ setUniformMatrix4fv()

void scg::ShaderCore::setUniformMatrix4fv ( const std::string &  name,
GLsizei  count,
const GLfloat *  value 
) const
inline

Set uniform variable.

Definition at line 211 of file ShaderCore.h.

Member Data Documentation

◆ program_

GLuint scg::ShaderCore::program_
protected

Definition at line 242 of file ShaderCore.h.

◆ shaderCoreOld_

ShaderCore* scg::ShaderCore::shaderCoreOld_
protected

Definition at line 244 of file ShaderCore.h.

◆ shaderIDs_

std::vector<ShaderID> scg::ShaderCore::shaderIDs_
protected

Definition at line 243 of file ShaderCore.h.

◆ uniformLocMap_

std::unordered_map<std::string, GLint> scg::ShaderCore::uniformLocMap_
mutableprotected

Definition at line 245 of file ShaderCore.h.


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