Ultralight C API 1.3.0
Loading...
Searching...
No Matches
CAPI_Platform.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_Platform.h
11///
12/// Global platform singleton, manages user-defined platform handlers.
13///
14/// The library uses the Platform API for most platform-specific operations (eg, file access,
15/// clipboard, font loading, GPU access, etc.).
16///
17/// @par Overview of which platform handlers are required / optional / provided:
18///
19/// | | ulCreateRenderer() | ulCreateApp() |
20/// |-------------------|--------------------|---------------|
21/// | FileSystem | **Required** | *Provided* |
22/// | FontLoader | **Required** | *Provided* |
23/// | Clipboard | *Optional* | *Provided* |
24/// | GPUDriver | *Optional* | *Provided* |
25/// | Logger | *Optional* | *Provided* |
26/// | SurfaceDefinition | *Provided* | *Provided* |
27///
28/// @note This singleton should be set up before creating the Renderer or App.
29///
30#ifndef ULTRALIGHT_CAPI_PLATFORM_H
31#define ULTRALIGHT_CAPI_PLATFORM_H
32
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45/******************************************************************************
46 * Platform
47 *****************************************************************************/
48
49///
50/// Set a custom Logger implementation.
51///
52/// This is used to log debug messages to the console or to a log file.
53///
54/// You should call this before ulCreateRenderer() or ulCreateApp().
55///
56/// @note ulCreateApp() will use the default logger if you never call this.
57///
58/// @note If you're not using ulCreateApp(), (eg, using ulCreateRenderer()) you can still use the
59/// default logger by calling ulEnableDefaultLogger() (@see <AppCore/CAPI.h>)
60///
62
63///
64/// Set a custom FileSystem implementation.
65///
66/// The library uses this to load all file URLs (eg, <file:///page.html>).
67///
68/// You can provide the library with your own FileSystem implementation so that file assets are
69/// loaded from your own pipeline.
70///
71/// You should call this before ulCreateRenderer() or ulCreateApp().
72///
73/// @warning This is required to be defined before calling ulCreateRenderer()
74///
75/// @note ulCreateApp() will use the default platform file system if you never call this.
76///
77/// @note If you're not using ulCreateApp(), (eg, using ulCreateRenderer()) you can still use the
78/// default platform file system by calling ulEnablePlatformFileSystem()'
79/// (@see <AppCore/CAPI.h>)
80///
82
83///
84/// Set a custom FontLoader implementation.
85///
86/// The library uses this to load all system fonts.
87///
88/// Every operating system has its own library of installed system fonts. The FontLoader interface
89/// is used to lookup these fonts and fetch the actual font data (raw TTF/OTF file data) for a given
90/// given font description.
91///
92/// You should call this before ulCreateRenderer() or ulCreateApp().
93///
94/// @warning This is required to be defined before calling ulCreateRenderer()
95///
96/// @note ulCreateApp() will use the default platform font loader if you never call this.
97///
98/// @note If you're not using ulCreateApp(), (eg, using ulCreateRenderer()) you can still use the
99/// default platform font loader by calling ulEnablePlatformFontLoader()'
100/// (@see <AppCore/CAPI.h>)
101///
103
104///
105/// Set a custom Surface implementation.
106///
107/// This can be used to wrap a platform-specific GPU texture, Windows DIB, macOS CGImage, or any
108/// other pixel buffer target for display on screen.
109///
110/// By default, the library uses a bitmap surface for all surfaces but you can override this by
111/// providing your own surface definition here.
112///
113/// You should call this before ulCreateRenderer() or ulCreateApp().
114///
116
117///
118/// Set a custom GPUDriver implementation.
119///
120/// This should be used if you have enabled the GPU renderer in the Config and are using
121/// ulCreateRenderer() (which does not provide its own GPUDriver implementation).
122///
123/// The GPUDriver interface is used by the library to dispatch GPU calls to your native GPU context
124/// (eg, D3D11, Metal, OpenGL, Vulkan, etc.) There are reference implementations for this interface
125/// in the AppCore repo.
126///
127/// You should call this before ulCreateRenderer().
128///
130
131///
132/// Set a custom Clipboard implementation.
133///
134/// This should be used if you are using ulCreateRenderer() (which does not provide its own
135/// clipboard implementation).
136///
137/// The Clipboard interface is used by the library to make calls to the system's native clipboard
138/// (eg, cut, copy, paste).
139///
140/// You should call this before ulCreateRenderer().
141///
143
144#ifdef __cplusplus
145} // extern "C"
146#endif
147
148#endif // ULTRALIGHT_CAPI_PLATFORM_H
#define ULExport
Definition CAPI_Defines.h:27
ULExport void ulPlatformSetFileSystem(ULFileSystem file_system)
Set a custom FileSystem implementation.
ULExport void ulPlatformSetClipboard(ULClipboard clipboard)
Set a custom Clipboard implementation.
ULExport void ulPlatformSetLogger(ULLogger logger)
Set a custom Logger implementation.
ULExport void ulPlatformSetFontLoader(ULFontLoader font_loader)
Set a custom FontLoader implementation.
ULExport void ulPlatformSetSurfaceDefinition(ULSurfaceDefinition surface_definition)
Set a custom Surface implementation.
ULExport void ulPlatformSetGPUDriver(ULGPUDriver gpu_driver)
Set a custom GPUDriver implementation.
Definition CAPI_Clipboard.h:38
Definition CAPI_FileSystem.h:60
Definition CAPI_FontLoader.h:63
Definition CAPI_GPUDriver.h:292
Definition CAPI_Logger.h:28
Definition CAPI_Surface.h:194