src/render/opengles/SDL_render_gles.c
changeset 10399 8e4a030053c2
parent 9998 f67cf37e9cd4
child 10402 48b40c223503
     1.1 --- a/src/render/opengles/SDL_render_gles.c	Sat Oct 01 10:39:03 2016 -0700
     1.2 +++ b/src/render/opengles/SDL_render_gles.c	Sat Oct 01 10:43:01 2016 -0700
     1.3 @@ -129,8 +129,6 @@
     1.4      GLES_FBOList *framebuffers;
     1.5      GLuint window_framebuffer;
     1.6  
     1.7 -    SDL_bool useDrawTexture;
     1.8 -    SDL_bool GL_OES_draw_texture_supported;
     1.9      SDL_bool GL_OES_blend_func_separate_supported;
    1.10  } GLES_RenderData;
    1.11  
    1.12 @@ -369,19 +367,6 @@
    1.13          renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
    1.14      }
    1.15  
    1.16 -#if SDL_VIDEO_DRIVER_PANDORA
    1.17 -    data->GL_OES_draw_texture_supported = SDL_FALSE;
    1.18 -    data->useDrawTexture = SDL_FALSE;
    1.19 -#else
    1.20 -    if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) {
    1.21 -        data->GL_OES_draw_texture_supported = SDL_TRUE;
    1.22 -        data->useDrawTexture = SDL_TRUE;
    1.23 -    } else {
    1.24 -        data->GL_OES_draw_texture_supported = SDL_FALSE;
    1.25 -        data->useDrawTexture = SDL_FALSE;
    1.26 -    }
    1.27 -#endif
    1.28 -
    1.29      value = 0;
    1.30      data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
    1.31      renderer->info.max_texture_width = value;
    1.32 @@ -952,71 +937,42 @@
    1.33  
    1.34      GLES_SetTexCoords(data, SDL_TRUE);
    1.35  
    1.36 -    if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
    1.37 -        /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
    1.38 -        GLint cropRect[4];
    1.39 -        int w, h;
    1.40 -        SDL_Window *window = renderer->window;
    1.41 +    minx = dstrect->x;
    1.42 +    miny = dstrect->y;
    1.43 +    maxx = dstrect->x + dstrect->w;
    1.44 +    maxy = dstrect->y + dstrect->h;
    1.45  
    1.46 -        SDL_GetWindowSize(window, &w, &h);
    1.47 -        if (renderer->target) {
    1.48 -            cropRect[0] = srcrect->x;
    1.49 -            cropRect[1] = srcrect->y;
    1.50 -            cropRect[2] = srcrect->w;
    1.51 -            cropRect[3] = srcrect->h;
    1.52 -            data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
    1.53 -                                   cropRect);
    1.54 -            data->glDrawTexfOES(renderer->viewport.x + dstrect->x, renderer->viewport.y + dstrect->y, 0,
    1.55 -                                dstrect->w, dstrect->h);
    1.56 -        } else {
    1.57 -            cropRect[0] = srcrect->x;
    1.58 -            cropRect[1] = srcrect->y + srcrect->h;
    1.59 -            cropRect[2] = srcrect->w;
    1.60 -            cropRect[3] = -srcrect->h;
    1.61 -            data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
    1.62 -                                   cropRect);
    1.63 -            data->glDrawTexfOES(renderer->viewport.x + dstrect->x,
    1.64 -                        h - (renderer->viewport.y + dstrect->y) - dstrect->h, 0,
    1.65 -                        dstrect->w, dstrect->h);
    1.66 -        }
    1.67 -    } else {
    1.68 +    minu = (GLfloat) srcrect->x / texture->w;
    1.69 +    minu *= texturedata->texw;
    1.70 +    maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
    1.71 +    maxu *= texturedata->texw;
    1.72 +    minv = (GLfloat) srcrect->y / texture->h;
    1.73 +    minv *= texturedata->texh;
    1.74 +    maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
    1.75 +    maxv *= texturedata->texh;
    1.76  
    1.77 -        minx = dstrect->x;
    1.78 -        miny = dstrect->y;
    1.79 -        maxx = dstrect->x + dstrect->w;
    1.80 -        maxy = dstrect->y + dstrect->h;
    1.81 -
    1.82 -        minu = (GLfloat) srcrect->x / texture->w;
    1.83 -        minu *= texturedata->texw;
    1.84 -        maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
    1.85 -        maxu *= texturedata->texw;
    1.86 -        minv = (GLfloat) srcrect->y / texture->h;
    1.87 -        minv *= texturedata->texh;
    1.88 -        maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
    1.89 -        maxv *= texturedata->texh;
    1.90 +    vertices[0] = minx;
    1.91 +    vertices[1] = miny;
    1.92 +    vertices[2] = maxx;
    1.93 +    vertices[3] = miny;
    1.94 +    vertices[4] = minx;
    1.95 +    vertices[5] = maxy;
    1.96 +    vertices[6] = maxx;
    1.97 +    vertices[7] = maxy;
    1.98  
    1.99 -        vertices[0] = minx;
   1.100 -        vertices[1] = miny;
   1.101 -        vertices[2] = maxx;
   1.102 -        vertices[3] = miny;
   1.103 -        vertices[4] = minx;
   1.104 -        vertices[5] = maxy;
   1.105 -        vertices[6] = maxx;
   1.106 -        vertices[7] = maxy;
   1.107 +    texCoords[0] = minu;
   1.108 +    texCoords[1] = minv;
   1.109 +    texCoords[2] = maxu;
   1.110 +    texCoords[3] = minv;
   1.111 +    texCoords[4] = minu;
   1.112 +    texCoords[5] = maxv;
   1.113 +    texCoords[6] = maxu;
   1.114 +    texCoords[7] = maxv;
   1.115  
   1.116 -        texCoords[0] = minu;
   1.117 -        texCoords[1] = minv;
   1.118 -        texCoords[2] = maxu;
   1.119 -        texCoords[3] = minv;
   1.120 -        texCoords[4] = minu;
   1.121 -        texCoords[5] = maxv;
   1.122 -        texCoords[6] = maxu;
   1.123 -        texCoords[7] = maxv;
   1.124 +    data->glVertexPointer(2, GL_FLOAT, 0, vertices);
   1.125 +    data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
   1.126 +    data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   1.127  
   1.128 -        data->glVertexPointer(2, GL_FLOAT, 0, vertices);
   1.129 -        data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
   1.130 -        data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   1.131 -    }
   1.132      data->glDisable(GL_TEXTURE_2D);
   1.133  
   1.134      return 0;