]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - image_png.c
changed collision brush loader to not discard planes that don't produce a polygon...
[xonotic/darkplaces.git] / image_png.c
index 2adb961727a8e7db4ad6cd9dc58c6774e8e1b9b6..2f8e76a7cfb3273c6cd931d5ff41097dd442b11d 100644 (file)
@@ -111,6 +111,7 @@ qboolean PNG_OpenLibrary (void)
                "libpng12.0.dylib",
 #else
                "libpng12.so.0",
+               "libpng.so", // FreeBSD
 #endif
                NULL
        };
@@ -170,7 +171,7 @@ void PNG_CloseLibrary (void)
 #define PNG_INFO_tRNS 0x0010
 
 // this struct is only used for status information during loading
-struct
+static struct
 {
        const unsigned char     *tmpBuf;
        int             tmpBuflength;
@@ -212,7 +213,7 @@ void PNG_fReadData(void *png, unsigned char *data, size_t length)
        }
        memcpy(data, my_png.tmpBuf + my_png.tmpi, length);
        my_png.tmpi += (int)length;
-       Com_HexDumpToConsole(data, (int)length);
+       //Com_HexDumpToConsole(data, (int)length);
 }
 
 void PNG_error_fn(void *png, const char *message)
@@ -243,13 +244,21 @@ unsigned char *PNG_LoadImage (const unsigned char *raw, int filesize, int matchw
 
        if(qpng_sig_cmp(raw, 0, filesize))
                return NULL;
-       png = qpng_create_read_struct(PNG_LIBPNG_VER_STRING, 0, PNG_error_fn, PNG_warning_fn);
+       png = (void *)qpng_create_read_struct(PNG_LIBPNG_VER_STRING, 0, (void *)PNG_error_fn, (void *)PNG_warning_fn);
        if(!png)
                return NULL;
 
        // NOTE: this relies on jmp_buf being the first thing in the png structure
        // created by libpng! (this is correct for libpng 1.2.x)
+#ifdef __cplusplus
+#ifdef MACOSX
+       if (setjmp((int *)png))
+#else
+       if (setjmp((__jmp_buf_tag *)png))
+#endif
+#else
        if (setjmp(png))
+#endif
        {
                qpng_destroy_read_struct(&png, &pnginfo, 0);
                return NULL;
@@ -276,7 +285,7 @@ unsigned char *PNG_LoadImage (const unsigned char *raw, int filesize, int matchw
        //my_png.Interlace      = 0;
        //my_png.Compression    = 0;
        //my_png.Filter         = 0;
-       qpng_set_read_fn(png, ioBuffer, PNG_fReadData);
+       qpng_set_read_fn(png, ioBuffer, (void *)PNG_fReadData);
        qpng_read_info(png, pnginfo);
        qpng_get_IHDR(png, pnginfo, &my_png.Width, &my_png.Height,&my_png.BitDepth, &my_png.ColorType, &my_png.Interlace, &my_png.Compression, &my_png.Filter);
        if ((matchwidth && my_png.Width != (unsigned int)matchwidth) || (matchheight && my_png.Height != (unsigned int)matchheight))
@@ -307,10 +316,10 @@ unsigned char *PNG_LoadImage (const unsigned char *raw, int filesize, int matchw
        my_png.FRowBytes = qpng_get_rowbytes(png, pnginfo);
        my_png.BytesPerPixel = qpng_get_channels(png, pnginfo);
 
-       my_png.FRowPtrs = Mem_Alloc(tempmempool, my_png.Height * sizeof(*my_png.FRowPtrs));
+       my_png.FRowPtrs = (unsigned char **)Mem_Alloc(tempmempool, my_png.Height * sizeof(*my_png.FRowPtrs));
        if (my_png.FRowPtrs)
        {
-               my_png.Data = Mem_Alloc(tempmempool, my_png.Height * my_png.FRowBytes);
+               my_png.Data = (unsigned char *)Mem_Alloc(tempmempool, my_png.Height * my_png.FRowBytes);
                if(my_png.Data)
                {
                        for(y = 0;y < my_png.Height;y++)