UI module

run_app

procedure · 1 overloadsince 0.31.0Source

Open a window and run build for every frame until the window closes. app is passed to build each frame. Returns false when the window or the GPU could not be set up.

Example
#import "Basic";
#import "Extensions/UI";

Counter :: struct {
    count: int;
}

main :: () {
    app: Counter;
    run_app(.{title = "Counter", width = 320, height = 200}, *app, build);
}

build :: (app: *Counter) {
    if button(tprint("Clicked % times", app.count)) app.count += 1;
}

This one is only checked to compile, not run.

run_app :: (options: App_Options, app: *$T, build: (app: *T)) -> bool

Open a window and run build for every frame until the window closes. app is passed to build each frame. Returns false when the window or the GPU could not be set up.

Parameters

options: App_Options
window title, size, theme, fonts and an optional frame limit.
app: *$T
your app state, passed to build each frame.
build: (app: *T)
declares the widgets for a frame.

Returns

bool
Example
#import "Basic";
#import "Extensions/UI";

Counter :: struct {
    count: int;
}

main :: () {
    app: Counter;
    run_app(.{title = "Counter", width = 320, height = 200}, *app, build);
}

build :: (app: *Counter) {
    if button(tprint("Clicked % times", app.count)) app.count += 1;
}

This one is only checked to compile, not run.

See also