diff options
Diffstat (limited to 'src/mbgl/geometry/vao.cpp')
-rw-r--r-- | src/mbgl/geometry/vao.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/mbgl/geometry/vao.cpp b/src/mbgl/geometry/vao.cpp index fef74396a9..4f6e89332f 100644 --- a/src/mbgl/geometry/vao.cpp +++ b/src/mbgl/geometry/vao.cpp @@ -5,11 +5,45 @@ 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::Bind(GLuint array) { + MBGL_CHECK_ERROR(BindVertexArray(array)); +} + +void VertexArrayObject::Delete(GLsizei n, const GLuint* arrays) { + MBGL_CHECK_ERROR(DeleteVertexArrays(n, arrays)); +} + VertexArrayObject::VertexArrayObject() { } VertexArrayObject::~VertexArrayObject() { - if (!gl::DeleteVertexArrays) return; + if (!DeleteVertexArrays) return; if (vao) { Environment::Get().abandonVAO(vao); @@ -17,7 +51,7 @@ VertexArrayObject::~VertexArrayObject() { } void VertexArrayObject::bindVertexArrayObject() { - if (!gl::GenVertexArrays || !gl::BindVertexArray) { + if (!GenVertexArrays || !BindVertexArray) { static bool reported = false; if (!reported) { Log::Warning(Event::OpenGL, "Not using Vertex Array Objects"); @@ -27,9 +61,9 @@ void VertexArrayObject::bindVertexArrayObject() { } if (!vao) { - MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &vao)); + MBGL_CHECK_ERROR(GenVertexArrays(1, &vao)); } - MBGL_CHECK_ERROR(gl::BindVertexArray(vao)); + MBGL_CHECK_ERROR(BindVertexArray(vao)); } void VertexArrayObject::verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, |