From 141e995806576364d185626176c1b993fc519291 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 28 Oct 2016 16:39:50 -0700 Subject: [core] Add support for data-driven styling --- src/mbgl/gl/context.hpp | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'src/mbgl/gl/context.hpp') diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 093afa20ed..636dfc9eac 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -13,7 +13,6 @@ #include #include #include -#include #include @@ -40,6 +39,7 @@ public: UniqueProgram createProgram(ShaderID vertexShader, ShaderID fragmentShader); void linkProgram(ProgramID); UniqueTexture createTexture(); + UniqueVertexArray createVertexArray(); template VertexBuffer createVertexBuffer(VertexVector&& v) { @@ -119,25 +119,20 @@ public: optional depth, optional stencil); - struct Drawable { - DrawMode drawMode; - DepthMode depthMode; - StencilMode stencilMode; - ColorMode colorMode; - gl::ProgramID program; - gl::BufferID vertexBuffer; - gl::BufferID indexBuffer; - const std::vector& segments; - std::function bindUniforms; - std::function bindAttributes; - }; - - void draw(const Drawable&); + void setDrawMode(const Points&); + void setDrawMode(const Lines&); + void setDrawMode(const LineStrip&); + void setDrawMode(const Triangles&); + void setDrawMode(const TriangleStrip&); void setDepthMode(const DepthMode&); void setStencilMode(const StencilMode&); void setColorMode(const ColorMode&); + void draw(PrimitiveType, + std::size_t indexOffset, + std::size_t indexLength); + // Actually remove the objects we marked as abandoned with the above methods. // Only call this while the OpenGL context is exclusive to this thread. void performCleanup(); @@ -164,6 +159,8 @@ public: std::array, 2> texture; State vertexArrayObject; State program; + State vertexBuffer; + State elementBuffer; #if not MBGL_USE_GLES2 State pixelZoom; @@ -196,8 +193,6 @@ private: #if not MBGL_USE_GLES2 State pointSize; #endif // MBGL_USE_GLES2 - State vertexBuffer; - State elementBuffer; UniqueBuffer createVertexBuffer(const void* data, std::size_t size); UniqueBuffer createIndexBuffer(const void* data, std::size_t size); @@ -210,12 +205,6 @@ private: void drawPixels(Size size, const void* data, TextureFormat); #endif // MBGL_USE_GLES2 - PrimitiveType operator()(const Points&); - PrimitiveType operator()(const Lines&); - PrimitiveType operator()(const LineStrip&); - PrimitiveType operator()(const Triangles&); - PrimitiveType operator()(const TriangleStrip&); - friend detail::ProgramDeleter; friend detail::ShaderDeleter; friend detail::BufferDeleter; -- cgit v1.2.1