Fixed issues closing lines with the OpenGL ES renderer.
authorSam Lantinga <slouken@libsdl.org>
Thu, 10 Nov 2011 00:22:44 -0500
changeset 6076 e69b1bd26e0b
parent 6075 a682a5c9a941
child 6077 ee00e4b80f79
Fixed issues closing lines with the OpenGL ES renderer.
src/render/direct3d/SDL_render_d3d.c
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
--- a/src/render/direct3d/SDL_render_d3d.c	Thu Nov 10 00:22:01 2011 -0500
+++ b/src/render/direct3d/SDL_render_d3d.c	Thu Nov 10 00:22:44 2011 -0500
@@ -889,7 +889,8 @@
 
     /* DirectX 9 has the same line rasterization semantics as GDI,
        so we need to close the endpoint of the line */
-    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
+    if (count == 2 ||
+        points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
         vertices[0].x = (float) points[count-1].x;
         vertices[0].y = (float) points[count-1].y;
         result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
--- a/src/render/opengles/SDL_render_gles.c	Thu Nov 10 00:22:01 2011 -0500
+++ b/src/render/opengles/SDL_render_gles.c	Thu Nov 10 00:22:44 2011 -0500
@@ -625,6 +625,8 @@
         glDrawArrays(GL_LINE_LOOP, 0, count);
     } else {
         glDrawArrays(GL_LINE_STRIP, 0, count);
+        /* We need to close the endpoint of the line */
+        glDrawArrays(GL_POINTS, count-1, 1);
     }
     SDL_stack_free(vertices);
 
--- a/src/render/opengles2/SDL_render_gles2.c	Thu Nov 10 00:22:01 2011 -0500
+++ b/src/render/opengles2/SDL_render_gles2.c	Thu Nov 10 00:22:44 2011 -0500
@@ -944,6 +944,12 @@
     glGetError();
     glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
     glDrawArrays(GL_LINE_STRIP, 0, count);
+
+    /* We need to close the endpoint of the line */
+    if (count == 2 ||
+        points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
+        glDrawArrays(GL_POINTS, count-1, 1);
+    }
     SDL_stack_free(vertices);
     if (glGetError() != GL_NO_ERROR)
     {