Fixed issues closing lines with the OpenGL ES renderer.
authorSam Lantinga <slouken@libsdl.org>
Thu, 10 Nov 2011 00:22:44 -0500
changeset 6076e69b1bd26e0b
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
     1.1 --- a/src/render/direct3d/SDL_render_d3d.c	Thu Nov 10 00:22:01 2011 -0500
     1.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Thu Nov 10 00:22:44 2011 -0500
     1.3 @@ -889,7 +889,8 @@
     1.4  
     1.5      /* DirectX 9 has the same line rasterization semantics as GDI,
     1.6         so we need to close the endpoint of the line */
     1.7 -    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
     1.8 +    if (count == 2 ||
     1.9 +        points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
    1.10          vertices[0].x = (float) points[count-1].x;
    1.11          vertices[0].y = (float) points[count-1].y;
    1.12          result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
     2.1 --- a/src/render/opengles/SDL_render_gles.c	Thu Nov 10 00:22:01 2011 -0500
     2.2 +++ b/src/render/opengles/SDL_render_gles.c	Thu Nov 10 00:22:44 2011 -0500
     2.3 @@ -625,6 +625,8 @@
     2.4          glDrawArrays(GL_LINE_LOOP, 0, count);
     2.5      } else {
     2.6          glDrawArrays(GL_LINE_STRIP, 0, count);
     2.7 +        /* We need to close the endpoint of the line */
     2.8 +        glDrawArrays(GL_POINTS, count-1, 1);
     2.9      }
    2.10      SDL_stack_free(vertices);
    2.11  
     3.1 --- a/src/render/opengles2/SDL_render_gles2.c	Thu Nov 10 00:22:01 2011 -0500
     3.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Thu Nov 10 00:22:44 2011 -0500
     3.3 @@ -944,6 +944,12 @@
     3.4      glGetError();
     3.5      glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
     3.6      glDrawArrays(GL_LINE_STRIP, 0, count);
     3.7 +
     3.8 +    /* We need to close the endpoint of the line */
     3.9 +    if (count == 2 ||
    3.10 +        points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
    3.11 +        glDrawArrays(GL_POINTS, count-1, 1);
    3.12 +    }
    3.13      SDL_stack_free(vertices);
    3.14      if (glGetError() != GL_NO_ERROR)
    3.15      {