diff options
Diffstat (limited to 'src/mbgl/geometry/vao.cpp')
-rw-r--r-- | src/mbgl/geometry/vao.cpp | 52 |
1 files changed, 7 insertions, 45 deletions
diff --git a/src/mbgl/geometry/vao.cpp b/src/mbgl/geometry/vao.cpp index d3ad16e64f..8239604264 100644 --- a/src/mbgl/geometry/vao.cpp +++ b/src/mbgl/geometry/vao.cpp @@ -1,59 +1,23 @@ #include <mbgl/geometry/vao.hpp> #include <mbgl/platform/log.hpp> -#include <mbgl/util/gl_object_store.hpp> +#include <mbgl/gl/gl_object_store.hpp> #include <mbgl/util/string.hpp> -#include <mbgl/util/thread_context.hpp> namespace mbgl { -static gl::ExtensionFunction< - void (GLuint array)> - BindVertexArray({ - {"GL_ARB_vertex_array_object", "glBindVertexArray"}, - {"GL_OES_vertex_array_object", "glBindVertexArrayOES"}, - {"GL_APPLE_vertex_array_object", "glBindVertexArrayAPPLE"} - }); - -static gl::ExtensionFunction< - void (GLsizei n, - const GLuint* arrays)> - DeleteVertexArrays({ - {"GL_ARB_vertex_array_object", "glDeleteVertexArrays"}, - {"GL_OES_vertex_array_object", "glDeleteVertexArraysOES"}, - {"GL_APPLE_vertex_array_object", "glDeleteVertexArraysAPPLE"} - }); - -static gl::ExtensionFunction< - void (GLsizei n, - GLuint* arrays)> - GenVertexArrays({ - {"GL_ARB_vertex_array_object", "glGenVertexArrays"}, - {"GL_OES_vertex_array_object", "glGenVertexArraysOES"}, - {"GL_APPLE_vertex_array_object", "glGenVertexArraysAPPLE"} - }); - void VertexArrayObject::Unbind() { - if (!BindVertexArray) return; - MBGL_CHECK_ERROR(BindVertexArray(0)); -} - -void VertexArrayObject::Delete(GLsizei n, const GLuint* arrays) { - MBGL_CHECK_ERROR(DeleteVertexArrays(n, arrays)); + if (!gl::BindVertexArray) return; + MBGL_CHECK_ERROR(gl::BindVertexArray(0)); } VertexArrayObject::VertexArrayObject() { } VertexArrayObject::~VertexArrayObject() { - if (!DeleteVertexArrays) return; - - if (vao) { - util::ThreadContext::getGLObjectStore()->abandonVAO(vao); - } } -void VertexArrayObject::bindVertexArrayObject() { - if (!GenVertexArrays || !BindVertexArray) { +void VertexArrayObject::bindVertexArrayObject(gl::GLObjectStore& glObjectStore) { + if (!gl::GenVertexArrays || !gl::BindVertexArray) { static bool reported = false; if (!reported) { Log::Warning(Event::OpenGL, "Not using Vertex Array Objects"); @@ -62,10 +26,8 @@ void VertexArrayObject::bindVertexArrayObject() { return; } - if (!vao) { - MBGL_CHECK_ERROR(GenVertexArrays(1, &vao)); - } - MBGL_CHECK_ERROR(BindVertexArray(vao)); + if (!vao) vao.create(glObjectStore); + MBGL_CHECK_ERROR(gl::BindVertexArray(vao.getID())); } void VertexArrayObject::verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, |