ubo (ugly for now)

This commit is contained in:
milek7
2018-06-26 01:05:46 +02:00
parent a9713a6ee4
commit 1c26096c5c
8 changed files with 145 additions and 54 deletions

26
gl/ubo.cpp Normal file
View File

@@ -0,0 +1,26 @@
#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);
}