setImage problem

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
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

setImage problem

Post by wsw1231 »

I can see the image using this code.

Code: Select all

 ITexture *texture = driver->getTexture("../../media/fire.bmp");
   IGUIImage *img = guienv->addImage(texture, core::vector2d<s32>(300,300), false);

But I can't see the image using that code

Code: Select all

 ITexture *texture = driver->getTexture("../../media/fire.bmp");
   IGUIImage *img = guienv->addImage(0, core::vector2d<s32>(300,300), false);
   img->setImage(texture);
Why is that?
Alpha Omega
Posts: 288
Joined: Wed Oct 29, 2008 12:07 pm

Post by Alpha Omega »

Not to familiar with writing textures but at least in this code you never stated where you wanted to apply your texture.
wsw1231
Posts: 148
Joined: Fri Oct 01, 2010 7:55 am

Post by wsw1231 »

I notice that img->setImage(texture); will not take into effect if the 1st parameter in addImage() is a null pointer.

Dont know why = =
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

There are two addImage overloads. Use the second one. The problem you run into is that the first only takes a position + and image and then resizes the image-element correspondingly. When you give it an invalid image then it has size 0 afterward. You would also see your other image when you would resize that gui-element.

But the easier solution in this case is using the other overload which allows you to set a fixed size from start.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply