SenOGL  0.2
Library aiming to ease the use of OpenGL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
Program Class Reference

Program. More...

#include <Program.hpp>

Inheritance diagram for Program:
OpenGLObject

Public Member Functions

 Program ()
 
virtual ~Program ()
 
void init ()
 Initializes the OpenGL object. More...
 
void cleanup ()
 Destroys the OpenGL object. More...
 
void attachShader (GLuint shaderName)
 Attach a shader to this Program by its OpenGL name. More...
 
void attachShader (const Shader &shader)
 Attach a shader to this Program. More...
 
void attachShader (ComputeShader &cshader)
 Attach a compute shader to this Program. More...
 
void setTransformFeedbackVaryings (GLsizei count, const char **varyings, bool intervealed) const
 Specifies values to record in transform feedback buffers. More...
 
template<size_t Count>
void setTransformFeedbackVaryings (const std::array< const char *, Count > &varyings, bool intervealed) const
 Specifies values to record in transform feedback buffers. More...
 
void link ()
 Linking the program (all shaders must be compiled). More...
 
void use () const
 Use (~bind) this Shader Program. More...
 
bool isValid () const override
 
GLint getAttribLocation (const std::string &name) const
 
void bindAttribLocation (GLuint index, const std::string &name) const
 Associate a vertex attribute index with named attribute variable. More...
 
GLint getUniformLocation (const std::string &name) const
 Query for the location of the specified uniform. More...
 
template<typename T >
void setUniform (const std::string &name, const T &value) const
 Call the wrapper around glUniform* declared for T in UniformBinding.hpp. More...
 
GLuint getResourceIndex (GLenum interface, const std::string &name) const
 glGetProgramResourceIndex More...
 
GLuint getUniformBlockIndex (const std::string &name) const
 glGetuniformBlockIndex More...
 
void bindUniformBlock (GLuint uniformBlockIndex, GLuint uniformBlockBindingPoint) const
 Assign a binding point to an active uniform block. More...
 
void bindUniformBlock (const std::string &name, GLuint uniformBlockBindingPoint) const
 Assign a Uniform Buffer Object (UBO) to an active uniform block. More...
 
void bindUniformBlock (const std::string &name, const UniformBuffer &uniformBuffer) const
 Assign a Uniform Buffer Object (UBO) to an active uniform block. More...
 
- Public Member Functions inherited from OpenGLObject
 OpenGLObject ()
 
 OpenGLObject (GLuint handle)
 Constructs a instance managing an existing OpenGL Object. More...
 
 OpenGLObject (const OpenGLObject &)=default
 
 OpenGLObject (OpenGLObject &&)=default
 
OpenGLObjectoperator= (const OpenGLObject &)=default
 
OpenGLObjectoperator= (OpenGLObject &&)=default
 
virtual ~OpenGLObject ()
 
GLuint getName () const
 Returns OpenGL name of the object. More...
 
void setName (GLuint n)
 Sets the OpenGL name of the object managed by this instance /!\ Use with caution ! (assignment operator is probably what you're looking for) More...
 
 operator bool () const
 Syntactic sugar for isValid(). More...
 

Static Public Member Functions

static void useNone ()
 Unbind any currently bound shader program. More...
 
static GLint getCurrent ()
 
static GLint getUniformLocation (GLuint programName, const std::string &uniformName)
 

Additional Inherited Members

- Protected Attributes inherited from OpenGLObject
GLuint _handle
 OpenGL name of the managed object. More...
 

Detailed Description

Program.

OpenGL Shader Program

Constructor & Destructor Documentation

Program::Program ( )
Program::~Program ( )
virtual

Member Function Documentation

void Program::attachShader ( GLuint  shaderName)

Attach a shader to this Program by its OpenGL name.

Be careful using this (especially for a ComputeShader)

Parameters
shaderNameShader's OpenGL name.
See also
attachShader(Shader&)
attachShader(ComputeShader&)
void Program::attachShader ( const Shader shader)

Attach a shader to this Program.

See also
attachShader(GLuint)
attachShader(ComputeShader&)
void Program::attachShader ( ComputeShader cshader)

Attach a compute shader to this Program.

(Overload of attachShader(Shader&), also links the compute shader to this particular program).

See also
attachShader(GLuint)
attachShader(Shader&)
void Program::bindAttribLocation ( GLuint  index,
const std::string &  name 
) const
inline

Associate a vertex attribute index with named attribute variable.

Parameters
indexIndex of the vertex attribute to be bound
nameName of the attribute to which index is to be bound
See also
glBindAttribLocation
void Program::bindUniformBlock ( GLuint  uniformBlockIndex,
GLuint  uniformBlockBindingPoint 
) const

Assign a binding point to an active uniform block.

Parameters
uniformBlockIndexIndex of a uniform block in one of the program's shaders
uniformBlockBindingPointBinding point of an active Uniform Buffer Object (UBO) to assign to this uniform block
void Program::bindUniformBlock ( const std::string &  name,
GLuint  uniformBlockBindingPoint 
) const

Assign a Uniform Buffer Object (UBO) to an active uniform block.

Parameters
nameName of a uniform block in one of the program's shaders
uniformBlockBindingPointBinding point of an active Uniform Buffer Object (UBO) to assign to this uniform block
void Program::bindUniformBlock ( const std::string &  name,
const UniformBuffer uniformBuffer 
) const

Assign a Uniform Buffer Object (UBO) to an active uniform block.

Parameters
nameName of a uniform block in one of the program's shaders
uniformBufferUniform Buffer Object (UBO) to assign to this uniform block
void Program::cleanup ( )
virtual

Destroys the OpenGL object.

Implements OpenGLObject.

GLint Program::getAttribLocation ( const std::string &  name) const
inline
Parameters
nameName of the vertex shader attribute
Returns
Location of the queried attribute
See also
glGetAttribLocation
GLint Program::getCurrent ( )
inlinestatic
Returns
Program currently bound.
GLuint Program::getResourceIndex ( GLenum  interface,
const std::string &  name 
) const

glGetProgramResourceIndex

Parameters
interfaceType of searched resource (ex: GL_SHADER_STORAGE_BLOCK)
nameName of the resource
Returns
Index of name in the program, or GL_INVALID_INDEX if not found
GLuint Program::getUniformBlockIndex ( const std::string &  name) const

glGetuniformBlockIndex

Parameters
nameName of the searched Uniform Block
Returns
Index of name in the program, or GL_INVALID_INDEX if not found
See also
bindUniformBlock(GLuint uniformBlockIndex, GLuint uniformBlockBindingPoint)
GLint Program::getUniformLocation ( const std::string &  name) const

Query for the location of the specified uniform.

(Simple wrapper around glGetUniformLocation)

Parameters
nameUniform's name
Returns
-1 if the uniform isn't defined in any of the attached shaders, its location otherwise.
GLint Program::getUniformLocation ( GLuint  programName,
const std::string &  uniformName 
)
inlinestatic
Returns
Location of uniform uniformName in specified program.
void Program::init ( )
virtual

Initializes the OpenGL object.

Implements OpenGLObject.

bool Program::isValid ( ) const
inlineoverridevirtual
Returns
true if the program is set and linked, false otherwise.

Reimplemented from OpenGLObject.

void Program::link ( )

Linking the program (all shaders must be compiled).

void Program::setTransformFeedbackVaryings ( GLsizei  count,
const char **  varyings,
bool  intervealed 
) const
inline

Specifies values to record in transform feedback buffers.

This have to be called before linking.

Parameters
countNumber of values to record.
varyingsArray of null terminated char strings specifying the names of the varyings to record.
intervealedSpecifies the mode of capture, if true, values will be intervealed (packed in one buffer). They will be separated otherwise (one buffer per value).
template<size_t Count>
void Program::setTransformFeedbackVaryings ( const std::array< const char *, Count > &  varyings,
bool  intervealed 
) const
inline

Specifies values to record in transform feedback buffers.

Syntactic sugar around setTransformFeedbackVaryings(GLsizei, const char**, bool). This have to be called before linking.

Parameters
varyingsArray of null terminated char strings specifying the names of the varyings to record.
intervealedSpecifies the mode of capture, if true, values will be intervealed (packed in one buffer). They will be separated otherwise (one buffer per value).
See also
setTransformFeedbackVaryings(GLsizei, const char**, bool).
template<typename T >
void Program::setUniform ( const std::string &  name,
const T &  value 
) const
inline

Call the wrapper around glUniform* declared for T in UniformBinding.hpp.

See also
UniformBinding.hpp
setUniform(GLint program, GLuint location, const T& value);
void Program::use ( ) const

Use (~bind) this Shader Program.

void Program::useNone ( )
static

Unbind any currently bound shader program.


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