Converting ITexture to IImage

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
wiznoe
Posts: 8
Joined: Wed Jun 18, 2008 4:40 am
Location: Jogja, Indonesia

Converting ITexture to IImage

Post by wiznoe »

Hi all,
I have troble for this code:

Code: Select all

ITexture* renderTarget = driver->createRenderTargetTexture(dimension2d<s32>(100,100),0);
driver->setRenderTarget(renderTarget);
smgr->drawAll();
stringc imageFile;
imageFile = "rumah_user/";
imageFile+=namaFileX;
imageFile+=".jpg";

IImage* im = driver->createImageFromData(renderTarget->getColorFormat() ,dimension2d<s32>(100,100),renderTarget); 
driver->writeImageToFile(im,(c8*)imageFile.c_str());
im->drop();

driver->setRenderTarget(0);
driver->removeTexture(renderTarget);
this code poduce an image but that image are broken.
anybody know what is my fault?

Sorry for my bad english. Thanks.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The render target is a texture pointer, you cannot use that directly in order to read out pixels. You have to lock the texture first, and the returned pointer is the one you should use in driver->createImageFromData.
Post Reply