UniformBuffer.cc 1 KB
Newer Older
Robert Menzel's avatar
Robert Menzel committed
1 2 3 4 5 6
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Computer Graphics Group RWTH Aachen University         //
// All rights reserved.                                                       //
////////////////////////////////////////////////////////////////////////////////

#include <ACGL/OpenGL/Objects/UniformBuffer.hh>
7
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
Robert Menzel's avatar
Robert Menzel committed
8 9 10 11 12 13

using namespace ACGL;
using namespace ACGL::OpenGL;

#if (ACGL_OPENGL_VERSION >= 31)

14
UniformBuffer::UniformBuffer( const ptr::shared_ptr<const ShaderProgram> &_shaderProgram, const std::string &_uboName ) : Buffer(GL_UNIFORM_BUFFER)
15 16 17 18 19
{
    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
}
Robert Menzel's avatar
Robert Menzel committed
20 21

#endif // OpenGL 3.1