summaryrefslogtreecommitdiff
path: root/src/mbgl/gfx
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-02-28 17:41:38 +0100
committerKonstantin Käfer <mail@kkaefer.com>2019-03-01 09:33:37 +0100
commitfd37d9065029c732d97e6fa59bc0a0d27ecd3c72 (patch)
tree32111ffa986b6338f2aa4311b2974c90ec09baff /src/mbgl/gfx
parentc53cbe52461e3c1f6f4e1bb6383a6a2e3e5a2cae (diff)
downloadqtlocation-mapboxgl-fd37d9065029c732d97e6fa59bc0a0d27ecd3c72.tar.gz
[core] move draw mode and primitives to gfx namespace
Diffstat (limited to 'src/mbgl/gfx')
-rw-r--r--src/mbgl/gfx/draw_mode.hpp72
-rw-r--r--src/mbgl/gfx/primitives.hpp24
-rw-r--r--src/mbgl/gfx/types.hpp19
3 files changed, 115 insertions, 0 deletions
diff --git a/src/mbgl/gfx/draw_mode.hpp b/src/mbgl/gfx/draw_mode.hpp
new file mode 100644
index 0000000000..a0a9b6c575
--- /dev/null
+++ b/src/mbgl/gfx/draw_mode.hpp
@@ -0,0 +1,72 @@
+#pragma once
+
+#include <mbgl/gfx/types.hpp>
+#include <mbgl/gfx/primitives.hpp>
+
+#include <cassert>
+
+namespace mbgl {
+namespace gfx {
+
+class Points {
+public:
+ using Primitive = Point;
+
+ static constexpr std::size_t bufferGroupSize = 1;
+ static constexpr PrimitiveType primitiveType = PrimitiveType::Points;
+
+ explicit Points(float pointSize_) : pointSize(pointSize_) {}
+
+ float pointSize;
+};
+
+class Lines {
+public:
+ using Primitive = Line;
+
+ static constexpr std::size_t bufferGroupSize = 2;
+ static constexpr PrimitiveType primitiveType = PrimitiveType::Lines;
+
+ explicit Lines(float lineWidth_) : lineWidth(lineWidth_) {
+ assert(lineWidth > 0);
+ }
+
+ float lineWidth;
+};
+
+class LineStrip {
+public:
+ // LineStrip is a form of "Line" rendering, but the element buffer
+ // cannot be grouped into logical elements beyond a single Point.
+ using Primitive = Line;
+
+ static constexpr std::size_t bufferGroupSize = 1;
+ static constexpr PrimitiveType primitiveType = PrimitiveType::LineStrip;
+
+ explicit LineStrip(float lineWidth_) : lineWidth(lineWidth_) {
+ assert(lineWidth > 0);
+ }
+
+ float lineWidth;
+};
+
+class Triangles {
+public:
+ using Primitive = Triangle;
+
+ static constexpr std::size_t bufferGroupSize = 3;
+ static constexpr PrimitiveType primitiveType = PrimitiveType::Triangles;
+};
+
+class TriangleStrip {
+public:
+ // TriangleStrip is a form of "Triangle" rendering, but the element buffer
+ // cannot be grouped into logical elements beyond a single Point.
+ using Primitive = Triangle;
+
+ static constexpr std::size_t bufferGroupSize = 1;
+ static constexpr PrimitiveType primitiveType = PrimitiveType::TriangleStrip;
+};
+
+} // namespace gfx
+} // namespace mbgl
diff --git a/src/mbgl/gfx/primitives.hpp b/src/mbgl/gfx/primitives.hpp
new file mode 100644
index 0000000000..f92b1ec525
--- /dev/null
+++ b/src/mbgl/gfx/primitives.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <cstddef>
+
+namespace mbgl {
+namespace gfx {
+
+class Point {
+public:
+ static constexpr std::size_t vertexCount = 1;
+};
+
+class Line {
+public:
+ static constexpr std::size_t vertexCount = 2;
+};
+
+class Triangle {
+public:
+ static constexpr std::size_t vertexCount = 3;
+};
+
+} // namespace gfx
+} // namespace mbgl
diff --git a/src/mbgl/gfx/types.hpp b/src/mbgl/gfx/types.hpp
new file mode 100644
index 0000000000..ea7b2da5dc
--- /dev/null
+++ b/src/mbgl/gfx/types.hpp
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <cstdint>
+
+namespace mbgl {
+namespace gfx {
+
+enum class PrimitiveType : uint8_t {
+ Points,
+ Lines,
+ LineLoop,
+ LineStrip,
+ Triangles,
+ TriangleStrip,
+ TriangleFan
+};
+
+} // namespace gfx
+} // namespace mbgl