tag 400051 + patch
quit
-----
Hello Gürkan,
i've tested 0.0.2-3 (i had to build it). Of course, i still get the
same problem except that there are more informations now that you've
modified the m3dtexture.cpp:
[EMAIL PROTECTED]:~/programmes/experimental$ antigrav
libpng error: Invalid image width
setjmp: Success
Invalid: can't load texture racer.png
Width 9900836, Height 9900840
libpng error: Invalid image width
setjmp: Success
Can't load texture road.png
Width -1508628612, Height -1508628616
Erreur de segmentation
Looking at the code, i quickly spotted the culprit: width and height.
Sometime declared as unsigned int and other times assumed png_uint_32.
That's not good!
I fixed the issue using png_uint_32 all over the place.
I've created a patch that you could include in your debian package.
The patch is attached.
-Pascal
PS: Looking at your diff, i see that you've made changes to main.cpp
and m3dtexture.cpp without using the patch system. I feel like this is
not the proper way of doing things.
I believe that only files from the debian/ directory should appear in your diff.
On 11/30/06, Gürkan Sengün <[EMAIL PROTECTED]> wrote:
dear pascal
please can you try antigravitaattori 0.0.2-3 and tell me what it says?
i don't have debian gnu/linux on a 64bit platform, so i'll need your
help to get this bug sorted out.
if your mirror is slow/doesn't have it yet, try from here:
http://gnu.ethz.ch/debian/antigrav/ (you'll need to build the source
package yourself)
thank you,
guerkan
--
Homepage (http://organact.mine.nu)
Debian GNU/Linux (http://www.debian.org)
École de technologie supérieure (http://www.etsmtl.ca)
--- antigrav-0.0.2/src/m3dtexture.h.old 2006-11-30 17:01:00.000000000 -0500
+++ antigrav-0.0.2/src/m3dtexture.h 2006-11-30 17:01:20.000000000 -0500
@@ -9,7 +9,7 @@
{
std::string filename;
GLuint handle;
- unsigned int width, height;
+ png_uint_32 width, height;
};
/// A texture
@@ -34,8 +34,8 @@
m3dTexture &operator=(const m3dTexture &t);
- static int loadPNG(const char *filename, unsigned char **data, unsigned
int *width, unsigned int *height);
- static int savePNG(const char *filename, const unsigned char *data,
unsigned int width, unsigned int height);
+ static int loadPNG(const char *filename, unsigned char **data,
png_uint_32 *width, png_uint_32 *height);
+ static int savePNG(const char *filename, const unsigned char *data,
png_uint_32 width, png_uint_32 height);
static int screenshot(const char *filename);
static GLuint loadTexture(const char *filename);
@@ -48,8 +48,8 @@
static void pngWriteCallbackSTDIO(png_structp pngPtr, png_bytep data,
png_size_t length);
static void pngFlushCallbackSTDIO(png_structp pngPtr);
- static int loadPNG(unsigned char **data, unsigned int *width, unsigned
int *height, void *handle, void (*pngReadCallback)(png_structp ctx, png_bytep
area, png_size_t size));
- static int savePNG(const unsigned char *data, unsigned int width,
unsigned int height, void *handle, void (*pngWriteCallback)(png_structp pngPtr,
png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp
pngPtr));
+ static int loadPNG(unsigned char **data, png_uint_32 *width,
png_uint_32 *height, void *handle, void (*pngReadCallback)(png_structp ctx,
png_bytep area, png_size_t size));
+ static int savePNG(const unsigned char *data, png_uint_32 width,
png_uint_32 height, void *handle, void (*pngWriteCallback)(png_structp pngPtr,
png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp
pngPtr));
};
#endif
--- antigrav-0.0.2/src/m3dtexture.cpp.old 2006-11-30 17:00:56.000000000
-0500
+++ antigrav-0.0.2/src/m3dtexture.cpp 2006-11-30 17:19:53.000000000 -0500
@@ -104,6 +104,7 @@
if(loadPNG(texUnits[n].filename.c_str(), &data,
&(texUnits[n].width), &(texUnits[n].height)) != 0)
{
fprintf(stderr, "Invalid: can't load texture %s\n",
texUnits[n].filename.c_str());
+ fprintf(stderr, "Width %d, Height
%d\n",&(texUnits[n].width), &(texUnits[n].height));
return -1;
}
@@ -148,6 +149,7 @@
if(loadPNG(texUnits[n].filename.c_str(), &data,
&(texUnits[n].width), &(texUnits[n].height)) != 0)
{
fprintf(stderr, "Invalid: can't load texture %s\n",
texUnits[n].filename.c_str());
+ fprintf(stderr, "Width %d, Height
%d\n",&(texUnits[n].width), &(texUnits[n].height));
return -1;
}
@@ -204,7 +206,7 @@
@param height a pointer where to store the image width
@return 0 on success, -1 on failure
*/
-int m3dTexture::loadPNG(const char *filename, unsigned char **data, unsigned
int *width, unsigned int *height)
+int m3dTexture::loadPNG(const char *filename, unsigned char **data,
png_uint_32 *width, png_uint_32 *height)
{
FILE *f;
int result;
@@ -221,7 +223,7 @@
return result;
}
-int m3dTexture::loadPNG(unsigned char **data, unsigned int *width, unsigned
int *height, void *handle, void (*pngReadCallback)(png_structp ctx, png_bytep
area, png_size_t size))
+int m3dTexture::loadPNG(unsigned char **data, png_uint_32 *width, png_uint_32
*height, void *handle, void (*pngReadCallback)(png_structp ctx, png_bytep area,
png_size_t size))
{
png_structp pngPtr;
png_infop pngInfoPtr;
@@ -258,7 +260,7 @@
png_set_read_fn(pngPtr, handle, pngReadCallback);
png_read_info(pngPtr, pngInfoPtr);
- png_get_IHDR(pngPtr, pngInfoPtr, (png_uint_32*)width,
(png_uint_32*)height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
+ png_get_IHDR(pngPtr, pngInfoPtr, width, height, &bitDepth, &colorType,
&interlaceType, NULL, NULL);
png_set_strip_16(pngPtr);
@@ -279,7 +281,7 @@
}
png_read_update_info(pngPtr, pngInfoPtr);
- png_get_IHDR(pngPtr, pngInfoPtr, (png_uint_32*)width,
(png_uint_32*)height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
+ png_get_IHDR(pngPtr, pngInfoPtr, width, height, &bitDepth, &colorType,
&interlaceType, NULL, NULL);
(*data) = new unsigned char[(*width) * (*height) *
pngInfoPtr->channels];
if((*data) == NULL)
@@ -312,7 +314,7 @@
return 0;
}
-int m3dTexture::savePNG(const char *filename, const unsigned char *data,
unsigned int width, unsigned int height)
+int m3dTexture::savePNG(const char *filename, const unsigned char *data,
png_uint_32 width, png_uint_32 height)
{
FILE *f;
int result;
@@ -345,7 +347,7 @@
fflush(f);
}
-int m3dTexture::savePNG(const unsigned char *data, unsigned int width,
unsigned int height, void *handle, void (*pngWriteCallback)(png_structp pngPtr,
png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp
pngPtr))
+int m3dTexture::savePNG(const unsigned char *data, png_uint_32 width,
png_uint_32 height, void *handle, void (*pngWriteCallback)(png_structp pngPtr,
png_bytep data, png_size_t length), void (*pngFlushCallback)(png_structp
pngPtr))
{
png_structp pngPtr;
png_infop pngInfoPtr;
@@ -435,7 +437,7 @@
GLuint m3dTexture::loadTexture(const char *filename)
{
unsigned char *data;
- unsigned int width, height;
+ png_uint_32 width, height;
GLuint tex;
glGenTextures(1, &tex);
@@ -443,6 +445,7 @@
if(m3dTexture::loadPNG(filename, &data, &width, &height) != 0)
{
fprintf(stderr, "Can't load texture %s\n", filename);
+ fprintf(stderr, "Width %d, Height %d\n",&width, &height);
return 0;
}