We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › GLPersistance: hack-solution to OPENGL flickering
Page Index Toggle Pages: 1
GLPersistance: hack-solution to OPENGL flickering (Read 1043 times)
GLPersistance: hack-solution to OPENGL flickering
Jul 6th, 2009, 6:18am
 
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 frame
ON 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 Use

Basic 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!
Advanced

If 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
Re: GLPersistance: hack-solution to OPENGL flickering
Reply #1 - Jul 6th, 2009, 3:46pm
 
Very related bug, and explanation:
http://dev.processing.org/bugs/show_bug.cgi?id=1054
Re: GLPersistance: hack-solution to OPENGL flickering
Reply #2 - Jul 20th, 2009, 7:58am
 
Slick work-around,
But I have a few problems:

The advanced solution runs fine in my browser but when I download the source and try to run it from processing your example is throwing up an error in the TaiShaders class:

"Couldn't load shader: Shader2. Check that Shader2.vert / .frag exist in sketch!"

Also, in the Basic Solution is there any way to draw the background in some other colour besides white?
Page Index Toggle Pages: 1