make text layers respect the translate-anchor

you can now specify "translate-anchor": "viewport" to have the text translated
in screen coordinates rather than relative to the tile. The default value
remains "translate-anchor": "map"

refs #189
This commit is contained in:
Konstantin Käfer
2014-05-13 19:02:22 +02:00
parent 2135f855d1
commit c8a3b916b3
3 changed files with 33 additions and 7 deletions

View File

@@ -16,8 +16,6 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
const TextProperties& properties = text_properties_it->second;
if (!properties.enabled) return;
translateLayer(properties.translate, id);
mat4 exMatrix;
matrix::copy(exMatrix, projMatrix);
if (bucket.geom_desc.path == TextPathType::Curve) {
@@ -33,8 +31,10 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
float fontSize = fmin(properties.size, bucket.geom_desc.font_size);
matrix::scale(exMatrix, exMatrix, fontSize / 24.0f, fontSize / 24.0f, 1.0f);
const mat4 vtxMatrix = translatedMatrix(properties.translate, id, properties.translateAnchor);
useProgram(textShader->program);
textShader->setMatrix(matrix);
textShader->setMatrix(vtxMatrix);
textShader->setExtrudeMatrix(exMatrix);
map.getGlyphAtlas().bind();
@@ -109,6 +109,4 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
textShader->setBuffer((256.0f - 64.0f) / 256.0f);
glDepthRange(strata + strata_epsilon, 1.0f);
bucket.drawGlyphs(*textShader);
translateLayer(properties.translate, id, true);
}