]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_textures.c
added Print versions of Printf functions and made all calls that do not need formatin...
[xonotic/darkplaces.git] / gl_textures.c
index e1ccf153a9f1eb5ce7bb4388021a9c2fb5aaa3f2..ad9a4ca947caf50e3d2fae6e59832a544405fdb7 100644 (file)
@@ -8,6 +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"};
 
 int            gl_filter_min = GL_LINEAR_MIPMAP_LINEAR;
 int            gl_filter_mag = GL_LINEAR;
@@ -38,11 +39,12 @@ typedef struct
 }
 textypeinfo_t;
 
-static textypeinfo_t textype_palette       = {TEXTYPE_PALETTE, 1, 4, GL_RGBA, 3};
-static textypeinfo_t textype_rgb           = {TEXTYPE_RGB    , 3, 3, GL_RGB , 3};
-static textypeinfo_t textype_rgba          = {TEXTYPE_RGBA   , 4, 4, GL_RGBA, 3};
-static textypeinfo_t textype_palette_alpha = {TEXTYPE_PALETTE, 1, 4, GL_RGBA, 4};
-static textypeinfo_t textype_rgba_alpha    = {TEXTYPE_RGBA   , 4, 4, GL_RGBA, 4};
+static textypeinfo_t textype_palette       = {TEXTYPE_PALETTE, 1, 4, GL_RGBA   , 3};
+static textypeinfo_t textype_rgb           = {TEXTYPE_RGB    , 3, 3, GL_RGB    , 3};
+static textypeinfo_t textype_rgba          = {TEXTYPE_RGBA   , 4, 4, GL_RGBA   , 3};
+static textypeinfo_t textype_palette_alpha = {TEXTYPE_PALETTE, 1, 4, GL_RGBA   , 4};
+static textypeinfo_t textype_rgba_alpha    = {TEXTYPE_RGBA   , 4, 4, GL_RGBA   , 4};
+static textypeinfo_t textype_dsdt          = {TEXTYPE_DSDT   , 2, 2, GL_DSDT_NV, GL_DSDT8_NV};
 
 // a tiling texture (most common type)
 #define GLIMAGETYPE_TILE 0
@@ -166,6 +168,8 @@ static textypeinfo_t *R_GetTexTypeInfo(int textype, int flags)
                        return &textype_rgb;
                case TEXTYPE_RGBA:
                        return &textype_rgba;
+               case TEXTYPE_DSDT:
+                       return &textype_dsdt;
                default:
                        Host_Error("R_GetTexTypeInfo: unknown texture format\n");
                        return NULL;
@@ -334,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;
        }
 
@@ -347,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;
        }
 
@@ -361,7 +365,7 @@ static void GL_TextureMode_f (void)
                for (image = pool->imagechain;image;image = image->imagechain)
                {
                        // only update already uploaded images
-                       if (!(image->flags & GLTEXF_UPLOAD))
+                       if (!(image->flags & GLTEXF_UPLOAD) && !(image->flags & (TEXF_FORCENEAREST | TEXF_FORCELINEAR)))
                        {
                                qglGetIntegerv(gltexturetypebindingenums[image->texturetype], &oldbindtexnum);
                                qglBindTexture(gltexturetypeenums[image->texturetype], image->texnum);
@@ -448,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)
@@ -519,6 +523,7 @@ void R_Textures_Init (void)
        Cvar_RegisterVariable (&r_picmip);
        Cvar_RegisterVariable (&r_lerpimages);
        Cvar_RegisterVariable (&r_precachetextures);
+       Cvar_RegisterVariable (&gl_texture_anisotropy);
 
        R_RegisterModule("R_Textures", r_textures_start, r_textures_shutdown, r_textures_newmap);
 }
@@ -565,6 +570,8 @@ 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);
        if (gltexturetypedimensions[texturetype] >= 3)
@@ -624,7 +631,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)
@@ -779,7 +786,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);
@@ -1028,6 +1035,8 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
                        }
                }
                break;
+       case TEXTYPE_DSDT:
+               break;
        default:
                Host_Error("R_LoadTexture: unknown texture type\n");
        }