Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes
omni::visual::UniformHandler Struct Reference

Uniform handler for a shader program Cares about bind and releasing shaders and texture uniforms. Should only be used with the visual::useShader function. More...

#include <UniformHandler.h>

Collaboration diagram for omni::visual::UniformHandler:
Collaboration graph
[legend]

Public Member Functions

 UniformHandler (QOpenGLFunctions &_gl, QOpenGLShaderProgram &_shader)
 
 ~UniformHandler ()
 Destructor. Unbind all active texture units. More...
 
template<typename... ARGS>
void uniform (const char *_name, ARGS &&..._args)
 Set uniform value. More...
 
void texUniform (const char *_name, GLuint _texId, GLuint _target=GL_TEXTURE_2D)
 Set uniform value for texture with id and optional target. More...
 
template<typename TEXTURE >
void texUniform (const char *_name, TEXTURE &_tex)
 Set uniform value for texture object Texture object can be either QOpenGLTexture or Texture32F. More...
 
void texRectUniform (const char *_name, GLuint _texId, QSize _size)
 

Private Attributes

QOpenGLFunctions & gl_
 
QOpenGLShaderProgram & shader_
 
GLint currentTextureUnit_ = 0
 
std::set< GLuint > usedTextureTargets_
 

Detailed Description

Uniform handler for a shader program Cares about bind and releasing shaders and texture uniforms. Should only be used with the visual::useShader function.

Constructor & Destructor Documentation

omni::visual::UniformHandler::UniformHandler ( QOpenGLFunctions &  _gl,
QOpenGLShaderProgram &  _shader 
)
30  :
31  gl_(_gl),
32  shader_(_shader) {}
QOpenGLFunctions & gl_
Definition: UniformHandler.h:63
QOpenGLShaderProgram & shader_
Definition: UniformHandler.h:64
omni::visual::UniformHandler::~UniformHandler ( )

Destructor. Unbind all active texture units.

34  {
35  gl_.glActiveTexture(GL_TEXTURE0);
36 
37  for (auto& _usedTextureTarget : usedTextureTargets_) {
38  gl_.glBindTexture(_usedTextureTarget, 0);
39  }
40  }
std::set< GLuint > usedTextureTargets_
Definition: UniformHandler.h:66
QOpenGLFunctions & gl_
Definition: UniformHandler.h:63

Member Function Documentation

void omni::visual::UniformHandler::texRectUniform ( const char *  _name,
GLuint  _texId,
QSize  _size 
)
42  {
43  texUniform(_name,_texId,GL_TEXTURE_RECTANGLE);
44  uniform(
45  QString(QString(_name) + "_size").toUtf8().data(),
46  QVector2D(_size.width(),_size.height()));
47  }
void texUniform(const char *_name, GLuint _texId, GLuint _target=GL_TEXTURE_2D)
Set uniform value for texture with id and optional target.
Definition: UniformHandler.cpp:49
void uniform(const char *_name, ARGS &&..._args)
Set uniform value.
Definition: UniformHandler.h:43
void omni::visual::UniformHandler::texUniform ( const char *  _name,
GLuint  _texId,
GLuint  _target = GL_TEXTURE_2D 
)

Set uniform value for texture with id and optional target.

51  {
53  gl_.glActiveTexture(GL_TEXTURE0 + currentTextureUnit_);
54  gl_.glBindTexture(_target, _texId);
55  usedTextureTargets_.insert(_target);
57  }
std::set< GLuint > usedTextureTargets_
Definition: UniformHandler.h:66
void uniform(const char *_name, ARGS &&..._args)
Set uniform value.
Definition: UniformHandler.h:43
GLint currentTextureUnit_
Definition: UniformHandler.h:65
QOpenGLFunctions & gl_
Definition: UniformHandler.h:63
template<typename TEXTURE >
void omni::visual::UniformHandler::texUniform ( const char *  _name,
TEXTURE &  _tex 
)
inline

Set uniform value for texture object Texture object can be either QOpenGLTexture or Texture32F.

56  {
57  texUniform(_name, _tex.textureId(), _tex.target());
58  }
void texUniform(const char *_name, GLuint _texId, GLuint _target=GL_TEXTURE_2D)
Set uniform value for texture with id and optional target.
Definition: UniformHandler.cpp:49
template<typename... ARGS>
void omni::visual::UniformHandler::uniform ( const char *  _name,
ARGS &&...  _args 
)
inline

Set uniform value.

43  {
44  shader_.setUniformValue(_name, _args ...);
45  }
QOpenGLShaderProgram & shader_
Definition: UniformHandler.h:64

Field Documentation

GLint omni::visual::UniformHandler::currentTextureUnit_ = 0
private
QOpenGLFunctions& omni::visual::UniformHandler::gl_
private
QOpenGLShaderProgram& omni::visual::UniformHandler::shader_
private
std::set<GLuint> omni::visual::UniformHandler::usedTextureTargets_
private

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