add style object
This commit is contained in:
@@ -12,6 +12,7 @@ SET(llmr_SOURCES
|
||||
renderer/shader.cpp
|
||||
renderer/fill_bucket.cpp
|
||||
shader/shaders.cpp
|
||||
style/style.cpp
|
||||
util/animation.cpp
|
||||
util/mat4.cpp
|
||||
)
|
||||
|
||||
@@ -14,6 +14,7 @@ Map::Map(Settings& settings)
|
||||
: settings(settings),
|
||||
transform(),
|
||||
painter(transform, settings),
|
||||
style(),
|
||||
min_zoom(0),
|
||||
max_zoom(14) {
|
||||
}
|
||||
@@ -25,6 +26,11 @@ void Map::setup() {
|
||||
painter.setup();
|
||||
}
|
||||
|
||||
void Map::loadStyle(const uint8_t *data, uint32_t bytes) {
|
||||
style.load(pbf(data, bytes));
|
||||
update();
|
||||
}
|
||||
|
||||
void Map::loadSettings() {
|
||||
transform.setAngle(settings.angle);
|
||||
transform.setScale(settings.scale);
|
||||
|
||||
@@ -91,9 +91,9 @@ void FillBucket::addGeometry(pbf& geom) {
|
||||
|
||||
void FillBucket::render(Painter& painter) {
|
||||
// TODO: obtain the correct style information for this layer
|
||||
FillStyle style;
|
||||
style.fill_color = {{ 0, 0, 1, 0.5 }};
|
||||
style.stroke_color = style.fill_color;
|
||||
FillProperties properties;
|
||||
properties.fill_color = {{ 0, 0, 1, 0.5 }};
|
||||
properties.stroke_color = properties.fill_color;
|
||||
|
||||
painter.renderFill(*this, style);
|
||||
painter.renderFill(*this, properties);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ void Painter::render(const Tile::Ptr& tile) {
|
||||
renderBackground();
|
||||
}
|
||||
|
||||
void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) {
|
||||
void Painter::renderFill(const FillBucket& bucket, const FillProperties& properties) {
|
||||
// Draw the stencil mask.
|
||||
{
|
||||
// We're only drawing to the first seven bits (== support a maximum of
|
||||
@@ -193,7 +193,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) {
|
||||
// orientation, while all holes (see below) are in CW orientation.
|
||||
glStencilFunc(GL_NOTEQUAL, 0x80, 0x80);
|
||||
|
||||
if (style.winding == EvenOdd) {
|
||||
if (properties.winding == EvenOdd) {
|
||||
// When we draw an even/odd winding fill, we just invert all the bits.
|
||||
glStencilOp(GL_INVERT, GL_KEEP, GL_KEEP);
|
||||
} else {
|
||||
@@ -234,17 +234,17 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) {
|
||||
|
||||
// Because we're drawing top-to-bottom, and we update the stencil mask
|
||||
// below, we have to draw the outline first (!)
|
||||
if (style.antialiasing) {
|
||||
if (properties.antialiasing) {
|
||||
switchShader(outlineShader);
|
||||
glUniformMatrix4fv(outlineShader->u_matrix, 1, GL_FALSE, matrix);
|
||||
glLineWidth(2);
|
||||
|
||||
if (style.stroke_color != style.fill_color) {
|
||||
if (properties.stroke_color != properties.fill_color) {
|
||||
// If we defined a different color for the fill outline, we are
|
||||
// going to ignore the bits in 0x3F and just care about the global
|
||||
// clipping mask.
|
||||
glStencilFunc(GL_EQUAL, 0x80, 0x80);
|
||||
glUniform4fv(outlineShader->u_color, 1, style.stroke_color.data());
|
||||
glUniform4fv(outlineShader->u_color, 1, properties.stroke_color.data());
|
||||
} else {
|
||||
// Otherwise, we only want to draw the antialiased parts that are
|
||||
// *outside* the current shape. This is important in case the fill
|
||||
@@ -252,7 +252,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) {
|
||||
// the current shape, some pixels from the outline stroke overlapped
|
||||
// the (non-antialiased) fill.
|
||||
glStencilFunc(GL_EQUAL, 0x80, 0xBF);
|
||||
glUniform4fv(outlineShader->u_color, 1, style.fill_color.data());
|
||||
glUniform4fv(outlineShader->u_color, 1, properties.fill_color.data());
|
||||
}
|
||||
|
||||
glUniform2f(outlineShader->u_world, transform.fb_width, transform.fb_height);
|
||||
@@ -292,7 +292,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillStyle& style) {
|
||||
// Draw filling rectangle.
|
||||
switchShader(fillShader);
|
||||
glUniformMatrix4fv(fillShader->u_matrix, 1, GL_FALSE, matrix);
|
||||
glUniform4fv(fillShader->u_color, 1, style.fill_color.data());
|
||||
glUniform4fv(fillShader->u_color, 1, properties.fill_color.data());
|
||||
}
|
||||
|
||||
// Only draw regions that we marked
|
||||
|
||||
15
src/style/style.cpp
Normal file
15
src/style/style.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <llmr/style/style.hpp>
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
Style::Style() {
|
||||
|
||||
}
|
||||
|
||||
void Style::reset() {
|
||||
|
||||
}
|
||||
|
||||
void Style::load(pbf data) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user