Distorted images being displayed in a demo

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
mbosticky
Posts: 5
Joined: Wed May 30, 2007 10:39 am

Distorted images being displayed in a demo

Post by mbosticky »

Hi all,

Hi, I am new to irrlicht and 3D technology but not to C++ programming. I have done some tutorials etc on irrlicht. I have this problem with displaying images:

I modified the user interface tutorial (05.UserInterface) and replaced the logo with my own image. In windows explorer I can see the image clearly displayed but in the demo drawn by the irrlicht engine it looks distorted. What am i doing wrong? I tried number of different images. They all end up being distorted. I am not doing any re-scaling as far as i can tell. I tried setting the useAlphaChannel to true and false but it makes no difference.

Any suggestions would be much appreciated.

Code Line:
env->addImage(driver->getTexture("gfx/Test.png"),
position2d<int>(10,10), false);
Martin
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

You image dimensions have to be power of 2 ... 32x32, 256x128 etc. Otherwise they are scaled.
mbosticky
Posts: 5
Joined: Wed May 30, 2007 10:39 am

Post by mbosticky »

Great this works. Thanks very much for ur help Eigen.

I assume that they have to be powers of 2 in order to aid optimisation of the 3d accelerated cards?

Since the engine resizes an image if i is not power of 2 on either axis, does that mean that all images must be 2^nx2^m? What if i want an image which is 15x21? I could buffer up the image with transparent area but it would still potentially overlay other GUI components and block events no?
Martin
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

Blocking depends on the order you draw your gui elements. If you first draw the image and then a button then the image won't disturb it. There's also a way to draw only a part of the image you need, see draw2DImage. But you can't use it on the gui directly because it's only drawn for one frame.

The image scale only happens with directX. With OpenGL images are not resized. I think.
mbosticky
Posts: 5
Joined: Wed May 30, 2007 10:39 am

Post by mbosticky »

hmm, but what if i wanted to create a cusom widget that is a non-standard size? tricks of the trade i suppose
Martin
Post Reply