mirror of https://github.com/encounter/SDL.git
Fixed bug 3373 - OpenGL implementation differences of glDrawTexfOES
Simon Hug It seems not everyone implemented glDrawTexfOES the same. Intel and Mesa ignore the viewport entirely, whereas the Raspberry Pi implementation offsets the coordinates and does viewport clipping. The glDrawTexfOES extension text [1] for the function says "Xs and Ys are given directly in window (viewport) coordinates." I guess this wasn't clear enough. Alex Szpakowski Honestly I'd probably remove that codepath from SDL_Render entirely. It's an OpenGL ES 1-specific extension that isn't likely to give huge performance gains and adds additional maintenance overhead to SDL_Render while also having bugs in some drivers (as seen here).
This commit is contained in:
parent
ca8ef2b73f
commit
2ccb46cebc
|
@ -129,8 +129,6 @@ typedef struct
|
||||||
GLES_FBOList *framebuffers;
|
GLES_FBOList *framebuffers;
|
||||||
GLuint window_framebuffer;
|
GLuint window_framebuffer;
|
||||||
|
|
||||||
SDL_bool useDrawTexture;
|
|
||||||
SDL_bool GL_OES_draw_texture_supported;
|
|
||||||
SDL_bool GL_OES_blend_func_separate_supported;
|
SDL_bool GL_OES_blend_func_separate_supported;
|
||||||
} GLES_RenderData;
|
} GLES_RenderData;
|
||||||
|
|
||||||
|
@ -369,19 +367,6 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_PANDORA
|
|
||||||
data->GL_OES_draw_texture_supported = SDL_FALSE;
|
|
||||||
data->useDrawTexture = SDL_FALSE;
|
|
||||||
#else
|
|
||||||
if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) {
|
|
||||||
data->GL_OES_draw_texture_supported = SDL_TRUE;
|
|
||||||
data->useDrawTexture = SDL_TRUE;
|
|
||||||
} else {
|
|
||||||
data->GL_OES_draw_texture_supported = SDL_FALSE;
|
|
||||||
data->useDrawTexture = SDL_FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
value = 0;
|
value = 0;
|
||||||
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
|
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
|
||||||
renderer->info.max_texture_width = value;
|
renderer->info.max_texture_width = value;
|
||||||
|
@ -952,35 +937,6 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
|
|
||||||
GLES_SetTexCoords(data, SDL_TRUE);
|
GLES_SetTexCoords(data, SDL_TRUE);
|
||||||
|
|
||||||
if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
|
|
||||||
/* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
|
|
||||||
GLint cropRect[4];
|
|
||||||
int w, h;
|
|
||||||
SDL_Window *window = renderer->window;
|
|
||||||
|
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
|
||||||
if (renderer->target) {
|
|
||||||
cropRect[0] = srcrect->x;
|
|
||||||
cropRect[1] = srcrect->y;
|
|
||||||
cropRect[2] = srcrect->w;
|
|
||||||
cropRect[3] = srcrect->h;
|
|
||||||
data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
|
|
||||||
cropRect);
|
|
||||||
data->glDrawTexfOES(renderer->viewport.x + dstrect->x, renderer->viewport.y + dstrect->y, 0,
|
|
||||||
dstrect->w, dstrect->h);
|
|
||||||
} else {
|
|
||||||
cropRect[0] = srcrect->x;
|
|
||||||
cropRect[1] = srcrect->y + srcrect->h;
|
|
||||||
cropRect[2] = srcrect->w;
|
|
||||||
cropRect[3] = -srcrect->h;
|
|
||||||
data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
|
|
||||||
cropRect);
|
|
||||||
data->glDrawTexfOES(renderer->viewport.x + dstrect->x,
|
|
||||||
h - (renderer->viewport.y + dstrect->y) - dstrect->h, 0,
|
|
||||||
dstrect->w, dstrect->h);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
minx = dstrect->x;
|
minx = dstrect->x;
|
||||||
miny = dstrect->y;
|
miny = dstrect->y;
|
||||||
maxx = dstrect->x + dstrect->w;
|
maxx = dstrect->x + dstrect->w;
|
||||||
|
@ -1016,7 +972,7 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
||||||
data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
||||||
data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
|
||||||
data->glDisable(GL_TEXTURE_2D);
|
data->glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue