]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_textures.c
made darkplaces compile successfully with g++ to test for errors C doesn't care about...
[xonotic/darkplaces.git] / gl_textures.c
index 982ea4d3bde8eafcbf293e8083de2e7f58e3ba95..3d2c5b06f7ba9d4020ee53c9aa2e2207c9285371 100644 (file)
@@ -238,7 +238,7 @@ void R_FreeTexture(rtexture_t *rt)
                        else
                                Host_Error("R_FreeTexture: image not linked in pool\n");
                        if (image->texnum)
-                               qglDeleteTextures(1, &image->texnum);
+                               qglDeleteTextures(1, (GLuint *)&image->texnum);
                        if (image->blockallocation)
                                Mem_Free(image->blockallocation);
                        Mem_Free(image);
@@ -255,7 +255,7 @@ rtexturepool_t *R_AllocTexturePool(void)
        gltexturepool_t *pool;
        if (texturemempool == NULL)
                return NULL;
-       pool = Mem_Alloc(texturemempool, sizeof(gltexturepool_t));
+       pool = (gltexturepool_t *)Mem_Alloc(texturemempool, sizeof(gltexturepool_t));
        if (pool == NULL)
                return NULL;
        pool->next = gltexturepoolchain;
@@ -283,7 +283,7 @@ void R_FreeTexturePool(rtexturepool_t **rtexturepool)
        while (pool->gltchain)
                R_FreeTexture((rtexture_t *)pool->gltchain);
        if (pool->imagechain)
-               Sys_Error("R_FreeTexturePool: not all images freed\n");
+               Con_Printf("R_FreeTexturePool: not all images freed\n");
        Mem_Free(pool);
 }
 
@@ -458,8 +458,6 @@ static void R_TextureStats_f(void)
        R_TextureStats_Print(true, true, true);
 }
 
-char engineversion[40];
-
 static void r_textures_start(void)
 {
        // deal with size limits of various drivers (3dfx in particular)
@@ -552,7 +550,7 @@ void R_Textures_Frame (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_MIPMAP))
                                {
                                        qglGetIntegerv(gltexturetypebindingenums[image->texturetype], &oldbindtexnum);
 
@@ -575,8 +573,8 @@ void R_MakeResizeBufferBigger(int size)
                        Mem_Free(resizebuffer);
                if (colorconvertbuffer)
                        Mem_Free(colorconvertbuffer);
-               resizebuffer = Mem_Alloc(texturemempool, resizebuffersize);
-               colorconvertbuffer = Mem_Alloc(texturemempool, resizebuffersize);
+               resizebuffer = (qbyte *)Mem_Alloc(texturemempool, resizebuffersize);
+               colorconvertbuffer = (qbyte *)Mem_Alloc(texturemempool, resizebuffersize);
                if (!resizebuffer || !colorconvertbuffer)
                        Host_Error("R_Upload: out of memory\n");
        }
@@ -589,7 +587,7 @@ static void GL_SetupTextureParameters(int flags, int texturetype)
 
        CHECKGLERROR
 
-       if (gl_support_anisotropy)
+       if (gl_support_anisotropy && (flags & TEXF_MIPMAP))
        {
                int aniso = bound(1, gl_texture_anisotropy.integer, gl_max_anisotropy);
                if (gl_texture_anisotropy.integer != aniso)
@@ -926,9 +924,12 @@ static void R_FindImageForTexture(gltexture_t *glt)
                        return;
                }
 
-               image = Mem_Alloc(texturemempool, sizeof(gltextureimage_t));
+               image = (gltextureimage_t *)Mem_Alloc(texturemempool, sizeof(gltextureimage_t));
                if (image == NULL)
-                       Sys_Error("R_FindImageForTexture: ran out of memory\n");
+               {
+                       Con_Printf ("R_FindImageForTexture: ran out of memory\n");
+                       return;
+               }
                image->type = GLIMAGETYPE_FRAGMENTS;
                // make sure the created image is big enough for the fragment
                for (image->width = block_size;image->width < glt->width;image->width <<= 1);
@@ -938,7 +939,7 @@ static void R_FindImageForTexture(gltexture_t *glt)
                image->depth = 1;
                if (gltexturetypedimensions[glt->texturetype] >= 3)
                        for (image->depth = block_size;image->depth < glt->depth;image->depth <<= 1);
-               image->blockallocation = Mem_Alloc(texturemempool, image->width * sizeof(short));
+               image->blockallocation = (short int *)Mem_Alloc(texturemempool, image->width * sizeof(short));
                memset(image->blockallocation, 0, image->width * sizeof(short));
 
                x = 0;
@@ -951,9 +952,12 @@ static void R_FindImageForTexture(gltexture_t *glt)
        {
                for (imagechainpointer = &pool->imagechain;*imagechainpointer;imagechainpointer = &(*imagechainpointer)->imagechain);
 
-               image = Mem_Alloc(texturemempool, sizeof(gltextureimage_t));
+               image = (gltextureimage_t *)Mem_Alloc(texturemempool, sizeof(gltextureimage_t));
                if (image == NULL)
-                       Sys_Error("R_FindImageForTexture: ran out of memory\n");
+               {
+                       Con_Printf ("R_FindImageForTexture: ran out of memory\n");
+                       return;
+               }
                image->type = GLIMAGETYPE_TILE;
                image->blockallocation = NULL;
 
@@ -980,13 +984,13 @@ static void R_FindImageForTexture(gltexture_t *glt)
        image->bytesperpixel = texinfo->internalbytesperpixel;
        image->sides = image->texturetype == GLTEXTURETYPE_CUBEMAP ? 6 : 1;
        // get a texture number to use
-       qglGenTextures(1, &image->texnum);
+       qglGenTextures(1, (GLuint *)&image->texnum);
        *imagechainpointer = image;
        image->texturecount++;
 
        glt->x = x;
        glt->y = y;
-       glt->y = z;
+       glt->z = z;
        glt->image = image;
 }
 
@@ -1018,16 +1022,28 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
                return NULL;
 
        if (flags & TEXF_FRAGMENT && texturetype != GLTEXTURETYPE_2D)
-               Sys_Error("R_LoadTexture: only 2D fragment textures implemented\n");
+       {
+               Con_Printf ("R_LoadTexture: only 2D fragment textures implemented\n");
+               return NULL;
+       }
        if (texturetype == GLTEXTURETYPE_CUBEMAP && !gl_texturecubemap)
-               Sys_Error("R_LoadTexture: cubemap texture not supported by driver\n");
+       {
+               Con_Printf ("R_LoadTexture: cubemap texture not supported by driver\n");
+               return NULL;
+       }
        if (texturetype == GLTEXTURETYPE_3D && !gl_texture3d)
-               Sys_Error("R_LoadTexture: 3d texture not supported by driver\n");
+       {
+               Con_Printf ("R_LoadTexture: 3d texture not supported by driver\n");
+               return NULL;
+       }
 
        texinfo = R_GetTexTypeInfo(textype, flags);
        size = width * height * depth * sides * texinfo->inputbytesperpixel;
        if (size < 1)
-               Sys_Error("R_LoadTexture: bogus texture size (%dx%dx%dx%dbppx%dsides = %d bytes)\n", width, height, depth, texinfo->inputbytesperpixel * 8, sides);
+       {
+               Con_Printf ("R_LoadTexture: bogus texture size (%dx%dx%dx%dbppx%dsides = %d bytes)\n", width, height, depth, texinfo->inputbytesperpixel * 8, sides);
+               return NULL;
+       }
 
        // clear the alpha flag if the texture has no transparent pixels
        switch(textype)
@@ -1076,7 +1092,7 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
                Host_Error("R_LoadTexture: unknown texture type\n");
        }
 
-       glt = Mem_Alloc(texturemempool, sizeof(gltexture_t));
+       glt = (gltexture_t *)Mem_Alloc(texturemempool, sizeof(gltexture_t));
        if (identifier)
                strlcpy (glt->identifier, identifier, sizeof(glt->identifier));
        glt->pool = pool;
@@ -1093,10 +1109,11 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
 
        if (data)
        {
-               glt->inputtexels = Mem_Alloc(texturemempool, size);
+               glt->inputtexels = (qbyte *)Mem_Alloc(texturemempool, size);
                if (glt->inputtexels == NULL)
-                       Sys_Error("R_LoadTexture: out of memory\n");
-               memcpy(glt->inputtexels, data, size);
+                       Con_Printf ("R_LoadTexture: out of memory\n");
+               else
+                       memcpy(glt->inputtexels, data, size);
        }
        else
                glt->inputtexels = NULL;