addRenderTargetTexture

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
merovingian
Posts: 37
Joined: Thu Feb 28, 2008 4:34 am
Location: Perth, Western Australia

addRenderTargetTexture

Post 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?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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. */
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post 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.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
merovingian
Posts: 37
Joined: Thu Feb 28, 2008 4:34 am
Location: Perth, Western Australia

Post by merovingian »

Thanks a lot for the replies fellas.
Post Reply