I'm trying to get Irrlicht working with loading images, because a project I started hacking on a project that uses Irrlicht for graphics. The problem I run into is that everytime I try to load a PNG image as a texture, I get the following error:
In order to fix this, I decided to isolate the texture loading code in order to see what's wrong. I used a jpeg file, and converted it into a png file, and tried to load both. The jpeg file loaded perfectly, but the png file failed with the same error. I used the code attached at the end of the post.PNG FATAL ERROR: Invalid image width
PNG FATAL ERROR: Invalid image width
Could not load texture: back-next.png
Does anyone know what the problem could be? I'm using irrlicht 1.3.1 on 64bit Gentoo Linux.
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main()
{
IrrlichtDevice *device =
createDevice(EDT_SOFTWARE, dimension2d<s32>(512, 384), 16,
false, false, false, 0);
device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"Hello World! This is the Irrlicht Software engine!",
rect<int>(10,10,200,22), true);
ITexture* ATB_Sel=driver->getTexture("back-next.jpg");
ITexture* ATB_Sel2=driver->getTexture("back-next.png");
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
driver->draw2DImage(ATB_Sel, core::position2d<s32>(100,100), core::rect<s32>(0,0,128,64), 0, video::SColor(255, 255, 255, 255),true);
driver->draw2DImage(ATB_Sel2, core::position2d<s32>(300,100), core::rect<s32>(0,0,128,64), 0, video::SColor(255, 255, 255, 255),true);
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}