make fillbucket members private

This commit is contained in:
Konstantin Käfer
2014-01-23 15:45:48 +01:00
parent d153bdeff4
commit ac063ad90e
4 changed files with 33 additions and 19 deletions

View File

@@ -15,11 +15,13 @@ class FillBucket : public Bucket {
public:
FillBucket(FillBuffer& buffer);
void addGeometry(pbf& data);
virtual void render(Painter& painter);
public:
void addGeometry(pbf& data);
void drawElements(int32_t attrib);
void drawVertices(int32_t attrib);
private:
FillBuffer& buffer;
struct group {

View File

@@ -34,7 +34,7 @@ public:
void renderDebug(const std::shared_ptr<Tile>& tile);
void renderBackground();
void renderFill(const FillBucket& bucket, const FillProperties& style);
void renderFill(FillBucket& bucket, const FillProperties& style);
void drawClippingMask();

View File

@@ -5,6 +5,10 @@
#include <llmr/renderer/painter.hpp>
#include <llmr/style/style.hpp>
#include <llmr/platform/gl.hpp>
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
#include <cassert>
struct geometry_too_long_exception : std::exception {};
@@ -89,6 +93,25 @@ void FillBucket::addGeometry(pbf& geom) {
}
}
void FillBucket::drawElements(int32_t attrib) {
char *vertex_index = BUFFER_OFFSET(vertex_start * 2 * sizeof(uint16_t));
char *elements_index = BUFFER_OFFSET(elements_start * 3 * sizeof(uint16_t));
buffer.bind();
for (const auto& group : groups) {
glVertexAttribPointer(attrib, 2, GL_SHORT, GL_FALSE, 0, vertex_index);
glDrawElements(GL_TRIANGLES, group.elements_length * 3, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * 2 * sizeof(uint16_t);
elements_index += group.elements_length * 3 * sizeof(uint16_t);
}
}
void FillBucket::drawVertices(int32_t attrib) {
// Draw the entire line
char *vertex_index = BUFFER_OFFSET(vertex_start * 2 * sizeof(uint16_t));
glVertexAttribPointer(attrib, 2, GL_SHORT, GL_FALSE, 0, vertex_index);
glDrawArrays(GL_LINE_STRIP, 0, length);
}
void FillBucket::render(Painter& painter) {
// TODO: obtain the correct style information for this layer
FillProperties properties;

View File

@@ -179,7 +179,7 @@ void Painter::render(const Tile::Ptr& tile) {
renderBackground();
}
void Painter::renderFill(const FillBucket& bucket, const FillProperties& properties) {
void Painter::renderFill(FillBucket& bucket, const FillProperties& properties) {
// Draw the stencil mask.
{
// We're only drawing to the first seven bits (== support a maximum of
@@ -213,15 +213,7 @@ void Painter::renderFill(const FillBucket& bucket, const FillProperties& propert
glUniformMatrix4fv(fillShader->u_matrix, 1, GL_FALSE, matrix);
// Draw all groups
char *vertex_index = BUFFER_OFFSET(bucket.vertex_start * 2 * sizeof(uint16_t));
char *elements_index = BUFFER_OFFSET(bucket.elements_start * 3 * sizeof(uint16_t));
bucket.buffer.bind();
for (const auto& group : bucket.groups) {
glVertexAttribPointer(fillShader->a_pos, 2, GL_SHORT, GL_FALSE, 0, vertex_index);
glDrawElements(GL_TRIANGLES, group.elements_length * 3, GL_UNSIGNED_SHORT, elements_index);
vertex_index += group.vertex_length * 2 * sizeof(uint16_t);
elements_index += group.elements_length * 3 * sizeof(uint16_t);
}
bucket.drawElements(fillShader->a_pos);
// Now that we have the stencil mask in the stencil buffer, we can start
// writing to the color buffer.
@@ -255,13 +247,10 @@ void Painter::renderFill(const FillBucket& bucket, const FillProperties& propert
glUniform4fv(outlineShader->u_color, 1, properties.fill_color.data());
}
glUniform2f(outlineShader->u_world, transform.fb_width, transform.fb_height);
// Draw the entire line
char *vertex_index = BUFFER_OFFSET(bucket.vertex_start * 2 * sizeof(uint16_t));
glVertexAttribPointer(outlineShader->a_pos, 2, GL_SHORT, GL_FALSE, 0, vertex_index);
glUniform2f(outlineShader->u_world, transform.fb_width, transform.fb_height);
glLineWidth(2.0f);
glDrawArrays(GL_LINE_STRIP, 0, bucket.length);
bucket.drawVertices(outlineShader->a_pos);
}
// var imagePos = layerStyle.image && imageSprite.getPosition(layerStyle.image, true);