The scale mode is per texture, not per texture unit.
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Mar 2011 17:15:49 -0700
changeset 5503be88d105e91c
parent 5502 ed5f117c949d
child 5504 469da3d31cbd
The scale mode is per texture, not per texture unit.
src/render/opengl/SDL_render_gl.c
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Mon Mar 21 16:36:17 2011 -0700
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Mon Mar 21 17:15:49 2011 -0700
     1.3 @@ -91,7 +91,6 @@
     1.4          GL_Shader shader;
     1.5          Uint32 color;
     1.6          int blendMode;
     1.7 -        GLenum scaleMode;
     1.8      } current;
     1.9  
    1.10      /* OpenGL functions */
    1.11 @@ -119,7 +118,6 @@
    1.12      GLenum formattype;
    1.13      void *pixels;
    1.14      int pitch;
    1.15 -    int scaleMode;
    1.16      SDL_Rect locked_rect;
    1.17  
    1.18      /* YV12 texture support */
    1.19 @@ -220,7 +218,6 @@
    1.20      data->current.shader = SHADER_NONE;
    1.21      data->current.color = 0;
    1.22      data->current.blendMode = -1;
    1.23 -    data->current.scaleMode = 0;
    1.24  
    1.25      data->glDisable(GL_DEPTH_TEST);
    1.26      data->glDisable(GL_CULL_FACE);
    1.27 @@ -413,6 +410,7 @@
    1.28      GLint internalFormat;
    1.29      GLenum format, type;
    1.30      int texture_w, texture_h;
    1.31 +    GLenum scaleMode;
    1.32      GLenum result;
    1.33  
    1.34      GL_ActivateRenderer(renderer);
    1.35 @@ -467,9 +465,11 @@
    1.36  
    1.37      data->format = format;
    1.38      data->formattype = type;
    1.39 -    data->scaleMode = GetScaleQuality();
    1.40 +    scaleMode = GetScaleQuality();
    1.41      renderdata->glEnable(data->type);
    1.42      renderdata->glBindTexture(data->type, data->texture);
    1.43 +    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode);
    1.44 +    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode);
    1.45      renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
    1.46                                  GL_CLAMP_TO_EDGE);
    1.47      renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
    1.48 @@ -524,6 +524,10 @@
    1.49          renderdata->glEnable(data->type);
    1.50  
    1.51          renderdata->glBindTexture(data->type, data->utexture);
    1.52 +        renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
    1.53 +                                    scaleMode);
    1.54 +        renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
    1.55 +                                    scaleMode);
    1.56          renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
    1.57                                      GL_CLAMP_TO_EDGE);
    1.58          renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
    1.59 @@ -532,6 +536,10 @@
    1.60                                   texture_h/2, 0, format, type, NULL);
    1.61  
    1.62          renderdata->glBindTexture(data->type, data->vtexture);
    1.63 +        renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
    1.64 +                                    scaleMode);
    1.65 +        renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
    1.66 +                                    scaleMode);
    1.67          renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
    1.68                                      GL_CLAMP_TO_EDGE);
    1.69          renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
    1.70 @@ -855,34 +863,14 @@
    1.71      if (texturedata->yuv) {
    1.72          data->glActiveTextureARB(GL_TEXTURE2_ARB);
    1.73          data->glBindTexture(texturedata->type, texturedata->vtexture);
    1.74 -        if (texturedata->scaleMode != data->current.scaleMode) {
    1.75 -            data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
    1.76 -                                  texturedata->scaleMode);
    1.77 -            data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
    1.78 -                                  texturedata->scaleMode);
    1.79 -        }
    1.80  
    1.81          data->glActiveTextureARB(GL_TEXTURE1_ARB);
    1.82          data->glBindTexture(texturedata->type, texturedata->utexture);
    1.83 -        if (texturedata->scaleMode != data->current.scaleMode) {
    1.84 -            data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
    1.85 -                                  texturedata->scaleMode);
    1.86 -            data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
    1.87 -                                  texturedata->scaleMode);
    1.88 -        }
    1.89  
    1.90          data->glActiveTextureARB(GL_TEXTURE0_ARB);
    1.91      }
    1.92      data->glBindTexture(texturedata->type, texturedata->texture);
    1.93  
    1.94 -    if (texturedata->scaleMode != data->current.scaleMode) {
    1.95 -        data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
    1.96 -                              texturedata->scaleMode);
    1.97 -        data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
    1.98 -                              texturedata->scaleMode);
    1.99 -        data->current.scaleMode = texturedata->scaleMode;
   1.100 -    }
   1.101 -
   1.102      if (texture->modMode) {
   1.103          GL_SetColor(data, texture->r, texture->g, texture->b, texture->a);
   1.104      } else {
     2.1 --- a/src/render/opengles/SDL_render_gles.c	Mon Mar 21 16:36:17 2011 -0700
     2.2 +++ b/src/render/opengles/SDL_render_gles.c	Mon Mar 21 17:15:49 2011 -0700
     2.3 @@ -88,7 +88,6 @@
     2.4      struct {
     2.5          Uint32 color;
     2.6          int blendMode;
     2.7 -        GLenum scaleMode;
     2.8          SDL_bool tex_coords;
     2.9      } current;
    2.10  
    2.11 @@ -106,7 +105,6 @@
    2.12      GLenum formattype;
    2.13      void *pixels;
    2.14      int pitch;
    2.15 -    GLenum scaleMode;
    2.16  } GLES_TextureData;
    2.17  
    2.18  static void
    2.19 @@ -175,7 +173,6 @@
    2.20  
    2.21      data->current.color = 0;
    2.22      data->current.blendMode = -1;
    2.23 -    data->current.scaleMode = 0;
    2.24      data->current.tex_coords = SDL_FALSE;
    2.25  
    2.26      glDisable(GL_DEPTH_TEST);
    2.27 @@ -312,6 +309,7 @@
    2.28      GLint internalFormat;
    2.29      GLenum format, type;
    2.30      int texture_w, texture_h;
    2.31 +    GLenum scaleMode;
    2.32      GLenum result;
    2.33  
    2.34      GLES_ActivateRenderer(renderer);
    2.35 @@ -358,8 +356,10 @@
    2.36  
    2.37      data->format = format;
    2.38      data->formattype = type;
    2.39 -    data->scaleMode = GetScaleQuality();
    2.40 +    scaleMode = GetScaleQuality();
    2.41      glBindTexture(data->type, data->texture);
    2.42 +    glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode);
    2.43 +    glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode);
    2.44      glTexParameteri(data->type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    2.45      glTexParameteri(data->type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    2.46  
    2.47 @@ -674,14 +674,6 @@
    2.48  
    2.49      glBindTexture(texturedata->type, texturedata->texture);
    2.50  
    2.51 -    if (texturedata->scaleMode != data->current.scaleMode) {
    2.52 -        glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
    2.53 -                        texturedata->scaleMode);
    2.54 -        glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
    2.55 -                        texturedata->scaleMode);
    2.56 -        data->current.scaleMode = texturedata->scaleMode;
    2.57 -    }
    2.58 -
    2.59      if (texture->modMode) {
    2.60          GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a);
    2.61      } else {
     3.1 --- a/src/render/opengles2/SDL_render_gles2.c	Mon Mar 21 16:36:17 2011 -0700
     3.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Mon Mar 21 17:15:49 2011 -0700
     3.3 @@ -59,7 +59,6 @@
     3.4      GLenum pixel_type;
     3.5      void *pixel_data;
     3.6      size_t pitch;
     3.7 -    GLenum scaleMode;
     3.8  } GLES2_TextureData;
     3.9  
    3.10  typedef struct GLES2_ShaderCacheEntry
    3.11 @@ -122,7 +121,6 @@
    3.12      SDL_GLContext *context;
    3.13      struct {
    3.14          int blendMode;
    3.15 -        GLenum scaleMode;
    3.16          SDL_bool tex_coords;
    3.17      } current;
    3.18  
    3.19 @@ -253,6 +251,7 @@
    3.20      GLES2_TextureData *tdata;
    3.21      GLenum format;
    3.22      GLenum type;
    3.23 +    GLenum scaleMode;
    3.24  
    3.25      GLES2_ActivateRenderer(renderer);
    3.26  
    3.27 @@ -279,7 +278,7 @@
    3.28      tdata->texture_type = GL_TEXTURE_2D;
    3.29      tdata->pixel_format = format;
    3.30      tdata->pixel_type = type;
    3.31 -    tdata->scaleMode = GetScaleQuality();
    3.32 +    scaleMode = GetScaleQuality();
    3.33  
    3.34      /* Allocate a blob for image data */
    3.35      if (texture->access == SDL_TEXTUREACCESS_STREAMING)
    3.36 @@ -299,6 +298,8 @@
    3.37      glGenTextures(1, &tdata->texture);
    3.38      glActiveTexture(GL_TEXTURE0);
    3.39      glBindTexture(tdata->texture_type, tdata->texture);
    3.40 +    glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
    3.41 +    glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
    3.42      glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    3.43      glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    3.44      glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
    3.45 @@ -1007,14 +1008,6 @@
    3.46      glBindTexture(tdata->texture_type, tdata->texture);
    3.47      glUniform1i(locTexture, 0);
    3.48  
    3.49 -    if (tdata->scaleMode != rdata->current.scaleMode) {
    3.50 -        glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER,
    3.51 -                        tdata->scaleMode);
    3.52 -        glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER,
    3.53 -                        tdata->scaleMode);
    3.54 -        rdata->current.scaleMode = tdata->scaleMode;
    3.55 -    }
    3.56 -
    3.57      /* Configure color modulation */
    3.58      locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION];
    3.59      glUniform4f(locModulation,
    3.60 @@ -1083,7 +1076,6 @@
    3.61      }
    3.62  
    3.63      rdata->current.blendMode = -1;
    3.64 -    rdata->current.scaleMode = 0;
    3.65      rdata->current.tex_coords = SDL_FALSE;
    3.66  
    3.67      glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);