summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-08-15 13:39:49 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-08-15 13:39:49 +0200
commit8c3675755e2b0692599ac887178ba0ef8689e89c (patch)
tree0ccc037c64a27ed249b9b56755556b1243fcb405 /include
parentba67fcd830d41399ec8d225fd9536a4f780056ff (diff)
downloadqtlocation-mapboxgl-8c3675755e2b0692599ac887178ba0ef8689e89c.tar.gz
base static vertexbuffer on buffer object
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/geometry/static_vertex_buffer.hpp26
-rw-r--r--include/mbgl/geometry/vertex_buffer.hpp40
-rw-r--r--include/mbgl/renderer/painter.hpp28
-rw-r--r--include/mbgl/renderer/raster_bucket.hpp6
4 files changed, 43 insertions, 57 deletions
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 <mbgl/geometry/buffer.hpp>
+
+#include <vector>
+#include <cstddef>
+#include <cstdint>
+#include <cmath>
+
+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<std::pair<int16_t, int16_t>> 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 <vector>
-#include <cstddef>
-#include <cstdint>
-#include <cmath>
-
-namespace mbgl {
-
-class VertexBuffer {
-public:
- typedef int16_t vertex_type;
- VertexBuffer(std::initializer_list<vertex_type> 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<vertex_type> 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 <mbgl/map/tile_data.hpp>
#include <mbgl/geometry/vao.hpp>
-#include <mbgl/geometry/vertex_buffer.hpp>
+#include <mbgl/geometry/static_vertex_buffer.hpp>
#include <mbgl/util/mat4.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/renderer/frame_history.hpp>
@@ -176,16 +176,16 @@ public:
std::unique_ptr<GaussianShader> 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;