Smooth lines now draw the entire line in 1 OpenGL draw call, rather than 2.

This commit is contained in:
Alex Szpakowski
2015-06-21 20:28:26 -03:00
parent 9d635fa63a
commit bf1b409da1
2 changed files with 73 additions and 32 deletions
+10 -5
View File
@@ -46,12 +46,14 @@ class Polyline
{
public:
Polyline(GLenum mode = GL_TRIANGLE_STRIP, bool quadindices = false)
: vertices(NULL)
, overdraw(NULL)
: vertices(nullptr)
, overdraw(nullptr)
, vertex_count(0)
, overdraw_vertex_count(0)
, draw_mode(mode)
, use_quad_indices(quadindices)
, vertex_start(0)
, overdraw_vertex_start(0)
{}
virtual ~Polyline();
@@ -70,6 +72,7 @@ public:
void draw();
protected:
virtual void calc_overdraw_vertex_count(bool is_looping);
virtual void render_overdraw(const std::vector<Vector> &normals, float pixel_size, bool is_looping);
virtual void fill_color_array(Color *colors);
@@ -94,6 +97,8 @@ protected:
size_t overdraw_vertex_count;
GLenum draw_mode;
bool use_quad_indices;
size_t vertex_start;
size_t overdraw_vertex_start;
}; // Polyline
@@ -112,13 +117,13 @@ public:
void render(const float *vertices, size_t count, float halfwidth, float pixel_size, bool draw_overdraw)
{
Polyline::render(vertices, count, 2 * count - 4, halfwidth, pixel_size, draw_overdraw);
// discard the first and last two vertices. (these are redundant)
for (size_t i = 0; i < vertex_count - 2; ++i)
this->vertices[i] = this->vertices[i+2];
// discard the first two vertices. (these are redundant)
vertex_start = 2;
vertex_count -= 2;
}
protected:
virtual void calc_overdraw_vertex_count(bool is_looping);
virtual void render_overdraw(const std::vector<Vector> &normals, float pixel_size, bool is_looping);
virtual void fill_color_array(Color *colors);
virtual void renderEdge(std::vector<Vector> &anchors, std::vector<Vector> &normals,