![]() |
Ultralight C API 1.3.0
|
Go to the source code of this file.
The AppCore API is a convenient windowing system for desktop platforms built on top of the Ultralight renderer.
It automatically sets up the Renderer, creates a run loop, and handles all window creation, painting, and platform-specific operations for you.
To initialize your application, you should first call ulCreateApp().
To create a window, call ulCreateWindow().
To create a web-page overlay within a window, call ulCreateOverlay().
Functions | |
ACExport ULSettings | ulCreateSettings () |
Create settings with default values (see <AppCore/App.h>). | |
ACExport void | ulDestroySettings (ULSettings settings) |
Destroy settings. | |
ACExport void | ulSettingsSetDeveloperName (ULSettings settings, ULString name) |
Set the name of the developer of this app. | |
ACExport void | ulSettingsSetAppName (ULSettings settings, ULString name) |
Set the name of this app. | |
ACExport void | ulSettingsSetFileSystemPath (ULSettings settings, ULString path) |
Set the root file path for our file system, you should set this to the relative path where all of your app data is. | |
ACExport void | ulSettingsSetLoadShadersFromFileSystem (ULSettings settings, bool enabled) |
Set whether or not we should load and compile shaders from the file system (eg, from the /shaders/ path, relative to file_system_path). | |
ACExport void | ulSettingsSetForceCPURenderer (ULSettings settings, bool force_cpu) |
We try to use the GPU renderer when a compatible GPU is detected. | |
ACExport ULApp | ulCreateApp (ULSettings settings, ULConfig config) |
Create the App singleton. | |
ACExport void | ulDestroyApp (ULApp app) |
Destroy the App instance. | |
ACExport void | ulAppSetUpdateCallback (ULApp app, ULUpdateCallback callback, void *user_data) |
Set a callback for whenever the App updates. | |
ACExport bool | ulAppIsRunning (ULApp app) |
Whether or not the App is running. | |
ACExport ULMonitor | ulAppGetMainMonitor (ULApp app) |
Get the main monitor (this is never NULL). | |
ACExport ULRenderer | ulAppGetRenderer (ULApp app) |
Get the underlying Renderer instance. | |
ACExport void | ulAppRun (ULApp app) |
Run the main loop. | |
ACExport void | ulAppQuit (ULApp app) |
Quit the application. | |
ACExport double | ulMonitorGetScale (ULMonitor monitor) |
Get the monitor's DPI scale (1.0 = 100%). | |
ACExport unsigned int | ulMonitorGetWidth (ULMonitor monitor) |
Get the width of the monitor (in pixels). | |
ACExport unsigned int | ulMonitorGetHeight (ULMonitor monitor) |
Get the height of the monitor (in pixels). | |
ACExport ULWindow | ulCreateWindow (ULMonitor monitor, unsigned int width, unsigned int height, bool fullscreen, unsigned int window_flags) |
Create a new Window. | |
ACExport void | ulDestroyWindow (ULWindow window) |
Destroy a Window. | |
ACExport void | ulWindowSetCloseCallback (ULWindow window, ULCloseCallback callback, void *user_data) |
Set a callback to be notified when a window closes. | |
ACExport void | ulWindowSetResizeCallback (ULWindow window, ULResizeCallback callback, void *user_data) |
Set a callback to be notified when a window resizes (parameters are passed back in pixels). | |
ACExport unsigned int | ulWindowGetScreenWidth (ULWindow window) |
Get window width (in screen coordinates). | |
ACExport unsigned int | ulWindowGetWidth (ULWindow window) |
Get window width (in pixels). | |
ACExport unsigned int | ulWindowGetScreenHeight (ULWindow window) |
Get window height (in screen coordinates). | |
ACExport unsigned int | ulWindowGetHeight (ULWindow window) |
Get window height (in pixels). | |
ACExport void | ulWindowMoveTo (ULWindow window, int x, int y) |
Move the window to a new position (in screen coordinates) relative to the top-left of the monitor area. | |
ACExport void | ulWindowMoveToCenter (ULWindow) |
Move the window to the center of the monitor. | |
ACExport int | ulWindowGetPositionX (ULWindow window) |
Get the x-position of the window (in screen coordinates) relative to the top-left of the monitor area. | |
ACExport int | ulWindowGetPositionY (ULWindow window) |
Get the y-position of the window (in screen coordinates) relative to the top-left of the monitor area. | |
ACExport bool | ulWindowIsFullscreen (ULWindow window) |
Get whether or not a window is fullscreen. | |
ACExport double | ulWindowGetScale (ULWindow window) |
Get the DPI scale of a window. | |
ACExport void | ulWindowSetTitle (ULWindow window, const char *title) |
Set the window title. | |
ACExport void | ulWindowSetCursor (ULWindow window, ULCursor cursor) |
Set the cursor for a window. | |
ACExport void | ulWindowShow (ULWindow window) |
Show the window (if it was previously hidden). | |
ACExport void | ulWindowHide (ULWindow window) |
Hide the window. | |
ACExport bool | ulWindowIsVisible (ULWindow window) |
Whether or not the window is currently visible (not hidden). | |
ACExport void | ulWindowClose (ULWindow window) |
Close a window. | |
ACExport int | ulWindowScreenToPixels (ULWindow window, int val) |
Convert screen coordinates to pixels using the current DPI scale. | |
ACExport int | ulWindowPixelsToScreen (ULWindow window, int val) |
Convert pixels to screen coordinates using the current DPI scale. | |
ACExport void * | ulWindowGetNativeHandle (ULWindow window) |
Get the underlying native window handle. | |
ACExport ULOverlay | ulCreateOverlay (ULWindow window, unsigned int width, unsigned int height, int x, int y) |
Create a new Overlay. | |
ACExport ULOverlay | ulCreateOverlayWithView (ULWindow window, ULView view, int x, int y) |
Create a new Overlay, wrapping an existing View. | |
ACExport void | ulDestroyOverlay (ULOverlay overlay) |
Destroy an overlay. | |
ACExport ULView | ulOverlayGetView (ULOverlay overlay) |
Get the underlying View. | |
ACExport unsigned int | ulOverlayGetWidth (ULOverlay overlay) |
Get the width (in pixels). | |
ACExport unsigned int | ulOverlayGetHeight (ULOverlay overlay) |
Get the height (in pixels). | |
ACExport int | ulOverlayGetX (ULOverlay overlay) |
Get the x-position (offset from the left of the Window), in pixels. | |
ACExport int | ulOverlayGetY (ULOverlay overlay) |
Get the y-position (offset from the top of the Window), in pixels. | |
ACExport void | ulOverlayMoveTo (ULOverlay overlay, int x, int y) |
Move the overlay to a new position (in pixels). | |
ACExport void | ulOverlayResize (ULOverlay overlay, unsigned int width, unsigned int height) |
Resize the overlay (and underlying View), dimensions should be specified in pixels. | |
ACExport bool | ulOverlayIsHidden (ULOverlay overlay) |
Whether or not the overlay is hidden (not drawn). | |
ACExport void | ulOverlayHide (ULOverlay overlay) |
Hide the overlay (will no longer be drawn). | |
ACExport void | ulOverlayShow (ULOverlay overlay) |
Show the overlay. | |
ACExport bool | ulOverlayHasFocus (ULOverlay overlay) |
Whether or not an overlay has keyboard focus. | |
ACExport void | ulOverlayFocus (ULOverlay overlay) |
Grant this overlay exclusive keyboard focus. | |
ACExport void | ulOverlayUnfocus (ULOverlay overlay) |
Remove keyboard focus. | |
ACExport void | ulEnablePlatformFontLoader () |
This is only needed if you are not calling ulCreateApp(). | |
ACExport void | ulEnablePlatformFileSystem (ULString base_dir) |
This is only needed if you are not calling ulCreateApp(). | |
ACExport void | ulEnableDefaultLogger (ULString log_path) |
This is only needed if you are not calling ulCreateApp(). | |
Macros | |
#define | ACExport __attribute__((visibility("default"))) |
Typedefs | |
typedef struct C_Settings * | ULSettings |
typedef struct C_App * | ULApp |
typedef struct C_Window * | ULWindow |
typedef struct C_Monitor * | ULMonitor |
typedef struct C_Overlay * | ULOverlay |
typedef void(* | ULUpdateCallback) (void *user_data) |
typedef void(* | ULCloseCallback) (void *user_data, ULWindow window) |
typedef void(* | ULResizeCallback) (void *user_data, ULWindow window, unsigned int width, unsigned int height) |
Enumerations | |
enum | ULWindowFlags { kWindowFlags_Borderless = 1 << 0 , kWindowFlags_Titled = 1 << 1 , kWindowFlags_Resizable = 1 << 2 , kWindowFlags_Maximizable = 1 << 3 , kWindowFlags_Hidden = 1 << 4 } |
Window creation flags. More... | |
Get the main monitor (this is never NULL).
ACExport ULRenderer ulAppGetRenderer | ( | ULApp | app | ) |
Get the underlying Renderer instance.
ACExport void ulAppSetUpdateCallback | ( | ULApp | app, |
ULUpdateCallback | callback, | ||
void * | user_data | ||
) |
Set a callback for whenever the App updates.
You should update all app logic here.
ACExport ULApp ulCreateApp | ( | ULSettings | settings, |
ULConfig | config | ||
) |
Create the App singleton.
settings | Settings to customize App runtime behavior. You can pass NULL for this parameter to use default settings. |
config | Config options for the Ultralight renderer. You can pass NULL for this parameter to use default config. |
ACExport ULOverlay ulCreateOverlay | ( | ULWindow | window, |
unsigned int | width, | ||
unsigned int | height, | ||
int | x, | ||
int | y | ||
) |
Create a new Overlay.
window | The window to create the Overlay in. |
width | The width in pixels. |
height | The height in pixels. |
x | The x-position (offset from the left of the Window), in pixels. |
y | The y-position (offset from the top of the Window), in pixels. |
Create a new Overlay, wrapping an existing View.
window | The window to create the Overlay in. (we currently only support one window per application) |
view | The View to wrap (will use its width and height). |
x | The x-position (offset from the left of the Window), in pixels. |
y | The y-position (offset from the top of the Window), in pixels. |
ACExport ULSettings ulCreateSettings | ( | ) |
Create settings with default values (see <AppCore/App.h>).
ACExport ULWindow ulCreateWindow | ( | ULMonitor | monitor, |
unsigned int | width, | ||
unsigned int | height, | ||
bool | fullscreen, | ||
unsigned int | window_flags | ||
) |
Create a new Window.
monitor | The monitor to create the Window on. |
width | The width (in screen coordinates). |
height | The height (in screen coordinates). |
fullscreen | Whether or not the window is fullscreen. |
window_flags | Various window flags. |
ACExport void ulDestroySettings | ( | ULSettings | settings | ) |
Destroy settings.
This is only needed if you are not calling ulCreateApp().
Initializes the default logger (writes the log to a file).
You should specify a writable log path to write the log to for example "./ultralight.log".
This is only needed if you are not calling ulCreateApp().
Initializes the platform file system (needed for loading file:/// URLs) and sets it as the current FileSystem.
You can specify a base directory path to resolve relative paths against.
ACExport void ulEnablePlatformFontLoader | ( | ) |
This is only needed if you are not calling ulCreateApp().
Initializes the platform font loader and sets it as the current FontLoader.
Get the height of the monitor (in pixels).
Get the width of the monitor (in pixels).
Get the x-position (offset from the left of the Window), in pixels.
Get the y-position (offset from the top of the Window), in pixels.
Whether or not the overlay is hidden (not drawn).
Move the overlay to a new position (in pixels).
Resize the overlay (and underlying View), dimensions should be specified in pixels.
ACExport void ulSettingsSetAppName | ( | ULSettings | settings, |
ULString | name | ||
) |
Set the name of this app.
This is used to generate a unique path to store local application data on the user's machine.
Default is "MyApp"
ACExport void ulSettingsSetDeveloperName | ( | ULSettings | settings, |
ULString | name | ||
) |
Set the name of the developer of this app.
This is used to generate a unique path to store local application data on the user's machine.
Default is "MyCompany"
ACExport void ulSettingsSetFileSystemPath | ( | ULSettings | settings, |
ULString | path | ||
) |
Set the root file path for our file system, you should set this to the relative path where all of your app data is.
This will be used to resolve all file URLs, eg file:///page.html
This relative path is resolved using the following logic: - Windows: relative to the executable path - Linux: relative to the executable path - macOS: relative to YourApp.app/Contents/Resources/
ACExport void ulSettingsSetForceCPURenderer | ( | ULSettings | settings, |
bool | force_cpu | ||
) |
We try to use the GPU renderer when a compatible GPU is detected.
Set this to true to force the engine to always use the CPU renderer.
ACExport void ulSettingsSetLoadShadersFromFileSystem | ( | ULSettings | settings, |
bool | enabled | ||
) |
Set whether or not we should load and compile shaders from the file system (eg, from the /shaders/ path, relative to file_system_path).
If this is false (the default), we will instead load pre-compiled shaders from memory which speeds up application startup time.
Get the underlying native window handle.
Get the x-position of the window (in screen coordinates) relative to the top-left of the monitor area.
Get the y-position of the window (in screen coordinates) relative to the top-left of the monitor area.
Get window height (in screen coordinates).
Get window width (in screen coordinates).
Whether or not the window is currently visible (not hidden).
Move the window to a new position (in screen coordinates) relative to the top-left of the monitor area.
Convert pixels to screen coordinates using the current DPI scale.
Convert screen coordinates to pixels using the current DPI scale.
ACExport void ulWindowSetCloseCallback | ( | ULWindow | window, |
ULCloseCallback | callback, | ||
void * | user_data | ||
) |
Set a callback to be notified when a window closes.
ACExport void ulWindowSetResizeCallback | ( | ULWindow | window, |
ULResizeCallback | callback, | ||
void * | user_data | ||
) |
Set a callback to be notified when a window resizes (parameters are passed back in pixels).
#define ACExport __attribute__((visibility("default"))) |
typedef struct C_App* ULApp |
typedef void(* ULCloseCallback) (void *user_data, ULWindow window) |
typedef struct C_Monitor* ULMonitor |
typedef struct C_Overlay* ULOverlay |
typedef void(* ULResizeCallback) (void *user_data, ULWindow window, unsigned int width, unsigned int height) |
typedef struct C_Settings* ULSettings |
typedef void(* ULUpdateCallback) (void *user_data) |
typedef struct C_Window* ULWindow |
enum ULWindowFlags |