From 3bf85cc55d662c218e371a03040c4cd5c3cca771 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Sun, 19 Jun 2016 19:25:33 +0300 Subject: [core] Added StaticRasterVertexBuffer --- src/mbgl/geometry/static_vertex_buffer.cpp | 18 ++++++++++++---- src/mbgl/geometry/static_vertex_buffer.hpp | 17 ++++++++++----- src/mbgl/renderer/painter.cpp | 1 + src/mbgl/renderer/painter.hpp | 33 ++++++++++++++++++------------ 4 files changed, 47 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/mbgl/geometry/static_vertex_buffer.cpp b/src/mbgl/geometry/static_vertex_buffer.cpp index 254b01b6b6..c66b194748 100644 --- a/src/mbgl/geometry/static_vertex_buffer.cpp +++ b/src/mbgl/geometry/static_vertex_buffer.cpp @@ -3,11 +3,21 @@ namespace mbgl { -StaticVertexBuffer::StaticVertexBuffer(std::initializer_list> init) { +StaticVertexBuffer::StaticVertexBuffer(std::initializer_list> init) { for (const auto& vertex : init) { - vertex_type *vertices = static_cast(addElement()); - vertices[0] = vertex.first; - vertices[1] = vertex.second; + VertexType* vertices = static_cast(addElement()); + vertices[0] = std::get<0>(vertex); + vertices[1] = std::get<1>(vertex); + } +} + +StaticRasterVertexBuffer::StaticRasterVertexBuffer(std::initializer_list> init) { + for (const auto& vertex : init) { + VertexType* vertices = static_cast(addElement()); + vertices[0] = std::get<0>(vertex); + vertices[1] = std::get<1>(vertex); + vertices[2] = std::get<2>(vertex); + vertices[3] = std::get<3>(vertex); } } diff --git a/src/mbgl/geometry/static_vertex_buffer.hpp b/src/mbgl/geometry/static_vertex_buffer.hpp index 79f6117cbc..2e738afc98 100644 --- a/src/mbgl/geometry/static_vertex_buffer.hpp +++ b/src/mbgl/geometry/static_vertex_buffer.hpp @@ -2,10 +2,8 @@ #include -#include -#include +#include #include -#include namespace mbgl { @@ -15,9 +13,18 @@ class StaticVertexBuffer : public Buffer< 32 // default length > { public: - typedef int16_t vertex_type; + using VertexType = int16_t; + StaticVertexBuffer(std::initializer_list>); +}; - StaticVertexBuffer(std::initializer_list> init); +class StaticRasterVertexBuffer : public Buffer< + 8, // bytes per vertex (4 * signed short == 8 bytes) + GL_ARRAY_BUFFER, + 32 // default length +> { +public: + using VertexType = int16_t; + StaticRasterVertexBuffer(std::initializer_list>); }; } // namespace mbgl diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index 7661d80e9c..0e2cfc30b4 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -133,6 +133,7 @@ void Painter::render(const Style& style, const FrameData& frame_, SpriteAtlas& a MBGL_DEBUG_GROUP("upload"); tileStencilBuffer.upload(store); + rasterBoundsBuffer.upload(store); tileBorderBuffer.upload(store); spriteAtlas->upload(store); lineAtlas->upload(store); diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index 0ea3596775..304132595c 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -225,16 +225,23 @@ private: std::unique_ptr circleOverdrawShader; // Set up the stencil quad we're using to generate the stencil mask. - StaticVertexBuffer tileStencilBuffer = { + StaticVertexBuffer tileStencilBuffer { // top left triangle - { 0, 0 }, - { util::EXTENT, 0 }, - { 0, util::EXTENT }, + {{ 0, 0 }}, + {{ util::EXTENT, 0 }}, + {{ 0, util::EXTENT }}, // bottom right triangle - { util::EXTENT, 0 }, - { 0, util::EXTENT }, - { util::EXTENT, util::EXTENT }, + {{ util::EXTENT, 0 }}, + {{ 0, util::EXTENT }}, + {{ util::EXTENT, util::EXTENT }}, + }; + + StaticRasterVertexBuffer rasterBoundsBuffer { + {{ 0, 0, 0, 0 }}, + {{ util::EXTENT, 0, 32767, 0 }}, + {{ 0, util::EXTENT, 0, 32767 }}, + {{ util::EXTENT, util::EXTENT, 32767, 32767 }}, }; VertexArrayObject coveringPlainArray; @@ -248,12 +255,12 @@ private: VertexArrayObject backgroundOverdrawArray; // Set up the tile boundary lines we're using to draw the tile outlines. - StaticVertexBuffer tileBorderBuffer = { - { 0, 0 }, - { util::EXTENT, 0 }, - { util::EXTENT, util::EXTENT }, - { 0, util::EXTENT }, - { 0, 0 }, + StaticVertexBuffer tileBorderBuffer { + {{ 0, 0 }}, + {{ util::EXTENT, 0 }}, + {{ util::EXTENT, util::EXTENT }}, + {{ 0, util::EXTENT }}, + {{ 0, 0 }}, }; VertexArrayObject tileBorderArray; -- cgit v1.2.1