Superposing Image in a JOGL animation

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Superposing Image in a JOGL animation

Vishiv
Hello,

I would like to superpose differrent images during the time animation (FPSanimator).

I put a condition (work well) for the command gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT)    (and also for the different glLoadIdentity for modelview and projection)
After this test, I draw the new image but the last one has been erased.

It seems like each call to display clear the color_buffer_bit automatically.

Is that right ? How to conserve last image and superpose the new one ?

Thank you for your attention,
Nicolas
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

gouessej
Administrator
Why not drawing the both images in a single display call instead?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

Vishiv
Because the drawing of each image is costing a lot of calcultation,
because it is an animation =,
and because i don't want to superpose just 2 image but a number that is not known at the begining.

Is it true that each call to display clear the color buffer ?
Is it possible to change this comportement ?

If it is necessary, is it possible to backup the previous image between to call of display ?
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

Vishiv
Note : I have already some notion of blending.
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

gouessej
Administrator
In reply to this post by Vishiv
The auto swap buffer mode is enabled by default (buffer swap != clear color). You could use an offscreen buffer to save the result of a drawing (the previous image(s)) and draw over it at each frame.

Why would the drawing of each image cost a lot of computations?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

Vishiv
Because there is a lot (3600*100*4) vertices and for each, at every time of the animation, I have a calculation to do for all coordinates (space, texture...). So I don't want to have to recalculate them if I have done it allready...

I will search for the offscreen buffer and return to you if it work... or not :)

Thanks for your help.
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

vishiv
Hello,
I have searched about offscreen buffers during the WE (it's a personal project) and I have found a piste about FBO (frame buffer objects).
I have read many tutos (in frencj and english) and I think it could help me. These are principally about texture handing, image saving, but I didn't found some about my purpose : saving the previous image (with depth renderer) and redraw it before drawing the new one.
If you know one tuto or documentation about it, it could help me and save me many time.
Thanks for your help in any case.
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

gouessej
Administrator
Have you looked at jogl-demos on github?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

vishiv
No and I don't understand how it works (I am not a professional in programmation or informatic).
Reply | Threaded
Open this post in threaded view
|

Re: Superposing Image in a JOGL animation

vishiv
HI,
for response (if someone search same key codes as me).
I have found my solution with the accumulation buffer. I read about it in framebuffer article in  :
http://www.glprogramming.com/red/chapter10.html
It's quite easy to use in JOGL and I think it work well now.
Thanks for help