Fixed smooth lines drawn with the 'none' line join mode.

This commit is contained in:
Alex Szpakowski
2015-06-27 17:51:57 -03:00
parent 6da759047e
commit ee90d09937
2 changed files with 14 additions and 6 deletions
+1 -1
View File
@@ -420,7 +420,7 @@ void Polyline::draw()
gl.useVertexAttribArrays(enabledattribs);
glVertexAttribPointer(ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, vertices + vertex_start);
glVertexAttribPointer(ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, vertices);
// Draw the core line and the overdraw in a single draw call. We can do this
// because the vertex array contains both the core line and the overdraw
+13 -5
View File
@@ -30,6 +30,7 @@
// C++
#include <vector>
#include <string.h>
namespace love
{
@@ -52,7 +53,6 @@ public:
, overdraw_vertex_count(0)
, draw_mode(mode)
, use_quad_indices(quadindices)
, vertex_start(0)
, overdraw_vertex_start(0)
{}
virtual ~Polyline();
@@ -97,7 +97,6 @@ protected:
size_t overdraw_vertex_count;
GLenum draw_mode;
bool use_quad_indices;
size_t vertex_start;
size_t overdraw_vertex_start;
}; // Polyline
@@ -117,9 +116,18 @@ 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 two vertices. (these are redundant)
vertex_start = 2;
vertex_count -= 2;
// discard the first and last two vertices. (these are redundant)
for (size_t i = 0; i < vertex_count - 4; ++i)
this->vertices[i] = this->vertices[i+2];
// The last quad is now garbage, so zero it out to make sure it doesn't
// get rasterized. These vertices are in between the core line vertices
// and the overdraw vertices in the combined vertex array, so they still
// get "rendered" since we draw everything with one draw call.
memset(&this->vertices[vertex_count - 4], 0, sizeof(love::Vector) * 4);
vertex_count -= 4;
}
protected: