diff options
Diffstat (limited to 'src/render/io/glbuffer.cpp')
-rw-r--r-- | src/render/io/glbuffer.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/render/io/glbuffer.cpp b/src/render/io/glbuffer.cpp index bff4cb3e4..8e7636964 100644 --- a/src/render/io/glbuffer.cpp +++ b/src/render/io/glbuffer.cpp @@ -86,23 +86,28 @@ GLBuffer::GLBuffer() { } -void GLBuffer::bind(GraphicsContext *ctx, Type t) +bool GLBuffer::bind(GraphicsContext *ctx, Type t) { + if (m_bufferId == 0) + return false; m_lastTarget = glBufferTypes[t]; ctx->openGLContext()->functions()->glBindBuffer(m_lastTarget, m_bufferId); m_bound = true; + return true; } -void GLBuffer::release(GraphicsContext *ctx) +bool GLBuffer::release(GraphicsContext *ctx) { m_bound = false; ctx->openGLContext()->functions()->glBindBuffer(m_lastTarget, 0); + return true; } -void GLBuffer::create(GraphicsContext *ctx) +bool GLBuffer::create(GraphicsContext *ctx) { ctx->openGLContext()->functions()->glGenBuffers(1, &m_bufferId); m_isCreated = true; + return m_bufferId != 0; } void GLBuffer::destroy(GraphicsContext *ctx) @@ -118,6 +123,11 @@ void GLBuffer::allocate(GraphicsContext *ctx, uint size, bool dynamic) ctx->openGLContext()->functions()->glBufferData(m_lastTarget, size, NULL, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); } +void GLBuffer::allocate(GraphicsContext *ctx, const void *data, uint size, bool dynamic) +{ + ctx->openGLContext()->functions()->glBufferData(m_lastTarget, size, data, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); +} + void GLBuffer::update(GraphicsContext *ctx, const void *data, uint size, int offset) { ctx->openGLContext()->functions()->glBufferSubData(m_lastTarget, offset, size, data); |