![]() |
Cinder
0.9.1
|
#include <GlslProg.h>
Classes | |
struct | Attribute |
struct | Format |
struct | Uniform |
Public Types | |
typedef std::map< std::string, UniformSemantic > | UniformSemanticMap |
typedef std::map< std::string, geom::Attrib > | AttribSemanticMap |
Public Member Functions | |
~GlslProg () | |
void | bind () const |
GLuint | getHandle () const |
void | uniform (const std::string &name, bool data) const |
void | uniform (const std::string &name, int data) const |
void | uniform (const std::string &name, float data) const |
void | uniform (const std::string &name, uint32_t data) const |
void | uniform (int location, uint32_t data) const |
void | uniform (int location, bool data) const |
void | uniform (int location, int data) const |
void | uniform (int location, float data) const |
void | uniform (const std::string &name, const vec2 &data) const |
void | uniform (const std::string &name, const vec3 &data) const |
void | uniform (const std::string &name, const vec4 &data) const |
void | uniform (int location, const vec2 &data) const |
void | uniform (int location, const vec3 &data) const |
void | uniform (int location, const vec4 &data) const |
void | uniform (const std::string &name, const ivec2 &data) const |
void | uniform (const std::string &name, const ivec3 &data) const |
void | uniform (const std::string &name, const ivec4 &data) const |
void | uniform (int location, const ivec2 &data) const |
void | uniform (int location, const ivec3 &data) const |
void | uniform (int location, const ivec4 &data) const |
void | uniform (const std::string &name, const uvec2 &data) const |
void | uniform (const std::string &name, const uvec3 &data) const |
void | uniform (const std::string &name, const uvec4 &data) const |
void | uniform (int location, const uvec2 &data) const |
void | uniform (int location, const uvec3 &data) const |
void | uniform (int location, const uvec4 &data) const |
void | uniform (const std::string &name, const mat2 &data, bool transpose=false) const |
void | uniform (const std::string &name, const mat3 &data, bool transpose=false) const |
void | uniform (const std::string &name, const mat4 &data, bool transpose=false) const |
void | uniform (int location, const mat2 &data, bool transpose=false) const |
void | uniform (int location, const mat3 &data, bool transpose=false) const |
void | uniform (int location, const mat4 &data, bool transpose=false) const |
void | uniform (const std::string &name, const uint32_t *data, int count) const |
void | uniform (int location, const uint32_t *data, int count) const |
void | uniform (const std::string &name, const int *data, int count) const |
void | uniform (int location, const int *data, int count) const |
void | uniform (const std::string &name, const float *data, int count) const |
void | uniform (int location, const float *data, int count) const |
void | uniform (const std::string &name, const ivec2 *data, int count) const |
void | uniform (const std::string &name, const vec2 *data, int count) const |
void | uniform (const std::string &name, const vec3 *data, int count) const |
void | uniform (const std::string &name, const vec4 *data, int count) const |
void | uniform (int location, const ivec2 *data, int count) const |
void | uniform (int location, const vec2 *data, int count) const |
void | uniform (int location, const vec3 *data, int count) const |
void | uniform (int location, const vec4 *data, int count) const |
void | uniform (const std::string &name, const mat2 *data, int count, bool transpose=false) const |
void | uniform (const std::string &name, const mat3 *data, int count, bool transpose=false) const |
void | uniform (const std::string &name, const mat4 *data, int count, bool transpose=false) const |
void | uniform (int location, const mat2 *data, int count, bool transpose=false) const |
void | uniform (int location, const mat3 *data, int count, bool transpose=false) const |
void | uniform (int location, const mat4 *data, int count, bool transpose=false) const |
bool | hasAttribSemantic (geom::Attrib semantic) const |
GLint | getAttribSemanticLocation (geom::Attrib semantic) const |
GLint | operator[] (geom::Attrib sem) const |
GLint | getAttribLocation (const std::string &name) const |
const std::vector< Attribute > & | getActiveAttributes () const |
const Attribute * | findAttrib (const std::string &name) const |
const Attribute * | findAttrib (geom::Attrib semantic) const |
GLint | getUniformLocation (const std::string &name) const |
const std::vector< Uniform > & | getActiveUniforms () const |
const Uniform * | findUniform (const std::string &name, int *resultLocation) const |
std::string | getShaderLog (GLuint handle) const |
std::vector< fs::path > | getIncludedFiles () const |
const std::string & | getLabel () const |
void | setLabel (const std::string &label) |
template<typename T > | |
string | cppTypeToGlslTypeName () |
template<> | |
void | uniformFunc (int location, const uint32_t &data) const |
template<> | |
void | uniformFunc (int location, const uvec2 &data) const |
template<> | |
void | uniformFunc (int location, const uvec3 &data) const |
template<> | |
void | uniformFunc (int location, const uvec4 &data) const |
template<> | |
void | uniformFunc (int location, const uint32_t *data, int count) const |
template<> | |
void | uniformFunc (int location, const int &data) const |
template<> | |
void | uniformFunc (int location, const ivec2 &data) const |
template<> | |
void | uniformFunc (int location, const ivec3 &data) const |
template<> | |
void | uniformFunc (int location, const ivec4 &data) const |
template<> | |
void | uniformFunc (int location, const int *data, int count) const |
template<> | |
void | uniformFunc (int location, const ivec2 *data, int count) const |
template<> | |
void | uniformFunc (int location, const float &data) const |
template<> | |
void | uniformFunc (int location, const vec2 &data) const |
template<> | |
void | uniformFunc (int location, const vec3 &data) const |
template<> | |
void | uniformFunc (int location, const vec4 &data) const |
template<> | |
void | uniformMatFunc (int location, const mat2 &data, bool transpose) const |
template<> | |
void | uniformMatFunc (int location, const mat3 &data, bool transpose) const |
template<> | |
void | uniformMatFunc (int location, const mat4 &data, bool transpose) const |
template<> | |
void | uniformFunc (int location, const float *data, int count) const |
template<> | |
void | uniformFunc (int location, const vec2 *data, int count) const |
template<> | |
void | uniformFunc (int location, const vec3 *data, int count) const |
template<> | |
void | uniformFunc (int location, const vec4 *data, int count) const |
template<> | |
void | uniformMatFunc (int location, const mat2 *data, int count, bool transpose) const |
template<> | |
void | uniformMatFunc (int location, const mat3 *data, int count, bool transpose) const |
template<> | |
void | uniformMatFunc (int location, const mat4 *data, int count, bool transpose) const |
Static Public Member Functions | |
static GlslProgRef | create (const Format &format) |
static GlslProgRef | create (DataSourceRef vertexShader, DataSourceRef fragmentShader=DataSourceRef(), DataSourceRef geometryShader=DataSourceRef(), DataSourceRef tessEvalShader=DataSourceRef(), DataSourceRef tessCtrlShader=DataSourceRef()) |
static GlslProgRef | create (const std::string &vertexShader, const std::string &fragmentShader=std::string(), const std::string &geometryShader=std::string(), const std::string &tessEvalShader=std::string(), const std::string &tessCtrlShader=std::string()) |
static UniformSemanticMap & | getDefaultUniformNameToSemanticMap () |
static AttribSemanticMap & | getDefaultAttribNameToSemanticMap () |
Protected Member Functions | |
GlslProg (const Format &format) | |
void | bindImpl () const |
void | loadShader (const std::string &shaderSource, const fs::path &shaderPath, GLint shaderType) |
void | attachShaders () |
void | link () |
void | cacheActiveAttribs () |
Attribute * | findAttrib (const std::string &name) |
void | cacheActiveUniforms () |
const Uniform * | findUniform (int location, int *resultLocation) const |
template<typename LookUp , typename T > | |
void | uniformImpl (const LookUp &lookUp, const T &data) const |
template<typename T > | |
void | uniformFunc (int location, const T &data) const |
template<typename LookUp , typename T > | |
void | uniformMatImpl (const LookUp &lookUp, const T &data, bool transpose) const |
template<typename T > | |
void | uniformMatFunc (int location, const T &data, bool transpose) const |
template<typename LookUp , typename T > | |
void | uniformImpl (const LookUp &lookUp, const T *data, int count) const |
template<typename T > | |
void | uniformFunc (int location, const T *data, int count) const |
template<typename LookUp , typename T > | |
void | uniformMatImpl (const LookUp &lookUp, const T *data, int count, bool transpose) const |
template<typename T > | |
void | uniformMatFunc (int location, const T *data, int count, bool transpose) const |
void | logMissingUniform (const std::string &name) const |
void | logMissingUniform (int location) const |
void | logUniformWrongType (const std::string &name, GLenum uniformType, const std::string &userType) const |
template<typename T > | |
bool | validateUniform (const Uniform &uniform, int uniformLocation, const T &val) const |
template<typename T > | |
bool | validateUniform (const Uniform &uniform, int uniformLocation, const T *val, int count) const |
bool | checkUniformValueCache (const Uniform &uniform, int location, const void *val, int count) const |
template<typename T > | |
bool | checkUniformType (GLenum uniformType) const |
template<typename T > | |
bool | checkUniformType (GLenum uniformType, std::string &typeName) const |
template<> | |
void | uniformFunc (int location, const bool &data) const |
Static Protected Member Functions | |
template<typename T > | |
static std::string | cppTypeToGlslTypeName () |
Protected Attributes | |
GLuint | mHandle |
std::vector< Attribute > | mAttributes |
std::vector< Uniform > | mUniforms |
std::unique_ptr< UniformValueCache > | mUniformValueCache |
std::set< std::string > | mLoggedUniformNames |
std::set< int > | mLoggedUniformLocations |
std::string | mLabel |
std::unique_ptr< ShaderPreprocessor > | mShaderPreprocessor |
std::vector< fs::path > | mShaderPreprocessorIncludedFiles |
Friends | |
class | Context |
std::ostream & | operator<< (std::ostream &os, const GlslProg &rhs) |
typedef std::map<std::string,UniformSemantic> cinder::gl::GlslProg::UniformSemanticMap |
typedef std::map<std::string,geom::Attrib> cinder::gl::GlslProg::AttribSemanticMap |
cinder::gl::GlslProg::~GlslProg | ( | ) |
|
protected |
|
static |
|
static |
|
static |
void cinder::gl::GlslProg::bind | ( | ) | const |
GLuint cinder::gl::GlslProg::getHandle | ( | ) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
bool | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
int | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
float | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
uint32_t | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
uint32_t | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
bool | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
int | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
float | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const vec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const vec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const vec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const vec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const vec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const vec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const ivec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const ivec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const ivec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const ivec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const ivec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const ivec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const uvec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const uvec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const uvec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const uvec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const uvec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const uvec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const mat2 & | data, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const mat3 & | data, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const mat4 & | data, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const mat2 & | data, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const mat3 & | data, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const mat4 & | data, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const uint32_t * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const uint32_t * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const int * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const int * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const float * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const float * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const ivec2 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const vec2 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const vec3 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const vec4 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const ivec2 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const vec2 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const vec3 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const vec4 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const mat2 * | data, | ||
int | count, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const mat3 * | data, | ||
int | count, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | const std::string & | name, |
const mat4 * | data, | ||
int | count, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const mat2 * | data, | ||
int | count, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const mat3 * | data, | ||
int | count, | ||
bool | transpose = false |
||
) | const |
void cinder::gl::GlslProg::uniform | ( | int | location, |
const mat4 * | data, | ||
int | count, | ||
bool | transpose = false |
||
) | const |
bool cinder::gl::GlslProg::hasAttribSemantic | ( | geom::Attrib | semantic | ) | const |
GLint cinder::gl::GlslProg::getAttribSemanticLocation | ( | geom::Attrib | semantic | ) | const |
GLint cinder::gl::GlslProg::operator[] | ( | geom::Attrib | sem | ) | const |
|
static |
Default mapping from uniform name to semantic. Can be modified via the reference. Not thread-safe.
|
static |
Default mapping from attribute name to semantic. Can be modified via the reference. Not thread-safe.
GLint cinder::gl::GlslProg::getAttribLocation | ( | const std::string & | name | ) | const |
Returns the attrib location of the Attribute that matches name.
const std::vector<Attribute>& cinder::gl::GlslProg::getActiveAttributes | ( | ) | const |
Returns a const reference to the Active Attribute cache.
const GlslProg::Attribute * cinder::gl::GlslProg::findAttrib | ( | const std::string & | name | ) | const |
Returns a const pointer to the Attribute that matches name. Returns nullptr if the attrib doesn't exist.
const GlslProg::Attribute * cinder::gl::GlslProg::findAttrib | ( | geom::Attrib | semantic | ) | const |
Returns a const pointer to the Attribute that matches semantic. Returns nullptr if the attrib doesn't exist.
GLint cinder::gl::GlslProg::getUniformLocation | ( | const std::string & | name | ) | const |
Returns the uniform location of the Uniform that matches name.
const std::vector<Uniform>& cinder::gl::GlslProg::getActiveUniforms | ( | ) | const |
Returns a const reference to the Active Uniform cache.
const GlslProg::Uniform * cinder::gl::GlslProg::findUniform | ( | const std::string & | name, |
int * | resultLocation | ||
) | const |
Returns a const pointer to the Uniform that matches name. Returns nullptr if the uniform doesn't exist. The uniform location (accounting for indices, like "example[2]") is stored in resultLocation if it's non-null.
std::string cinder::gl::GlslProg::getShaderLog | ( | GLuint | handle | ) | const |
std::vector<fs::path> cinder::gl::GlslProg::getIncludedFiles | ( | ) | const |
Returns a list of included files (via the #include
directive) detected and parsed by the ShaderPreprocessor.
const std::string& cinder::gl::GlslProg::getLabel | ( | ) | const |
Returns the debugging label associated with the Program.
void cinder::gl::GlslProg::setLabel | ( | const std::string & | label | ) |
Sets the debugging label associated with the Program. Calls glObjectLabel() when available.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Caches all active Attributes after linking.
|
protected |
Returns a pointer to the Attribute that matches name. Returns nullptr if the attrib doesn't exist.
|
protected |
Caches all active Uniforms after linrking.
|
protected |
Returns a pointer to the Uniform that matches location. Returns nullptr if the uniform doesn't exist.
|
protected |
Performs the finding, validation, and implementation of single uniform variables. Ends by calling the location variant uniform function.
|
protected |
|
protected |
Performs the finding, validation, and implementation of single uniform Matrix variables. Ends by calling the location variant uniform function.
|
protected |
|
protected |
Performs the finding, validation, and implementation of multiple uniform variables. Ends by calling the location variant uniform function.
|
protected |
|
protected |
Performs the finding, validation, and implementation of multiple uniform Matrix variables. Ends by calling the location variant uniform function.
|
protected |
|
protected |
Logs an error and caches the name.
|
protected |
Logs an error and caches the name.
|
protected |
Logs a warning and caches the name.
|
protected |
Checks the validity of the settings on this uniform, specifically type and value.
|
protected |
Checks the validity of the settings on this uniform, specifically type and value.
|
protected |
|
protected |
Checks the type of the uniform against the provided type of data in validateUniform. If the provided type, uniformType, and the type T match this function returns true, otherwise it returns false.
|
protected |
|
staticprotected |
string cinder::gl::GlslProg::cppTypeToGlslTypeName | ( | ) |
|
protected |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const uint32_t & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const uvec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const uvec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const uvec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const uint32_t * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const int & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const ivec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const ivec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const ivec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const int * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const ivec2 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const float & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const vec2 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const vec3 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const vec4 & | data | ||
) | const |
void cinder::gl::GlslProg::uniformMatFunc | ( | int | location, |
const mat2 & | data, | ||
bool | transpose | ||
) | const |
void cinder::gl::GlslProg::uniformMatFunc | ( | int | location, |
const mat3 & | data, | ||
bool | transpose | ||
) | const |
void cinder::gl::GlslProg::uniformMatFunc | ( | int | location, |
const mat4 & | data, | ||
bool | transpose | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const float * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const vec2 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const vec3 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniformFunc | ( | int | location, |
const vec4 * | data, | ||
int | count | ||
) | const |
void cinder::gl::GlslProg::uniformMatFunc | ( | int | location, |
const mat2 * | data, | ||
int | count, | ||
bool | transpose | ||
) | const |
void cinder::gl::GlslProg::uniformMatFunc | ( | int | location, |
const mat3 * | data, | ||
int | count, | ||
bool | transpose | ||
) | const |
void cinder::gl::GlslProg::uniformMatFunc | ( | int | location, |
const mat4 * | data, | ||
int | count, | ||
bool | transpose | ||
) | const |
|
friend |
|
friend |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |