Ultralight C API 1.3.0
Loading...
Searching...
No Matches
CAPI_Renderer.h File Reference

Go to the source code of this file.

Details

Core renderer singleton for the library, coordinates all library functions.

The Renderer class is responsible for creating and painting Views , managing Sessions , as well as coordinating network requests, events, JavaScript execution, and more.

Initializing the Renderer

To initialize the library, you should set up the Platform singleton and call ulCreateRenderer().

Note
If you'd like to let the library manage window creation you can instead call ulCreateApp().

Functions

ULExport ULRenderer ulCreateRenderer (ULConfig config)
 Create the core renderer singleton for the library directly.
 
ULExport void ulDestroyRenderer (ULRenderer renderer)
 Destroy the renderer.
 
ULExport void ulUpdate (ULRenderer renderer)
 Update timers and dispatch internal callbacks (JavaScript and network).
 
ULExport void ulRender (ULRenderer renderer)
 Render all active Views.
 
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).
 

Function Documentation

◆ ulCreateRenderer()

ULExport ULRenderer ulCreateRenderer ( ULConfig  config)

Create the core renderer singleton for the library directly.

Unlike ulCreateApp(), this does not use any native windows for drawing and allows you to manage your own runloop and painting. This method is recommended for those wishing to integrate the library into a game.

This singleton manages the lifetime of all Views and coordinates all painting, rendering, network requests, and event dispatch.

You should only call this once per process lifetime.

You must set up your platform handlers before calling this. At a minimum, you must call ulPlatformSetFileSystem() and ulPlatformSetFontLoader() before calling this.

Note
You should not call this if you are using ulCreateApp(), it creates its own renderer and provides default implementations for various platform handlers automatically.

◆ ulDestroyRenderer()

ULExport void ulDestroyRenderer ( ULRenderer  renderer)

Destroy the renderer.

◆ ulFireGamepadAxisEvent()

ULExport void ulFireGamepadAxisEvent ( ULRenderer  renderer,
ULGamepadAxisEvent  evt 
)

Fire a gamepad axis event (to be called when an axis value is changed).

Note
The gamepad should be connected via a previous call to ulFireGamepadEvent.
See also
https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/axes

◆ ulFireGamepadButtonEvent()

ULExport void ulFireGamepadButtonEvent ( ULRenderer  renderer,
ULGamepadButtonEvent  evt 
)

Fire a gamepad button event (to be called when a button value is changed).

Note
The gamepad should be connected via a previous call to ulFireGamepadEvent.
See also
https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/buttons

◆ ulFireGamepadEvent()

ULExport void ulFireGamepadEvent ( ULRenderer  renderer,
ULGamepadEvent  evt 
)

Fire a gamepad event (connection / disconnection).

Note
The gamepad should first be described via ulSetGamepadDetails before calling this function.
See also
https://developer.mozilla.org/en-US/docs/Web/API/Gamepad

◆ ulLogMemoryUsage()

ULExport void ulLogMemoryUsage ( ULRenderer  renderer)

Print detailed memory usage statistics to the log.

(

See also
ulPlatformSetLogger)

◆ ulPurgeMemory()

ULExport void ulPurgeMemory ( ULRenderer  renderer)

Attempt to release as much memory as possible.

Don't call this from any callbacks or driver code.

◆ ulRender()

ULExport void ulRender ( ULRenderer  renderer)

Render all active Views.

◆ ulSetGamepadDetails()

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.

Parameters
rendererThe active renderer instance.
indexThe unique index (or "connection slot") of the gamepad. For example, controller #1 would be "1", controller #2 would be "2" and so on.
idA string ID representing the device, this will be made available in JavaScript as gamepad.id
axis_countThe number of axes on the device.
button_countThe number of buttons on the device.

◆ ulStartRemoteInspectorServer()

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:

inspector://<ADDRESS>:<PORT>
Returns
Returns whether the server started successfully or not.

◆ ulUpdate()

ULExport void ulUpdate ( ULRenderer  renderer)

Update timers and dispatch internal callbacks (JavaScript and network).