Page 1 of 1

addRenderTargetTexture

Posted: Mon Jan 19, 2009 6:03 am
by merovingian
I've just been trying Irrlicht 1.5 for the first time. Very pleased with it. Especially loving the non-flipped OpenGL RTTs, and the addition of joystick support - SDL about to get the flick from my project.

Irrlicht 1.5 kept telling me that createRenderTargetTexture() was deprecated, so I've swapped to addRenderTargetTexture(). Two queries relating to this:

1) The docs say that the width and height of the RTT "should be a power of 2". Mine have always been 200. 200 seems to work with addRenderTargetTexture(). So how important is the use of the word "should"? Will I eventually suffer some sort of horrible problem (in the middle of a customer demo no doubt)?

2) I was suffering segmentation faults in device->drop(). Stack trace was showing it was related to deleting RTTs. Docs didn't seem to have an answer. Looking in changes.txt, I saw the following comment "but also changes the way of removing the RTTs, and especially one must not drop the pointer anymore". So now I use removeTexture(), and all seems well. This is the correct method yes?

Posted: Mon Jan 19, 2009 8:57 am
by hybrid
1) Some hardware doesn't support NPOT RTTs. Irrlicht should choose the proper next POT dimension, but I had some reports about non-working RTTs in such cases. So it seems wiser to keep POT RTTs if you don't have full control over the target platform.
2) Yes, you need to call removeTexture and avoid drop when changin to addRenderTargetTexture. However, the docs should also tell you:
\return Pointer to the created texture or 0 if the texture
could not be created. This pointer should not be dropped. See
IReferenceCounted::drop() for more information. */

Posted: Mon Jan 19, 2009 4:45 pm
by Mel
Just in case you need to render a space which is non power of 2 (e.g. 640 x 480 for the case's sake) you still could create a big enough RTT, and use IVideoDriver::setViewPort(const core::rect< s32 > & area ) to render the area you need, then, after that, you clip all the operations you have to do in that texture to the viewport size, and virtually, you have NPOT RTT in POT RTT.

Much people tend to forget this small trick, but it saves rendering time.

Posted: Tue Jan 20, 2009 12:52 am
by merovingian
Thanks a lot for the replies fellas.