Files
maszyna/gl/ubo.cpp
2018-06-26 01:05:46 +02:00

27 lines
498 B
C++

#include "stdafx.h"
#include "ubo.h"
gl::ubo::ubo(int size, int index)
{
glGenBuffers(1, *this);
bind();
glBufferData(GL_UNIFORM_BUFFER, size, nullptr, GL_DYNAMIC_DRAW);
glBindBufferBase(GL_UNIFORM_BUFFER, index, *this);
}
gl::ubo::~ubo()
{
glDeleteBuffers(1, *this);
}
void gl::ubo::bind(GLuint i)
{
glBindBuffer(GL_UNIFORM_BUFFER, i);
}
void gl::ubo::update(void *data, int offset, int size)
{
bind();
glBufferSubData(GL_UNIFORM_BUFFER, offset, size, data);
}