diff --git a/src/mbgl/gl/drawable_gl.cpp b/src/mbgl/gl/drawable_gl.cpp index e926ae2c1..4a80138c7 100644 --- a/src/mbgl/gl/drawable_gl.cpp +++ b/src/mbgl/gl/drawable_gl.cpp @@ -56,18 +56,17 @@ void DrawableGL::draw(const PaintParameters& parameters) const { bindTextures(); auto& glContext = static_cast(parameters.context); - const auto saveVertexArray = glContext.bindVertexArray.getCurrentValue(); for (const auto& seg : impl->segments) { const auto& glSeg = static_cast(*seg); const auto& mlSeg = glSeg.getSegment(); if (glSeg.getVertexArray().isValid()) { glContext.bindVertexArray = glSeg.getVertexArray().getID(); + glContext.draw(glSeg.getMode(), mlSeg.indexOffset, mlSeg.indexLength); } - glContext.draw(glSeg.getMode(), mlSeg.indexOffset, mlSeg.indexLength); } - glContext.bindVertexArray = saveVertexArray; + glContext.bindVertexArray = value::BindVertexArray::Default; unbindTextures(); unbindUniformBuffers(); diff --git a/src/mbgl/gl/vertex_array.hpp b/src/mbgl/gl/vertex_array.hpp index 6a9ec974e..707172d84 100644 --- a/src/mbgl/gl/vertex_array.hpp +++ b/src/mbgl/gl/vertex_array.hpp @@ -70,7 +70,9 @@ public: return *this; } - bool isValid() const { return state.operator bool(); } + bool isValid() const { + return state && state->vertexArray && state->vertexArray.get(); + } VertexArrayID getID() const { return state->vertexArray; }