reorder cpp file
parent
d6c05fa236
commit
b770baa78d
|
@ -82,11 +82,6 @@ namespace blt::gfx
|
||||||
{
|
{
|
||||||
return i != -1;
|
return i != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline operator int() const
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unordered_map<std::string, IntDefaultedToMinusOne> uniformVars;
|
std::unordered_map<std::string, IntDefaultedToMinusOne> uniformVars;
|
||||||
|
|
|
@ -22,6 +22,54 @@
|
||||||
|
|
||||||
namespace blt::gfx
|
namespace blt::gfx
|
||||||
{
|
{
|
||||||
|
uniform_buffer::uniform_buffer(size_t size, GLuint location): size_(size), location_(location)
|
||||||
|
{
|
||||||
|
glGenBuffers(1, &uboID);
|
||||||
|
bind();
|
||||||
|
glBufferData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(size), nullptr, GL_DYNAMIC_READ);
|
||||||
|
unbind();
|
||||||
|
|
||||||
|
glBindBufferBase(GL_UNIFORM_BUFFER, location, uboID);
|
||||||
|
}
|
||||||
|
|
||||||
|
uniform_buffer::uniform_buffer(void* data, size_t size, GLuint location): size_(size), location_(location)
|
||||||
|
{
|
||||||
|
glGenBuffers(1, &uboID);
|
||||||
|
bind();
|
||||||
|
glBufferData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(size), data, GL_DYNAMIC_READ);
|
||||||
|
unbind();
|
||||||
|
|
||||||
|
glBindBufferBase(GL_UNIFORM_BUFFER, location, uboID);
|
||||||
|
}
|
||||||
|
|
||||||
|
uniform_buffer& uniform_buffer::resize(size_t newSize)
|
||||||
|
{
|
||||||
|
bind();
|
||||||
|
size_ = newSize;
|
||||||
|
glBufferData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(size_), nullptr, GL_DYNAMIC_READ);
|
||||||
|
unbind();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
uniform_buffer& uniform_buffer::upload(void* data, size_t size, size_t offset)
|
||||||
|
{
|
||||||
|
bind();
|
||||||
|
glBufferSubData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(offset), static_cast<GLsizeiptr>(size), data);
|
||||||
|
unbind();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
uniform_buffer& uniform_buffer::bind()
|
||||||
|
{
|
||||||
|
glBindBuffer(GL_UNIFORM_BUFFER, uboID);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
uniform_buffer::~uniform_buffer()
|
||||||
|
{
|
||||||
|
glDeleteBuffers(1, &uboID);
|
||||||
|
}
|
||||||
|
|
||||||
static std::string removeEmptyFirstLines(const std::string& string)
|
static std::string removeEmptyFirstLines(const std::string& string)
|
||||||
{
|
{
|
||||||
auto lines = blt::string::split(string, "\n");
|
auto lines = blt::string::split(string, "\n");
|
||||||
|
@ -173,54 +221,6 @@ namespace blt::gfx
|
||||||
move.programID = -1;
|
move.programID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uniform_buffer::uniform_buffer(size_t size, GLuint location): size_(size), location_(location)
|
|
||||||
{
|
|
||||||
glGenBuffers(1, &uboID);
|
|
||||||
bind();
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(size), nullptr, GL_DYNAMIC_READ);
|
|
||||||
unbind();
|
|
||||||
|
|
||||||
glBindBufferBase(GL_UNIFORM_BUFFER, location, uboID);
|
|
||||||
}
|
|
||||||
|
|
||||||
uniform_buffer::uniform_buffer(void* data, size_t size, GLuint location): size_(size), location_(location)
|
|
||||||
{
|
|
||||||
glGenBuffers(1, &uboID);
|
|
||||||
bind();
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(size), data, GL_DYNAMIC_READ);
|
|
||||||
unbind();
|
|
||||||
|
|
||||||
glBindBufferBase(GL_UNIFORM_BUFFER, location, uboID);
|
|
||||||
}
|
|
||||||
|
|
||||||
uniform_buffer& uniform_buffer::resize(size_t newSize)
|
|
||||||
{
|
|
||||||
bind();
|
|
||||||
size_ = newSize;
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(size_), nullptr, GL_DYNAMIC_READ);
|
|
||||||
unbind();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
uniform_buffer& uniform_buffer::upload(void* data, size_t size, size_t offset)
|
|
||||||
{
|
|
||||||
bind();
|
|
||||||
glBufferSubData(GL_UNIFORM_BUFFER, static_cast<GLsizeiptr>(offset), static_cast<GLsizeiptr>(size), data);
|
|
||||||
unbind();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
uniform_buffer& uniform_buffer::bind()
|
|
||||||
{
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, uboID);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
uniform_buffer::~uniform_buffer()
|
|
||||||
{
|
|
||||||
glDeleteBuffers(1, &uboID);
|
|
||||||
}
|
|
||||||
|
|
||||||
shader_base_t& shader_base_t::setBool(const std::string& name, bool value)
|
shader_base_t& shader_base_t::setBool(const std::string& name, bool value)
|
||||||
{
|
{
|
||||||
if (auto i = getUniformLocation(name))
|
if (auto i = getUniformLocation(name))
|
||||||
|
|
Loading…
Reference in New Issue