mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
ubo (ugly for now)
This commit is contained in:
26
gl/ubo.cpp
Normal file
26
gl/ubo.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user