Texture rendering problem of Irrlicht on iPhone

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
thichxemphim_01
Posts: 4
Joined: Sat Jul 03, 2010 9:47 am

Texture rendering problem of Irrlicht on iPhone

Post by thichxemphim_01 »

Hi everybody,

I have compiled Irrlicht library for iPhone successfully using instructions at here: http://irrlicht.sourceforge.net/phpBB2/ ... e&start=60
And I have built some simple applications on Iphone using compiled library.

However, now I got a problem of texture rendering:
when I try to run HelloWorld example on iPhone, everything works well except the texture of the girl. The texture does not display.

When I change the texture file from "sydney.bmp" to other image file such as "wall.bmp", the texture displays successfully.
But when I try other image files, most of them don't not display as texture of the girl.

does any body have the same problem?
Any comment would be appreciated.

Thanks in advance.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

IIRC, the sydney.bmp has no power of two dimension. Maybe it's a problem due to NPOT problems.
thichxemphim_01
Posts: 4
Joined: Sat Jul 03, 2010 9:47 am

Post by thichxemphim_01 »

hybrid wrote:IIRC, the sydney.bmp has no power of two dimension. Maybe it's a problem due to NPOT problems.
That's correct. I changed the size of the image, it worked correctly.
Thank you very much.
Garfinkle
Posts: 36
Joined: Wed Jul 07, 2010 11:35 am
Location: Manchester, UK

Post by Garfinkle »

Hi All,

I'm having the same issue. The sydney.md2 is not loading it's own texture, but is loading the wall.bmp texture. I read this topic and resized the image to 256x256 (same dimensions as the wall.bmp) and the app crashes when I try to load the texture.

The following error is thrown

Code: Select all

Loaded mesh: sydney.md2
TestApp(377,0x3e2b47c8) malloc: *** mmap(size=4294705152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
I added a malloc_error_break and the line that is causing the issue is the marked below (found in the file CImage.cpp, line 43)

Code: Select all

void CImage::initData()
{
#ifdef _DEBUG
	setDebugName("CImage");
#endif
	BytesPerPixel = getBitsPerPixelFromFormat(Format) / 8;

	// Pitch should be aligned...
	Pitch = BytesPerPixel * Size.Width;

	if (!Data)
		Data = new u8[Size.Height * Pitch]; //<--- ERROR ON THIS LINE
}
Size.Height has the value 4294967040 assigned to it and Pitch as 1024 assigned to it. Judging by the value in size... this is where the issue may be but not sure why.

Anyone know why this issue is thrown when i resize the bmp to 256x256 yet other images of the same size work fine.

Thanks in advance.

Matt
Garfinkle
Posts: 36
Joined: Wed Jul 07, 2010 11:35 am
Location: Manchester, UK

Post by Garfinkle »

Hi All,

I figured out what the issue was.

Depending on what software you use to resize the image, the software embeds specific header information into the file which is not filtered by the irrlicht engine.

I found this out by testing the image in PNG format. I created the image using photoshop and when trying to load the image a Fatal PNG error was given out by the app.

I ran a program called PNGenie (MAC OSX Software) that strips useless information out of PNGs and reduces the image size by approx 50%. By passing the PNG through this program, all the header information was stripped out and the texture now loads perfectly fine and is 16kb compared to the BMP version of 201kb.

Not sure what information was being stored in the BMP file and it is probably safer to resize these files in Windows as BMP is a native file format for windows systems.
Post Reply