diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-02-28 17:41:38 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-02-28 17:43:40 +0100 |
commit | 695ebb1155906a09d2e9c4431f2925236e026410 (patch) | |
tree | 32111ffa986b6338f2aa4311b2974c90ec09baff /src/mbgl/gfx | |
parent | 0ee8f3849ed1e7fc2ba11ac3896d307dd655714a (diff) | |
download | qtlocation-mapboxgl-695ebb1155906a09d2e9c4431f2925236e026410.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.hpp | 72 | ||||
-rw-r--r-- | src/mbgl/gfx/primitives.hpp | 24 | ||||
-rw-r--r-- | src/mbgl/gfx/types.hpp | 19 |
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 |