I thought the following might be useful to other people here.
I've been developing a Windows program that displays graphics of various kinds using the built-in graphics objects (Circle, Poly, Rect, etc.). In some cases the entire screen foreground is being updated very quickly (every 0.05 second), with multiple objects being displayed and a lot of movement. I found that on certain PCs, particularly laptops, there was a lot of flickering occurring during the screen updates. I tried many methods of reducing the flickering, including double-buffering, but nothing was working. Then I discovered an extremely easy solution which was "hidden" in the Dyalog APL documentation.
I did some Googling and found this about reducing flickering: "The flashing is going back and forth between the background and what's painted over it. Once the background has stopped being painted, it stops conflicting with what is painted over it, which includes filling the window with a solid color, so there will still be a background anyway."
I realized that, once I had set the background color of what I was displaying, I wasn't changing the background. Only the foreground. In the Dyalog for Microsoft Windows Object Reference Guide, under the BCol property, is this statement:
"If BCol is set to ⍬ (Zilde), Dyalog APL will never paint the background of the object. If therefore the object is overlaid by another window and then exposed, its background will not be redrawn and it will simply contain whatever was previously shown on that area of the screen."
I simply added the property ('BCol' ⍬) when creating my form, and the flickering completely stopped. Apparently (and I'm guessing here) when BCol is set to a number (default 0), whenever a screen update occurs, Dyalog APL alternates writing the background with writing the foreground, which on slow hardware causes visible flickering. By setting BCol to zilde, only the foreground is written. No more flickering. Perhaps someone here can give a more informed technical explanation.
Note that depending on what you're displaying, setting BCol to zilde may not be appropriate, i.e. if the background is also changing or only part of the screen is being updated.
Hidden gem prevents flickering when displaying graphics
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
-
- Posts: 439
- Joined: Wed Oct 01, 2008 9:39 am
Re: Hidden gem prevents flickering when displaying graphics
Hi Rav,
Interesting!
Thanks for finding and trying that and letting us know about your experiences.
Regards,
Vince
Interesting!
Thanks for finding and trying that and letting us know about your experiences.
Regards,
Vince
Re: Hidden gem prevents flickering when displaying graphics
Thank you RAV!
Flickering animations while using ⎕WC have been "bugging" me for many years.
Your trick has stopped it in the 4 workspaces I have updated so far!
Thank you once again.
Ray
Flickering animations while using ⎕WC have been "bugging" me for many years.
Your
Code: Select all
('BCol' ⍬)
Thank you once again.
Ray
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
Re: Hidden gem prevents flickering when displaying graphics
You're welcome, Ray! Your post made my day. I had wondered if I was the only one who had run into this issue, and wasn't sure if I should post that info. I'm glad I did and that I could help! / Rav