[core] Added StaticRasterVertexBuffer

This commit is contained in:
Bruno de Oliveira Abinader
2016-06-19 19:25:33 +03:00
parent d8a10ac509
commit 3bf85cc55d
4 changed files with 47 additions and 22 deletions

View File

@@ -3,11 +3,21 @@
namespace mbgl {
StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::pair<int16_t, int16_t>> init) {
StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::array<VertexType, 2>> init) {
for (const auto& vertex : init) {
vertex_type *vertices = static_cast<vertex_type *>(addElement());
vertices[0] = vertex.first;
vertices[1] = vertex.second;
VertexType* vertices = static_cast<VertexType*>(addElement());
vertices[0] = std::get<0>(vertex);
vertices[1] = std::get<1>(vertex);
}
}
StaticRasterVertexBuffer::StaticRasterVertexBuffer(std::initializer_list<std::array<VertexType, 4>> init) {
for (const auto& vertex : init) {
VertexType* vertices = static_cast<VertexType*>(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);
}
}

View File

@@ -2,10 +2,8 @@
#include <mbgl/geometry/buffer.hpp>
#include <vector>
#include <cstddef>
#include <array>
#include <cstdint>
#include <cmath>
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<std::array<VertexType, 2>>);
};
StaticVertexBuffer(std::initializer_list<std::pair<int16_t, int16_t>> 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<std::array<VertexType, 4>>);
};
} // namespace mbgl

View File

@@ -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);

View File

@@ -225,16 +225,23 @@ private:
std::unique_ptr<CircleShader> 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;