[wxruby-users] Tearing in my buffered animation test script...

Paul w Florczykowski lists at ruby-forum.com
Wed Mar 19 15:59:19 EDT 2008


Hi Jay!

I have tested your application, and indeed there is great deal of 
flicker as expected. You are not making any particular errors in your 
code; the problem occurs because the drawing, or more precisely, the 
copying of graphics (blit) is not synchronized with the vertical sync 
signal your screen receives from your graphics card. (I'm speaking in 
terms of analog signal CRT, but actually this applies to any kind of 
digital screen as well, as far the application is concerned)

The usual way to deal with this is:

1. Draw all the graphics onto an backbuffer (any surface that does not 
appear on the screen yet)

2. Await the V-blank (the vertical sync signal)

3. Copy the contents of this backbuffer onto the screen (the 
frontbuffer), or simply swap the buffers if your API supports it

4. repeat from 1

What you are currently doing is similar but lacks the point (2). wxRuby 
aims to support this on a lower level (i think). There is a method 
called "paint_buffered" (in stead of "paint") that provides a 
BufferedDC-object instead of ClientDC or DC. Drawing to the BufferedDC 
is then not supposed to be visible first after: 1. the actual drawing 
you are making on it is finally completed ie. the block provided to 
"buffered_paint" finishes, and 2. the V-blank occurs.

Sadly enough, this feature does not seem to be working properly with 
wxruby 1.9.5. I have currently similar problem - have not yet decided 
whether to devise another method to signal V-blank to Ruby, or to accept 
the moderate flicker in my application.

Best regards,

Paul W Florczykowski
-- 
Posted via http://www.ruby-forum.com/.


More information about the wxruby-users mailing list