comparison src/video/SDL_renderer_gl.c @ 3473:7bdc10624cba

This is terrible, but the OpenGL standard says that lines are half open, which means that one endpoint is not covered so adjoining lines don't overlap. It also doesn't define which end is open, and indeed Mac OS X and Linux differ. Mac OS X seems to leave the second endpoint open, but Linux uses the right-most endpoint for x major lines and the bottom-most endpoint for y major lines.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 21 Nov 2009 07:14:21 +0000
parents fdd2f2e9cd97
children 1edb86163d62
comparison
equal deleted inserted replaced
3472:fdd2f2e9cd97 3473:7bdc10624cba
1148 data->glColor4f((GLfloat) renderer->r * inv255f, 1148 data->glColor4f((GLfloat) renderer->r * inv255f,
1149 (GLfloat) renderer->g * inv255f, 1149 (GLfloat) renderer->g * inv255f,
1150 (GLfloat) renderer->b * inv255f, 1150 (GLfloat) renderer->b * inv255f,
1151 (GLfloat) renderer->a * inv255f); 1151 (GLfloat) renderer->a * inv255f);
1152 1152
1153 /* The line is half open, so we need tiny segments at the endpoints
1154 * so that we guarantee coverage of the beginning and final pixels.
1155 * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html
1156 */
1153 data->glBegin(GL_LINES); 1157 data->glBegin(GL_LINES);
1158 /* Ensure coverage of the first point */
1159 data->glVertex2f(0.1f + x1, 0.1f + y1);
1160 data->glVertex2f(0.5f + x1, 0.5f + y1);
1161 /* Draw the requested line */
1154 data->glVertex2f(0.5f + x1, 0.5f + y1); 1162 data->glVertex2f(0.5f + x1, 0.5f + y1);
1155 data->glVertex2f(0.5f + x2, 0.5f + y2); 1163 data->glVertex2f(0.5f + x2, 0.5f + y2);
1156 data->glEnd(); 1164 /* Ensure coverage of the second point */
1157 1165 data->glVertex2f(0.5f + x2, 0.5f + y2);
1158 /* For some reason the rightmost or lowest endpoint is skipped */ 1166 data->glVertex2f(0.9f + x2, 0.9f + y2);
1159 data->glBegin(GL_POINTS);
1160 if (x1 > x2) {
1161 data->glVertex2f(0.5f + x1, 0.5f + y1);
1162 } else if (x2 > x1) {
1163 data->glVertex2f(0.5f + x2, 0.5f + y2);
1164 } else if (y1 > y2) {
1165 data->glVertex2f(0.5f + x1, 0.5f + y1);
1166 } else if (y2 > y1) {
1167 data->glVertex2f(0.5f + x2, 0.5f + y2);
1168 }
1169 data->glEnd(); 1167 data->glEnd();
1170 1168
1171 return 0; 1169 return 0;
1172 } 1170 }
1173 1171