Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vertical retrace



Hi Bob,

What RezLib does for vertical retraces on X is that it sets up a thread
that tries to loop over MPDelayUntil() with the appropriate delays such
that it regains the CPU at an appropriate time to mimic the behavior of
the old Slot Manager VBL interrupt. The MP task calls
CGDisplayBeamPosition() to get the current beam scanline to keep itself in
synchronization and correct for any drift. RezLib is open source and free.

http://idisk.mac.com/rezlib/Public/

Attempting to sync to the VBL can be complicated by displays (mostly LCDs)
that report a 0 refresh rate. CGDisplayBeamPosition() may report 0 for
them as well. In this case, the recommended approach is to just similate a
artifical retrace pulse using the Time Manager and put up with the
tearing, if there is any.

Note: in many or most cases you should not have to sync to the VBL. If you
go through the normal double buffered window drawing mechanism in Carbon,
calling LockPortBits(), UnlockPortBits() and QDFlushPortBuffer() as
appropriate, then you should get sync to VBL for free. This does not mean
that your graphics loop will be locked into one update per screen refresh
however. It may update faster or slower than that:

http://developer.apple.com/samplecode/Sample_Code/Graphics_2D/BlitVBL.htm
http://developer.apple.com/technotes/tn/tn2051.html
http://developer.apple.com/techpubs/macosx/Essentials/Performance/Carbon/Carbon_and___X_Graphics.html

This example shows how to avoid tearing in OpenGL:

http://developer.apple.com/samplecode/Sample_Code/Graphics_3D/VBL.htm

Ian

---------------------------------------------------
Ian Ollmann, Ph.D. email@hidden
---------------------------------------------------
_______________________________________________
mac-games-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/mac-games-dev
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.