UniformBuffer.cc 1.07 KB
Newer Older
1 2 3 4 5
/***********************************************************************
 * Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
 * All rights reserved.                                                *
 * Distributed under the terms of the MIT License (see LICENSE.TXT).   *
 **********************************************************************/
Robert Menzel's avatar
Robert Menzel committed
6 7

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

using namespace ACGL;
using namespace ACGL::OpenGL;

#if (ACGL_OPENGL_VERSION >= 31)

15
UniformBuffer::UniformBuffer( const ptr::shared_ptr<const ShaderProgram> &_shaderProgram, const std::string &_uboName ) : Buffer(GL_UNIFORM_BUFFER)
16
{
17
    mBlockName = _uboName;
18 19 20 21
    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
22 23

#endif // OpenGL 3.1