src/render/opengles2/SDL_render_gles2.c
changeset 5484 e20c93bc9122
parent 5402 5d102cd8aef3
child 5503 be88d105e91c
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Sun Mar 13 11:17:11 2011 -0700
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sun Mar 13 11:18:35 2011 -0700
     1.3 @@ -24,6 +24,7 @@
     1.4  
     1.5  #if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
     1.6  
     1.7 +#include "SDL_hints.h"
     1.8  #include "SDL_opengles2.h"
     1.9  #include "../SDL_sysrender.h"
    1.10  #include "SDL_shaders_gles2.h"
    1.11 @@ -234,6 +235,18 @@
    1.12  static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
    1.13                                 const void *pixels, int pitch);
    1.14  
    1.15 +static GLenum
    1.16 +GetScaleQuality(void)
    1.17 +{
    1.18 +    const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
    1.19 +
    1.20 +    if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) {
    1.21 +        return GL_NEAREST;
    1.22 +    } else {
    1.23 +        return GL_LINEAR;
    1.24 +    }
    1.25 +}
    1.26 +
    1.27  static int
    1.28  GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
    1.29  {
    1.30 @@ -266,7 +279,7 @@
    1.31      tdata->texture_type = GL_TEXTURE_2D;
    1.32      tdata->pixel_format = format;
    1.33      tdata->pixel_type = type;
    1.34 -    tdata->scaleMode = GL_LINEAR;
    1.35 +    tdata->scaleMode = GetScaleQuality();
    1.36  
    1.37      /* Allocate a blob for image data */
    1.38      if (texture->access == SDL_TEXTUREACCESS_STREAMING)
    1.39 @@ -286,8 +299,6 @@
    1.40      glGenTextures(1, &tdata->texture);
    1.41      glActiveTexture(GL_TEXTURE0);
    1.42      glBindTexture(tdata->texture_type, tdata->texture);
    1.43 -    glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    1.44 -    glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    1.45      glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    1.46      glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    1.47      glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);