First, see the demos, because if you go to the explanation first, you may lose your appetite.
Demo1: Without using my hack, you'll see flickering in opengl on processing
IF you try to use cumulative-effects (i.e., don't call background every frameON SOME PLATFORMS. Many DON'T have this problem; this technique helps the rest though.
See if you have the problem.*Note for vista users: try disabling aero; I only have the problem when the basic-theme is enabled !!!
Ok, so here is my solution; These demos certainly make it look good:
Basic use, just redraw the last frame at the start of the frame
Basic UseBasic use-Optimized. You can get higher performance, by pixelizing
the copy. Then again, it looks sorta bad. But its fast!
Pixels!!!Advanced, draw the last frame using a GLSL shader; IOW, cumulative shader effects! Nice!
AdvancedIf you have any bugs, I'm totally into this. So, post em here, please. Also, know that my first response to bugs will be to request that you update your drivers, especially if I'm clueless. (Always clueless.)
Alright, so here's the technique:
1) At the end of a frame, call afterDraw() on a GLPersistance object. This does NOT call get(), because getting java pixels from openGL is very very slow. Instead, it uses glCopySubTexImage2D to shove pixels around inside the GPU.
2) At the beginning of the frame, it blits up the texture it made last frame via glCopySubTexImage2D.
Thats all it is; I can get full framerate on my brand spankin new lappy here for all 4 examples; when you make the window size something substantial though, they drop to around 20fps. That's good enough for me, sometimes. We shall see
comment!
-taif
edit: OOPS forgot the library.
http://taif09.exofire.net/taifun/GLPersistanceLib-processing-1.0.4.zip