Custom drawable layer: Simple Fill (#1810)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alex Cristici <alex.cristici@gmail.com>
This commit is contained in:
@@ -204,6 +204,8 @@ public:
|
||||
/// return the curent vertex count
|
||||
std::size_t curVertexCount() const;
|
||||
|
||||
bool empty() const { return !(drawables.size() || curVertexCount()); }
|
||||
|
||||
protected:
|
||||
/// Create an instance of the appropriate drawable type
|
||||
virtual UniqueDrawable createDrawable() const = 0;
|
||||
|
||||
25
include/mbgl/gfx/fill_generator.hpp
Normal file
25
include/mbgl/gfx/fill_generator.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/tile/geometry_tile_data.hpp>
|
||||
#include <mbgl/gfx/vertex_vector.hpp>
|
||||
#include <mbgl/gfx/index_vector.hpp>
|
||||
#include <mbgl/programs/fill_program.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
void generateFillBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& vertices,
|
||||
SegmentVector<FillAttributes>& triangleSegments,
|
||||
gfx::IndexVector<Triangles>& triangles);
|
||||
|
||||
void generateFillAndOutineBuffers(const GeometryCollection& geometry,
|
||||
gfx::VertexVector<FillLayoutVertex>& vertices,
|
||||
SegmentVector<FillAttributes>& lineSegments,
|
||||
gfx::IndexVector<gfx::Lines>& lines,
|
||||
SegmentVector<FillAttributes>& triangleSegments,
|
||||
gfx::IndexVector<gfx::Triangles>& triangles);
|
||||
|
||||
} // namespace gfx
|
||||
} // namespace mbgl
|
||||
@@ -41,6 +41,11 @@ public:
|
||||
gfx::PolylineGeneratorOptions geometry;
|
||||
};
|
||||
|
||||
struct FillOptions {
|
||||
Color color;
|
||||
float opacity = 1.f;
|
||||
};
|
||||
|
||||
public:
|
||||
/// @brief Construct a new Interface object (internal core use only)
|
||||
Interface(RenderLayer& layer,
|
||||
@@ -72,6 +77,13 @@ public:
|
||||
*/
|
||||
void setLineOptions(const LineOptions& options);
|
||||
|
||||
/**
|
||||
* @brief Set the fill options
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
void setFillOptions(const FillOptions& options);
|
||||
|
||||
/**
|
||||
* @brief Add a polyline
|
||||
*
|
||||
@@ -80,17 +92,14 @@ public:
|
||||
*/
|
||||
void addPolyline(const GeometryCoordinates& coordinates);
|
||||
|
||||
void addFill(const GeometryCollection& geometry);
|
||||
|
||||
/**
|
||||
* @brief Finishe the current drawable building session
|
||||
* @brief Finish the current drawable building session
|
||||
*
|
||||
*/
|
||||
void finish();
|
||||
|
||||
protected:
|
||||
gfx::ShaderPtr lineShaderDefault() const;
|
||||
|
||||
std::unique_ptr<gfx::DrawableBuilder> createBuilder(const std::string& name, gfx::ShaderPtr shader) const;
|
||||
|
||||
public:
|
||||
RenderLayer& layer;
|
||||
LayerGroupBasePtr& layerGroup;
|
||||
@@ -102,9 +111,17 @@ public:
|
||||
UniqueChangeRequestVec& changes;
|
||||
|
||||
private:
|
||||
gfx::ShaderPtr lineShaderDefault() const;
|
||||
gfx::ShaderPtr fillShaderDefault() const;
|
||||
|
||||
std::unique_ptr<gfx::DrawableBuilder> createBuilder(const std::string& name, gfx::ShaderPtr shader) const;
|
||||
|
||||
gfx::ShaderPtr lineShader;
|
||||
gfx::ShaderPtr fillShader;
|
||||
std::unique_ptr<gfx::DrawableBuilder> builder;
|
||||
std::optional<OverscaledTileID> tileID;
|
||||
LineOptions lineOptions;
|
||||
FillOptions fillOptions;
|
||||
};
|
||||
|
||||
class CustomDrawableLayer final : public Layer {
|
||||
|
||||
Reference in New Issue
Block a user