diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-02-17 10:09:49 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-02-20 08:24:42 -0800 |
commit | 4e752f63b94b71d901a1933a1bb121332fffe96b (patch) | |
tree | 3d94e81332b9ec66219ae15a08bf2b6c519dc069 /src/mbgl | |
parent | f8ab327874d32c77e591be82fd46c8cb741c130c (diff) | |
download | qtlocation-mapboxgl-4e752f63b94b71d901a1933a1bb121332fffe96b.tar.gz |
[core] Redo approach to unsupported VAO extension
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/gl/context.cpp | 19 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/gl/segment.hpp | 17 |
3 files changed, 23 insertions, 15 deletions
diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 5726eca5dc..9c2031ccfd 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -122,17 +122,17 @@ UniqueTexture Context::createTexture() { return UniqueTexture{ std::move(id), { this } }; } +bool Context::supportsVertexArrays() const { + return gl::GenVertexArrays && + gl::BindVertexArray && + gl::DeleteVertexArrays && + !disableVAOExtension; +} + UniqueVertexArray Context::createVertexArray() { + assert(supportsVertexArrays()); VertexArrayID id = 0; - if (gl::GenVertexArrays && !disableVAOExtension) { - MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id)); - } else { - static bool reported = false; - if (!reported) { - Log::Warning(Event::OpenGL, "Not using Vertex Array Objects"); - reported = true; - } - } + MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id)); return UniqueVertexArray(std::move(id), { this }); } @@ -529,6 +529,7 @@ void Context::performCleanup() { } if (!abandonedVertexArrays.empty()) { + assert(supportsVertexArrays()); for (const auto id : abandonedVertexArrays) { if (vertexArrayObject == id) { vertexArrayObject.setDirty(); diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index d1be794240..9d3ecec662 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -39,6 +39,8 @@ public: UniqueProgram createProgram(ShaderID vertexShader, ShaderID fragmentShader); void linkProgram(ProgramID); UniqueTexture createTexture(); + + bool supportsVertexArrays() const; UniqueVertexArray createVertexArray(); template <class Vertex, class DrawMode> diff --git a/src/mbgl/gl/segment.hpp b/src/mbgl/gl/segment.hpp index 7ce90e53a6..b2761a2102 100644 --- a/src/mbgl/gl/segment.hpp +++ b/src/mbgl/gl/segment.hpp @@ -3,6 +3,7 @@ #include <mbgl/gl/context.hpp> #include <mbgl/gl/vertex_buffer.hpp> #include <mbgl/util/optional.hpp> +#include <mbgl/util/logging.hpp> #include <cstddef> #include <vector> @@ -32,12 +33,11 @@ public: BufferID indexBuffer_, const typename Attributes::Locations& attributeLocations, const typename Attributes::Bindings& attributeBindings_) const { - if (!vao) { - vao = context.createVertexArray(); - context.vertexBuffer.setDirty(); - } - - if (*vao) { + if (context.supportsVertexArrays()) { + if (!vao) { + vao = context.createVertexArray(); + context.vertexBuffer.setDirty(); + } context.vertexArrayObject = *vao; if (indexBuffer != indexBuffer_) { indexBuffer = indexBuffer_; @@ -46,6 +46,11 @@ public: } } else { // No VAO support. Force attributes to be rebound. + static bool reported = false; + if (!reported) { + Log::Warning(Event::OpenGL, "Not using Vertex Array Objects"); + reported = true; + } context.elementBuffer = indexBuffer_; variableBindings = {}; } |