diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2015-12-09 13:23:07 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2016-01-13 16:10:10 +0000 |
commit | d0ab2359f5b4b23dcd017ed6abb2c063deb98a85 (patch) | |
tree | 3e574c6172c58a27affb2474a6683a19e83a3794 /src/render/io | |
parent | d7f99a581d7a0430c25f68449240311152a51b1b (diff) |
GraphicsContext: use GLBuffer instead of QOpenGLBuffer
This will be needed to simplify the process of binding SSBO/UBO buffers.
Change-Id: Ice3bb97381328c5bddf1c9e46af30b4814ff2572
Note: ShaderData UBO handling temporarly disabled.
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/io')
-rw-r--r-- | src/render/io/glbuffer.cpp | 16 | ||||
-rw-r--r-- | src/render/io/glbuffer_p.h | 9 |
2 files changed, 17 insertions, 8 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); diff --git a/src/render/io/glbuffer_p.h b/src/render/io/glbuffer_p.h index 9d47a52db..1dc8adb3c 100644 --- a/src/render/io/glbuffer_p.h +++ b/src/render/io/glbuffer_p.h @@ -59,8 +59,6 @@ namespace Render { class GraphicsContext; -typedef QPair<Qt3DCore::QNodeId, Qt3DCore::QNodeId> BufferShaderKey; - class GLBuffer { public: @@ -76,11 +74,12 @@ public: PixelUnpackBuffer }; - void bind(GraphicsContext *ctx, Type t); - void release(GraphicsContext *ctx); - void create(GraphicsContext *ctx); + bool bind(GraphicsContext *ctx, Type t); + bool release(GraphicsContext *ctx); + bool create(GraphicsContext *ctx); void destroy(GraphicsContext *ctx); void allocate(GraphicsContext *ctx, uint size, bool dynamic = true); + void allocate(GraphicsContext *ctx, const void *data, uint size, bool dynamic = true); void update(GraphicsContext *ctx, const void *data, uint size, int offset = 0); void bindToUniformBlock(GraphicsContext *ctx, int bindingPoint); |