]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_textures.c
added S_RawSamples_Enqueue, S_RawSamples_Dequeue, and S_RawSamples_ClearQueue functio...
[xonotic/darkplaces.git] / gl_textures.c
index f8f1fa3828dd2e7c4fc53d29698732b61721bd3f..43bf88e8b8e5f1522cfba9f97f191102f82662cc 100644 (file)
@@ -1,3 +1,4 @@
+
 #include "quakedef.h"
 
 cvar_t r_max_size = {CVAR_SAVE, "r_max_size", "2048"};
@@ -6,7 +7,7 @@ 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"};
 
-int            gl_filter_min = GL_LINEAR_MIPMAP_LINEAR; //NEAREST;
+int            gl_filter_min = GL_LINEAR_MIPMAP_LINEAR;
 int            gl_filter_mag = GL_LINEAR;
 
 
@@ -231,7 +232,7 @@ static void R_FreeTexture(gltexture_t *glt)
                {
                        texnum = image->texnum;
                        gltexnuminuse[image->texnum] = 0;
-                       glDeleteTextures(1, &texnum);
+                       qglDeleteTextures(1, &texnum);
                }
                if (image->blockallocation)
                        Mem_Free(image->blockallocation);
@@ -269,7 +270,6 @@ rtexturepool_t *R_AllocTexturePool(void)
        pool = Mem_Alloc(texturemempool, sizeof(gltexturepool_t));
        if (pool == NULL)
                return NULL;
-       //memset(pool, 0, sizeof(gltexturepool_t));
        pool->next = gltexturepoolchain;
        gltexturepoolchain = pool;
        pool->sentinel = TEXTUREPOOL_SENTINEL;
@@ -360,12 +360,12 @@ static void GL_TextureMode_f (void)
                        // only update already uploaded images
                        if (!(image->flags & GLTEXF_UPLOAD))
                        {
-                               glBindTexture(GL_TEXTURE_2D, image->texnum);
+                               qglBindTexture(GL_TEXTURE_2D, image->texnum);
                                if (image->flags & TEXF_MIPMAP)
-                                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+                                       qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
                                else
-                                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
-                               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+                                       qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+                               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
                        }
                }
        }
@@ -462,7 +462,7 @@ char engineversion[40];
 static void r_textures_start(void)
 {
        // deal with size limits of various drivers (3dfx in particular)
-       glGetIntegerv(GL_MAX_TEXTURE_SIZE, &realmaxsize);
+       qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &realmaxsize);
        CHECKGLERROR
 
        // use the largest scrap texture size we can (not sure if this is really a good idea)
@@ -472,7 +472,6 @@ static void r_textures_start(void)
        texturedatamempool = Mem_AllocPool("Texture Storage (not yet uploaded)");
        textureprocessingmempool = Mem_AllocPool("Texture Processing Buffers");
        gltexnuminuse = Mem_Alloc(texturemempool, MAX_GLTEXTURES);
-       //memset(gltexnuminuse, 0, MAX_GLTEXTURES);
 }
 
 static void r_textures_shutdown(void)
@@ -484,12 +483,6 @@ static void r_textures_shutdown(void)
                R_FreeTexturePool(&temp);
        }
 
-       /*
-       if (resizebuffer) Mem_Free(resizebuffer);resizebuffer = NULL;
-       if (colorconvertbuffer) Mem_Free(colorconvertbuffer);colorconvertbuffer = NULL;
-       if (texturebuffer) Mem_Free(texturebuffer);texturebuffer = NULL;
-       if (gltexnuminuse) Mem_Free(gltexnuminuse);gltexnuminuse = NULL;
-       */
        resizebuffersize = 0;
        texturebuffersize = 0;
        resizebuffer = NULL;
@@ -525,7 +518,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
        qbyte *prevbuffer;
        prevbuffer = data;
 
-       glBindTexture(GL_TEXTURE_2D, glt->image->texnum);
+       qglBindTexture(GL_TEXTURE_2D, glt->image->texnum);
        CHECKGLERROR
 
        gl_backend_rebindtextures = true;
@@ -552,11 +545,11 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                        Con_DPrintf("uploaded new fragments image\n");
                        glt->image->flags &= ~GLTEXF_UPLOAD;
                        memset(resizebuffer, 255, glt->image->width * glt->image->height * glt->image->bytesperpixel);
-                       glTexImage2D (GL_TEXTURE_2D, 0, glt->image->glinternalformat, glt->image->width, glt->image->height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, resizebuffer);
+                       qglTexImage2D (GL_TEXTURE_2D, 0, glt->image->glinternalformat, glt->image->width, glt->image->height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, resizebuffer);
                        CHECKGLERROR
-                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+                       qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
                        CHECKGLERROR
-                       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+                       qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
                        CHECKGLERROR
                }
 
@@ -573,7 +566,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                        prevbuffer = colorconvertbuffer;
                }
 
-               glTexSubImage2D(GL_TEXTURE_2D, 0, glt->x, glt->y, glt->width, glt->height, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+               qglTexSubImage2D(GL_TEXTURE_2D, 0, glt->x, glt->y, glt->width, glt->height, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
                CHECKGLERROR
                return;
        }
@@ -634,7 +627,7 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                internalformat = 4;
 
        mip = 0;
-       glTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+       qglTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
        CHECKGLERROR
        if (glt->flags & TEXF_MIPMAP)
        {
@@ -643,20 +636,20 @@ static void R_Upload(gltexture_t *glt, qbyte *data)
                        Image_MipReduce(prevbuffer, resizebuffer, &width, &height, 1, 1, glt->image->bytesperpixel);
                        prevbuffer = resizebuffer;
 
-                       glTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
+                       qglTexImage2D(GL_TEXTURE_2D, mip++, internalformat, width, height, 0, glt->image->glformat, GL_UNSIGNED_BYTE, prevbuffer);
                        CHECKGLERROR
                }
 
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
                CHECKGLERROR
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
                CHECKGLERROR
        }
        else
        {
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
                CHECKGLERROR
-               glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+               qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
                CHECKGLERROR
        }
 }
@@ -719,7 +712,6 @@ static void R_FindImageForTexture(gltexture_t *glt)
                image = Mem_Alloc(texturemempool, sizeof(gltextureimage_t));
                if (image == NULL)
                        Sys_Error("R_FindImageForTexture: ran out of memory\n");
-               //memset(image, 0, sizeof(*image));
                image->type = GLIMAGETYPE_FRAGMENTS;
                image->width = block_size;
                image->height = block_size;
@@ -738,7 +730,6 @@ static void R_FindImageForTexture(gltexture_t *glt)
                image = Mem_Alloc(texturemempool, sizeof(gltextureimage_t));
                if (image == NULL)
                        Sys_Error("R_FindImageForTexture: ran out of memory\n");
-               //memset(image, 0, sizeof(*image));
                image->type = GLIMAGETYPE_TILE;
                image->blockallocation = NULL;
 
@@ -810,7 +801,6 @@ static gltexture_t *R_SetupTexture(gltexturepool_t *pool, char *identifier, int
 {
        gltexture_t *glt;
        glt = Mem_Alloc(texturemempool, sizeof(gltexture_t));
-       //memset(glt, 0, sizeof(gltexture_t));
        if (identifier)
        {
                glt->identifier = Mem_Alloc(texturemempool, strlen(identifier)+1);
@@ -872,10 +862,6 @@ rtexture_t *R_LoadTexture (rtexturepool_t *rtexturepool, char *identifier, int w
 
        texinfo = R_GetTexTypeInfo(textype, flags);
 
-       // data can be NULL
-//     if (data == NULL)
-//             Host_Error("R_LoadTexture: \"%s\" has no data\n", identifier);
-
        if (flags & TEXF_FRAGMENT)
        {
                if (width > block_size || height > block_size)
@@ -955,9 +941,6 @@ rtexture_t *R_ProceduralTexture (rtexturepool_t *rtexturepool, char *identifier,
 
        texinfo = R_GetTexTypeInfo(textype, flags);
 
-       // no function is supported, for odd uses
-//     if (generate == NULL)
-//             Host_Error("R_ProceduralTexture: \"%s\" has no generate function\n", identifier);
        if (flags & TEXF_FRAGMENT)
        {
                if (width > block_size || height > block_size)
@@ -1086,19 +1069,7 @@ void R_UpdateTexture(rtexture_t *rt, qbyte *data)
        if (data == NULL)
                Host_Error("R_UpdateTexture: no data supplied\n");
        glt = (gltexture_t *)rt;
-       /*
-       if (!(glt->flags & GLTEXF_PROCEDURAL))
-       {
-               if (glt->inputtexels == NULL)
-               {
-                       glt->inputtexels = Mem_Alloc(texturedatamempool, glt->width * glt->height * glt->textype->inputbytesperpixel);
-                       if (glt->inputtexels == NULL)
-                               Host_Error("R_UpdateTexture: ran out of memory\n");
-               }
-               memcpy(glt->inputtexels, data, glt->width * glt->height * glt->textype->inputbytesperpixel);
-       }
-       R_Upload(glt, data);
-       */
+
        // if it has not been uploaded yet, update the data that will be used when it is
        if (glt->inputtexels)
                memcpy(glt->inputtexels, data, glt->width * glt->height * glt->textype->inputbytesperpixel);