]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_textures.c
*** empty log message ***
[xonotic/darkplaces.git] / gl_textures.c
index f3e8a1b24725f79354ef47fbb8096cea351b55e4..0b03b0a4d020718dadec181f151cd255f3930e9f 100644 (file)
@@ -8,7 +8,7 @@ cvar_t  r_max_scrapsize = {CVAR_SAVE, "r_max_scrapsize", "256"};
 cvar_t r_picmip = {CVAR_SAVE, "r_picmip", "0"};
 cvar_t r_lerpimages = {CVAR_SAVE, "r_lerpimages", "1"};
 cvar_t r_precachetextures = {CVAR_SAVE, "r_precachetextures", "1"};
-cvar_t  gl_texture_anisotropy = {CVAR_SAVE, "gl_texture_anisotropy", "0"};
+cvar_t  gl_texture_anisotropy = {CVAR_SAVE, "gl_texture_anisotropy", "1"};
 
 int            gl_filter_min = GL_LINEAR_MIPMAP_LINEAR;
 int            gl_filter_mag = GL_LINEAR;
@@ -338,11 +338,11 @@ static void GL_TextureMode_f (void)
                {
                        if (gl_filter_min == modes[i].minification)
                        {
-                               Con_Printf ("%s\n", modes[i].name);
+                               Con_Printf("%s\n", modes[i].name);
                                return;
                        }
                }
-               Con_Print("current filter is unknown???\n");
+               Con_Print("current filter is unknown???\n");
                return;
        }
 
@@ -351,7 +351,7 @@ static void GL_TextureMode_f (void)
                        break;
        if (i == 6)
        {
-               Con_Print("bad filter name\n");
+               Con_Print("bad filter name\n");
                return;
        }
 
@@ -452,7 +452,7 @@ static void R_TextureStats_f(void)
        int loaded;
        gltexture_t *glt;
        gltexturepool_t *pool;
-       Con_Printf("glsize input loaded mip alpha name\n");
+       Con_Print("glsize input loaded mip alpha name\n");
        for (pool = gltexturepoolchain;pool;pool = pool->next)
        {
                for (glt = pool->gltchain;glt;glt = glt->chain)
@@ -571,40 +571,62 @@ static void GL_SetupTextureParameters(int flags, int texturetype)
        CHECKGLERROR
 
        if (gl_support_anisotropy)
-               qglTexParameterf(textureenum, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_anisotropy.value);
-       qglTexParameteri(textureenum, GL_TEXTURE_WRAP_S, wrapmode);
-       qglTexParameteri(textureenum, GL_TEXTURE_WRAP_T, wrapmode);
+       {
+               int aniso = bound(1, gl_texture_anisotropy.integer, 128);
+               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);
+       {
+               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);
+               {
+                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);CHECKGLERROR
+               }
                else
-                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-               qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+               {
+                       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);
+                       {
+                               qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);CHECKGLERROR
+                       }
                        else
-                               qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+                       {
+                               qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);CHECKGLERROR
+                       }
                }
                else
-                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-               qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+               {
+                       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);
+               {
+                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_min);CHECKGLERROR
+               }
                else
-                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
-               qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+               {
+                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_mag);CHECKGLERROR
+               }
+               qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, gl_filter_mag);CHECKGLERROR
        }
 
        CHECKGLERROR
@@ -631,7 +653,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                if (glt->image->flags & GLTEXF_UPLOAD)
                {
                        glt->image->flags &= ~GLTEXF_UPLOAD;
-                       Con_DPrintf("uploaded new fragments image\n");
+                       Con_DPrint("uploaded new fragments image\n");
                        R_MakeResizeBufferBigger(glt->image->width * glt->image->height * glt->image->depth * glt->image->bytesperpixel);
                        memset(resizebuffer, 255, glt->image->width * glt->image->height * glt->image->depth * glt->image->bytesperpixel);
                        switch(glt->image->texturetype)
@@ -786,7 +808,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                        for (i = 0;i < 6;i++)
                        {
                                prevbuffer = texturebuffer;
-                               texturebuffer += width * height * depth * glt->textype->inputbytesperpixel;
+                               texturebuffer += glt->width * glt->height * glt->depth * glt->textype->inputbytesperpixel;
                                if (glt->width != width || glt->height != height || glt->depth != depth)
                                {
                                        Image_Resample(prevbuffer, glt->width, glt->height, glt->depth, resizebuffer, width, height, depth, glt->image->bytesperpixel, r_lerpimages.integer);