RequestAnimationFrame
The RequestAnimationFrame method, part of the VSyncObserver class, allows you to schedule a function to be executed just before the next screen repaint, synchronized with the vertical synchronization (VSync) signal. This is the standard and most efficient way to run animations or perform visual updates in Lynx, as it ensures that your code executes at the optimal time, avoiding unnecessary rendering and improving performance.
There are two overloads for this method, allowing you to use either a C++ std::function or a traditional C-style function pointer as a callback.
Method Signature
With std::function callback
With C-function callback
Parameters
Callback Functions
The C++ lynx::pub::VSyncObserverCallback signature is:
The C vsync_observer_callback signature is:
frame_start_time: The timestamp indicating the start of the VSync frame.frame_end_time: The timestamp indicating the end of the VSync frame.
Example
Here's an example of how to use RequestAnimationFrame with a C++ lambda function.
Compatibility
LCD tables only load in the browser