mirror of https://github.com/encounter/SDL.git
Fixed performance regression caused by the fix for bug 2158
This commit is contained in:
parent
0b7c69fe12
commit
1c9cc8c9b7
|
@ -89,8 +89,8 @@ SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func))
|
||||||
SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
|
SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
|
||||||
SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
|
SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
|
||||||
SDL_PROC(void, glDisable, (GLenum cap))
|
SDL_PROC(void, glDisable, (GLenum cap))
|
||||||
SDL_PROC(void, glDisableClientState, (GLenum array))
|
SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array))
|
||||||
SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
|
SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
|
||||||
SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode))
|
SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode))
|
||||||
SDL_PROC_UNUSED(void, glDrawElements,
|
SDL_PROC_UNUSED(void, glDrawElements,
|
||||||
(GLenum mode, GLsizei count, GLenum type,
|
(GLenum mode, GLsizei count, GLenum type,
|
||||||
|
@ -103,7 +103,7 @@ SDL_PROC_UNUSED(void, glEdgeFlagPointer,
|
||||||
(GLsizei stride, const GLvoid * pointer))
|
(GLsizei stride, const GLvoid * pointer))
|
||||||
SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag))
|
SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag))
|
||||||
SDL_PROC(void, glEnable, (GLenum cap))
|
SDL_PROC(void, glEnable, (GLenum cap))
|
||||||
SDL_PROC(void, glEnableClientState, (GLenum array))
|
SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array))
|
||||||
SDL_PROC(void, glEnd, (void))
|
SDL_PROC(void, glEnd, (void))
|
||||||
SDL_PROC_UNUSED(void, glEndList, (void))
|
SDL_PROC_UNUSED(void, glEndList, (void))
|
||||||
SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u))
|
SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u))
|
||||||
|
@ -448,7 +448,7 @@ SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v))
|
||||||
SDL_PROC_UNUSED(void, glVertex4s,
|
SDL_PROC_UNUSED(void, glVertex4s,
|
||||||
(GLshort x, GLshort y, GLshort z, GLshort w))
|
(GLshort x, GLshort y, GLshort z, GLshort w))
|
||||||
SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v))
|
SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v))
|
||||||
SDL_PROC(void, glVertexPointer,
|
SDL_PROC_UNUSED(void, glVertexPointer,
|
||||||
(GLint size, GLenum type, GLsizei stride,
|
(GLint size, GLenum type, GLsizei stride,
|
||||||
const GLvoid * pointer))
|
const GLvoid * pointer))
|
||||||
SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
|
SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
|
||||||
|
|
|
@ -1048,17 +1048,15 @@ GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
||||||
int count)
|
int count)
|
||||||
{
|
{
|
||||||
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
||||||
|
int i;
|
||||||
|
|
||||||
GL_SetDrawingState(renderer);
|
GL_SetDrawingState(renderer);
|
||||||
|
|
||||||
data->glTranslatef(0.5f, 0.5f, 0.0f);
|
data->glBegin(GL_POINTS);
|
||||||
data->glVertexPointer(2, GL_FLOAT, 0, points);
|
for (i = 0; i < count; ++i) {
|
||||||
data->glEnableClientState(GL_VERTEX_ARRAY);
|
data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
|
||||||
|
}
|
||||||
data->glDrawArrays(GL_POINTS, 0, count);
|
data->glEnd();
|
||||||
|
|
||||||
data->glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
data->glTranslatef(-0.5f, -0.5f, 0.0f);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1068,28 +1066,62 @@ GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
||||||
int count)
|
int count)
|
||||||
{
|
{
|
||||||
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
||||||
|
int i;
|
||||||
|
|
||||||
GL_SetDrawingState(renderer);
|
GL_SetDrawingState(renderer);
|
||||||
|
|
||||||
data->glTranslatef(0.5f, 0.5f, 0.0f);
|
|
||||||
data->glVertexPointer(2, GL_FLOAT, 0, points);
|
|
||||||
data->glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
if (count > 2 &&
|
if (count > 2 &&
|
||||||
points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
|
points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
|
||||||
|
data->glBegin(GL_LINE_LOOP);
|
||||||
/* GL_LINE_LOOP takes care of the final segment */
|
/* GL_LINE_LOOP takes care of the final segment */
|
||||||
data->glDrawArrays(GL_LINE_LOOP, 0, count-1);
|
--count;
|
||||||
} else {
|
for (i = 0; i < count; ++i) {
|
||||||
data->glDrawArrays(GL_LINE_STRIP, 0, count);
|
data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
|
||||||
}
|
}
|
||||||
/* Make sure all the line endpoints are closed.
|
data->glEnd();
|
||||||
* http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html
|
} else {
|
||||||
* Which points need to be drawn varies by driver, so just draw all of them.
|
#if defined(__MACOSX__) || defined(__WIN32__)
|
||||||
*/
|
#else
|
||||||
data->glDrawArrays(GL_POINTS, 0, count);
|
int x1, y1, x2, y2;
|
||||||
data->glDisableClientState(GL_VERTEX_ARRAY);
|
#endif
|
||||||
data->glTranslatef(-0.5f, -0.5f, 0.0f);
|
|
||||||
|
|
||||||
|
data->glBegin(GL_LINE_STRIP);
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y);
|
||||||
|
}
|
||||||
|
data->glEnd();
|
||||||
|
|
||||||
|
/* The line is half open, so we need one more point to complete it.
|
||||||
|
* http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
data->glBegin(GL_POINTS);
|
||||||
|
#if defined(__MACOSX__) || defined(__WIN32__)
|
||||||
|
/* Mac OS X and Windows seem to always leave the last point open */
|
||||||
|
data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y);
|
||||||
|
#else
|
||||||
|
/* Linux seems to leave the right-most or bottom-most point open */
|
||||||
|
x1 = points[0].x;
|
||||||
|
y1 = points[0].y;
|
||||||
|
x2 = points[count-1].x;
|
||||||
|
y2 = points[count-1].y;
|
||||||
|
|
||||||
|
if (x1 > x2) {
|
||||||
|
data->glVertex2f(0.5f + x1, 0.5f + y1);
|
||||||
|
} else if (x2 > x1) {
|
||||||
|
data->glVertex2f(0.5f + x2, 0.5f + y2);
|
||||||
|
}
|
||||||
|
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 GL_CheckError("", renderer);
|
return GL_CheckError("", renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue