Page 1 of 1

Distorted images being displayed in a demo

Posted: Wed May 30, 2007 10:55 am
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);

Posted: Wed May 30, 2007 11:36 am
by Eigen
You image dimensions have to be power of 2 ... 32x32, 256x128 etc. Otherwise they are scaled.

Posted: Wed May 30, 2007 1:59 pm
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?

Posted: Wed May 30, 2007 2:15 pm
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.

Posted: Wed May 30, 2007 4:02 pm
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