+
+ if (old_aniso != gl_texture_anisotropy.integer)
+ {
+ gltextureimage_t *image;
+ gltexturepool_t *pool;
+ GLint oldbindtexnum;
+
+ old_aniso = bound(1, gl_texture_anisotropy.integer, gl_max_anisotropy);
+
+ Cvar_SetValueQuick(&gl_texture_anisotropy, old_aniso);
+
+ for (pool = gltexturepoolchain;pool;pool = pool->next)
+ {
+ for (image = pool->imagechain;image;image = image->imagechain)
+ {
+ // only update already uploaded images
+ if (!(image->flags & GLTEXF_UPLOAD))
+ {
+ qglGetIntegerv(gltexturetypebindingenums[image->texturetype], &oldbindtexnum);
+
+ qglBindTexture(gltexturetypeenums[image->texturetype], image->texnum);
+ qglTexParameteri(gltexturetypeenums[image->texturetype], GL_TEXTURE_MAX_ANISOTROPY_EXT, old_aniso);CHECKGLERROR
+
+ qglBindTexture(gltexturetypeenums[image->texturetype], oldbindtexnum);
+ }
+ }
+ }
+ }
+}
+
+void R_MakeResizeBufferBigger(int size)
+{
+ if (resizebuffersize < size)
+ {
+ resizebuffersize = size;
+ if (resizebuffer)
+ Mem_Free(resizebuffer);
+ if (colorconvertbuffer)
+ Mem_Free(colorconvertbuffer);
+ resizebuffer = Mem_Alloc(texturemempool, resizebuffersize);
+ colorconvertbuffer = Mem_Alloc(texturemempool, resizebuffersize);
+ if (!resizebuffer || !colorconvertbuffer)
+ Host_Error("R_Upload: out of memory\n");
+ }
+}
+
+static void GL_SetupTextureParameters(int flags, int texturetype)
+{
+ int textureenum = gltexturetypeenums[texturetype];
+ int wrapmode = ((flags & TEXF_CLAMP) && gl_support_clamptoedge) ? GL_CLAMP_TO_EDGE : GL_REPEAT;
+
+ CHECKGLERROR
+
+ if (gl_support_anisotropy)
+ {
+ int aniso = bound(1, gl_texture_anisotropy.integer, gl_max_anisotropy);
+ if (gl_texture_anisotropy.integer != aniso)
+ Cvar_SetValueQuick(&gl_texture_anisotropy, aniso);
+ qglTexParameteri(textureenum, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso);CHECKGLERROR
+ }
+ qglTexParameteri(textureenum, GL_TEXTURE_WRAP_S, wrapmode);CHECKGLERROR
+ qglTexParameteri(textureenum, GL_TEXTURE_WRAP_T, wrapmode);CHECKGLERROR
+ if (gltexturetypedimensions[texturetype] >= 3)
+ {
+ qglTexParameteri(textureenum, GL_TEXTURE_WRAP_R, wrapmode);CHECKGLERROR
+ }
+
+ CHECKGLERROR
+ if (flags & TEXF_FORCENEAREST)
+ {
+ if (flags & TEXF_MIPMAP)
+ {
+ qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);CHECKGLERROR
+ }
+ else
+ {
+ qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_NEAREST);CHECKGLERROR
+ }
+ qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, GL_NEAREST);CHECKGLERROR
+ }
+ else if (flags & TEXF_FORCELINEAR)
+ {
+ if (flags & TEXF_MIPMAP)
+ {
+ if (gl_filter_min == GL_NEAREST_MIPMAP_LINEAR || gl_filter_min == GL_LINEAR_MIPMAP_LINEAR)
+ {
+ qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);CHECKGLERROR
+ }
+ else
+ {
+ qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);CHECKGLERROR
+ }
+ }
+ else
+ {
+ qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR);CHECKGLERROR
+ }
+ qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, GL_LINEAR);CHECKGLERROR
+ }
+ else
+ {
+ if (flags & TEXF_MIPMAP)
+ {
+ qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_min);CHECKGLERROR
+ }
+ else
+ {
+ qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_mag);CHECKGLERROR
+ }
+ qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, gl_filter_mag);CHECKGLERROR
+ }
+
+ CHECKGLERROR