From 8c3675755e2b0692599ac887178ba0ef8689e89c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Fri, 15 Aug 2014 13:39:49 +0200 Subject: base static vertexbuffer on buffer object --- include/mbgl/geometry/static_vertex_buffer.hpp | 26 +++++++++++++++++ include/mbgl/geometry/vertex_buffer.hpp | 40 -------------------------- include/mbgl/renderer/painter.hpp | 28 +++++++++--------- include/mbgl/renderer/raster_bucket.hpp | 6 ++-- 4 files changed, 43 insertions(+), 57 deletions(-) create mode 100644 include/mbgl/geometry/static_vertex_buffer.hpp delete mode 100644 include/mbgl/geometry/vertex_buffer.hpp (limited to 'include/mbgl') diff --git a/include/mbgl/geometry/static_vertex_buffer.hpp b/include/mbgl/geometry/static_vertex_buffer.hpp new file mode 100644 index 0000000000..ce932269f0 --- /dev/null +++ b/include/mbgl/geometry/static_vertex_buffer.hpp @@ -0,0 +1,26 @@ +#ifndef MBGL_GEOMETRY_STATIC_VERTEX_BUFFER +#define MBGL_GEOMETRY_STATIC_VERTEX_BUFFER + +#include + +#include +#include +#include +#include + +namespace mbgl { + +class StaticVertexBuffer : public Buffer< + 4, // bytes per vertex (2 * signed short == 4 bytes) + GL_ARRAY_BUFFER, + 32 // default length +> { +public: + typedef int16_t vertex_type; + + StaticVertexBuffer(std::initializer_list> init); +}; + +} + +#endif diff --git a/include/mbgl/geometry/vertex_buffer.hpp b/include/mbgl/geometry/vertex_buffer.hpp deleted file mode 100644 index 05cda94245..0000000000 --- a/include/mbgl/geometry/vertex_buffer.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef MBGL_GEOMETRY_VERTEX_BUFFER -#define MBGL_GEOMETRY_VERTEX_BUFFER - -#include -#include -#include -#include - -namespace mbgl { - -class VertexBuffer { -public: - typedef int16_t vertex_type; - VertexBuffer(std::initializer_list init); - ~VertexBuffer(); - - /* - * Returns the number of elements in this buffer. This is not the number of - * bytes, but rather the number of coordinates with associated information. - */ - size_t index() const; - - /* - * Transfers this buffer to the GPU and binds the buffer to the GL context. - */ - void bind(); - - /* - * Returns the OpenGL ID of the buffer object. - */ - uint32_t getID() const; - -private: - const std::vector array; - uint32_t buffer = 0; -}; - -} - -#endif diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index 4cf99f102d..1ef5fee836 100644 --- a/include/mbgl/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include @@ -176,16 +176,16 @@ public: std::unique_ptr gaussianShader; // Set up the stencil quad we're using to generate the stencil mask. - VertexBuffer tileStencilBuffer = { + StaticVertexBuffer tileStencilBuffer = { // top left triangle - 0, 0, - 4096, 0, - 0, 4096, + { 0, 0 }, + { 4096, 0 }, + { 0, 4096 }, // bottom right triangle - 4096, 0, - 0, 4096, - 4096, 4096 + { 4096, 0 }, + { 0, 4096 }, + { 4096, 4096 }, }; VertexArrayObject coveringPlainArray; @@ -197,12 +197,12 @@ public: VertexArrayObject matteArray; // Set up the tile boundary lines we're using to draw the tile outlines. - VertexBuffer tileBorderBuffer = { - 0, 0, - 4096, 0, - 4096, 4096, - 0, 4096, - 0, 0 + StaticVertexBuffer tileBorderBuffer = { + { 0, 0 }, + { 4096, 0 }, + { 4096, 4096 }, + { 0, 4096 }, + { 0, 0 }, }; VertexArrayObject tileBorderArray; diff --git a/include/mbgl/renderer/raster_bucket.hpp b/include/mbgl/renderer/raster_bucket.hpp index a68475565b..66cceac8e7 100644 --- a/include/mbgl/renderer/raster_bucket.hpp +++ b/include/mbgl/renderer/raster_bucket.hpp @@ -11,7 +11,7 @@ namespace mbgl { class RasterShader; -class VertexBuffer; +class StaticVertexBuffer; class VertexArrayObject; class RasterBucket : public Bucket { @@ -26,9 +26,9 @@ public: const StyleBucketRaster &properties; PrerenderedTexture texture; - void drawRaster(RasterShader& shader, VertexBuffer &vertices, VertexArrayObject &array); + void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array); - void drawRaster(RasterShader& shader, VertexBuffer &vertices, VertexArrayObject &array, GLuint texture); + void drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture); Raster raster; -- cgit v1.2.1