[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.
This commit is contained in:
John Firebaugh
2016-11-07 12:26:05 -08:00
parent 66bdbc3b96
commit 1db2ffbc1b
42 changed files with 475 additions and 362 deletions

View File

@@ -28,11 +28,12 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
spriteAtlas->bind(true, context, 0);
for (const auto& tileID : util::tileCover(state, state.getIntegerZoom())) {
context.draw({
parameters.programs.fillPattern.draw(
context,
gl::Triangles(),
depthModeForSublayer(0, gl::DepthMode::ReadOnly),
gl::StencilMode::disabled(),
colorModeForRenderPass(),
parameters.programs.fillPattern,
FillPatternUniforms::values(
matrixForTile(tileID),
properties.backgroundOpacity.value,
@@ -43,16 +44,17 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
tileID,
state
),
gl::Unindexed<gl::TriangleStrip>(tileTriangleVertexBuffer)
});
tileTriangleVertexBuffer
);
}
} else {
for (const auto& tileID : util::tileCover(state, state.getIntegerZoom())) {
context.draw({
parameters.programs.fill.draw(
context,
gl::Triangles(),
depthModeForSublayer(0, gl::DepthMode::ReadOnly),
gl::StencilMode::disabled(),
colorModeForRenderPass(),
parameters.programs.fill,
FillProgram::UniformValues {
uniforms::u_matrix::Value{ matrixForTile(tileID) },
uniforms::u_opacity::Value{ properties.backgroundOpacity.value },
@@ -60,8 +62,8 @@ void Painter::renderBackground(PaintParameters& parameters, const BackgroundLaye
uniforms::u_outline_color::Value{ properties.backgroundColor.value },
uniforms::u_world::Value{ context.viewport.getCurrentValue().size },
},
gl::Unindexed<gl::TriangleStrip>(tileTriangleVertexBuffer)
});
tileTriangleVertexBuffer
);
}
}
}