summaryrefslogtreecommitdiffstats
path: root/src/render/io/glbuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/io/glbuffer.cpp')
-rw-r--r--src/render/io/glbuffer.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/render/io/glbuffer.cpp b/src/render/io/glbuffer.cpp
index 074868528..4918f9a56 100644
--- a/src/render/io/glbuffer.cpp
+++ b/src/render/io/glbuffer.cpp
@@ -140,6 +140,18 @@ void GLBuffer::update(GraphicsContext *ctx, const void *data, uint size, int off
ctx->openGLContext()->functions()->glBufferSubData(m_lastTarget, offset, size, data);
}
+QByteArray GLBuffer::download(GraphicsContext *ctx, uint size)
+{
+ char *gpu_ptr = ctx->mapBuffer(m_lastTarget);
+ QByteArray data;
+ if (gpu_ptr != nullptr) {
+ data.resize(size);
+ std::copy(gpu_ptr, gpu_ptr+size, data.data());
+ }
+ ctx->unmapBuffer(m_lastTarget);
+ return data;
+}
+
void GLBuffer::bindBufferBase(GraphicsContext *ctx, int bindingPoint, GLBuffer::Type t)
{
ctx->bindBufferBase(glBufferTypes[t], bindingPoint, m_bufferId);