diff options
Diffstat (limited to 'src/mbgl/geometry/vao.hpp')
-rw-r--r-- | src/mbgl/geometry/vao.hpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/mbgl/geometry/vao.hpp b/src/mbgl/geometry/vao.hpp index 2dcc02c76b..dcb66dd41d 100644 --- a/src/mbgl/geometry/vao.hpp +++ b/src/mbgl/geometry/vao.hpp @@ -2,26 +2,28 @@ #define MBGL_GEOMETRY_VAO #include <mbgl/shader/shader.hpp> -#include <mbgl/platform/gl.hpp> +#include <mbgl/gl/gl.hpp> +#include <mbgl/gl/gl_object_store.hpp> #include <mbgl/util/noncopyable.hpp> #include <stdexcept> namespace mbgl { +class Shader; + class VertexArrayObject : public util::noncopyable { public: static void Unbind(); - static void Delete(GLsizei n, const GLuint* arrays); VertexArrayObject(); ~VertexArrayObject(); template <typename Shader, typename VertexBuffer> - inline void bind(Shader& shader, VertexBuffer &vertexBuffer, GLbyte *offset) { - bindVertexArrayObject(); + inline void bind(Shader& shader, VertexBuffer &vertexBuffer, GLbyte *offset, gl::GLObjectStore& glObjectStore) { + bindVertexArrayObject(glObjectStore); if (bound_shader == 0) { - vertexBuffer.bind(); + vertexBuffer.bind(glObjectStore); shader.bind(offset); if (vao) { storeBinding(shader, vertexBuffer.getID(), 0, offset); @@ -32,11 +34,11 @@ public: } template <typename Shader, typename VertexBuffer, typename ElementsBuffer> - inline void bind(Shader& shader, VertexBuffer &vertexBuffer, ElementsBuffer &elementsBuffer, GLbyte *offset) { - bindVertexArrayObject(); + inline void bind(Shader& shader, VertexBuffer &vertexBuffer, ElementsBuffer &elementsBuffer, GLbyte *offset, gl::GLObjectStore& glObjectStore) { + bindVertexArrayObject(glObjectStore); if (bound_shader == 0) { - vertexBuffer.bind(); - elementsBuffer.bind(); + vertexBuffer.bind(glObjectStore); + elementsBuffer.bind(glObjectStore); shader.bind(offset); if (vao) { storeBinding(shader, vertexBuffer.getID(), elementsBuffer.getID(), offset); @@ -46,16 +48,16 @@ public: } } - inline GLuint getID() const { - return vao; + GLuint getID() const { + return vao.getID(); } private: - void bindVertexArrayObject(); + void bindVertexArrayObject(gl::GLObjectStore&); void storeBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, GLbyte *offset); void verifyBinding(Shader &shader, GLuint vertexBuffer, GLuint elementsBuffer, GLbyte *offset); - GLuint vao = 0; + gl::VAOHolder vao; // For debug reasons, we're storing the bind information so that we can // detect errors and report |