Commit 9da9cccf authored by Robert Menzel's avatar Robert Menzel

added UBO constructor to init a UBO for usage with a shader

parent 3d9f4470
......@@ -42,6 +42,8 @@
namespace ACGL{
namespace OpenGL{
class ShaderProgram;
class UniformBuffer : public Buffer
{
// ========================================================================================================= \/
......@@ -56,6 +58,9 @@ public:
: Buffer(_pBuffer, GL_UNIFORM_BUFFER)
{}
//! inits the uniformbuffer to be used with the given shaderprogram, _uboName is the name of this buffer in the shader
UniformBuffer( const ptr::shared_ptr<ShaderProgram> &_shaderProgram, const std::string &_uboName );
// ==================================================================================================== \/
// ============================================================================================ GETTERS \/
// ==================================================================================================== \/
......
......@@ -4,12 +4,18 @@
////////////////////////////////////////////////////////////////////////////////
#include <ACGL/OpenGL/Objects/UniformBuffer.hh>
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
using namespace ACGL;
using namespace ACGL::OpenGL;
#if (ACGL_OPENGL_VERSION >= 31)
UniformBuffer::UniformBuffer( const ptr::shared_ptr<ShaderProgram> &_shaderProgram, const std::string &_uboName ) : Buffer(GL_UNIFORM_BUFFER)
{
reserveMemory( _shaderProgram->getUniformBlockSize( _uboName ) );
setUniformOffsets( _shaderProgram->getUniformOffsetsOfBlock( _uboName ) ); // to enable intuitive setUniform functions
bindBufferBase( _shaderProgram->getUniformBlockBinding( _uboName ) ); // bind the UBO to the binding point where the shader expects it
}
#endif // OpenGL 3.1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment