globjects  2.0.0.690708773bba
Strict OpenGL objects wrapper.
globjects::Uniform< T > Class Template Reference

Wraps access to typed global GLSL variables. More...

#include <globjects/include/globjects/AbstractUniform.h>

Inheritance diagram for globjects::Uniform< T >:
globjects::AbstractUniform globjects::Instantiator< Uniform< T > >

Public Member Functions

 Uniform (const Program *program, gl::GLint location)
 
 Uniform (const Program *program, gl::GLint location, const T &value)
 
 Uniform (const Program *program, const std::string &name)
 
 Uniform (const Program *program, const std::string &name, const T &value)
 
virtual ~Uniform ()
 
void set (const T &value)
 
const T & value () const
 
- Public Member Functions inherited from globjects::AbstractUniform
 AbstractUniform (const Program *program, gl::GLint location, UniformType type)
 
 AbstractUniform (const Program *program, const std::string &name, UniformType type)
 
virtual ~AbstractUniform ()
 
const std::string & name () const
 
gl::GLint location () const
 
const LocationIdentityidentity () const
 
UniformType type () const
 

Protected Member Functions

virtual void updateAt (gl::GLint location) const override
 
- Protected Member Functions inherited from globjects::AbstractUniform
void changed ()
 
void update (bool invalidateLocation) const
 
void setValue (gl::GLint location, const float &value) const
 
void setValue (gl::GLint location, const int &value) const
 
void setValue (gl::GLint location, const unsigned int &value) const
 
void setValue (gl::GLint location, const bool &value) const
 
void setValue (gl::GLint location, const glm::vec2 &value) const
 
void setValue (gl::GLint location, const glm::vec3 &value) const
 
void setValue (gl::GLint location, const glm::vec4 &value) const
 
void setValue (gl::GLint location, const glm::ivec2 &value) const
 
void setValue (gl::GLint location, const glm::ivec3 &value) const
 
void setValue (gl::GLint location, const glm::ivec4 &value) const
 
void setValue (gl::GLint location, const glm::uvec2 &value) const
 
void setValue (gl::GLint location, const glm::uvec3 &value) const
 
void setValue (gl::GLint location, const glm::uvec4 &value) const
 
void setValue (gl::GLint location, const glm::mat2 &value) const
 
void setValue (gl::GLint location, const glm::mat3 &value) const
 
void setValue (gl::GLint location, const glm::mat4 &value) const
 
void setValue (gl::GLint location, const glm::mat2x3 &value) const
 
void setValue (gl::GLint location, const glm::mat3x2 &value) const
 
void setValue (gl::GLint location, const glm::mat2x4 &value) const
 
void setValue (gl::GLint location, const glm::mat4x2 &value) const
 
void setValue (gl::GLint location, const glm::mat3x4 &value) const
 
void setValue (gl::GLint location, const glm::mat4x3 &value) const
 
void setValue (gl::GLint location, const gl::GLuint64 &value) const
 
void setValue (gl::GLint location, const TextureHandle &value) const
 
void setValue (gl::GLint location, const std::vector< float > &value) const
 
void setValue (gl::GLint location, const std::vector< int > &value) const
 
void setValue (gl::GLint location, const std::vector< unsigned int > &value) const
 
void setValue (gl::GLint location, const std::vector< bool > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::vec2 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::vec3 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::vec4 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::ivec2 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::ivec3 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::ivec4 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::uvec2 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::uvec3 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::uvec4 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat2 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat3 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat4 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat2x3 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat3x2 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat2x4 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat4x2 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat3x4 > &value) const
 
void setValue (gl::GLint location, const std::vector< glm::mat4x3 > &value) const
 
void setValue (gl::GLint location, const std::vector< gl::GLuint64 > &value) const
 
void setValue (gl::GLint location, const std::vector< TextureHandle > &value) const
 
template<typename T , std::size_t Count>
void setValue (gl::GLint location, const std::array< T, Count > &value) const
 

Protected Attributes

m_value
 The uniforms value, explictly required when relinking programs. More...
 
- Protected Attributes inherited from globjects::AbstractUniform
LocationIdentity m_identity
 
const Programm_program
 
const UniformType m_type
 
gl::GLint m_location
 

Additional Inherited Members

- Public Types inherited from globjects::AbstractUniform
enum  BindlessImplementation { SeparateShaderObjectsARB, Legacy }
 
- Static Public Member Functions inherited from globjects::AbstractUniform
static void hintBindlessImplementation (const BindlessImplementation impl)
 
- Static Public Member Functions inherited from globjects::Instantiator< Uniform< T > >
static std::unique_ptr< Uniform< T > > create (Args &&...args)
 
static std::unique_ptr< Uniform< T > > fromId (gl::GLuint id, Args &&...args)
 

Detailed Description

template<typename T>
class globjects::Uniform< T >

Wraps access to typed global GLSL variables.

The Uniform class wraps access to typed global GLSL variables (uniforms). These are stored in the OpenGL program objects itself.

Supported OpenGL uniform setters are wrapped via specialized template set implementations. Note that unsupported uniform types result in compile time errors due to the default implementation of set.

Simple usage of an Uniform:

std::unique_ptr<Uniform<float>> u = Uniform<float>::create("u_ratio");
u->set(1.618f);
program->addUniform(u.get());
See also
AbstractUniform
Program
http://www.opengl.org/wiki/Uniform

Constructor & Destructor Documentation

template<typename T>
globjects::Uniform< T >::Uniform ( const Program program,
gl::GLint  location 
)
template<typename T>
globjects::Uniform< T >::Uniform ( const Program program,
gl::GLint  location,
const T &  value 
)
template<typename T>
globjects::Uniform< T >::Uniform ( const Program program,
const std::string &  name 
)
template<typename T>
globjects::Uniform< T >::Uniform ( const Program program,
const std::string &  name,
const T &  value 
)
template<typename T>
virtual globjects::Uniform< T >::~Uniform ( )
virtual

Member Function Documentation

template<typename T>
void globjects::Uniform< T >::set ( const T &  value)
template<typename T>
const T& globjects::Uniform< T >::value ( ) const
template<typename T>
virtual void globjects::Uniform< T >::updateAt ( gl::GLint  location) const
overrideprotectedvirtual

This function requires knowledge of the unifom's value.

Implements globjects::AbstractUniform.

Member Data Documentation

template<typename T>
T globjects::Uniform< T >::m_value
protected

The uniforms value, explictly required when relinking programs.


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