How to "Render to texture"

Started by hytparadisee, June 11, 2007, 08:22:34 AM

Previous topic - Next topic

hytparadisee

By looking at the "window_blinds" video i think that is something i need to use in the near future. Any hint on how is it done? And is it possible that image created on the fly (e.g. ImageIcon painted by Graphics) can be used as textures to be drown in this manner, and in GLCanvas mode?
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

halcor

QuoteAnd is it possible that image created on the fly (e.g. ImageIcon painted by Graphics) can be used as textures to be drown in this manner, and in GLCanvas mode?
Sure, construct an Image, add it to the texture manager (or modify existing texture), apply the texture to an object and here you go.

hytparadisee

#2
Thanks, i tried it and get it solved.

New question: what's the best way to update the image rendered to the texture on the fly? Is TextureManager.replaceTexture() alone enough? If that's the case, does it matter to produce so many Texture objects just because we need to update it every frame? I am inexperienced in all kinds of realtime app so i am sort of newbie about whether creating a new object per frame kills the app.
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

EgonOlsen

Uploading a new texture every frame is cheap in software mode but expensive in hardware mode. It's a bit cheaper to use an ITextureEffect to update a texture's content, but it's still expensive in hardware mode.

EgonOlsen

BTW: Render to texture is done via setting a texture as render target in the FrameBuffer.

hytparadisee

in other words, FrameBuffer.setRenderTarget() before calling FrameBuffer.update()?
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

EgonOlsen

No, before the whole render section, i.e. it has to include the clear() and everything. Set it first, do the usual stuff as you would do it when rendering directly to screen, remove it and render the scene one again, but now with the correct camera view.

hytparadisee

Now see whether my understanding is correct.

1. Create the object as usual.
2. Apply the initial texture as usual.
3. Before that series of rendering commands, do FrameBuffer.setRenderTarget()
4. Now update the texture (drawing, painting etc)
5. Render
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

EgonOlsen

No, render to texture and updating the texture from the "outside" via your application are totally different things. If all you want to do is to refill the texture with your generated content, then you don't have to care about render to texture.

hytparadisee

Sorry today something wrong with my head. ;D Ya how come I mixed them up, render to texture basically means capturing whatever it is in the buffer to an external texture right?
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution

EgonOlsen

Rendering to texture means to render the current scene into a texture instead of the framebuffer. Like the video shows it on the TV screen.

hytparadisee

QuoteRendering to texture means to render the current scene into a texture instead of the framebuffer.

:) No wonder you said:

Quotedo the usual stuff as you would do it when rendering directly to screen, remove it and render the scene one again, but now with the correct camera view
Today I finally found a problem to my soluuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuution