comparison 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
comparison
equal deleted inserted replaced
3473:7bdc10624cba 3474:1edb86163d62
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 1153 data->glBegin(GL_LINES);
1154 * so that we guarantee coverage of the beginning and final pixels. 1154 data->glVertex2f(0.5f + x1, 0.5f + y1);
1155 data->glVertex2f(0.5f + x2, 0.5f + y2);
1156 data->glEnd();
1157
1158 /* The line is half open, so we need one more point to complete the line.
1155 * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html 1159 * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html
1156 */ 1160 */
1157 data->glBegin(GL_LINES); 1161 data->glBegin(GL_POINTS);
1158 /* Ensure coverage of the first point */ 1162 #ifdef __APPLE__
1159 data->glVertex2f(0.1f + x1, 0.1f + y1); 1163 /* Mac OS X seems to always leave the second point open */
1160 data->glVertex2f(0.5f + x1, 0.5f + y1);
1161 /* Draw the requested line */
1162 data->glVertex2f(0.5f + x1, 0.5f + y1);
1163 data->glVertex2f(0.5f + x2, 0.5f + y2); 1164 data->glVertex2f(0.5f + x2, 0.5f + y2);
1164 /* Ensure coverage of the second point */ 1165 #else
1165 data->glVertex2f(0.5f + x2, 0.5f + y2); 1166 /* Linux seems to use the right-most or bottom-most point open */
1166 data->glVertex2f(0.9f + x2, 0.9f + y2); 1167 if (x1 > x2) {
1168 data->glVertex2f(0.5f + x1, 0.5f + y1);
1169 } else if (x2 > x1) {
1170 data->glVertex2f(0.5f + x2, 0.5f + y2);
1171 } else if (y1 > y2) {
1172 data->glVertex2f(0.5f + x1, 0.5f + y1);
1173 } else if (y2 > y1) {
1174 data->glVertex2f(0.5f + x2, 0.5f + y2);
1175 }
1176 #endif
1167 data->glEnd(); 1177 data->glEnd();
1168 1178
1169 return 0; 1179 return 0;
1170 } 1180 }
1171 1181