Platforms to show: All Mac Windows Linux Cross-Platform

Back to CGDisplayMBS class.

Previous items

CGDisplayMBS.WaitForBeamPositionOutsideLines(upperScanLine as UInt32, lowerScanLine as UInt32) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 3.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Wait until the beam position is outside the range specified.

Wait until the beam position is outside the range specified by upperScanLine and lowerScanLine.
Note that if upperScanLine and lowerScanLine encompass the entire display height, the function returns an error.
lowerScanLine must be greater than or equal to upperScanLine.

Some display systems may not conventional video vertical and horizontal sweep in painting.
These displays report a kCGDisplayRefreshRate of 0 in the CFDictionaryRef returned by CurrentMode(). On such displays, this function returns at once.

Some drivers may not implement support for this mechanism.
On such displays, this function returns at once.

Returns CGDisplayNoErr on success, and an error if display or upperScanLine and lowerScanLine are invalid.

The app should set the values of upperScanLine and lowerScanLine to allow enough lead time for the drawing operation to complete. A common strategy is to wait for the beam to pass the bottom of the drawing area, allowing almost a full vertical sweep period to perform drawing.

To do this, set upperScanLine to 0, and set lowerScanLine to the bottom of the bounding box:
lowerScanLine = (CGBeamPosition)(cgrect.origin.y + cgrect.size.height);

IOKit may implement this as a spin-loop on the beam position call used for BeamPosition().
On such system the function is CPU bound, and subject to all the usual scheduling pre-emption.
In particular, attempting to wait for the beam to hit a specific scanline may be an exercise in frustration.

These functions are advisary in nature, and depend on IOKit and hardware specific drivers to implement support. If you need extremely precise timing, or access to vertical blanking interrupts, you should consider writing a device driver to tie into hardware-specific capabilities.

Returns an error code.

Previous items

The items on this page are in the following plugins: MBS MacCG Plugin.


💬 Ask a question or report a problem
The biggest plugin in space...