The scale mode is per texture, not per texture unit.
authorSam Lantinga <slouken@libsdl.org>
Mon, 21 Mar 2011 17:15:49 -0700
changeset 5503 be88d105e91c
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
--- a/src/render/opengl/SDL_render_gl.c	Mon Mar 21 16:36:17 2011 -0700
+++ b/src/render/opengl/SDL_render_gl.c	Mon Mar 21 17:15:49 2011 -0700
@@ -91,7 +91,6 @@
         GL_Shader shader;
         Uint32 color;
         int blendMode;
-        GLenum scaleMode;
     } current;
 
     /* OpenGL functions */
@@ -119,7 +118,6 @@
     GLenum formattype;
     void *pixels;
     int pitch;
-    int scaleMode;
     SDL_Rect locked_rect;
 
     /* YV12 texture support */
@@ -220,7 +218,6 @@
     data->current.shader = SHADER_NONE;
     data->current.color = 0;
     data->current.blendMode = -1;
-    data->current.scaleMode = 0;
 
     data->glDisable(GL_DEPTH_TEST);
     data->glDisable(GL_CULL_FACE);
@@ -413,6 +410,7 @@
     GLint internalFormat;
     GLenum format, type;
     int texture_w, texture_h;
+    GLenum scaleMode;
     GLenum result;
 
     GL_ActivateRenderer(renderer);
@@ -467,9 +465,11 @@
 
     data->format = format;
     data->formattype = type;
-    data->scaleMode = GetScaleQuality();
+    scaleMode = GetScaleQuality();
     renderdata->glEnable(data->type);
     renderdata->glBindTexture(data->type, data->texture);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode);
+    renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode);
     renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
                                 GL_CLAMP_TO_EDGE);
     renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
@@ -524,6 +524,10 @@
         renderdata->glEnable(data->type);
 
         renderdata->glBindTexture(data->type, data->utexture);
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
+                                    scaleMode);
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
+                                    scaleMode);
         renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
                                     GL_CLAMP_TO_EDGE);
         renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
@@ -532,6 +536,10 @@
                                  texture_h/2, 0, format, type, NULL);
 
         renderdata->glBindTexture(data->type, data->vtexture);
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
+                                    scaleMode);
+        renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
+                                    scaleMode);
         renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
                                     GL_CLAMP_TO_EDGE);
         renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
@@ -855,34 +863,14 @@
     if (texturedata->yuv) {
         data->glActiveTextureARB(GL_TEXTURE2_ARB);
         data->glBindTexture(texturedata->type, texturedata->vtexture);
-        if (texturedata->scaleMode != data->current.scaleMode) {
-            data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
-                                  texturedata->scaleMode);
-            data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
-                                  texturedata->scaleMode);
-        }
 
         data->glActiveTextureARB(GL_TEXTURE1_ARB);
         data->glBindTexture(texturedata->type, texturedata->utexture);
-        if (texturedata->scaleMode != data->current.scaleMode) {
-            data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
-                                  texturedata->scaleMode);
-            data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
-                                  texturedata->scaleMode);
-        }
 
         data->glActiveTextureARB(GL_TEXTURE0_ARB);
     }
     data->glBindTexture(texturedata->type, texturedata->texture);
 
-    if (texturedata->scaleMode != data->current.scaleMode) {
-        data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
-                              texturedata->scaleMode);
-        data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
-                              texturedata->scaleMode);
-        data->current.scaleMode = texturedata->scaleMode;
-    }
-
     if (texture->modMode) {
         GL_SetColor(data, texture->r, texture->g, texture->b, texture->a);
     } else {
--- a/src/render/opengles/SDL_render_gles.c	Mon Mar 21 16:36:17 2011 -0700
+++ b/src/render/opengles/SDL_render_gles.c	Mon Mar 21 17:15:49 2011 -0700
@@ -88,7 +88,6 @@
     struct {
         Uint32 color;
         int blendMode;
-        GLenum scaleMode;
         SDL_bool tex_coords;
     } current;
 
@@ -106,7 +105,6 @@
     GLenum formattype;
     void *pixels;
     int pitch;
-    GLenum scaleMode;
 } GLES_TextureData;
 
 static void
@@ -175,7 +173,6 @@
 
     data->current.color = 0;
     data->current.blendMode = -1;
-    data->current.scaleMode = 0;
     data->current.tex_coords = SDL_FALSE;
 
     glDisable(GL_DEPTH_TEST);
@@ -312,6 +309,7 @@
     GLint internalFormat;
     GLenum format, type;
     int texture_w, texture_h;
+    GLenum scaleMode;
     GLenum result;
 
     GLES_ActivateRenderer(renderer);
@@ -358,8 +356,10 @@
 
     data->format = format;
     data->formattype = type;
-    data->scaleMode = GetScaleQuality();
+    scaleMode = GetScaleQuality();
     glBindTexture(data->type, data->texture);
+    glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode);
+    glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode);
     glTexParameteri(data->type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     glTexParameteri(data->type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
@@ -674,14 +674,6 @@
 
     glBindTexture(texturedata->type, texturedata->texture);
 
-    if (texturedata->scaleMode != data->current.scaleMode) {
-        glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
-                        texturedata->scaleMode);
-        glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER,
-                        texturedata->scaleMode);
-        data->current.scaleMode = texturedata->scaleMode;
-    }
-
     if (texture->modMode) {
         GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a);
     } else {
--- a/src/render/opengles2/SDL_render_gles2.c	Mon Mar 21 16:36:17 2011 -0700
+++ b/src/render/opengles2/SDL_render_gles2.c	Mon Mar 21 17:15:49 2011 -0700
@@ -59,7 +59,6 @@
     GLenum pixel_type;
     void *pixel_data;
     size_t pitch;
-    GLenum scaleMode;
 } GLES2_TextureData;
 
 typedef struct GLES2_ShaderCacheEntry
@@ -122,7 +121,6 @@
     SDL_GLContext *context;
     struct {
         int blendMode;
-        GLenum scaleMode;
         SDL_bool tex_coords;
     } current;
 
@@ -253,6 +251,7 @@
     GLES2_TextureData *tdata;
     GLenum format;
     GLenum type;
+    GLenum scaleMode;
 
     GLES2_ActivateRenderer(renderer);
 
@@ -279,7 +278,7 @@
     tdata->texture_type = GL_TEXTURE_2D;
     tdata->pixel_format = format;
     tdata->pixel_type = type;
-    tdata->scaleMode = GetScaleQuality();
+    scaleMode = GetScaleQuality();
 
     /* Allocate a blob for image data */
     if (texture->access == SDL_TEXTUREACCESS_STREAMING)
@@ -299,6 +298,8 @@
     glGenTextures(1, &tdata->texture);
     glActiveTexture(GL_TEXTURE0);
     glBindTexture(tdata->texture_type, tdata->texture);
+    glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode);
+    glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode);
     glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
@@ -1007,14 +1008,6 @@
     glBindTexture(tdata->texture_type, tdata->texture);
     glUniform1i(locTexture, 0);
 
-    if (tdata->scaleMode != rdata->current.scaleMode) {
-        glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER,
-                        tdata->scaleMode);
-        glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER,
-                        tdata->scaleMode);
-        rdata->current.scaleMode = tdata->scaleMode;
-    }
-
     /* Configure color modulation */
     locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION];
     glUniform4f(locModulation,
@@ -1083,7 +1076,6 @@
     }
 
     rdata->current.blendMode = -1;
-    rdata->current.scaleMode = 0;
     rdata->current.tex_coords = SDL_FALSE;
 
     glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION);