Disable screen refresh, when rendering to texture

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Kuzy
Posts: 21
Joined: Fri Feb 18, 2011 10:30 am

Disable screen refresh, when rendering to texture

Post by Kuzy »

Hello,

for generating a video I am rendering my scene to a texture. I want to use the irrlicht-window to show the rendered texture as a video-preview.

Now I discovered that irrlicht clears my window, even if I set my rendering target to texture.
The result is that my preview is flickering.

Can anyone tell me how I can prevent irrlicht to clear my window?

Thanks in advance
Kuzy
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Disable screen refresh, when rendering to texture

Post by Mel »

Check the documentation.

http://irrlicht.sourceforge.net/docu/cl ... eb0749e7eb "setRenderTarget"
http://irrlicht.sourceforge.net/docu/cl ... 81be1e9945 "beginScene"

set the "clear backbuffer" parameter to false, and the render doesn't get cleared each time.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Kuzy
Posts: 21
Joined: Fri Feb 18, 2011 10:30 am

Re: Disable screen refresh, when rendering to texture

Post by Kuzy »

Hi Mel,
that doesn't help.
The flags only prevent the refreshing of the buffer, but the "unrefreshed" buffer is painted everytime the WM_PAINT message is fired...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Disable screen refresh, when rendering to texture

Post by hybrid »

No, that's definitely not so. There's only one framebuffer at each call that gets cleared. On beginScene it's the default backbuffer, on setRenderTarget it's the render target that will be cleared. Note, though, that on setRenderTarget(0) you will also clear the default backbuffer. So make sure that you have the flag set to flase both in beginScene and setRenderTarget(0) if you want to vavoid the clear call. Copying the backbuffer to the frontbuffer (or swapping the two) will happen on endScene, and this cannot be prevented unless by creating a much larger render loop.
Kuzy
Posts: 21
Joined: Fri Feb 18, 2011 10:30 am

Re: Disable screen refresh, when rendering to texture

Post by Kuzy »

When I set both flags to false, I had an ugly rendering result (but the flickering stopped).

Now I found a solution for me:

I set the rendering rectangle to zero:
SExposedVideoData videoData = SExposedVideoData(0);
rect<s32> rec = rect<s32>(0,0,0,0);
driver->beginScene(true, true, backgroundColor,videoData,&rec);

Now my window is not cleared anymore and my texture looks like it should...

Thanks to all...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Disable screen refresh, when rendering to texture

Post by hybrid »

Well, if you don't clear the zbuffer you'll get strange results. The screen will only render if there's some zfight win for the render part. Of course, this would work for plain 2d rendering, which ignores the depth information. But you should not keep the zbuffer anyway. Just set the backbuffer flag to false.
Post Reply