fix background painting

This commit is contained in:
Konstantin Käfer
2014-07-02 17:31:55 +02:00
parent 415214d759
commit ac57125bd5
4 changed files with 16 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ class Sprite;
class Source;
class StyleLayer;
class StyleLayerGroup;
class BackgroundProperties;
class Style {
public:
@@ -45,10 +46,11 @@ public:
bool hasTransitions() const;
const BackgroundProperties &getBackgroundProperties() const;
public:
std::shared_ptr<Sprite> sprite;
std::shared_ptr<StyleLayerGroup> layers;
std::shared_ptr<StyleLayer> background;
std::vector<std::string> appliedClasses;
std::string sprite_url;
std::string glyph_url;

View File

@@ -137,8 +137,7 @@ void Painter::clear() {
glStencilMask(0xFF);
depthMask(true);
std::shared_ptr<StyleLayer> background_layer = map.getStyle()->background;
const BackgroundProperties &properties = background_layer ? background_layer->getProperties<BackgroundProperties>() : defaultStyleProperties<BackgroundProperties>();
const BackgroundProperties &properties = map.getStyle()->getBackgroundProperties();
glClearColor(properties.color[0], properties.color[1], properties.color[2], properties.color[3]);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

View File

@@ -108,4 +108,15 @@ void Style::loadJSON(const uint8_t *const data) {
updateClasses();
}
const BackgroundProperties &Style::getBackgroundProperties() const {
if (layers && layers->layers.size()) {
const auto first = layers->layers.front();
if (first && first->id == "background") {
return first->getProperties<BackgroundProperties>();
}
}
return defaultStyleProperties<BackgroundProperties>();
}
}

View File

@@ -925,6 +925,7 @@ void StyleParser::parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer) {
} break;
default:
layer->bucket.reset();
fprintf(stderr, "[WARNING] bucket type of layer '%s' is invalid\n", layer->id.c_str());
break;
}