PDA

View Full Version : Fading out an image



tomgupper
10-28-2007, 02:41 AM
I'm working on a visualisation creation tool at the moment. It has multiple visual presets in it. When the user loads another preset, I'd like the two presets to 'blend' into eachother, or at least for the previous preset to fade out.

I'm working in processing, and they've got a saveFrame() function which saves an image of the current stage. I can then apply that to QUADs and fade it out. That works fine, but it's quite slow.

I was hoping there was an opengl alternative that might be faster ?

Essentially what I'd like to be able to do is :
-Save/record a shot of the current screen layout.
-Display that saved record, and fade it out.

Any suggestions ?

ZbuffeR
10-28-2007, 07:04 AM
With glCopyTexSubImage2D you can easily (and pure hardware accelerated) copy to a texture (should be created beforehand to be faster) then blend your quads. Usage of mutitexturing should be faster.

renderpreset1
swapbuffers

GL_READ_BUFFER : front
copytex(tex1)

renderpreset2
GL_READ_BUFFER : back
copytex(tex2)

:fadeloop
clear
draw blend of tex1 & tex2
swapbuffers
during fade, goto :fadeloop

I played with these some time ago, you may have a look at my messy code, if you dare :
http://www.chez.com/dedebuffer/
But forgot about pbuffers, it is completely outdated by FBO :
The only constraints of glCopyTex* is that if you have some other windows obscuring part of gl viewport.
In that case, you need the FBO route (Framebuffer object) to render direcly to texture.