Mercurial > sdl-ios-xcode
diff src/video/SDL_renderer_gl.c @ 3474:1edb86163d62
Of COURSE that trick wouldn't work on all renderers. Fall back to something for now, hopefully figure out a better way to do this later.
If we have to, we can use vertical line and horizontal line textures for vertical and horizontal lines, and then create custom textures for diagonal lines and software render those. It's terrible, but at least it would be pixel perfect.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 21 Nov 2009 07:22:59 +0000 |
parents | 7bdc10624cba |
children | 3bd01435287f |
line wrap: on
line diff
--- a/src/video/SDL_renderer_gl.c Sat Nov 21 07:14:21 2009 +0000 +++ b/src/video/SDL_renderer_gl.c Sat Nov 21 07:22:59 2009 +0000 @@ -1150,20 +1150,30 @@ (GLfloat) renderer->b * inv255f, (GLfloat) renderer->a * inv255f); - /* The line is half open, so we need tiny segments at the endpoints - * so that we guarantee coverage of the beginning and final pixels. + data->glBegin(GL_LINES); + data->glVertex2f(0.5f + x1, 0.5f + y1); + data->glVertex2f(0.5f + x2, 0.5f + y2); + data->glEnd(); + + /* The line is half open, so we need one more point to complete the line. * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html */ - data->glBegin(GL_LINES); - /* Ensure coverage of the first point */ - data->glVertex2f(0.1f + x1, 0.1f + y1); - data->glVertex2f(0.5f + x1, 0.5f + y1); - /* Draw the requested line */ - data->glVertex2f(0.5f + x1, 0.5f + y1); + data->glBegin(GL_POINTS); +#ifdef __APPLE__ + /* Mac OS X seems to always leave the second point open */ data->glVertex2f(0.5f + x2, 0.5f + y2); - /* Ensure coverage of the second point */ - data->glVertex2f(0.5f + x2, 0.5f + y2); - data->glVertex2f(0.9f + x2, 0.9f + y2); +#else + /* Linux seems to use the right-most or bottom-most point open */ + if (x1 > x2) { + data->glVertex2f(0.5f + x1, 0.5f + y1); + } else if (x2 > x1) { + data->glVertex2f(0.5f + x2, 0.5f + y2); + } else if (y1 > y2) { + data->glVertex2f(0.5f + x1, 0.5f + y1); + } else if (y2 > y1) { + data->glVertex2f(0.5f + x2, 0.5f + y2); + } +#endif data->glEnd(); return 0;