diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-07 12:26:05 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-08 08:09:29 -0800 |
commit | 1db2ffbc1b69069eca39f786cacc45dbb02c3052 (patch) | |
tree | 9d6ed2a7302492f41c52ea3fdeadabf6466b0d8d /src/mbgl/renderer/painter.cpp | |
parent | 66bdbc3b969083b9d647abdf72784be64a125949 (diff) | |
download | qtlocation-mapboxgl-1db2ffbc1b69069eca39f786cacc45dbb02c3052.tar.gz |
[core] Use gl::Program to resolve some rough edges in the GL binding types
* Extract `ignore` util to separate header.
* `Segment` now tracks offset and length of indices, rather than primitives. This is more natural.
* Introduce `VertexVector` and `IndexVector` types. These types carry information about the intended draw mode (`Triangles`, `LineStrip`, etc.), and ensure that elements are always appended in a group size appropriate for that draw mode, for both indexed and unindexed rendering.
* `Program`, rather than `Drawable`, is now the unifying object for draw calls. `Program` is the best place to type check the draw call, because it is typed to carry information about the intended primitive, vertex type, attributes, and uniforms.
* Use the debug shaders for debug tile rendering, like gl-js.
* Fix the draw mode for background. It was drawing triangle strips with a triangles array. Surprised this didn’t cause issues. Now it’s type checked.
Diffstat (limited to 'src/mbgl/renderer/painter.cpp')
-rw-r--r-- | src/mbgl/renderer/painter.cpp | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index d9e7f9fd35..a09e3b73fc 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -41,30 +41,44 @@ namespace mbgl { using namespace style; -Painter::Painter(gl::Context& context_, const TransformState& state_) - : context(context_), - state(state_), - tileTriangleVertexBuffer(context.createVertexBuffer(std::vector<FillVertex> {{ +static gl::VertexVector<FillVertex, gl::Triangles> tileTriangles() { + gl::VertexVector<FillVertex, gl::Triangles> result; + result.emplace_back( FillAttributes::vertex({ 0, 0 }), FillAttributes::vertex({ util::EXTENT, 0 }), - FillAttributes::vertex({ 0, util::EXTENT }), - FillAttributes::vertex({ util::EXTENT, 0 }), - FillAttributes::vertex({ 0, util::EXTENT }), - FillAttributes::vertex({ util::EXTENT, util::EXTENT }) - }})), - tileLineStripVertexBuffer(context.createVertexBuffer(std::vector<FillVertex> {{ - FillAttributes::vertex({ 0, 0 }), + FillAttributes::vertex({ 0, util::EXTENT })); + result.emplace_back( FillAttributes::vertex({ util::EXTENT, 0 }), - FillAttributes::vertex({ util::EXTENT, util::EXTENT }), FillAttributes::vertex({ 0, util::EXTENT }), - FillAttributes::vertex({ 0, 0 }) - }})), - rasterVertexBuffer(context.createVertexBuffer(std::vector<RasterVertex> {{ - RasterProgram::vertex({ 0, 0 }, { 0, 0 }), - RasterProgram::vertex({ util::EXTENT, 0 }, { 32767, 0 }), - RasterProgram::vertex({ 0, util::EXTENT }, { 0, 32767 }), - RasterProgram::vertex({ util::EXTENT, util::EXTENT }, { 32767, 32767 }) - }})) { + FillAttributes::vertex({ util::EXTENT, util::EXTENT })); + return result; +} + +static gl::VertexVector<FillVertex, gl::LineStrip> tileLineStrip() { + gl::VertexVector<FillVertex, gl::LineStrip> result; + result.emplace_back(FillAttributes::vertex({ 0, 0 })); + result.emplace_back(FillAttributes::vertex({ util::EXTENT, 0 })); + result.emplace_back(FillAttributes::vertex({ util::EXTENT, util::EXTENT })); + result.emplace_back(FillAttributes::vertex({ 0, util::EXTENT })); + result.emplace_back(FillAttributes::vertex({ 0, 0 })); + return result; +} + +static gl::VertexVector<RasterVertex, gl::TriangleStrip> rasterTriangleStrip() { + gl::VertexVector<RasterVertex, gl::TriangleStrip> result; + result.emplace_back(RasterProgram::vertex({ 0, 0 }, { 0, 0 })); + result.emplace_back(RasterProgram::vertex({ util::EXTENT, 0 }, { 32767, 0 })); + result.emplace_back(RasterProgram::vertex({ 0, util::EXTENT }, { 0, 32767 })); + result.emplace_back(RasterProgram::vertex({ util::EXTENT, util::EXTENT }, { 32767, 32767 })); + return result; +} + +Painter::Painter(gl::Context& context_, const TransformState& state_) + : context(context_), + state(state_), + tileTriangleVertexBuffer(context.createVertexBuffer(tileTriangles())), + tileLineStripVertexBuffer(context.createVertexBuffer(tileLineStrip())), + rasterVertexBuffer(context.createVertexBuffer(rasterTriangleStrip())) { #ifndef NDEBUG gl::debugging::enable(); #endif |