CSCI441 OpenGL Library 6.0.1.1
CS@Mines CSCI441 Computer Graphics Course Library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CSCI441::UniformBufferObject Class Referencefinal

Storage of UBO related data. More...

#include <UniformBufferObject.hpp>

Public Member Functions

 UniformBufferObject ()=delete
 
 UniformBufferObject (UniformBufferObject &unused)=delete
 
UniformBufferObjectoperator= (UniformBufferObject &unused)=delete
 
 UniformBufferObject (UniformBufferObject &&) noexcept
 Move Constructor an existing UBO.
 
UniformBufferObjectoperator= (UniformBufferObject &&) noexcept
 Move Assign an existing UBO.
 
 UniformBufferObject (const char *UNIFORM_BLOCK_NAME, std::initializer_list< const char * > uniformNamesList)
 Initializes the UniformBufferObject object.
 
 ~UniformBufferObject ()
 Deletes the UBO from the GPU and frees all memory on the CPU.
 
 UniformBufferObject (const UniformBufferObject &)=delete
 do not allow UBOs to be copied
 
UniformBufferObjectoperator= (const UniformBufferObject &)=delete
 do not allow UBOs to be copied
 
void setupWithShaderProgram (ShaderProgram *shaderProgram, GLuint bindingPoint)
 creates the UBO and allocates memory on both the CPU & GPU. binds the UBO and the uniform block for the provided ShaderProgram to the same binding point.
 
void bindToShaderProgram (ShaderProgram *shaderProgram)
 sets the shader programs binding point to match this uniform buffer object
 
void copyToOffset (unsigned int offset, const void *src, size_t len)
 copies the value pointed to by addr to the corresponding location within the UBO as denoted by the offset
 
void copyToBuffer (const char *UNIFORM_NAME, const void *src, size_t len)
 copies the value pointed to by addr to the corresponding location within the UBO as denoted by the uniform name
 
void setUniform (const char *UNIFORM_NAME, GLboolean value)
 sets the uniform value within the uniform buffer block
 
void setUniform (const char *UNIFORM_NAME, GLint value)
 sets the uniform value within the uniform buffer block
 
void setUniform (const char *UNIFORM_NAME, GLfloat value)
 sets the uniform value within the uniform buffer block
 
void setUniform (const char *UNIFORM_NAME, glm::vec3 vec)
 sets the uniform value within the uniform buffer block
 
void setUniform (const char *UNIFORM_NAME, glm::vec4 vec)
 sets the uniform value within the uniform buffer block
 
void setUniform (const char *UNIFORM_NAME, glm::mat4 mtx)
 sets the uniform value within the uniform buffer block
 
void setUniform (const char *UNIFORM_NAME, const GLint *pArray, GLint count)
 sets the uniform value within the uniform buffer block
 
void setUniform (const char *UNIFORM_NAME, const glm::ivec4 *pArray, GLint count)
 sets the uniform value within the uniform buffer block
 
void bindBuffer () const
 binds UBO object to UBO buffer
 
void bufferSubData () const
 transfers UBO data to UBO buffer
 

Detailed Description

Storage of UBO related data.

Constructor & Destructor Documentation

◆ UniformBufferObject() [1/3]

CSCI441::UniformBufferObject::UniformBufferObject ( )
delete
Note
must use `UniformBufferObject(const char*, std::initializer_list<const char*>

◆ UniformBufferObject() [2/3]

CSCI441::UniformBufferObject::UniformBufferObject ( UniformBufferObject unused)
delete
Note
cannot copy UBOs

◆ UniformBufferObject() [3/3]

CSCI441::UniformBufferObject::UniformBufferObject ( const char *  UNIFORM_BLOCK_NAME,
std::initializer_list< const char * >  uniformNamesList 
)

Initializes the UniformBufferObject object.

Parameters
UNIFORM_BLOCK_NAMEname of the uniform block
uniformNamesListlist of names that makeup the uniform block components

Member Function Documentation

◆ bindToShaderProgram()

void CSCI441::UniformBufferObject::bindToShaderProgram ( ShaderProgram shaderProgram)
inline

sets the shader programs binding point to match this uniform buffer object

Parameters
shaderProgram
Note
need to call UniformBufferObject::setupWithShaderProgram() before calling this with a second shader program

◆ copyToBuffer()

void CSCI441::UniformBufferObject::copyToBuffer ( const char *  UNIFORM_NAME,
const void *  src,
size_t  len 
)
inline

copies the value pointed to by addr to the corresponding location within the UBO as denoted by the uniform name

Parameters
UNIFORM_NAMEname of the uniform within the block to copy value to
srcstarting address of source to copy from
lenlength of buffer to copy

◆ copyToOffset()

void CSCI441::UniformBufferObject::copyToOffset ( unsigned int  offset,
const void *  src,
size_t  len 
)
inline

copies the value pointed to by addr to the corresponding location within the UBO as denoted by the offset

Parameters
offsetUBO offset to copy value to
srcstarting address of source to copy from
lenlength of buffer to copy

◆ operator=() [1/2]

CSCI441::UniformBufferObject & CSCI441::UniformBufferObject::operator= ( UniformBufferObject &&  src)
inlinenoexcept

Move Assign an existing UBO.

Returns
this now reconfigured UBO

◆ operator=() [2/2]

UniformBufferObject & CSCI441::UniformBufferObject::operator= ( UniformBufferObject unused)
delete
Note
cannot copy UBOs

◆ setUniform() [1/8]

void CSCI441::UniformBufferObject::setUniform ( const char *  UNIFORM_NAME,
const GLint *  pArray,
GLint  count 
)
inline

sets the uniform value within the uniform buffer block

Parameters
UNIFORM_NAMEuniform to set
pArraypointer to array of values to set
countsize of array

◆ setUniform() [2/8]

void CSCI441::UniformBufferObject::setUniform ( const char *  UNIFORM_NAME,
const glm::ivec4 *  pArray,
GLint  count 
)
inline

sets the uniform value within the uniform buffer block

Parameters
UNIFORM_NAMEuniform to set
pArraypointer to array of values to set
countsize of array

◆ setUniform() [3/8]

void CSCI441::UniformBufferObject::setUniform ( const char *  UNIFORM_NAME,
GLboolean  value 
)
inline

sets the uniform value within the uniform buffer block

Parameters
UNIFORM_NAMEuniform to set
valuevalue to set

◆ setUniform() [4/8]

void CSCI441::UniformBufferObject::setUniform ( const char *  UNIFORM_NAME,
GLfloat  value 
)
inline

sets the uniform value within the uniform buffer block

Parameters
UNIFORM_NAMEuniform to set
valuevalue to set

◆ setUniform() [5/8]

void CSCI441::UniformBufferObject::setUniform ( const char *  UNIFORM_NAME,
GLint  value 
)
inline

sets the uniform value within the uniform buffer block

Parameters
UNIFORM_NAMEuniform to set
valuevalue to set

◆ setUniform() [6/8]

void CSCI441::UniformBufferObject::setUniform ( const char *  UNIFORM_NAME,
glm::mat4  mtx 
)
inline

sets the uniform value within the uniform buffer block

Parameters
UNIFORM_NAMEuniform to set
mtxvalue to set

◆ setUniform() [7/8]

void CSCI441::UniformBufferObject::setUniform ( const char *  UNIFORM_NAME,
glm::vec3  vec 
)
inline

sets the uniform value within the uniform buffer block

Parameters
UNIFORM_NAMEuniform to set
vecvalue to set

◆ setUniform() [8/8]

void CSCI441::UniformBufferObject::setUniform ( const char *  UNIFORM_NAME,
glm::vec4  vec 
)
inline

sets the uniform value within the uniform buffer block

Parameters
UNIFORM_NAMEuniform to set
vecvalue to set

◆ setupWithShaderProgram()

void CSCI441::UniformBufferObject::setupWithShaderProgram ( ShaderProgram shaderProgram,
GLuint  bindingPoint 
)
inline

creates the UBO and allocates memory on both the CPU & GPU. binds the UBO and the uniform block for the provided ShaderProgram to the same binding point.

Parameters
shaderProgramShaderProgram object that utilizes the uniformBlock
bindingPointBinding point to bind the UBO and ShaderProgram Uniform Block to
Note
need to call before calling UniformBufferObject::bindToShaderProgram() for a second shader program

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