Ultralight C API 1.3.0
Loading...
Searching...
No Matches
CAPI_Renderer.h
Go to the documentation of this file.
1/******************************************************************************
2 * This file is a part of Ultralight, an ultra-portable web-browser engine. *
3 * *
4 * See <https://ultralig.ht> for licensing and more. *
5 * *
6 * (C) 2023 Ultralight, Inc. *
7 *****************************************************************************/
8
9///
10/// @file CAPI_Renderer.h
11///
12/// Core renderer singleton for the library, coordinates all library functions.
13///
14/// The Renderer class is responsible for creating and painting \link CAPI_View.h Views \endlink,
15/// managing \link CAPI_Session.h Sessions \endlink, as well as coordinating network requests,
16/// events, JavaScript execution, and more.
17///
18/// ## Initializing the Renderer
19///
20/// To initialize the library, you should set up the \link CAPI_Platform.h Platform \endlink
21/// singleton and call ulCreateRenderer().
22///
23/// @note If you'd like to let the library manage window creation you can instead call
24/// ulCreateApp().
25///
26#ifndef ULTRALIGHT_CAPI_RENDERER_H
27#define ULTRALIGHT_CAPI_RENDERER_H
28
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35///
36/// Create the core renderer singleton for the library directly.
37///
38/// Unlike ulCreateApp(), this does not use any native windows for drawing and allows you to manage
39/// your own runloop and painting. This method is recommended for those wishing to integrate the
40/// library into a game.
41///
42/// This singleton manages the lifetime of all Views and coordinates all painting, rendering,
43/// network requests, and event dispatch.
44///
45/// You should only call this once per process lifetime.
46///
47/// You must set up your platform handlers before calling this. At a minimum, you must call
48/// ulPlatformSetFileSystem() and ulPlatformSetFontLoader() before calling this.
49///
50/// @note You should not call this if you are using ulCreateApp(), it creates its own renderer and
51/// provides default implementations for various platform handlers automatically.
52///
54
55///
56/// Destroy the renderer.
57///
59
60///
61/// Update timers and dispatch internal callbacks (JavaScript and network).
62///
64
65///
66/// Render all active Views.
67///
69
70///
71/// Attempt to release as much memory as possible. Don't call this from any callbacks or driver
72/// code.
73///
75
76///
77/// Print detailed memory usage statistics to the log. (@see ulPlatformSetLogger)
78///
80
81///
82/// Start the remote inspector server.
83///
84/// While the remote inspector is active, Views that are loaded into this renderer
85/// will be able to be remotely inspected from another Ultralight instance either locally
86/// (another app on same machine) or remotely (over the network) by navigating a View to:
87///
88/// \code
89/// inspector://<ADDRESS>:<PORT>
90/// \endcode
91///
92/// @return Returns whether the server started successfully or not.
93///
94ULExport bool ulStartRemoteInspectorServer(ULRenderer renderer, const char* address,
95 unsigned short port);
96
97///
98/// Describe the details of a gamepad, to be used with ulFireGamepadEvent and related
99/// events below. This can be called multiple times with the same index if the details change.
100///
101/// @param renderer The active renderer instance.
102///
103/// @param index The unique index (or "connection slot") of the gamepad. For example,
104/// controller #1 would be "1", controller #2 would be "2" and so on.
105///
106/// @param id A string ID representing the device, this will be made available
107/// in JavaScript as gamepad.id
108///
109/// @param axis_count The number of axes on the device.
110///
111/// @param button_count The number of buttons on the device.
112///
113ULExport void ulSetGamepadDetails(ULRenderer renderer, unsigned int index, ULString id,
114 unsigned int axis_count, unsigned int button_count);
115
116///
117/// Fire a gamepad event (connection / disconnection).
118///
119/// @note The gamepad should first be described via ulSetGamepadDetails before calling this
120/// function.
121///
122/// @see <https://developer.mozilla.org/en-US/docs/Web/API/Gamepad>
123///
125
126///
127/// Fire a gamepad axis event (to be called when an axis value is changed).
128///
129/// @note The gamepad should be connected via a previous call to ulFireGamepadEvent.
130///
131/// @see <https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/axes>
132///
134
135///
136/// Fire a gamepad button event (to be called when a button value is changed).
137///
138/// @note The gamepad should be connected via a previous call to ulFireGamepadEvent.
139///
140/// @see <https://developer.mozilla.org/en-US/docs/Web/API/Gamepad/buttons>
141///
143
144#ifdef __cplusplus
145} // extern "C"
146#endif
147
148#endif // ULTRALIGHT_CAPI_RENDERER_H
struct C_GamepadButtonEvent * ULGamepadButtonEvent
Definition CAPI_Defines.h:61
struct C_String * ULString
Definition CAPI_Defines.h:54
struct C_Config * ULConfig
Definition CAPI_Defines.h:48
#define ULExport
Definition CAPI_Defines.h:27
struct C_GamepadAxisEvent * ULGamepadAxisEvent
Definition CAPI_Defines.h:60
struct C_Renderer * ULRenderer
Definition CAPI_Defines.h:49
struct C_GamepadEvent * ULGamepadEvent
Definition CAPI_Defines.h:59
ULExport void ulFireGamepadEvent(ULRenderer renderer, ULGamepadEvent evt)
Fire a gamepad event (connection / disconnection).
ULExport void ulFireGamepadButtonEvent(ULRenderer renderer, ULGamepadButtonEvent evt)
Fire a gamepad button event (to be called when a button value is changed).
ULExport void ulLogMemoryUsage(ULRenderer renderer)
Print detailed memory usage statistics to the log.
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 ULRenderer ulCreateRenderer(ULConfig config)
Create the core renderer singleton for the library directly.
ULExport bool ulStartRemoteInspectorServer(ULRenderer renderer, const char *address, unsigned short port)
Start the remote inspector server.
ULExport void ulRender(ULRenderer renderer)
Render all active Views.
ULExport void ulFireGamepadAxisEvent(ULRenderer renderer, ULGamepadAxisEvent evt)
Fire a gamepad axis event (to be called when an axis value is changed).
ULExport void ulPurgeMemory(ULRenderer renderer)
Attempt to release as much memory as possible.
ULExport void ulDestroyRenderer(ULRenderer renderer)
Destroy the renderer.
ULExport void ulUpdate(ULRenderer renderer)
Update timers and dispatch internal callbacks (JavaScript and network).