globjects
2.0.0.690708773bba
Strict OpenGL objects wrapper.
|
Wraps an OpenGL program. More...
#include <globjects/include/globjects/Program.h>
Public Types | |
enum | BinaryImplementation { BinaryImplementation::GetProgramBinaryARB, BinaryImplementation::None } |
Public Types inherited from globjects::Object | |
enum | NameImplementation { NameImplementation::DebugKHR, NameImplementation::Legacy } |
Public Member Functions | |
Program () | |
Program (std::unique_ptr< ProgramBinary > &&binary) | |
virtual | ~Program () |
virtual void | accept (ObjectVisitor &visitor) override |
void | use () const |
bool | isUsed () const |
bool | isLinked () const |
void | attach (Shader *shader) |
template<class... Shaders> | |
void | attach (Shader *shader, Shaders...shaders) |
void | detach (Shader *shader) |
const std::set< Shader * > & | shaders () const |
void | link () const |
void | invalidate () const |
void | setBinary (std::unique_ptr< ProgramBinary > &&binary) |
ProgramBinary * | binary () const |
std::string | infoLog () const |
gl::GLint | get (gl::GLenum pname) const |
bool | isValid () const |
void | validate () |
void | setParameter (gl::GLenum pname, gl::GLint value) const |
void | setParameter (gl::GLenum pname, gl::GLboolean value) const |
void | getActiveAttrib (gl::GLuint index, gl::GLsizei bufSize, gl::GLsizei *length, gl::GLint *size, gl::GLenum *type, gl::GLchar *name) const |
gl::GLint | getAttributeLocation (const std::string &name) const |
gl::GLint | getUniformLocation (const std::string &name) const |
std::vector< gl::GLint > | getAttributeLocations (const std::vector< std::string > &names) const |
std::vector< gl::GLint > | getUniformLocations (const std::vector< std::string > &names) const |
void | bindAttributeLocation (gl::GLuint index, const std::string &name) const |
void | bindFragDataLocation (gl::GLuint index, const std::string &name) const |
gl::GLint | getFragDataLocation (const std::string &name) const |
gl::GLint | getFragDataIndex (const std::string &name) const |
void | getInterface (gl::GLenum programInterface, gl::GLenum pname, gl::GLint *params) const |
gl::GLuint | getResourceIndex (gl::GLenum programInterface, const std::string &name) const |
void | getResourceName (gl::GLenum programInterface, gl::GLuint index, gl::GLsizei bufSize, gl::GLsizei *length, char *name) const |
void | getResource (gl::GLenum programInterface, gl::GLuint index, gl::GLsizei propCount, const gl::GLenum *props, gl::GLsizei bufSize, gl::GLsizei *length, gl::GLint *params) const |
gl::GLint | getResourceLocation (gl::GLenum programInterface, const std::string &name) const |
gl::GLint | getResourceLocationIndex (gl::GLenum programInterface, const std::string &name) const |
gl::GLint | getInterface (gl::GLenum programInterface, gl::GLenum pname) const |
gl::GLint | getResource (gl::GLenum programInterface, gl::GLuint index, gl::GLenum prop, gl::GLsizei *length=nullptr) const |
std::vector< gl::GLint > | getResource (gl::GLenum programInterface, gl::GLuint index, const std::vector< gl::GLenum > &props, gl::GLsizei *length=nullptr) const |
void | getResource (gl::GLenum programInterface, gl::GLuint index, const std::vector< gl::GLenum > &props, gl::GLsizei bufSize, gl::GLsizei *length, gl::GLint *params) const |
gl::GLuint | getUniformBlockIndex (const std::string &name) const |
UniformBlock * | uniformBlock (gl::GLuint uniformBlockIndex) |
const UniformBlock * | uniformBlock (gl::GLuint uniformBlockIndex) const |
UniformBlock * | uniformBlock (const std::string &name) |
const UniformBlock * | uniformBlock (const std::string &name) const |
void | getActiveUniforms (gl::GLsizei uniformCount, const gl::GLuint *uniformIndices, gl::GLenum pname, gl::GLint *params) const |
std::vector< gl::GLint > | getActiveUniforms (const std::vector< gl::GLuint > &uniformIndices, gl::GLenum pname) const |
std::vector< gl::GLint > | getActiveUniforms (const std::vector< gl::GLint > &uniformIndices, gl::GLenum pname) const |
gl::GLint | getActiveUniform (gl::GLuint uniformIndex, gl::GLenum pname) const |
std::string | getActiveUniformName (gl::GLuint uniformIndex) const |
template<typename T > | |
void | setUniform (const std::string &name, const T &value) |
template<typename T > | |
void | setUniform (gl::GLint location, const T &value) |
template<typename T > | |
Uniform< T > * | getUniform (const std::string &name) |
template<typename T > | |
const Uniform< T > * | getUniform (const std::string &name) const |
template<typename T > | |
Uniform< T > * | getUniform (gl::GLint location) |
template<typename T > | |
const Uniform< T > * | getUniform (gl::GLint location) const |
void | setShaderStorageBlockBinding (gl::GLuint storageBlockIndex, gl::GLuint storageBlockBinding) const |
void | dispatchCompute (gl::GLuint numGroupsX, gl::GLuint numGroupsY, gl::GLuint numGroupsZ) |
void | dispatchCompute (const glm::uvec3 &numGroups) |
void | dispatchComputeGroupSize (gl::GLuint numGroupsX, gl::GLuint numGroupsY, gl::GLuint numGroupsZ, gl::GLuint groupSizeX, gl::GLuint groupSizeY, gl::GLuint groupSizeZ) |
void | dispatchComputeGroupSize (const glm::uvec3 &numGroups, const glm::uvec3 &groupSizes) |
virtual gl::GLenum | objectType () const override |
Public Member Functions inherited from globjects::Object | |
gl::GLuint | id () const |
std::string | name () const |
void | setName (const std::string &name) |
bool | hasName () const |
bool | isDefault () const |
void | detach () |
Public Member Functions inherited from globjects::Changeable | |
Changeable () | |
virtual | ~Changeable () |
void | changed () const |
void | registerListener (ChangeListener *listener) |
void | deregisterListener (ChangeListener *listener) |
Static Public Member Functions | |
static void | hintBinaryImplementation (BinaryImplementation impl) |
static void | release () |
static std::unique_ptr< ProgramBinary > | obtainBinary (Program *program) |
Static Public Member Functions inherited from globjects::Object | |
static void | hintNameImplementation (NameImplementation impl) |
Static Public Member Functions inherited from globjects::Instantiator< Program > | |
static std::unique_ptr< Program > | create (Args &&...args) |
static std::unique_ptr< Program > | fromId (gl::GLuint id, Args &&...args) |
Protected Member Functions | |
bool | checkLinkStatus () const |
void | checkDirty () const |
bool | compileAttachedShaders () const |
void | updateUniforms () const |
void | updateUniformBlockBindings () const |
void | addUniform (std::unique_ptr< AbstractUniform > &&uniform) |
virtual void | notifyChanged (const Changeable *sender) override |
template<typename T > | |
void | setUniformByIdentity (const LocationIdentity &identity, const T &value) |
template<typename T > | |
Uniform< T > * | getUniformByIdentity (const LocationIdentity &identity) |
template<typename T > | |
const Uniform< T > * | getUniformByIdentity (const LocationIdentity &identity) const |
UniformBlock * | getUniformBlockByIdentity (const LocationIdentity &identity) |
const UniformBlock * | getUniformBlockByIdentity (const LocationIdentity &identity) const |
Protected Member Functions inherited from globjects::Object | |
Object (std::unique_ptr< IDResource > &&resource) | |
virtual | ~Object () |
Protected Member Functions inherited from globjects::ChangeListener | |
void | addSubject (Changeable *subject) |
virtual void | removeSubject (Changeable *subject) |
virtual | ~ChangeListener () |
Protected Member Functions inherited from globjects::Changeable | |
Changeable () | |
virtual | ~Changeable () |
void | changed () const |
void | registerListener (ChangeListener *listener) |
void | deregisterListener (ChangeListener *listener) |
Static Protected Member Functions | |
static gl::GLuint | createProgram () |
Static Protected Member Functions inherited from globjects::Instantiator< Program > | |
static std::unique_ptr< Program > | create (Args &&...args) |
static std::unique_ptr< Program > | fromId (gl::GLuint id, Args &&...args) |
Protected Attributes | |
std::set< Shader * > | m_shaders |
std::unique_ptr< ProgramBinary > | m_binary |
std::unordered_map< LocationIdentity, std::unique_ptr< AbstractUniform > > | m_uniforms |
std::unordered_map< LocationIdentity, UniformBlock > | m_uniformBlocks |
bool | m_linked |
bool | m_dirty |
Protected Attributes inherited from globjects::Object | |
std::unique_ptr< IDResource > | m_resource |
void * | m_objectLabelState |
Protected Attributes inherited from globjects::ChangeListener | |
std::set< Changeable * > | m_subjects |
Protected Attributes inherited from globjects::Changeable | |
std::set< ChangeListener * > | m_listeners |
Friends | |
class | UniformBlock |
class | ProgramBinaryImplementation_GetProgramBinaryARB |
class | ProgramBinaryImplementation_None |
Wraps an OpenGL program.
Therefor it suclasses Object. Programs get attached a set of shaders with attach(). It inherits ChangeListener to react to changes to attached shaders. To use a program for rendering, call use(). During use() the program ensure that all attached shaders are compiled and linked. After that, the program is registered in OpenGL to be used during the upcoming rendering pileline calls.
Shaders can be detached using detach() and queried with shaders().
To use a program as a compute program, dispatchCompute() can be used to start the kernel.
Example code for setting up a program and use it for rendering
[TODO]: Adjust examples
Example code for using a program as compute program [TODO]: Adjust examples
|
strong |
globjects::Program::Program | ( | ) |
globjects::Program::Program | ( | std::unique_ptr< ProgramBinary > && | binary | ) |
|
virtual |
|
static |
|
overridevirtual |
Implements globjects::Object.
void globjects::Program::use | ( | ) | const |
|
static |
bool globjects::Program::isUsed | ( | ) | const |
bool globjects::Program::isLinked | ( | ) | const |
void globjects::Program::attach | ( | Shader * | shader | ) |
void globjects::Program::attach | ( | Shader * | shader, |
Shaders... | shaders | ||
) |
void globjects::Program::detach | ( | Shader * | shader | ) |
const std::set<Shader*>& globjects::Program::shaders | ( | ) | const |
void globjects::Program::link | ( | ) | const |
void globjects::Program::invalidate | ( | ) | const |
void globjects::Program::setBinary | ( | std::unique_ptr< ProgramBinary > && | binary | ) |
ProgramBinary* globjects::Program::binary | ( | ) | const |
|
static |
std::string globjects::Program::infoLog | ( | ) | const |
gl::GLint globjects::Program::get | ( | gl::GLenum | pname | ) | const |
bool globjects::Program::isValid | ( | ) | const |
void globjects::Program::validate | ( | ) |
void globjects::Program::setParameter | ( | gl::GLenum | pname, |
gl::GLint | value | ||
) | const |
void globjects::Program::setParameter | ( | gl::GLenum | pname, |
gl::GLboolean | value | ||
) | const |
void globjects::Program::getActiveAttrib | ( | gl::GLuint | index, |
gl::GLsizei | bufSize, | ||
gl::GLsizei * | length, | ||
gl::GLint * | size, | ||
gl::GLenum * | type, | ||
gl::GLchar * | name | ||
) | const |
gl::GLint globjects::Program::getAttributeLocation | ( | const std::string & | name | ) | const |
gl::GLint globjects::Program::getUniformLocation | ( | const std::string & | name | ) | const |
std::vector<gl::GLint> globjects::Program::getAttributeLocations | ( | const std::vector< std::string > & | names | ) | const |
std::vector<gl::GLint> globjects::Program::getUniformLocations | ( | const std::vector< std::string > & | names | ) | const |
void globjects::Program::bindAttributeLocation | ( | gl::GLuint | index, |
const std::string & | name | ||
) | const |
void globjects::Program::bindFragDataLocation | ( | gl::GLuint | index, |
const std::string & | name | ||
) | const |
gl::GLint globjects::Program::getFragDataLocation | ( | const std::string & | name | ) | const |
gl::GLint globjects::Program::getFragDataIndex | ( | const std::string & | name | ) | const |
void globjects::Program::getInterface | ( | gl::GLenum | programInterface, |
gl::GLenum | pname, | ||
gl::GLint * | params | ||
) | const |
gl::GLuint globjects::Program::getResourceIndex | ( | gl::GLenum | programInterface, |
const std::string & | name | ||
) | const |
void globjects::Program::getResourceName | ( | gl::GLenum | programInterface, |
gl::GLuint | index, | ||
gl::GLsizei | bufSize, | ||
gl::GLsizei * | length, | ||
char * | name | ||
) | const |
void globjects::Program::getResource | ( | gl::GLenum | programInterface, |
gl::GLuint | index, | ||
gl::GLsizei | propCount, | ||
const gl::GLenum * | props, | ||
gl::GLsizei | bufSize, | ||
gl::GLsizei * | length, | ||
gl::GLint * | params | ||
) | const |
gl::GLint globjects::Program::getResourceLocation | ( | gl::GLenum | programInterface, |
const std::string & | name | ||
) | const |
gl::GLint globjects::Program::getResourceLocationIndex | ( | gl::GLenum | programInterface, |
const std::string & | name | ||
) | const |
gl::GLint globjects::Program::getInterface | ( | gl::GLenum | programInterface, |
gl::GLenum | pname | ||
) | const |
Convenience methods for getInterface()
gl::GLint globjects::Program::getResource | ( | gl::GLenum | programInterface, |
gl::GLuint | index, | ||
gl::GLenum | prop, | ||
gl::GLsizei * | length = nullptr |
||
) | const |
Convenience methods for getResource()
std::vector<gl::GLint> globjects::Program::getResource | ( | gl::GLenum | programInterface, |
gl::GLuint | index, | ||
const std::vector< gl::GLenum > & | props, | ||
gl::GLsizei * | length = nullptr |
||
) | const |
void globjects::Program::getResource | ( | gl::GLenum | programInterface, |
gl::GLuint | index, | ||
const std::vector< gl::GLenum > & | props, | ||
gl::GLsizei | bufSize, | ||
gl::GLsizei * | length, | ||
gl::GLint * | params | ||
) | const |
gl::GLuint globjects::Program::getUniformBlockIndex | ( | const std::string & | name | ) | const |
UniformBlock* globjects::Program::uniformBlock | ( | gl::GLuint | uniformBlockIndex | ) |
const UniformBlock* globjects::Program::uniformBlock | ( | gl::GLuint | uniformBlockIndex | ) | const |
UniformBlock* globjects::Program::uniformBlock | ( | const std::string & | name | ) |
const UniformBlock* globjects::Program::uniformBlock | ( | const std::string & | name | ) | const |
void globjects::Program::getActiveUniforms | ( | gl::GLsizei | uniformCount, |
const gl::GLuint * | uniformIndices, | ||
gl::GLenum | pname, | ||
gl::GLint * | params | ||
) | const |
std::vector<gl::GLint> globjects::Program::getActiveUniforms | ( | const std::vector< gl::GLuint > & | uniformIndices, |
gl::GLenum | pname | ||
) | const |
std::vector<gl::GLint> globjects::Program::getActiveUniforms | ( | const std::vector< gl::GLint > & | uniformIndices, |
gl::GLenum | pname | ||
) | const |
gl::GLint globjects::Program::getActiveUniform | ( | gl::GLuint | uniformIndex, |
gl::GLenum | pname | ||
) | const |
std::string globjects::Program::getActiveUniformName | ( | gl::GLuint | uniformIndex | ) | const |
void globjects::Program::setUniform | ( | const std::string & | name, |
const T & | value | ||
) |
void globjects::Program::setUniform | ( | gl::GLint | location, |
const T & | value | ||
) |
Uniform<T>* globjects::Program::getUniform | ( | const std::string & | name | ) |
Retrieves the existing or creates a new typed uniform, named <name>.
const Uniform<T>* globjects::Program::getUniform | ( | const std::string & | name | ) | const |
Uniform<T>* globjects::Program::getUniform | ( | gl::GLint | location | ) |
const Uniform<T>* globjects::Program::getUniform | ( | gl::GLint | location | ) | const |
void globjects::Program::setShaderStorageBlockBinding | ( | gl::GLuint | storageBlockIndex, |
gl::GLuint | storageBlockBinding | ||
) | const |
void globjects::Program::dispatchCompute | ( | gl::GLuint | numGroupsX, |
gl::GLuint | numGroupsY, | ||
gl::GLuint | numGroupsZ | ||
) |
void globjects::Program::dispatchCompute | ( | const glm::uvec3 & | numGroups | ) |
void globjects::Program::dispatchComputeGroupSize | ( | gl::GLuint | numGroupsX, |
gl::GLuint | numGroupsY, | ||
gl::GLuint | numGroupsZ, | ||
gl::GLuint | groupSizeX, | ||
gl::GLuint | groupSizeY, | ||
gl::GLuint | groupSizeZ | ||
) |
void globjects::Program::dispatchComputeGroupSize | ( | const glm::uvec3 & | numGroups, |
const glm::uvec3 & | groupSizes | ||
) |
|
overridevirtual |
Implements globjects::Object.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
overrideprotectedvirtual |
Reimplemented from globjects::ChangeListener.
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
friend |
|
friend |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |