rename point => icon
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include <llmr/renderer/point_bucket.hpp>
|
||||
#include <llmr/geometry/point_buffer.hpp>
|
||||
#include <llmr/renderer/icon_bucket.hpp>
|
||||
#include <llmr/geometry/icon_buffer.hpp>
|
||||
#include <llmr/geometry/elements_buffer.hpp>
|
||||
#include <llmr/geometry/geometry.hpp>
|
||||
|
||||
@@ -15,14 +15,14 @@ struct geometry_too_long_exception : std::exception {};
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
PointBucket::PointBucket(PointVertexBuffer& vertexBuffer,
|
||||
IconBucket::IconBucket(IconVertexBuffer& vertexBuffer,
|
||||
const BucketDescription& bucket_desc)
|
||||
: geometry(bucket_desc.geometry),
|
||||
vertexBuffer(vertexBuffer),
|
||||
vertex_start(vertexBuffer.index()) {
|
||||
}
|
||||
|
||||
void PointBucket::addGeometry(pbf& geom) {
|
||||
void IconBucket::addGeometry(pbf& geom) {
|
||||
Geometry::command cmd;
|
||||
Geometry geometry(geom);
|
||||
int32_t x, y;
|
||||
@@ -30,28 +30,28 @@ void PointBucket::addGeometry(pbf& geom) {
|
||||
if (cmd == Geometry::move_to) {
|
||||
vertexBuffer.add(x, y);
|
||||
} else {
|
||||
fprintf(stderr, "other command than move_to in point geometry\n");
|
||||
fprintf(stderr, "other command than move_to in icon geometry\n");
|
||||
}
|
||||
}
|
||||
|
||||
vertex_end = vertexBuffer.index();
|
||||
}
|
||||
|
||||
void PointBucket::render(Painter& painter, const std::string& layer_name, const Tile::ID& id) {
|
||||
painter.renderPoint(*this, layer_name, id);
|
||||
void IconBucket::render(Painter& painter, const std::string& layer_name, const Tile::ID& id) {
|
||||
painter.renderIcon(*this, layer_name, id);
|
||||
}
|
||||
|
||||
bool PointBucket::hasData() const {
|
||||
bool IconBucket::hasData() const {
|
||||
return vertex_end > 0;
|
||||
}
|
||||
|
||||
void PointBucket::drawPoints(PointShader& shader) {
|
||||
void IconBucket::drawIcons(IconShader& shader) {
|
||||
char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize);
|
||||
array.bind(shader, vertexBuffer, vertex_index);
|
||||
glDrawArrays(GL_POINTS, 0, (GLsizei)(vertex_end - vertex_start));
|
||||
}
|
||||
|
||||
void PointBucket::drawPoints(DotShader& shader) {
|
||||
void IconBucket::drawIcons(DotShader& shader) {
|
||||
char *vertex_index = BUFFER_OFFSET(vertex_start * vertexBuffer.itemSize);
|
||||
array.bind(shader, vertexBuffer, vertex_index);
|
||||
glDrawArrays(GL_POINTS, 0, (GLsizei)(vertex_end - vertex_start));
|
||||
@@ -63,7 +63,7 @@ void Painter::setupShaders() {
|
||||
lineShader = std::make_unique<LineShader>();
|
||||
linejoinShader = std::make_unique<LinejoinShader>();
|
||||
patternShader = std::make_unique<PatternShader>();
|
||||
pointShader = std::make_unique<PointShader>();
|
||||
iconShader = std::make_unique<IconShader>();
|
||||
rasterShader = std::make_unique<RasterShader>();
|
||||
textShader = std::make_unique<TextShader>();
|
||||
dotShader = std::make_unique<DotShader>();
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#include <llmr/renderer/painter.hpp>
|
||||
#include <llmr/renderer/point_bucket.hpp>
|
||||
#include <llmr/renderer/icon_bucket.hpp>
|
||||
#include <llmr/map/map.hpp>
|
||||
#include <llmr/style/sprite.hpp>
|
||||
#include <llmr/util/math.hpp>
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
void Painter::renderPoint(PointBucket& bucket, const std::string& layer_name, const Tile::ID& id) {
|
||||
void Painter::renderIcon(IconBucket& bucket, const std::string& layer_name, const Tile::ID& id) {
|
||||
// Abort early.
|
||||
if (!bucket.hasData()) return;
|
||||
if (pass == Opaque) return;
|
||||
|
||||
auto point_properties = map.getStyle().computed.points;
|
||||
auto point_properties_it = point_properties.find(layer_name);
|
||||
if (point_properties_it == point_properties.end()) return;
|
||||
auto icon_properties = map.getStyle().computed.icons;
|
||||
auto icon_properties_it = icon_properties.find(layer_name);
|
||||
if (icon_properties_it == icon_properties.end()) return;
|
||||
|
||||
const PointProperties& properties = point_properties_it->second;
|
||||
const IconProperties& properties = icon_properties_it->second;
|
||||
if (!properties.enabled) return;
|
||||
|
||||
Color color = properties.color;
|
||||
@@ -43,41 +43,41 @@ void Painter::renderPoint(PointBucket& bucket, const std::string& layer_name, co
|
||||
dotShader->setMatrix(vtxMatrix);
|
||||
dotShader->setColor(color);
|
||||
|
||||
const float pointSize = (properties.radius ? properties.radius * 2 : 8) * map.getState().getPixelRatio();
|
||||
dotShader->setSize(pointSize);
|
||||
const float iconSize = (properties.radius ? properties.radius * 2 : 8) * map.getState().getPixelRatio();
|
||||
dotShader->setSize(iconSize);
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
glPointSize(pointSize);
|
||||
glPointSize(iconSize);
|
||||
glEnable(GL_POINT_SPRITE);
|
||||
#endif
|
||||
dotShader->setBlur((properties.blur ? properties.blur : 1.5) / pointSize);
|
||||
dotShader->setBlur((properties.blur ? properties.blur : 1.5) / iconSize);
|
||||
|
||||
glDepthRange(strata, 1.0f);
|
||||
bucket.drawPoints(*dotShader);
|
||||
bucket.drawIcons(*dotShader);
|
||||
} else {
|
||||
useProgram(pointShader->program);
|
||||
pointShader->setMatrix(vtxMatrix);
|
||||
pointShader->setColor(color);
|
||||
pointShader->setImage(0);
|
||||
pointShader->setPosition({{
|
||||
useProgram(iconShader->program);
|
||||
iconShader->setMatrix(vtxMatrix);
|
||||
iconShader->setColor(color);
|
||||
iconShader->setImage(0);
|
||||
iconShader->setPosition({{
|
||||
0.5f * (imagePos.tl.x + imagePos.br.x),
|
||||
0.5f * (imagePos.tl.y + imagePos.br.y),
|
||||
}});
|
||||
|
||||
pointShader->setDimension({{
|
||||
iconShader->setDimension({{
|
||||
static_cast<float>(sprite->raster.width),
|
||||
static_cast<float>(sprite->raster.height)
|
||||
}});
|
||||
|
||||
sprite->raster.bind(map.getState().isChanging());
|
||||
|
||||
const float pointSize = util::max(imagePos.size.x, imagePos.size.y) + 2;
|
||||
pointShader->setSize(pointSize);
|
||||
const float iconSize = util::max(imagePos.size.x, imagePos.size.y) + 2;
|
||||
iconShader->setSize(iconSize);
|
||||
#ifndef GL_ES_VERSION_2_0
|
||||
glPointSize(pointSize);
|
||||
glPointSize(iconSize);
|
||||
glEnable(GL_POINT_SPRITE);
|
||||
#endif
|
||||
|
||||
glDepthRange(strata, 1.0f);
|
||||
bucket.drawPoints(*pointShader);
|
||||
bucket.drawIcons(*iconShader);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user