X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=gl_textures.c;h=710d2164010a733a7e9d56cdc0d9eed96b0e9c0e;hb=7139b3ada26cb263795aa7f965197428c4c7ea7d;hp=076f12da5da407ca9c8a5327b6f7b2a53ae62a2d;hpb=6fb3daf04a26ac42b15c02c2276f6820ffe795a8;p=xonotic%2Fdarkplaces.git diff --git a/gl_textures.c b/gl_textures.c index 076f12da..710d2164 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -1,6 +1,7 @@ #include "quakedef.h" #include "image.h" +#include "jpeg.h" cvar_t r_max_size = {CVAR_SAVE, "r_max_size", "2048"}; cvar_t r_max_scrapsize = {CVAR_SAVE, "r_max_scrapsize", "256"}; @@ -476,11 +477,16 @@ static void r_textures_start(void) texturemempool = Mem_AllocPool("Texture Info"); texturedatamempool = Mem_AllocPool("Texture Storage (not yet uploaded)"); textureprocessingmempool = Mem_AllocPool("Texture Processing Buffers"); + + JPEG_OpenLibrary (); } static void r_textures_shutdown(void) { rtexturepool_t *temp; + + JPEG_CloseLibrary (); + while(gltexturepoolchain) { temp = (rtexturepool_t *) gltexturepoolchain; @@ -953,6 +959,8 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden 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); // clear the alpha flag if the texture has no transparent pixels switch(textype) @@ -1023,7 +1031,7 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden { glt->inputtexels = Mem_Alloc(texturedatamempool, size); if (glt->inputtexels == NULL) - Sys_Error("R_SetupTexture: out of memory\n"); + Sys_Error("R_LoadTexture: out of memory\n"); memcpy(glt->inputtexels, data, size); } else