What’s the fastest way to change a window from all black to all white repeatedly? I’d like to use my computer screen as a sort of strobe to flash at 25-60 times per second. I’ve got the code working, but performance is abysmal, especially when the window is maximized. Would using some Cocoa API calls yield better results perhaps, or should I just program my Arduino to flash some LEDs?
Oh, forgot to mention that my current approach is to use FillRect on the window’s graphics context. I just alternately fill it with black and white. Is there a faster way?
Create two pictures, one all-black, the other all-white, then swap those pictures in Graphics. It sounds like you are recreating the images on each “flash”, and there is no reason to do that.
MBS plugins had something… Display.DrawingContext. It’s analogous to the Cocoa api’s. I’m pretty sure that would be the fastest possible way in Cocoa of course you have to use the CG drawing functions, but if you’re only flashing it, then it shouldn’t be a major problem.
Why, does it matter? Although the post mentions Cocoa APIs, the developer did not specify a specific operating system and it might be useful if this question was answered with regard for Windows and Linux.
Just tried an experiment using self.backcolor and under cocoa (on an old macbook) I’m seeing 800+fps on a small sized window down to about 30fps fullscreen. Seems like the simplest solution. Just be sure to turn on customColor in the window properties.