diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-03-05 16:07:58 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-03-06 16:12:51 +0100 |
commit | 4737a45383911fcddf93f0a33e7e25246a5da07e (patch) | |
tree | a41a32f4d05297ede3c6d685cabf81a0f6dadcdc /src/mbgl/gl/context.cpp | |
parent | f13c2b86e427e29a856ca8f0f79379203c61f431 (diff) | |
download | qtlocation-mapboxgl-4737a45383911fcddf93f0a33e7e25246a5da07e.tar.gz |
[core] move IndexBuffer to gfx namespace
Diffstat (limited to 'src/mbgl/gl/context.cpp')
-rw-r--r-- | src/mbgl/gl/context.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 72d59737f3..6fda803a94 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -1,5 +1,6 @@ #include <mbgl/gl/context.hpp> #include <mbgl/gl/enum.hpp> +#include <mbgl/gl/index_buffer.hpp> #include <mbgl/gl/debugging_extension.hpp> #include <mbgl/gl/vertex_array_extension.hpp> #include <mbgl/gl/program_binary_extension.hpp> @@ -261,21 +262,22 @@ void Context::updateVertexBuffer(UniqueBuffer& buffer, const void* data, std::si MBGL_CHECK_ERROR(glBufferSubData(GL_ARRAY_BUFFER, 0, size, data)); } -UniqueBuffer Context::createIndexBuffer(const void* data, std::size_t size, const BufferUsage usage) { +std::unique_ptr<const gfx::IndexBufferResource> +Context::createIndexBuffer(const void* data, std::size_t size, const BufferUsage usage) { BufferID id = 0; MBGL_CHECK_ERROR(glGenBuffers(1, &id)); UniqueBuffer result { std::move(id), { this } }; bindVertexArray = 0; globalVertexArrayState.indexBuffer = result; MBGL_CHECK_ERROR(glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, data, static_cast<GLenum>(usage))); - return result; + return std::make_unique<gl::IndexBufferResource>(std::move(result)); } -void Context::updateIndexBuffer(UniqueBuffer& buffer, const void* data, std::size_t size) { +void Context::updateIndexBuffer(const gfx::IndexBufferResource& resource, const void* data, std::size_t size) { // Be sure to unbind any existing vertex array object before binding the index buffer // so that we don't mess up another VAO bindVertexArray = 0; - globalVertexArrayState.indexBuffer = buffer; + globalVertexArrayState.indexBuffer = reinterpret_cast<const gl::IndexBufferResource&>(resource).buffer; MBGL_CHECK_ERROR(glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, size, data)); } |