Ultralight C API 1.4.0
|
Core renderer singleton for the library, coordinates all library functions.
#include <Ultralight/CAPI/CAPI_Renderer.h>
The Renderer class is responsible for creating and painting Views, managing Sessions, as well as coordinating network requests, events, JavaScript execution, and more.
Before creating the Renderer, you should define your platform handlers via the Platform singleton (see CAPI_Platform.h). This can be used to customize file loading, font loading, clipboard access, and other functionality typically provided by the OS.
Default implementations for most platform handlers are available in the AppCore repo. You can use these stock implementations by copying the code into your project, or you can write your own.
At a minimum, you should provide a ULFileSystem and ULFontLoader otherwise Renderer creation will fail.
Once you've set up the Platform handlers you can create the Renderer by calling ulCreateRenderer()
.
You should call ulUpdate() from your main update loop as often as possible to give the library an opportunity to dispatch events and timers:
When your program is ready to display a new frame (usually in synchrony with the monitor refresh rate), you should call ulRefreshDisplay()
and ulRender
so the library can render all active Views as needed.
Functions | |
ULExport ULRenderer | ulCreateRenderer (ULConfig config) |
Create the core renderer singleton for the library. | |
ULExport void | ulDestroyRenderer (ULRenderer renderer) |
Destroy the renderer. | |
ULExport void | ulUpdate (ULRenderer renderer) |
Update timers and dispatch internal callbacks (JavaScript and network). | |
ULExport void | ulRefreshDisplay (ULRenderer renderer, unsigned int display_id) |
Notify the renderer that a display has refreshed (you should call this after vsync). | |
ULExport void | ulRender (ULRenderer renderer) |
Render all active Views to their respective surfaces and render targets. | |
ULExport void | ulPurgeMemory (ULRenderer renderer) |
Attempt to release as much memory as possible. | |
ULExport void | ulLogMemoryUsage (ULRenderer renderer) |
Print detailed memory usage statistics to the log. | |
ULExport bool | ulStartRemoteInspectorServer (ULRenderer renderer, const char *address, unsigned short port) |
Start the remote inspector server. | |
ULExport void | ulSetGamepadDetails (ULRenderer renderer, unsigned int index, ULString id, unsigned int axis_count, unsigned int button_count) |
Describe the details of a gamepad, to be used with ulFireGamepadEvent and related events below. | |
ULExport void | ulFireGamepadEvent (ULRenderer renderer, ULGamepadEvent evt) |
Fire a gamepad event (connection / disconnection). | |
ULExport void | ulFireGamepadAxisEvent (ULRenderer renderer, ULGamepadAxisEvent evt) |
Fire a gamepad axis event (to be called when an axis value is changed). | |
ULExport void | ulFireGamepadButtonEvent (ULRenderer renderer, ULGamepadButtonEvent evt) |
Fire a gamepad button event (to be called when a button value is changed). | |
ULExport ULRenderer ulCreateRenderer | ( | ULConfig | config | ) |
Create the core renderer singleton for the library.
You should set up the Platform singleton (see CAPI_Platform.h) before calling this function.
config | The configuration to use for the renderer. |
ULExport void ulDestroyRenderer | ( | ULRenderer | renderer | ) |
Destroy the renderer.
renderer | The renderer instance to destroy. |
ULExport void ulFireGamepadAxisEvent | ( | ULRenderer | renderer, |
ULGamepadAxisEvent | evt ) |
Fire a gamepad axis event (to be called when an axis value is changed).
renderer | The active renderer instance. |
evt | The event to fire. |
ULExport void ulFireGamepadButtonEvent | ( | ULRenderer | renderer, |
ULGamepadButtonEvent | evt ) |
Fire a gamepad button event (to be called when a button value is changed).
renderer | The active renderer instance. |
evt | The event to fire. |
ULExport void ulFireGamepadEvent | ( | ULRenderer | renderer, |
ULGamepadEvent | evt ) |
Fire a gamepad event (connection / disconnection).
renderer | The active renderer instance. |
evt | The event to fire. |
ULExport void ulLogMemoryUsage | ( | ULRenderer | renderer | ) |
Print detailed memory usage statistics to the log.
(
renderer | The active renderer instance. |
ULExport void ulPurgeMemory | ( | ULRenderer | renderer | ) |
Attempt to release as much memory as possible.
Don't call this from any callbacks or driver code.
renderer | The active renderer instance. |
ULExport void ulRefreshDisplay | ( | ULRenderer | renderer, |
unsigned int | display_id ) |
Notify the renderer that a display has refreshed (you should call this after vsync).
This updates animations, smooth scroll, and window.requestAnimationFrame() for all Views matching the display id.
renderer | The active renderer instance. |
display_id | The display ID to refresh (0 by default). |
ULExport void ulRender | ( | ULRenderer | renderer | ) |
Render all active Views to their respective surfaces and render targets.
renderer | The active renderer instance. |
ULExport void ulSetGamepadDetails | ( | ULRenderer | renderer, |
unsigned int | index, | ||
ULString | id, | ||
unsigned int | axis_count, | ||
unsigned int | button_count ) |
Describe the details of a gamepad, to be used with ulFireGamepadEvent and related events below.
This can be called multiple times with the same index if the details change.
renderer | The active renderer instance. |
index | The unique index (or "connection slot") of the gamepad. For example, controller #1 would be "1", controller #2 would be "2" and so on. |
id | A string ID representing the device, this will be made available in JavaScript as gamepad.id |
axis_count | The number of axes on the device. |
button_count | The number of buttons on the device. |
ULExport bool ulStartRemoteInspectorServer | ( | ULRenderer | renderer, |
const char * | address, | ||
unsigned short | port ) |
Start the remote inspector server.
While the remote inspector is active, Views that are loaded into this renderer will be able to be remotely inspected from another Ultralight instance either locally (another app on same machine) or remotely (over the network) by navigating a View to:
renderer | The active renderer instance. |
address | The address for the server to listen on (eg, "127.0.0.1") |
port | The port for the server to listen on (eg, 9222) |
ULExport void ulUpdate | ( | ULRenderer | renderer | ) |
Update timers and dispatch internal callbacks (JavaScript and network).
renderer | The active renderer instance. |