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,71 +937,42 @@ 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) {
|
minx = dstrect->x;
|
||||||
/* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
|
miny = dstrect->y;
|
||||||
GLint cropRect[4];
|
maxx = dstrect->x + dstrect->w;
|
||||||
int w, h;
|
maxy = dstrect->y + dstrect->h;
|
||||||
SDL_Window *window = renderer->window;
|
|
||||||
|
|
||||||
SDL_GetWindowSize(window, &w, &h);
|
minu = (GLfloat) srcrect->x / texture->w;
|
||||||
if (renderer->target) {
|
minu *= texturedata->texw;
|
||||||
cropRect[0] = srcrect->x;
|
maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
|
||||||
cropRect[1] = srcrect->y;
|
maxu *= texturedata->texw;
|
||||||
cropRect[2] = srcrect->w;
|
minv = (GLfloat) srcrect->y / texture->h;
|
||||||
cropRect[3] = srcrect->h;
|
minv *= texturedata->texh;
|
||||||
data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
|
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
|
||||||
cropRect);
|
maxv *= texturedata->texh;
|
||||||
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;
|
vertices[0] = minx;
|
||||||
miny = dstrect->y;
|
vertices[1] = miny;
|
||||||
maxx = dstrect->x + dstrect->w;
|
vertices[2] = maxx;
|
||||||
maxy = dstrect->y + dstrect->h;
|
vertices[3] = miny;
|
||||||
|
vertices[4] = minx;
|
||||||
|
vertices[5] = maxy;
|
||||||
|
vertices[6] = maxx;
|
||||||
|
vertices[7] = maxy;
|
||||||
|
|
||||||
minu = (GLfloat) srcrect->x / texture->w;
|
texCoords[0] = minu;
|
||||||
minu *= texturedata->texw;
|
texCoords[1] = minv;
|
||||||
maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
|
texCoords[2] = maxu;
|
||||||
maxu *= texturedata->texw;
|
texCoords[3] = minv;
|
||||||
minv = (GLfloat) srcrect->y / texture->h;
|
texCoords[4] = minu;
|
||||||
minv *= texturedata->texh;
|
texCoords[5] = maxv;
|
||||||
maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
|
texCoords[6] = maxu;
|
||||||
maxv *= texturedata->texh;
|
texCoords[7] = maxv;
|
||||||
|
|
||||||
vertices[0] = minx;
|
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
||||||
vertices[1] = miny;
|
data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
||||||
vertices[2] = maxx;
|
data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
vertices[3] = miny;
|
|
||||||
vertices[4] = minx;
|
|
||||||
vertices[5] = maxy;
|
|
||||||
vertices[6] = maxx;
|
|
||||||
vertices[7] = maxy;
|
|
||||||
|
|
||||||
texCoords[0] = minu;
|
|
||||||
texCoords[1] = minv;
|
|
||||||
texCoords[2] = maxu;
|
|
||||||
texCoords[3] = minv;
|
|
||||||
texCoords[4] = minu;
|
|
||||||
texCoords[5] = maxv;
|
|
||||||
texCoords[6] = maxu;
|
|
||||||
texCoords[7] = maxv;
|
|
||||||
|
|
||||||
data->glVertexPointer(2, GL_FLOAT, 0, vertices);
|
|
||||||
data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
|
||||||
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