]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_textures.c
changed TEXF_CLAMP to use GL_CLAMP_TO_EDGE (GL_EXT_texture_edge_clamp or GL_SGIS_text...
[xonotic/darkplaces.git] / gl_textures.c
index edd0b7dbac9ba494ea1774fe31567f2ca819c61f..f0b74a3c902fa4ea9a0ecc27c26a4f62fcaf0c27 100644 (file)
@@ -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"};
@@ -120,7 +121,7 @@ gltexture_t;
 
 typedef struct gltexturepool_s
 {
-       int sentinel;
+       unsigned int sentinel;
        struct gltextureimage_s *imagechain;
        struct gltexture_s *gltchain;
        struct gltexturepool_s *next;
@@ -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;
@@ -552,7 +558,7 @@ void R_MakeResizeBufferBigger(int size)
 static void GL_SetupTextureParameters(int flags, int texturetype)
 {
        int textureenum = gltexturetypeenums[texturetype];
-       int wrapmode = (flags & TEXF_CLAMP) ? GL_CLAMP : GL_REPEAT;
+       int wrapmode = ((flags & TEXF_CLAMP) && gl_support_clamptoedge) ? GL_CLAMP_TO_EDGE : GL_REPEAT;
 
        CHECKGLERROR
 
@@ -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