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).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c
index 0d59da3..9f79691 100644
--- a/src/render/opengles/SDL_render_gles.c
+++ b/src/render/opengles/SDL_render_gles.c
@@ -129,8 +129,6 @@ typedef struct
GLES_FBOList *framebuffers;
GLuint window_framebuffer;
- SDL_bool useDrawTexture;
- SDL_bool GL_OES_draw_texture_supported;
SDL_bool GL_OES_blend_func_separate_supported;
} GLES_RenderData;
@@ -369,19 +367,6 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
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;
data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
renderer->info.max_texture_width = value;
@@ -952,71 +937,42 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
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;
+ minx = dstrect->x;
+ miny = dstrect->y;
+ maxx = dstrect->x + dstrect->w;
+ maxy = dstrect->y + dstrect->h;
- 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;
- miny = dstrect->y;
- maxx = dstrect->x + dstrect->w;
- maxy = dstrect->y + dstrect->h;
+ minu = (GLfloat) srcrect->x / texture->w;
+ minu *= texturedata->texw;
+ maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
+ maxu *= texturedata->texw;
+ minv = (GLfloat) srcrect->y / texture->h;
+ minv *= texturedata->texh;
+ maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
+ maxv *= texturedata->texh;
- minu = (GLfloat) srcrect->x / texture->w;
- minu *= texturedata->texw;
- maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
- maxu *= texturedata->texw;
- minv = (GLfloat) srcrect->y / texture->h;
- minv *= texturedata->texh;
- maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
- maxv *= texturedata->texh;
+ vertices[0] = minx;
+ vertices[1] = miny;
+ vertices[2] = maxx;
+ vertices[3] = miny;
+ vertices[4] = minx;
+ vertices[5] = maxy;
+ vertices[6] = maxx;
+ vertices[7] = maxy;
- vertices[0] = minx;
- vertices[1] = miny;
- vertices[2] = maxx;
- 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;
- 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->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);
return 0;