Vis 2
Kinetic Visualization for 3D shape and structure
 All Classes Namespaces Functions Pages
Public Member Functions | List of all members
Shader Class Reference

Public Member Functions

 Shader (const std::string &name)
 
bool attachShaderSource (int type, const std::string &source)
 
bool attachShaderFile (int type, const std::string &path)
 
bool compileShaders ()
 
void setTransformFeedbackVaryings (int numVaryings, const GLchar **varyings, GLenum mode)
 
bool link ()
 
bool link (const std::string &out)
 
bool link (int numLocations, const std::string *out)
 
void bind () const
 
void unbind () const
 
GLint getUniformLocation (const std::string &name) const
 
GLint getSubroutineUniformLocation (GLenum shaderType, const std::string &name)
 
GLuint getSubroutineIndex (GLenum shaderType, const std::string &name)
 
GLint getAttribLocation (const std::string &name) const
 
void preprocess (unsigned numKeys, const std::regex *keys, const std::string *values)
 
const std::string & getName () const
 
GLuint getProgram () const
 

Constructor & Destructor Documentation

Shader::Shader ( const std::string &  name)

Creates a shader with an associated name. Name will be displayed to link error message to it.

Member Function Documentation

bool Shader::attachShaderFile ( int  type,
const std::string &  path 
)

Attaches source code from a file to this shader. Shader type is one of GL_VERTEX_SHADER, GL_GEOMETRY_SHADER, GL_FRAGMENT_SHADER.

Parameters
pathfile relative to the folder shaders/
bool Shader::attachShaderSource ( int  type,
const std::string &  source 
)

Attaches source code from a string to this shader. Shader type is one of GL_VERTEX_SHADER, GL_GEOMETRY_SHADER, GL_FRAGMENT_SHADER.

void Shader::bind ( ) const

Binds the shader to the context.

bool Shader::compileShaders ( )

Attempt to compile all source code attached to this object. Error messages are displayed at the standard output.

GLint Shader::getAttribLocation ( const std::string &  name) const

Returns the generic vertex attribute location name of this shader.

GLuint Shader::getSubroutineIndex ( GLenum  shaderType,
const std::string &  name 
)

Returns the index of a subroutine in a specific shader stage

Parameters
shaderTypeshader stage of the uniform (GL_VERTEX_SHADER, GL_GEOMETRY_SHADER or GL_FRAGMENT_SHADER)
namename of the subroutine
GLint Shader::getSubroutineUniformLocation ( GLenum  shaderType,
const std::string &  name 
)

Returns the location of a subroutine uniform in a specific shader stage.

Parameters
shaderTypeshader stage of the uniform (GL_VERTEX_SHADER, GL_GEOMETRY_SHADER or GL_FRAGMENT_SHADER)
namename of the subroutine uniform
GLint Shader::getUniformLocation ( const std::string &  name) const

Returns the uniform location name of this shader.

bool Shader::link ( )

Links all compiled shaders to form a shader program. Color output locations and indices are defined in the shader.

bool Shader::link ( const std::string &  out)

Links all compiled shaders to form a shader program. out will be bound to location 0, other bindings are unmodified.

bool Shader::link ( int  numLocations,
const std::string *  out 
)

Links all compiled shaders to form a shader program and sets color outputs explicitly. Bindings of color outputs that are not mentioned are unmodified.

Parameters
outpointer to the first element in an array of frag data locations
numAttachmentsnumber of frag data locations.
void Shader::setTransformFeedbackVaryings ( int  numVaryings,
const GLchar **  varyings,
GLenum  mode 
)

Sets the varyings that shall be recorded during transform feedback. If numVaryings is 0, the transform feedback varyings are removed.

Parameters
numVaryingsnumber of attributes to be recorded
varyingsarray of the attributes' names
nameGL_INTERLEAVED_ATTRIBS or GL_SEPARATE_ATTRIBS
void Shader::unbind ( ) const

Unbinds the currently bound shader from the context.


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