Skip to content

gg #

Description

gg is V's simple graphics module. It is currently implemented using sokol, and makes easy creating apps that just need a way to draw simple 2D shapes, and to react to user's keyboard/mouse input.

Example

module main

import gg

fn main() {
    mut context := gg.new_context(
        bg_color:     gg.rgb(174, 198, 255)
        width:        600
        height:       400
        window_title: 'Polygons'
        frame_fn:     frame
    )
    context.run()
}

fn frame(mut ctx gg.Context) {
    ctx.begin()
    ctx.draw_convex_poly([f32(100.0), 100.0, 200.0, 100.0, 300.0, 200.0, 200.0, 300.0, 100.0, 300.0],
        gg.blue)
    ctx.draw_poly_empty([f32(50.0), 50.0, 70.0, 60.0, 90.0, 80.0, 70.0, 110.0], gg.black)
    ctx.draw_triangle_filled(450, 142, 530, 280, 370, 280, gg.red)
    ctx.end()
}

Multi-Window Applications

gg.App is an additive multi-window facade for programs that need to manage more than one native window from the same gg application. It is opt-in and is compiled only when the program is built with -d gg_multiwindow. examples/gg/multiwindow.v is the interactive example:

v -d gg_multiwindow run examples/gg/multiwindow.v

The existing single-window gg.Context API and behavior are unchanged. A normal import gg program that uses gg.new_context() does not load the native multi-window implementation. Without -d gg_multiwindow, the opt-in API surface is a non-render compatibility stub: accidental gg.App calls report a clear "compile with -d gg_multiwindow" error instead of pulling in x.multiwindow or native backend code.

Users normally import only gg. x.multiwindow is the lower-level lifecycle, window and render-surface layer used by the facade, and is available for backend or direct-control callers. Use backend: .auto for native applications. It selects the appropriate platform backend at runtime/build time, falling back only when a native backend is unavailable. On Linux, X11 native windows are opt-in with -d x_multiwindow_x11; Wayland remains opt-in with -d sokol_wayland. Tests and headless tools can request backend: .mock explicitly; the lower-level .mock path remains dependency-light and does not link X11/EGL/OpenGL by default.

The basic lifecycle is:

import gg

fn main() {
    mut app := gg.new_app(backend: .auto)!
    defer {
        app.stop() or {}
    }

    main_window := app.create_window(
        title:  'Main'
        width:  800
        height: 600
    )!

    app.run(
        event_fn: fn (event gg.WindowEvent, mut app gg.App) ! {
            match event.kind {
                .window_close_requested {
                    app.destroy_window(event.window)!
                }
                .window_destroyed {
                    if app.window_ids()!.len == 0 {
                        app.stop()!
                    }
                }
                else {}
            }
        }
    )!

    _ = main_window
}

Lifecycle-only applications can run with just event_fn; they do not require a renderer. frame_fn and draw_window() require an already render-capable app; they do not re-run .auto backend selection. Programs that plan to render should use gg.new_app(require_renderer: true) or verify app.capabilities().explicit_swapchain before rendering. Linux X11 rendering, including under Xvfb, needs both flags:

xvfb-run -a v -d gg_multiwindow -d x_multiwindow_x11 run examples/gg/multiwindow.v

AppConfig.app_id supplies the native application identity (currently the Wayland xdg_toplevel app id). A modal WindowConfig must name a live owner from the same app; ownerless modal windows are rejected before native allocation, whether hidden or visible. Destroying an owner destroys its complete owned-window tree child-first; stop() uses the same child-before-owner order for every remaining window. Destroying the final window does not stop the app automatically, so event loops should call app.stop() explicitly. For every destroyed descendant, pending clipboard and portal requests are cancelled and portal leases are invalidated during sealing, before any teardown result can be delivered. Their service cancellations precede readback cancellation and the final window_destroyed event in the canonical queue; teardown replay does not duplicate those terminals. After a window generation is sealed, state/capability queries and new service, readback, and native-borrow admissions fail as stale. Already admitted work follows the terminal or cancellation flow, and queued terminals remain deliverable.

examples/gg/multiwindow_render_runtime.v is an unattended CI probe, not an interactive launch target. Backend lanes compile it with -d gg_multiwindow plus -d x_multiwindow_x11, -d sokol_wayland, -d sokol_metal, or -d sokol_d3d11 as appropriate, and select the matching backend through V_MULTIWINDOW_PROBE_BACKEND. A process-tree watchdog supplies the private parent gate, enforces the deadline, and checks process cleanup. After all window and renderer cleanup succeeds, the probe emits {"example":"multiwindow_render_runtime","status":"PASS","cleanup":"complete"}.

Multi-Window Events

gg.App.run() dispatches all four ordered event families: lifecycle through event_fn, input through input_fn, native service results through window_service_fn, and readback terminals through readback_fn. Lifecycle events use gg.WindowEvent and cover created, resized, close-requested and destroyed windows. Input events use gg.WindowInputEvent, which adds the target gg.WindowId to the normal gg.Event payload so existing key, mouse, scroll, focus and window-state event fields keep the same gg-facing types. If any of the four queue callbacks returns an error, run() reinserts the current event and every untouched suffix event in their original order. All four handlers must therefore be idempotent, not only readback handlers. For native multi-window events, gg.Event.frame_count is assigned by the underlying multi-window owner poll cycle so events collected by the same app.poll_events() call share a frame count.

input_fn has the gg.AppInputFn shape:

fn (event gg.WindowInputEvent, mut app gg.App) !

For manual owner loops, call app.poll_events() and then either app.drain_window_queued_events() or a specialized drain. The canonical drain returns lifecycle, input, service, and readback envelopes in exact global acceptance order. drain_events(), drain_input_events(), and drain_window_service_events() each consume only a contiguous prefix of their own family; if another family is at the head, they return empty without skipping it. There is deliberately no separate gg readback drain: consume readbacks via readback_fn in run() or .readback entries from the canonical drain.

Input support is capability-driven. Check app.capabilities() before relying on a class of native events: input_events, mouse_events, keyboard_events, text_events, focus_events, drop_events and touch_events report what the selected backend can actually deliver. cursor_shapes reports whether app.set_window_cursor(id, shape) can update native hover cursor feedback, and is independent from interactive move/resize support. interactive_move_resize reports whether the runtime backend has the native handles needed for app.begin_window_move(id) and app.begin_window_resize(id, edge); individual calls can still fail when the platform requires a recent user-action serial. native_decorations reports whether native/server-side window decorations are effective for the running backend. Plain capability probes do not necessarily open a display, so runtime globals are authoritative only after gg.new_app() via app.capabilities(); on Wayland that includes wl_touch for touch, wl_data_device for drops, seats for interactive move/resize, and xdg-decoration negotiation for native decorations. Wayland cursor-shape reporting is stricter: cursor_shapes is true only after a wp_cursor_shape_device_v1 has been created for the active wl_pointer. Wayland requests server-side decorations through xdg-decoration when available; the compositor's configure(mode) decides the effective server_side or client_side mode. If server_side is refused or xdg-decoration is unavailable, apps and examples may draw a client-side fallback. Wayland cursor shape feedback uses wp_cursor_shape_manager_v1 when the compositor exposes it and the seat has a pointer; cursor theme selection remains compositor-side. wl_cursor_theme client-side fallback is not implemented, so app.capabilities() reports cursor_shapes == false on Wayland compositors that do not advertise cursor-shape-v1. Wayland uses fractional-scale-v1 only when viewporter is also present; otherwise framebuffer metrics follow integer wl_output scale. Backends must leave unsupported classes false instead of emulating partial support. Current native backends route window-scoped mouse, keyboard, focus, resize and iconified/restored events where the platform implementation supports them. drop_events is true on native backends that clone dropped file paths into WindowInputEvent.dropped_files; touch_events is true only where native touch input is wired. Win32 reports the WM_TOUCH began/moved/ended states; AppKit also reports cancelled touches from touchesCancelledWithEvent:. Clipboard paste is reported as an event signal; clipboard contents are not carried by WindowInputEvent. X11 text uses XIM/XIC with Xutf8LookupString. X11 file drops accept inline or bounded 1 MiB ICCCM INCR XDND text/uri-list transfers, refresh their timeout only on progress, never publish a partial drop, and safely finish even if the source window disappears. Wayland text uses xkb keymap/state for key-press characters, and Wayland file drops use wl_data_device/wl_data_offer text/uri-list. A drop exactly at the byte limit is accepted only after EOF confirms that no extra byte remains; neither Linux text path implements full IME/composed text yet.

Window Services and Native Borrows

Services are capability-first. Query window_operation_capability(window, operation) on the running app immediately before an optional call. The runtime answer is authoritative: .conditional can still require compositor support, window configuration, or a recent user action. .asynchronous means the call is not synchronously authoritative; it does not promise a later queued result. Check .state_observable before waiting for a state observation. Wayland minimize is asynchronous with state_observable == false, so no resulting minimized-state observation is guaranteed. Use window_state() for the latest observed state and monitor_ids() plus monitor_info() for generation-checked monitor snapshots. Full observations can authoritatively clear membership; partial state observations preserve the last known ids. Monitor names are descriptive, not stable identities. X11 root work-area/current-desktop changes refresh the complete monitor projection while failed refreshes preserve the last snapshot. Win32 keeps the app-level monitor projection current even while the app has no managed windows and refreshes it before the next first window. Window membership observations contain only ids in the currently available public monitor snapshot; staged native monitor and metrics updates become visible together.

Clipboard reads and writes return ClipboardRequestId; match it with the terminal .clipboard WindowServiceEvent. Portal export returns PortalParentRequestId; a ready event contains both an opaque identifier and a PortalParentLeaseId. Keep the lease alive for the external consumer and call release_portal_parent() explicitly afterward. Native X11 identifiers start with x11: and Wayland xdg-foreign-v2 identifiers start with wayland:. Treat everything after the prefix as opaque. Wayland clipboard uses the seat data device, writes require a recent input serial, and portal export requires xdg-foreign-v2. If preparing a replacement Wayland clipboard source fails before selection submission, the previously published clipboard value remains unchanged. A compositor clipboard send already accepted by Wayland uses its own bounded text snapshot and can finish after replacement or source cancellation. Each active X11 clipboard read has an isolated native conversion requestor, so late inline, failure, or INCR replies cannot complete a later request; failure to start a queued conversion is delivered as its terminal failure. Replies to external X11 requestors, including INCR chunks, use a checked connection so an expired requestor fails that transfer without affecting later clipboard work. For X11 INCR reads, the advertised length is a lower bound; actual growth is accepted only within the per-request and aggregate clipboard byte limits. Queued clipboard terminal payloads share a 16 MiB, 64-operation bound across backends and remain charged until their service events are delivered or discarded.

with_native_window() is callback-only. Inside its callback, invoke exactly the accessor matching app.capabilities().backend:

  • with_win32: HWND;
  • with_appkit: NSWindow pointer;
  • with_x11: Display pointer and X11 Window;
  • with_wayland: wl_display and wl_surface pointers.

NativeWindowLease expires when the outer with_native_window() callback returns. A backend handle expires sooner, when its nested lease.with_* callback returns. Never store, return, or use either authority after its own callback lifetime.

Window and managed-image readbacks are asynchronous. WindowReadbackConfig{} captures the full target; rect requests a positive, fully contained region in framebuffer coordinates. Every request admits and enqueues one terminal result as .ready, .cancelled, or .failed, but a callback failure can replay that same queued result until acknowledgment; handlers must be idempotent. Ready results own top-left RGBA8 bytes, an explicit stride, dimensions, and the producing submitted_frame; cancellation/failure does not carry pixels. Pending and queued readbacks share a 256 MiB, 64-operation bound. A producer reserves its tight RGBA8 size before allocation or capture, and that storage remains charged until the terminal event is delivered or discarded. Pending requests are cancelled during window/app teardown. app.capabilities().readback is only the backend-wide availability summary for the current renderer (Mock has its deterministic window path; AppKit requires a ready Metal renderer). window_readback_capabilities() reports per-window path availability. The request still validates app/window ownership, same-window image scope, single-sample 2D render-target eligibility, and rectangle bounds.

The compact end-to-end example is:

v -d gg_multiwindow run examples/gg/multiwindow_services.v

It gates operations on runtime capabilities, queries state and monitors, correlates clipboard/portal request ids, releases portal leases, uses a scoped native borrow, and requests readback only when available.

Runtime support differs by backend:

Backend Service summary
Mock Deterministic state, monitors, clipboard, portal, and readback for tests; native borrow is unsupported.
X11 Native state/monitors, clipboard, portal (x11:), scoped borrow, and native window capture; focus is available only when the live server advertises EWMH _NET_ACTIVE_WINDOW, its request is asynchronous, and authoritative state comes from FocusIn/FocusOut. Position and supported window-manager minimize/maximize/fullscreen/restore requests are also asynchronous; root-coordinate observations triggered by ConfigureNotify and native WM-state property events are authoritative. Mouse-lock centers are refreshed after resize. Other EWMH, mouse-lock, and rendered-image support also depend on the live server/renderer.
Wayland Runtime-global-driven state/monitors, clipboard, portal (wayland:), scoped borrow, and mouse lock; focus/raise/position are unsupported. Hide/show remapping preserves configured metadata, ownership, constraints, decorations, and maximize/fullscreen intent; show fails hidden and retryable when no fresh compositor configure is available. Show/minimize/maximize/restore/fullscreen/mouse-lock are asynchronous, but minimize is not state-observable, so callers are not guaranteed a resulting minimized-state observation. Rendered readback requires the active GL path.
AppKit Native state/monitors, scoped borrow, clipboard, window operations, and titlebar appearance as reported by the live bridge; portal is unsupported and readback requires active Metal.
Win32 Native state/monitors (including zero-window observation), scoped borrow, clipboard, and standard window operations; focus/mouse lock are conditional. Focus loss releases mouse lock transactionally, retaining an error and retrying without a false unlocked observation if cleanup fails. Maximize depends on window configuration; fullscreen and restore become unsupported if the native fullscreen state is unknown. Portal/readback are currently unsupported.

This table is orientation only. Always prefer the live per-window capability over backend-name assumptions. Relative mouse lock on Wayland, for example, requires both relative-pointer and pointer-constraints globals.

The multi-window event queue is separate from legacy gg.Context callbacks. Normal single-window applications keep using the existing event_fn, keydown_fn, move_fn, scroll_fn and related callbacks on gg.Context, and do not import or initialize x.multiwindow.

gg.App manages native windows through x.multiwindow. The lower-level x.multiwindow layer owns native lifetimes and the owner queue; gg.App owns sokol.gfx/sokol.sgl renderer state only after rendering is initialized. Create, run, stop and render from the owner thread. Background threads should schedule owner-side work with app.post() or app.try_post() and let the run loop drain it. A gg.App render owner cannot coexist with an active legacy gg.Context renderer owner in the same process, but the legacy gg.Context API remains available for normal single-window programs.

The public facade maps gg.App/WindowId, WindowEvent, WindowInputEvent, WindowServiceEvent, WindowReadbackResult, and WindowQueuedEvent to the corresponding x.multiwindow app/id, lifecycle, input, service, readback, and queued-envelope types. Likewise, window_state, monitor_ids, window_operation_capability, and drain_window_queued_events map to the lower-level service_* queries and drain_queued_events. Keep application code on the gg side unless it deliberately needs the low-level backend layer; opaque ids, leases, and native handles are not interchangeable across the facade.

Per-Window Render API

With -d gg_multiwindow, WindowConfig provides per-window clear color, redraw mode, sample count, and init/frame/cleanup callbacks. Callback contexts provide immutable metrics and target snapshots, bounded frame/pass authority, app- and window-scoped managed resource IDs, pass methods, and the recording subset of WindowSglContext. RunConfig also provides app-resource lifecycle callbacks for resources shared by multiple windows.

Multi-window render targets support exactly sample_count: 1. A different sample count is rejected when a renderer is required or active. With an X11 or Wayland GL renderer active, request_window_capture() reads the framebuffer owned by gg after drawing and publishes it only after the producing frame is submitted. request_image_readback() reads a managed single-sample 2D render target. Without an active X11 renderer, window capture falls back to the native XGetImage path; that path reflects the X server drawable and cannot guarantee frame-exact compositor presentation under XWayland. Neither path is desktop or compositor capture. Results are owned top-left RGBA8 values delivered through RunConfig.readback_fn and support bounded pixel regions. Query window_readback_capabilities() before either operation. AppKit exposes the same asynchronous contract when its Metal renderer and private pre-present hook are active; GLCore33 and rendererless AppKit builds report unsupported. Win32 readback remains unsupported in this tranche.

Managed IDs are scoped to their app and, where applicable, their window. Stale, foreign, or expired IDs and callback leases return errors instead of exposing raw gfx.Environment, gfx.Swapchain, native drawable, command-buffer, or present authority. Rendering uses owner-thread batches, backend-issued ready credits, late target acquisition, ordered finalization, and one global commit per submitted batch.

Renderer behavior is exercised in the dedicated X11, Wayland, AppKit, and Win32 CI lanes. Those lanes set VGG_MULTIWINDOW_RUNTIME_PROBES=1, VGG_MULTIWINDOW_RUNTIME_BACKEND, and V_MULTIWINDOW_PROBE_BACKEND; compile with the matching native flag; and run tests and probes through the process-tree watchdog. The checks cover multi-window submission, resource cleanup and replacement, stale leases, callback-driven teardown, recovery, and native fault paths. A normal legacy gg.Context import remains isolated from x.multiwindow and native multi-window backend dependencies. The implementation follows the V-vendored Sokol revision and matching pinned sokol_gfx.h and sokol_gl.h contracts.

Troubleshooting

A common problem, if you draw a lot of primitive elements in the same frame, is that there is a chance that your program can exceed the maximum allowed amount of vertices and commands, imposed by sokol. The symptom is that your frame will be suddenly black, after it becomes more complex. Sokol's default for vertices is 131072. Sokol's default for commands is 32768.

To solve that, you can try adding these lines at the top of your program: #flag -D_SGL_DEFAULT_MAX_VERTICES=4194304 #flag -D_SGL_DEFAULT_MAX_COMMANDS=65536 You can see an example of that in: https://github.com/vlang/v/blob/master/examples/gg/many_thousands_of_circles_overriding_max_vertices.v

Another approach is to use several draw passes, and limit the amount of draw calls that you make in each, demonstrated in: https://github.com/vlang/v/blob/master/examples/gg/many_thousands_of_circles.v

Another approach to that problem, is to draw everything yourself in a streaming texture, then upload that streaming texture as a single draw command to the GPU. You can see an example of that done in: https://github.com/vlang/v/blob/master/examples/gg/random.v and in: https://github.com/vlang/v/blob/master/examples/gg/random_stars.v

A third approach, is to only upload your changing inputs to the GPU, and do all the calculations and drawing there in shaders.

Constants #

const black = Color{
	r: 0
	g: 0
	b: 0
}
const gray = Color{
	r: 128
	g: 128
	b: 128
}
const white = Color{
	r: 255
	g: 255
	b: 255
}
const red = Color{
	r: 255
	g: 0
	b: 0
}
const green = Color{
	r: 0
	g: 255
	b: 0
}
const blue = Color{
	r: 0
	g: 0
	b: 255
}
const yellow = Color{
	r: 255
	g: 255
	b: 0
}
const magenta = Color{
	r: 255
	g: 0
	b: 255
}
const cyan = Color{
	r: 0
	g: 255
	b: 255
}
const orange = Color{
	r: 255
	g: 165
	b: 0
}
const purple = Color{
	r: 128
	g: 0
	b: 128
}
const indigo = Color{
	r: 75
	g: 0
	b: 130
}
const pink = Color{
	r: 255
	g: 192
	b: 203
}
const violet = Color{
	r: 238
	g: 130
	b: 238
}
const dark_blue = Color{
	r: 0
	g: 0
	b: 139
}
const dark_gray = Color{
	r: 169
	g: 169
	b: 169
}
const dark_green = Color{
	r: 0
	g: 100
	b: 0
}
const dark_red = Color{
	r: 139
	g: 0
	b: 0
}
const light_blue = Color{
	r: 173
	g: 216
	b: 230
}
const light_gray = Color{
	r: 211
	g: 211
	b: 211
}
const light_green = Color{
	r: 144
	g: 238
	b: 144
}
const light_red = Color{
	r: 255
	g: 204
	b: 203
}
const align_right = HorizontalAlign.right
const align_left = HorizontalAlign.left

fn capabilities_for_backend #

fn capabilities_for_backend(backend MultiWindowBackend) !Capabilities

capabilities_for_backend reports capabilities for a backend policy.

fn capabilities_for_backend_with_renderer #

fn capabilities_for_backend_with_renderer(backend MultiWindowBackend) !Capabilities

capabilities_for_backend_with_renderer reports capabilities while requiring renderer startup. Compile with -d gg_multiwindow to enable this API.

fn color_from_string #

fn color_from_string(s string) Color

color_from_string returns a Color, corresponding to the given string or black Color if string is not found in lookup table, or a hex color if starting with #

fn create_default_pass #

fn create_default_pass(action gfx.PassAction) gfx.Pass

fn dpi_scale #

fn dpi_scale() f32

dpi_scale returns the DPI scale coefficient for the screen. Do not use for Android development, use Context.scale instead.

fn frgb #

fn frgb[T](r T, g T, b T) Color

frgb builds a Color instance from the given floating point values (between 0.0 and 1.0) r, g, b

fn frgba #

fn frgba[T](r T, g T, b T, a T) Color

frgba builds a Color instance from the given floating point values (between 0.0 and 1.0) r, g, b, a

fn hex #

fn hex(color u32) Color

hex takes in a 32 bit integer and splits it into 4 byte values

fn high_dpi #

fn high_dpi() bool

high_dpi returns true if gg is running on a high DPI monitor or screen.

fn is_fullscreen #

fn is_fullscreen() bool

is it fullscreen

fn new_app #

fn new_app(config AppConfig) !&App

new_app creates a gg multi-window application.

fn new_context #

fn new_context(cfg Config) &Context

new_context returns an initialized Context allocated on the heap.

fn rgb #

fn rgb(r u8, g u8, b u8) Color

rgb builds a Color instance from the given r, g, b u8 values

fn rgba #

fn rgba(r u8, g u8, b u8, a u8) Color

rgba builds a Color instance from the given r, g, b, a u8 values

fn screen_size #

fn screen_size() Size

screen_size returns the size of the active screen.

fn set_window_title #

fn set_window_title(title string)

set_window_title sets main window's title

fn start #

fn start(cfg Config)

start creates a new context and runs it right away. It is a convenient way to start short/throwaway gg based prototypes, that do not need to keep and update their own state, like simple animations/visualisations that depend only on the time, or the ctx.frame counter. Use gg.new_context() for more complex ones.

fn toggle_fullscreen #

fn toggle_fullscreen()

toggle fullscreen

fn window_size #

fn window_size() Size

window_size returns the Size of the active window. Do not use for Android development, use Context.window_size() instead.

fn window_size_real_pixels #

fn window_size_real_pixels() Size

window_size_real_pixels returns the Size of the active window without scale

fn EndEnum.from #

fn EndEnum.from[W](input W) !EndEnum

fn GfxRenderOwner.from #

fn GfxRenderOwner.from[W](input W) !GfxRenderOwner

fn HorizontalAlign.from #

fn HorizontalAlign.from[W](input W) !HorizontalAlign

fn ImageEffect.from #

fn ImageEffect.from[W](input W) !ImageEffect

fn KeyCode.from #

fn KeyCode.from[W](input W) !KeyCode

fn Modifier.from #

fn Modifier.from[W](input W) !Modifier

fn Modifier.zero #

fn Modifier.zero() Modifier

fn MouseButton.from #

fn MouseButton.from[W](input W) !MouseButton

fn MouseButtons.from #

fn MouseButtons.from[W](input W) !MouseButtons

fn MouseButtons.zero #

fn MouseButtons.zero() MouseButtons

fn MultiWindowBackend.from #

fn MultiWindowBackend.from[W](input W) !MultiWindowBackend

fn MultiWindowRenderPhase.from #

fn MultiWindowRenderPhase.from[W](input W) !MultiWindowRenderPhase

fn MultiWindowResourceOperation.from #

fn MultiWindowResourceOperation.from[W](input W) !MultiWindowResourceOperation

fn MultiWindowResourceScope.from #

fn MultiWindowResourceScope.from[W](input W) !MultiWindowResourceScope

fn PaintStyle.from #

fn PaintStyle.from[W](input W) !PaintStyle

fn PenLineType.from #

fn PenLineType.from[W](input W) !PenLineType

fn ScreenshotOutput.from #

fn ScreenshotOutput.from[W](input W) !ScreenshotOutput

fn TextureFilter.from #

fn TextureFilter.from[W](input W) !TextureFilter

fn VerticalAlign.from #

fn VerticalAlign.from[W](input W) !VerticalAlign

fn WindowCleanupReason.from #

fn WindowCleanupReason.from[W](input W) !WindowCleanupReason

fn WindowCursorShape.from #

fn WindowCursorShape.from[W](input W) !WindowCursorShape

fn WindowEventKind.from #

fn WindowEventKind.from[W](input W) !WindowEventKind

fn WindowMappingState.from #

fn WindowMappingState.from[W](input W) !WindowMappingState

fn WindowObservedBool.from #

fn WindowObservedBool.from[W](input W) !WindowObservedBool

fn WindowOperation.from #

fn WindowOperation.from[W](input W) !WindowOperation

fn WindowQueuedEventKind.from #

fn WindowQueuedEventKind.from[W](input W) !WindowQueuedEventKind

fn WindowReadbackStatus.from #

fn WindowReadbackStatus.from[W](input W) !WindowReadbackStatus

fn WindowRedrawMode.from #

fn WindowRedrawMode.from[W](input W) !WindowRedrawMode

fn WindowResizeEdge.from #

fn WindowResizeEdge.from[W](input W) !WindowResizeEdge

fn WindowServiceEventKind.from #

fn WindowServiceEventKind.from[W](input W) !WindowServiceEventKind

fn WindowServiceStatus.from #

fn WindowServiceStatus.from[W](input W) !WindowServiceStatus

fn WindowSupportLevel.from #

fn WindowSupportLevel.from[W](input W) !WindowSupportLevel

fn WindowTitlebarAppearance.from #

fn WindowTitlebarAppearance.from[W](input W) !WindowTitlebarAppearance

fn WindowVisibilityState.from #

fn WindowVisibilityState.from[W](input W) !WindowVisibilityState

type AppEventFn #

type AppEventFn = fn (event WindowEvent, mut app App) !

AppEventFn is called by App.run() for each drained multi-window event.

type AppFrameFn #

type AppFrameFn = fn (mut app App) !

AppFrameFn is a render-frame callback and requires a render-capable backend with explicit swapchains.

type AppInputFn #

type AppInputFn = fn (event WindowInputEvent, mut app App) !

AppInputFn is called by App.run() for each drained multi-window input event.

type AppJobFn #

type AppJobFn = fn (mut app App) !

AppJobFn is executed later by app.drain_pending() on the owner side.

type AppKitNativeWindowFn #

type AppKitNativeWindowFn = fn (ns_window voidptr) !

AppKitNativeWindowFn receives a borrowed NSWindow pointer valid only for the callback.

type AppResourceCleanupFn #

type AppResourceCleanupFn = fn (mut AppResourceContext) !

AppResourceCleanupFn releases app-scoped managed resources.

type AppResourceContext #

type AppResourceContext = WindowResourceContext

AppResourceContext uses the same managed resource operations with app scope.

type AppResourceFrameFn #

type AppResourceFrameFn = fn (mut AppResourceContext) !

AppResourceFrameFn updates app-scoped managed resources during a batch.

type AppResourceInitFn #

type AppResourceInitFn = fn (mut AppResourceContext) !

AppResourceInitFn initializes app-scoped managed resources.

type FNCb #

type FNCb = fn (data voidptr)

type FNChar #

type FNChar = fn (c u32, data voidptr)

FNChar defines the type of a function that will be called once per character

type FNClick #

type FNClick = fn (x f32, y f32, button MouseButton, data voidptr)

FNClick defines the type of a function that will be called for every mouse click

type FNEvent #

type FNEvent = fn (e &Event, data voidptr)

FNEvent defines the type of a function that will be called for every event

type FNEvent2 #

type FNEvent2 = fn (data voidptr, e &Event)

FNEvent2 same as FNEvent with inverted arguments TODO: deprecate this, in favor of event_fn

type FNFail #

type FNFail = fn (msg string, data voidptr)

FNFail defines the type of a function that will be called when there is a fail

type FNKeyDown #

type FNKeyDown = fn (c KeyCode, m Modifier, data voidptr)

FNKeyDown defines the type of a function that will be called for every key pressed down

type FNKeyUp #

type FNKeyUp = fn (c KeyCode, m Modifier, data voidptr)

FNKeyUp defines the type of a function that will be called for every release of a pressed key

type FNMove #

type FNMove = fn (x f32, y f32, data voidptr)

FNMove defines the type of a function that will be called for every mouse move on the screen

type FNUnClick #

type FNUnClick = fn (x f32, y f32, button MouseButton, data voidptr)

FNUnClick defines the type of a function that will be called every time a mouse button is released

type FNUpdate #

type FNUpdate = fn (dt f32, data voidptr)

FNUpdate defines the type of a function, that will be called at the start of each frame with an argument dt, that has the passed time in seconds, since the previous update.

type NativeWindowBorrowFn #

type NativeWindowBorrowFn = fn (mut NativeWindowLease) !

NativeWindowBorrowFn receives a native lease that expires with the callback.

type TouchPoint #

type TouchPoint = C.sapp_touchpoint

type WaylandNativeWindowFn #

type WaylandNativeWindowFn = fn (display voidptr, surface voidptr) !

WaylandNativeWindowFn receives borrowed wl_display and wl_surface pointers valid only for the callback.

type Win32NativeWindowFn #

type Win32NativeWindowFn = fn (hwnd voidptr) !

Win32NativeWindowFn receives a borrowed HWND valid only for the callback.

type WindowCleanupFn #

type WindowCleanupFn = fn (mut WindowCleanupContext) !

WindowCleanupFn releases window-scoped resources during terminal cleanup.

type WindowDrawFn #

type WindowDrawFn = fn (mut window WindowContext) !

WindowDrawFn records drawing commands for one WindowContext.

type WindowFrameFn #

type WindowFrameFn = fn (mut WindowContext) !

WindowFrameFn records one managed window frame.

type WindowInitFn #

type WindowInitFn = fn (mut WindowInitContext) !

WindowInitFn initializes window-scoped managed resources.

type WindowPassFn #

type WindowPassFn = fn (mut WindowPassContext) !

WindowPassFn records commands in one callback-bounded managed pass.

type WindowReadbackFn #

type WindowReadbackFn = fn (WindowReadbackResult, mut App) !

WindowReadbackFn receives ordered terminal readback results from App.run.

type WindowResourceFn #

type WindowResourceFn = fn (mut WindowResourceContext) !

WindowResourceFn receives callback-bounded managed resource authority.

type WindowServiceFn #

type WindowServiceFn = fn (event WindowServiceEvent, mut app App) !

WindowServiceFn is called by App.run for ordered native service events.

type WindowSglFn #

type WindowSglFn = fn (mut WindowSglContext) !

WindowSglFn records SGL commands in one callback-bounded managed pass.

type X11NativeWindowFn #

type X11NativeWindowFn = fn (display voidptr, window u64) !

X11NativeWindowFn receives borrowed Display and Window handles valid only for the callback.

enum EndEnum #

enum EndEnum {
	clear
	passthru
}

enum HorizontalAlign #

enum HorizontalAlign {
	left   = C.FONS_ALIGN_LEFT
	center = C.FONS_ALIGN_CENTER
	right  = C.FONS_ALIGN_RIGHT
}

enum ImageEffect #

enum ImageEffect {
	// TODO(FireRedz): Add more effects
	alpha
	add
}

enum KeyCode #

enum KeyCode {
	invalid       = 0
	space         = 32
	apostrophe    = 39 //'
	comma         = 44 //,
	minus         = 45 //-
	period        = 46 //.
	slash         = 47 ///
	_0            = 48
	_1            = 49
	_2            = 50
	_3            = 51
	_4            = 52
	_5            = 53
	_6            = 54
	_7            = 55
	_8            = 56
	_9            = 57
	semicolon     = 59 //;
	equal         = 61 //=
	a             = 65
	b             = 66
	c             = 67
	d             = 68
	e             = 69
	f             = 70
	g             = 71
	h             = 72
	i             = 73
	j             = 74
	k             = 75
	l             = 76
	m             = 77
	n             = 78
	o             = 79
	p             = 80
	q             = 81
	r             = 82
	s             = 83
	t             = 84
	u             = 85
	v             = 86
	w             = 87
	x             = 88
	y             = 89
	z             = 90
	left_bracket  = 91  //[
	backslash     = 92  //\
	right_bracket = 93  //]
	grave_accent  = 96  //`
	world_1       = 161 // non-us #1
	world_2       = 162 // non-us #2
	escape        = 256
	enter         = 257
	tab           = 258
	backspace     = 259
	insert        = 260
	delete        = 261
	right         = 262
	left          = 263
	down          = 264
	up            = 265
	page_up       = 266
	page_down     = 267
	home          = 268
	end           = 269
	caps_lock     = 280
	scroll_lock   = 281
	num_lock      = 282
	print_screen  = 283
	pause         = 284
	f1            = 290
	f2            = 291
	f3            = 292
	f4            = 293
	f5            = 294
	f6            = 295
	f7            = 296
	f8            = 297
	f9            = 298
	f10           = 299
	f11           = 300
	f12           = 301
	f13           = 302
	f14           = 303
	f15           = 304
	f16           = 305
	f17           = 306
	f18           = 307
	f19           = 308
	f20           = 309
	f21           = 310
	f22           = 311
	f23           = 312
	f24           = 313
	f25           = 314
	kp_0          = 320
	kp_1          = 321
	kp_2          = 322
	kp_3          = 323
	kp_4          = 324
	kp_5          = 325
	kp_6          = 326
	kp_7          = 327
	kp_8          = 328
	kp_9          = 329
	kp_decimal    = 330
	kp_divide     = 331
	kp_multiply   = 332
	kp_subtract   = 333
	kp_add        = 334
	kp_enter      = 335
	kp_equal      = 336
	left_shift    = 340
	left_control  = 341
	left_alt      = 342
	left_super    = 343
	right_shift   = 344
	right_control = 345
	right_alt     = 346
	right_super   = 347
	menu          = 348
}

enum Modifier #

@[flag]
enum Modifier {
	shift // (1<<0)
	ctrl  // (1<<1)
	alt   // (1<<2)
	super // (1<<3)
}

fn (Modifier) all #

fn (e &Modifier) all(flag_ Modifier) bool

fn (Modifier) clear #

fn (mut e Modifier) clear(flag_ Modifier)

fn (Modifier) clear_all #

fn (mut e Modifier) clear_all()

fn (Modifier) has #

fn (e &Modifier) has(flag_ Modifier) bool

fn (Modifier) is_empty #

fn (e &Modifier) is_empty() bool

fn (Modifier) set #

fn (mut e Modifier) set(flag_ Modifier)

fn (Modifier) set_all #

fn (mut e Modifier) set_all()

fn (Modifier) toggle #

fn (mut e Modifier) toggle(flag_ Modifier)

enum MouseButton #

enum MouseButton {
	left    = 0
	right   = 1
	middle  = 2
	invalid = 256
}

enum MouseButtons #

@[flag]
enum MouseButtons {
	left
	right
	middle
}

Note: unlike the MouseButton enum from above,the [flag]-ed enum here can have combined states, representing several pressed buttons at once.

fn (MouseButtons) all #

fn (e &MouseButtons) all(flag_ MouseButtons) bool

fn (MouseButtons) clear #

fn (mut e MouseButtons) clear(flag_ MouseButtons)

fn (MouseButtons) clear_all #

fn (mut e MouseButtons) clear_all()

fn (MouseButtons) has #

fn (e &MouseButtons) has(flag_ MouseButtons) bool

fn (MouseButtons) is_empty #

fn (e &MouseButtons) is_empty() bool

fn (MouseButtons) set #

fn (mut e MouseButtons) set(flag_ MouseButtons)

fn (MouseButtons) set_all #

fn (mut e MouseButtons) set_all()

fn (MouseButtons) toggle #

fn (mut e MouseButtons) toggle(flag_ MouseButtons)

enum MultiWindowBackend #

enum MultiWindowBackend {
	auto
	mock
	x11
	wayland
	appkit
	win32
}

MultiWindowBackend selects the implementation behind gg.App.

enum PaintStyle #

enum PaintStyle {
	fill
	stroke
}

enum PenLineType #

enum PenLineType {
	solid
	dashed
	dotted
}

enum TextureFilter #

enum TextureFilter {
	linear
	nearest
}

TextureFilter controls how gg samples textures when images are scaled.

enum VerticalAlign #

enum VerticalAlign {
	top      = C.FONS_ALIGN_TOP
	middle   = C.FONS_ALIGN_MIDDLE
	bottom   = C.FONS_ALIGN_BOTTOM
	baseline = C.FONS_ALIGN_BASELINE
}

enum WindowCleanupReason #

enum WindowCleanupReason {
	requested
	native_closed
	init_failed
	app_stop
	renderer_lost
}

WindowCleanupReason identifies why a window render lifetime is ending.

enum WindowCursorShape #

enum WindowCursorShape {
	default
	pointer
	move
	n_resize
	s_resize
	e_resize
	w_resize
	ne_resize
	nw_resize
	se_resize
	sw_resize
	ew_resize
	ns_resize
	nesw_resize
	nwse_resize
	grab
	grabbing
	text
	crosshair
	not_allowed
	resize_all
}

WindowCursorShape identifies a native cursor image for hover feedback.

enum WindowEventKind #

enum WindowEventKind {
	window_created
	window_destroyed
	window_close_requested
	window_resized
}

WindowEventKind describes lifecycle events routed to a specific window.

enum WindowMappingState #

enum WindowMappingState {
	unknown
	unmapped
	mapped
}

WindowMappingState reports whether a native window is attached to the platform's visible window hierarchy.

enum WindowObservedBool #

enum WindowObservedBool {
	unknown
	off
	on
}

WindowObservedBool distinguishes an observed false value from unavailable native state.

enum WindowOperation #

enum WindowOperation {
	show
	hide
	focus
	raise
	position
	minimize
	maximize
	restore
	fullscreen
	clipboard_read
	clipboard_write
	portal_parent
	native_borrow
	mouse_lock
	titlebar_appearance
	image_readback
	window_capture
}

WindowOperation identifies a runtime native-window service.

enum WindowQueuedEventKind #

enum WindowQueuedEventKind {
	lifecycle
	input
	service
	readback
}

WindowQueuedEventKind identifies one of the four canonical queue families.

enum WindowReadbackStatus #

enum WindowReadbackStatus {
	ready
	cancelled
	failed
}

WindowReadbackStatus is the terminal state of an asynchronous readback.

enum WindowRedrawMode #

enum WindowRedrawMode {
	on_demand
	continuous
}

WindowRedrawMode controls when a window is eligible for a render frame.

enum WindowResizeEdge #

enum WindowResizeEdge {
	top
	bottom
	left
	right
	top_left
	top_right
	bottom_left
	bottom_right
}

WindowResizeEdge identifies the edge or corner used for an interactive, user-driven native resize operation.

enum WindowServiceEventKind #

enum WindowServiceEventKind {
	state
	metrics
	capability
	monitor
	clipboard
	portal_parent
}

WindowServiceEventKind selects the payload carried by WindowServiceEvent.

enum WindowServiceStatus #

enum WindowServiceStatus {
	ready
	cancelled
	failed
}

WindowServiceStatus is the terminal status of an asynchronous service request.

enum WindowSupportLevel #

enum WindowSupportLevel {
	unsupported
	available
	conditional
}

WindowSupportLevel reports whether a native operation is usable for one live window on the selected backend.

enum WindowTitlebarAppearance #

enum WindowTitlebarAppearance {
	system
	light
	dark
}

WindowTitlebarAppearance requests the platform default or a light/dark native titlebar where the backend exposes such an operation.

enum WindowVisibilityState #

enum WindowVisibilityState {
	unknown
	hidden
	visible
	occluded
}

WindowVisibilityState is the latest native visibility observation.

struct App #

@[heap]
struct App {
pub:
	config AppConfig
}

App is the additive multi-window facade for gg users.

Compile with -d gg_multiwindow to enable this API.

fn (App) begin_window_move #

fn (mut app App) begin_window_move(id WindowId) !

begin_window_move starts a user-driven native move for a live window.

fn (App) begin_window_resize #

fn (mut app App) begin_window_resize(id WindowId, edge WindowResizeEdge) !

begin_window_resize starts a user-driven native resize for a live resizable window.

fn (App) capabilities #

fn (app &App) capabilities() Capabilities

capabilities reports the active app backend contract.

fn (App) create_window #

fn (mut app App) create_window(config WindowConfig) !WindowId

create_window creates a window managed by this app.

fn (App) destroy_window #

fn (mut app App) destroy_window(id WindowId) !

destroy_window destroys a live window and its owned descendants child-first. Destroying the final window does not stop the app; call stop explicitly.

fn (App) drain_events #

fn (mut app App) drain_events() ![]WindowEvent

drain_events consumes only the contiguous lifecycle prefix of the ordered queue.

fn (App) drain_input_events #

fn (mut app App) drain_input_events() ![]WindowInputEvent

drain_input_events consumes only the contiguous input prefix of the ordered queue.

fn (App) drain_pending #

fn (mut app App) drain_pending(max_jobs int) !int

drain_pending executes up to max_jobs queued owner-side callbacks.

fn (App) drain_window_queued_events #

fn (mut app App) drain_window_queued_events() ![]WindowQueuedEvent

drain_window_queued_events consumes lifecycle, input, service, and readback events in exact global admission order.

fn (App) drain_window_service_events #

fn (mut app App) drain_window_service_events() ![]WindowServiceEvent

drain_window_service_events consumes only the contiguous service prefix of the ordered queue. It never skips lifecycle, input, or readback events.

fn (App) draw_window #

fn (mut app App) draw_window(id WindowId, draw WindowDrawFn) !

draw_window renders one live window through its WindowContext.

fn (App) hide_window #

fn (mut app App) hide_window(id WindowId) !

hide_window requests that a live window become hidden or unmapped.

fn (App) maximize_window #

fn (mut app App) maximize_window(id WindowId) !

maximize_window requests native maximization.

fn (App) minimize_window #

fn (mut app App) minimize_window(id WindowId) !

minimize_window requests native minimization.

fn (App) monitor_ids #

fn (app &App) monitor_ids() ![]WindowMonitorId

monitor_ids returns generation-checked ids for currently available monitors.

fn (App) monitor_info #

fn (app &App) monitor_info(id WindowMonitorId) !WindowMonitorInfo

monitor_info returns the latest snapshot for a monitor generation. Names are descriptive; the generation-checked id is the identity.

fn (App) poll_events #

fn (mut app App) poll_events() !int

poll_events routes native lifecycle, input, service, and readback events into the gg.App canonical queue.

fn (App) post #

fn (mut app App) post(f AppJobFn) !

post submits a short callback to be executed when owner-side work is drained.

fn (App) raise_window #

fn (mut app App) raise_window(id WindowId) !

raise_window asks the platform to raise a live window.

fn (App) release_portal_parent #

fn (mut app App) release_portal_parent(id PortalParentLeaseId) !

release_portal_parent releases a ready portal-parent export lease.

fn (App) request_clipboard_text #

fn (mut app App) request_clipboard_text(id WindowId) !ClipboardRequestId

request_clipboard_text starts an asynchronous clipboard read. Match the id with a terminal clipboard WindowServiceEvent.

fn (App) request_portal_parent #

fn (mut app App) request_portal_parent(id WindowId) !PortalParentRequestId

request_portal_parent starts an asynchronous native-parent export. A ready event owns a lease that must be released explicitly.

fn (App) request_redraw #

fn (mut app App) request_redraw(id WindowId) !

request_redraw makes a window eligible for a future on-demand frame.

fn (App) request_window_capture #

fn (mut app App) request_window_capture(id WindowId, config WindowReadbackConfig) !WindowReadbackId

request_window_capture queues an asynchronous full-target or bounded-region capture. The terminal result is delivered by RunConfig.readback_fn or the canonical window queue; gg has no separate readback drain.

fn (App) request_window_focus #

fn (mut app App) request_window_focus(id WindowId) !

request_window_focus asks the platform to focus a live window.

fn (App) resize_window #

fn (mut app App) resize_window(id WindowId, width int, height int) !

resize_window requests a live window resize.

fn (App) restore_window #

fn (mut app App) restore_window(id WindowId) !

restore_window leaves the supported minimized, maximized, or fullscreen state.

fn (App) run #

fn (mut app App) run(config RunConfig) !

run starts the owner loop and dispatches lifecycle, input, service, and readback callbacks in canonical order. Rendering callbacks require swapchains. A queue-callback error reinserts the current event and untouched suffix, so event, input, service, and readback handlers must be idempotent.

fn (App) set_clipboard_text #

fn (mut app App) set_clipboard_text(id WindowId, text string) !ClipboardRequestId

set_clipboard_text starts an asynchronous clipboard write. Match the id with a terminal clipboard WindowServiceEvent.

fn (App) set_window_clear_color #

fn (mut app App) set_window_clear_color(id WindowId, color Color) !

set_window_clear_color updates the clear color used for the window's managed swapchain pass.

fn (App) set_window_cursor #

fn (mut app App) set_window_cursor(id WindowId, shape WindowCursorShape) !

set_window_cursor updates the native hover cursor for a live window.

fn (App) set_window_fullscreen #

fn (mut app App) set_window_fullscreen(id WindowId, enabled bool) !

set_window_fullscreen requests or leaves native fullscreen state.

fn (App) set_window_mouse_lock #

fn (mut app App) set_window_mouse_lock(id WindowId, enabled bool) !

set_window_mouse_lock requests or releases relative pointer confinement.

fn (App) set_window_position #

fn (mut app App) set_window_position(id WindowId, x int, y int) !

set_window_position requests a native top-level position when supported.

fn (App) set_window_title #

fn (mut app App) set_window_title(id WindowId, title string) !

set_window_title updates a live window title.

fn (App) set_window_titlebar_appearance #

fn (mut app App) set_window_titlebar_appearance(id WindowId, appearance WindowTitlebarAppearance) !

set_window_titlebar_appearance requests a supported native titlebar theme.

fn (App) show_window #

fn (mut app App) show_window(id WindowId) !

show_window requests that a live window become mapped and visible.

fn (App) stop #

fn (mut app App) stop() !

stop shuts down the app and destroys live windows.

fn (App) supports_window_cursor #

fn (app &App) supports_window_cursor(id WindowId, shape WindowCursorShape) !WindowSupportLevel

supports_window_cursor reports support for one native cursor shape.

fn (App) try_post #

fn (mut app App) try_post(f AppJobFn) !

try_post submits a short callback without waiting for queue capacity.

fn (App) window_exists #

fn (app &App) window_exists(id WindowId) bool

window_exists reports whether id still refers to a live window.

fn (App) window_ids #

fn (app &App) window_ids() ![]WindowId

window_ids returns live window ids in stable app order.

fn (App) window_info #

fn (app &App) window_info(id WindowId) !WindowInfo

window_info returns a snapshot of a live window.

fn (App) window_infos #

fn (app &App) window_infos() ![]WindowInfo

window_infos returns live window snapshots in stable app order.

fn (App) window_metrics #

fn (app &App) window_metrics(id WindowId) !WindowMetrics

window_metrics returns the latest committed logical and framebuffer metrics for a window.

fn (App) window_operation_capability #

fn (app &App) window_operation_capability(id WindowId, operation WindowOperation) !WindowOperationCapability

window_operation_capability reports authoritative runtime support for one operation on one live window. Query it immediately before optional operations.

fn (App) window_readback_capabilities #

fn (app &App) window_readback_capabilities(id WindowId) !WindowReadbackCapabilities

window_readback_capabilities reports current path availability for one live window. Requests still validate ownership, same-window image scope, single-sample render-target eligibility, and rectangle bounds.

fn (App) window_render_target_info #

fn (app &App) window_render_target_info(id WindowId) !WindowRenderTargetInfo

window_render_target_info returns the current color, depth, and sampling contract for a window.

fn (App) window_state #

fn (app &App) window_state(id WindowId) !WindowState

window_state returns the latest native state observed for a live window. Unknown fields were not reported by the running backend.

fn (App) with_native_window #

fn (mut app App) with_native_window(id WindowId, f NativeWindowBorrowFn) !

with_native_window borrows a live native window only for the callback. The lease and nested backend handles must not escape or be retained.

struct AppConfig #

@[params]
struct AppConfig {
pub:
	backend          MultiWindowBackend = .auto
	queue_size       int                = 128
	require_renderer bool
	app_id           string
}

AppConfig configures a multi-window gg application facade. app_id supplies the native application identity where supported (currently Wayland xdg-shell).

struct Capabilities #

struct Capabilities {
pub:
	backend                 MultiWindowBackend
	mock                    bool
	native                  bool
	multi_window            bool
	owner_queue             bool
	explicit_swapchain      bool
	readback                bool
	d3d11                   bool
	metal                   bool
	x11                     bool
	wayland                 bool
	win32                   bool
	gl                      bool
	input_events            bool
	mouse_events            bool
	keyboard_events         bool
	text_events             bool
	focus_events            bool
	drop_events             bool
	touch_events            bool
	cursor_shapes           bool
	interactive_move_resize bool
	native_decorations      bool
}

Capabilities reports the active gg.App backend-wide contract. Optional per-window service/readback queries remain authoritative for runtime state.

struct ClipboardRequestId #

struct ClipboardRequestId {
	app_instance u64
	serial       u64
}

ClipboardRequestId identifies one accepted asynchronous clipboard request.

fn (ClipboardRequestId) str #

fn (id ClipboardRequestId) str() string

str returns a diagnostic clipboard request identity.

struct ClipboardResult #

struct ClipboardResult {
pub:
	id     ClipboardRequestId
	window WindowId
	status WindowServiceStatus
	text   string
	error  string
}

ClipboardResult is the terminal result matched to ClipboardRequestId.

struct Color #

@[markused]
struct Color {
pub mut:
	r u8
	g u8
	b u8
	a u8 = 255
}

Color represents a 32 bit color value in sRGB format

fn (Color) + #

fn (a Color) + (b Color) Color
  • adds b to a, with a maximum value of 255 for each channel

fn (Color) - #

fn (a Color) - (b Color) Color
  • subtracts b from a, with a minimum value of 0 for each channel the alpha channel will be set as the minimum between a.a and b.a

fn (Color) * #

fn (c Color) * (c2 Color) Color
  • multiplies Color c and c2 keeping channel values in [0, 255] range

fn (Color) / #

fn (c Color) / (c2 Color) Color

/ divides c by c2 and converts each channel's value to u8(int)

fn (Color) over #

fn (a Color) over(b Color) Color

over implements an a over b operation. see https://keithp.com/~keithp/porterduff/p253-porter.pdf

fn (Color) eq #

fn (c Color) eq(c2 Color) bool

eq checks if color c and c2 are equal in every channel

fn (Color) str #

fn (c Color) str() string

str returns a string representation of the Color c

fn (Color) rgba8 #

fn (c Color) rgba8() i32

rgba8 converts a color value to an 32bit int in the RGBA8 order. see https://developer.apple.com/documentation/coreimage/ciformat

fn (Color) bgra8 #

fn (c Color) bgra8() i32

bgra8 converts a color value to an 32bit int in the BGRA8 order. see https://developer.apple.com/documentation/coreimage/ciformat

fn (Color) abgr8 #

fn (c Color) abgr8() i32

abgr8 converts a color value to an 32bit int in the ABGR8 order. see https://developer.apple.com/documentation/coreimage/ciformat

fn (Color) to_css_string #

fn (c Color) to_css_string() string

to_css_string returns a CSS compatible string e.g. rgba(10,11,12,13) of the color c.

struct Config #

struct Config {
pub:
	width         int = 800 // desired start width of the window
	height        int = 600 // desired start height of the window
	retina        bool // TODO: implement or deprecate
	resizable     bool = true // prevent user-initiated resizing when supported by the platform backend
	user_data     voidptr // a custom pointer to the application data/instance. When it is not set explicitly, it will default to a pointer to the current gg.Context instance.
	font_size     int     // TODO: implement or deprecate
	create_window bool    // TODO: implement or deprecate
	// window_user_ptr voidptr
	window_title      string = 'A GG Window. Set window_title: to change it.' // the desired title of the window
	icon              sapp.IconDesc
	html5_canvas_name string = 'canvas'
	borderless_window bool  // create the window without native decorations when supported by the platform backend
	always_on_top     bool  // TODO: implement or deprecate
	bg_color          Color // The background color of the window. By default, the first thing gg does in ctx.begin(), is clear the whole buffer with that color.
	init_fn           FNCb   = unsafe { nil } // Called once, after Sokol has finished its setup. Some gg and Sokol functions have to be called *in this* callback, or after this callback, but not before
	frame_fn          FNCb   = unsafe { nil } // Called once per frame, usually 60 times a second (depends on swap_interval). See also https://dri.freedesktop.org/wiki/ConfigurationOptions/#synchronizationwithverticalrefreshswapintervals
	native_frame_fn   FNCb   = unsafe { nil }
	cleanup_fn        FNCb   = unsafe { nil } // Called once, after Sokol determines that the application is finished/closed. Put your app specific cleanup/free actions here.
	fail_fn           FNFail = unsafe { nil } // Called once per Sokol error/log message. TODO: currently it does nothing with latest Sokol, reimplement using Sokol's new sapp_logger APIs.

	update_fn FNUpdate = unsafe { nil } // Called once at the start of each frame, so usually ~60 times a second. The first argument is the delta `dt` time passed, since the *previous* update call (in seconds).

	event_fn FNEvent  = unsafe { nil } // Called once per each user initiated event, received by Sokol/GG.
	on_event FNEvent2 = unsafe { nil } // Called once per each user initiated event, received by Sokol/GG. Same as event_fn, just the parameter order is different. TODO: deprecate this, in favor of event_fn
	quit_fn  FNEvent  = unsafe { nil } // Called when the user closes the app window.

	keydown_fn FNKeyDown = unsafe { nil } // Called once per key press, no matter how long the key is held down. Note that here you can access the scan code/physical key, but not the logical character.
	keyup_fn   FNKeyUp   = unsafe { nil } // Called once per key press, when the key is released.
	char_fn    FNChar    = unsafe { nil } // Called once per character (after the key is pressed down, and then released). Note that you can access the character/utf8 rune here, not just the scan code.

	move_fn    FNMove    = unsafe { nil } // Called while the mouse/touch point is moving.
	click_fn   FNClick   = unsafe { nil } // Called once when the mouse/touch button is clicked.
	unclick_fn FNUnClick = unsafe { nil } // Called once when the mouse/touch button is released.
	leave_fn   FNEvent   = unsafe { nil } // Called once when the mouse/touch point leaves the window.
	enter_fn   FNEvent   = unsafe { nil } // Called once when the mouse/touch point enters again the window.
	resized_fn FNEvent   = unsafe { nil } // Called once when the window has changed its size.
	scroll_fn  FNEvent   = unsafe { nil } // Called while the user is scrolling. The direction of scrolling is indicated by either 1 or -1.
	// wait_events       bool // set this to true for UIs, to save power
	fullscreen     bool // set this to true, if you want your window to start in fullscreen mode (suitable for games/demos/screensavers)
	scale          f32 = 1.0
	sample_count   int // bigger values usually have performance impact, but can produce smoother/antialiased lines, if you draw lines or polygons (2 is usually good enough)
	texture_filter TextureFilter = .linear // default texture filter for newly created images; use `.nearest` for pixel art scaling
	swap_interval  int           = 1       // 1 = 60fps, 2 = 30fps etc. Honored on Windows, macOS, Linux, iOS, and HTML5; Android support is not implemented yet.
	// ved needs this
	// init_text bool
	font_path             string
	custom_bold_font_path string
	ui_mode               bool // refreshes only on events to save CPU usage
	// font bytes for embedding
	font_bytes_normal []u8
	font_bytes_bold   []u8
	font_bytes_mono   []u8
	font_bytes_italic []u8
	native_rendering  bool // Cocoa on macOS/iOS, GDI+ on Windows
	// drag&drop
	enable_dragndrop             bool // enable file dropping (drag'n'drop), default is false
	max_dropped_files            int = 1    // max number of dropped files to process (default: 1)
	max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048)

	min_width  int // desired minimum width of the window
	min_height int // desired minimum height of the window
}

struct Context #

@[heap]
struct Context {
mut:
	render_text bool = true
	// a cache with all images created by the user. used for sokol image init and to save space
	// (so that the user can store image ids, not entire Image objects)
	image_cache                 []Image
	needs_refresh               bool = true
	ticks                       int // for ui mode only
	last_bg_overlay_frame       u64
	translucent_bg_seed_pending bool
pub:
	native_rendering bool
pub mut:
	scale       f32 = 1.0 // will get set to 2.0 for retina, will remain 1.0 for normal
	width       int
	height      int
	clear_pass  gfx.PassAction
	bg_color    Color
	window      sapp.Desc
	pipeline    &PipelineContainer = unsafe { nil }
	config      Config
	user_data   voidptr
	ft          &FT = unsafe { nil }
	font_inited bool
	ui_mode     bool // do not redraw everything 60 times/second, but only when the user requests
	frame       u64  // the current frame counted from the start of the application; always increasing
	//
	timer        time.StopWatch // starts right after new_context, and can be controlled/stopped/restarted in whatever way the user wants.
	update_timer time.StopWatch // measures how much time has passed since the start of the frame.
	frame_timer  time.StopWatch // enforces swap_interval as a fallback when the platform ignores vsync.
	// Note: when there is an update_fn, this timer is reset by GG itself, at the start of each frame.

	mbtn_mask     u8
	mouse_buttons MouseButtons // typed version of mbtn_mask; easier to use for user programs
	mouse_pos_x   int
	mouse_pos_y   int
	mouse_dx      int
	mouse_dy      int
	scroll_x      int
	scroll_y      int

	key_modifiers     Modifier           // the current key modifiers
	key_repeat        bool               // whether the pressed key was an autorepeated one
	pressed_keys      [key_code_max]bool // an array representing all currently pressed keys
	pressed_keys_edge [key_code_max]bool // true when the previous state of pressed_keys,
	// *before* the current event was different
	fps         FPSConfig
	has_started bool
}

fn (Context) begin #

fn (ctx &Context) begin()

begin prepares the context for drawing.

fn (Context) cache_image #

fn (mut ctx Context) cache_image(img Image) int

cache_image caches the image img in memory for later reuse. cache_image returns the cache index of the cached image.

See also: get_cached_image_by_idx See also: remove_cached_image_by_idx

fn (Context) create_image #

fn (mut ctx Context) create_image(file string, cfg ImageConfig) !Image

create_image creates an Image from file.

fn (Context) create_image_from_byte_array #

fn (mut ctx Context) create_image_from_byte_array(b []u8, cfg ImageConfig) !Image

create_image_from_byte_array creates an Image from the byte array b.

See also: create_image_from_memory

fn (Context) create_image_from_byte_array_with_filter #

deprecated: use Context.create_image_from_byte_array instead
fn (mut ctx Context) create_image_from_byte_array_with_filter(b []u8, texture_filter TextureFilter) !Image

create_image_from_byte_array_with_filter creates an Image from b with the requested texture filter.

fn (Context) create_image_from_memory #

fn (mut ctx Context) create_image_from_memory(buf &u8, bufsize int, cfg ImageConfig) !Image

create_image_from_memory creates an Image from the memory buffer buf of size bufsize.

See also: create_image_from_byte_array

fn (Context) create_image_from_memory_with_filter #

deprecated: use Context.create_image_from_memory instead
fn (mut ctx Context) create_image_from_memory_with_filter(buf &u8, bufsize int, texture_filter TextureFilter) !Image

create_image_from_memory_with_filter creates an Image from buf with the requested texture filter.

fn (Context) create_image_with_filter #

deprecated: use Context.create_image instead
fn (mut ctx Context) create_image_with_filter(file string, texture_filter TextureFilter) !Image

create_image_with_filter creates an Image from file with the requested texture filter.

fn (Context) create_image_with_size #

deprecated
fn (mut ctx Context) create_image_with_size(file string, width int, height int) Image

create_image_with_size creates an Image from file in the given width x height dimension.

Todo: copypasta

fn (Context) draw_arc_empty #

fn (ctx &Context) draw_arc_empty(x f32, y f32, inner_radius f32, thickness f32, start_angle f32, end_angle f32,
	segments int, c Color)

draw_arc_empty draws the outline of an arc. x,y defines the end point of the arc (center of the circle that the arc is part of). inner_radius defines the radius of the arc (length from the center point where the arc is drawn). thickness defines how wide the arc is drawn. start_angle is the angle in radians at which the arc starts. end_angle is the angle in radians at which the arc ends. segments affects how smooth/round the arc is. c is the color of the arc outline.

fn (Context) draw_arc_filled #

fn (ctx &Context) draw_arc_filled(x f32, y f32, inner_radius f32, thickness f32, start_angle f32, end_angle f32,
	segments int, c Color)

draw_arc_filled draws a filled arc. x,y defines the central point of the arc (center of the circle that the arc is part of). inner_radius defines the radius of the arc (length from the center point where the arc is drawn). thickness defines how wide the arc is drawn. start_angle is the angle in radians at which the arc starts. end_angle is the angle in radians at which the arc ends. segments affects how smooth/round the arc is. c is the fill color of the arc.

fn (Context) draw_arc_line #

fn (ctx Context) draw_arc_line(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int,
	c Color)

draw_arc_line draws a line arc. x,y defines the end point of the arc (center of the circle that the arc is part of). radius defines the radius of the arc (length from the center point where the arc is drawn). start_angle is the angle in radians at which the arc starts. end_angle is the angle in radians at which the arc ends. segments affects how smooth/round the arc is. c is the color of the arc/outline.

fn (Context) draw_circle_empty #

fn (ctx &Context) draw_circle_empty(x f32, y f32, radius f32, c Color)

draw_circle_empty draws the outline of a circle. x,y defines the center of the circle. radius defines the radius of the circle. c is the color of the outline.

fn (Context) draw_circle_filled #

fn (ctx &Context) draw_circle_filled(x f32, y f32, radius f32, c Color)

draw_circle_filled draws a filled circle. x,y defines the center of the circle. radius defines the radius of the circle. c is the fill color.

fn (Context) draw_circle_line #

fn (ctx &Context) draw_circle_line(x f32, y f32, radius int, segments int, c Color)

draw_circle_line draws the outline of a circle with a specific number of segments. x,y defines the center of the circle. radius defines the radius of the circle. segments affects how smooth/round the circle is. c is the color of the outline.

fn (Context) draw_circle_with_segments #

fn (ctx &Context) draw_circle_with_segments(x f32, y f32, radius f32, segments int, c Color)

draw_circle_with_segments draws a filled circle with a specific number of segments. x,y defines the center of the circle. radius defines the radius of the circle. segments affects how smooth/round the circle is. c is the fill color.

fn (Context) draw_convex_poly #

fn (ctx &Context) draw_convex_poly(points []f32, c Color)

draw_convex_poly draws a convex polygon, given an array of points, and a color. NOTE that the points must be given in clockwise winding order. The contents of the points array should be x and y coordinate pairs.

fn (Context) draw_cubic_bezier #

fn (ctx &Context) draw_cubic_bezier(points []f32, c Color)

draw_cubic_bezier draws a cubic Bézier curve, also known as a spline, from four points. The four points is provided as one points array which contains a stream of point pairs (x and y coordinates). Thus a cubic Bézier could be declared as: points := [x1, y1, control_x1, control_y1, control_x2, control_y2, x2, y2]. Please see draw_cubic_bezier_in_steps to control the amount of steps (segments) used to draw the curve.

fn (Context) draw_cubic_bezier_in_steps #

fn (ctx &Context) draw_cubic_bezier_in_steps(points []f32, steps u32, c Color)

draw_cubic_bezier_in_steps draws a cubic Bézier curve, also known as a spline, from four points. The smoothness of the curve can be controlled with the steps parameter. steps determines how many iterations is taken to draw the curve. The four points is provided as one points array which contains a stream of point pairs (x and y coordinates). Thus a cubic Bézier could be declared as: points := [x1, y1, control_x1, control_y1, control_x2, control_y2, x2, y2].

fn (Context) draw_cubic_bezier_recursive #

fn (ctx &Context) draw_cubic_bezier_recursive(points []f32, c Color)

draw_cubic_bezier_recursive draws a cubic Bézier curve, also known as a spline, from four points, where the first and the last points, will be part of the curve, and the middle 2 points are control ones. Unlike draw_cubic_bezier_in_steps, this method does not use a fixed number of steps for the whole curve, but tries to produce more tesselation points dynamically for the curvier parts.

fn (Context) draw_cubic_bezier_recursive_scalar #

fn (ctx &Context) draw_cubic_bezier_recursive_scalar(x1 f32, y1 f32, x2 f32, y2 f32, x3 f32, y3 f32,
	x4 f32, y4 f32, c Color)

draw_cubic_bezier_recursive_scalar is the same as draw_cubic_bezier_recursive, except that the points are given as indiviual x,y f32 scalar parameters, and not in a single dynamic array parameter.

fn (Context) draw_ellipse_empty #

fn (ctx &Context) draw_ellipse_empty(x f32, y f32, rw f32, rh f32, c Color)

draw_ellipse_empty draws the outline of an ellipse. x,y defines the center of the ellipse. rw defines the width radius of the ellipse. rh defines the height radius of the ellipse. c is the color of the outline.

fn (Context) draw_ellipse_empty_rotate #

fn (ctx &Context) draw_ellipse_empty_rotate(x f32, y f32, rw f32, rh f32, rota f32, c Color)

draw_ellipse_empty_rotate draws the outline of an ellipse. x,y defines the center of the ellipse. rw defines the width radius of the ellipse. rh defines the height radius of the ellipse. rota defines the rotation angle of the ellipse, in radians. c is the color of the outline.

fn (Context) draw_ellipse_filled #

fn (ctx &Context) draw_ellipse_filled(x f32, y f32, rw f32, rh f32, c Color)

draw_ellipse_filled draws an opaque ellipse. x,y defines the center of the ellipse. rw defines the width radius of the ellipse. rh defines the height radius of the ellipse. c is the fill color.

fn (Context) draw_ellipse_filled_rotate #

fn (ctx &Context) draw_ellipse_filled_rotate(x f32, y f32, rw f32, rh f32, rota f32, c Color)

draw_ellipse_filled draws an opaque ellipse. x,y defines the center of the ellipse. rw defines the width radius of the ellipse. rh defines the height radius of the ellipse. rota defines the rotation angle of the ellipse, in radians. c is the fill color.

fn (Context) draw_ellipse_thick #

fn (ctx &Context) draw_ellipse_thick(x f32, y f32, rw f32, rh f32, th f32, c Color)

draw_ellipse_empty draws the outline of an ellipse. x,y defines the center of the ellipse. rw defines the width radius of the ellipse. rh defines the height radius of the ellipse. th defines the thickness of the ellipse. c is the color of the outline.

fn (Context) draw_ellipse_thick_rotate #

fn (ctx &Context) draw_ellipse_thick_rotate(x f32, y f32, rw f32, rh f32, th f32, rota f32, c Color)

draw_ellipse_empty draws the outline of an ellipse. x,y defines the center of the ellipse. rw defines the width radius of the ellipse. rh defines the height radius of the ellipse. th defines the thickness of the ellipse. rota defines the rotation angle of the ellipse, in radians. c is the color of the outline.

fn (Context) draw_image #

fn (ctx &Context) draw_image(x f32, y f32, width f32, height f32, img_ &Image)

draw_image draws the provided image onto the screen.

fn (Context) draw_image_3d #

fn (ctx &Context) draw_image_3d(x f32, y f32, z f32, width f32, height f32, img_ &Image)

draw_image_3d draws an image with a z depth

fn (Context) draw_image_by_id #

fn (ctx &Context) draw_image_by_id(x f32, y f32, width f32, height f32, id int)

draw_image_by_id draws an image by its id

fn (Context) draw_image_flipped #

fn (ctx &Context) draw_image_flipped(x f32, y f32, width f32, height f32, img_ &Image)

draw_image_flipped draws the provided image flipped horizontally (use draw_image_with_config to flip vertically)

fn (Context) draw_image_part #

fn (ctx &Context) draw_image_part(img_rect Rect, part_rect Rect, img_ &Image)

Draw part of an image using uv coordinates img_rect is the size and position (in pixels on screen) of the displayed rectangle (ie the draw_image args) part_rect is the size and position (in absolute pixels in the image) of the wanted part eg. On a 600600 context, to display only the first 400400 pixels of a 2000*2000 image on the entire context surface, call : draw_image_part(Rect{0, 0, 600, 600}, Rect{0, 0, 400, 400}, img)

fn (Context) draw_image_with_config #

fn (ctx &Context) draw_image_with_config(config DrawImageConfig)

draw_image_with_config takes in a config that details how the provided image should be drawn onto the screen

fn (Context) draw_line #

fn (ctx &Context) draw_line(x f32, y f32, x2 f32, y2 f32, c Color)

draw_line draws a line between the points x,y and x2,y2 in color c.

fn (Context) draw_line_with_config #

fn (ctx &Context) draw_line_with_config(x f32, y f32, x2 f32, y2 f32, config PenConfig)

draw_line_with_config draws a line between the points x,y and x2,y2 using PenConfig.

fn (Context) draw_pixel #

fn (ctx &Context) draw_pixel(x f32, y f32, c Color, params DrawPixelConfig)

draw_pixel draws one pixel on the screen.

NOTE calling this function frequently is very inefficient, for drawing shapes it's recommended to draw whole primitives with functions like draw_rect_empty or draw_triangle_empty etc.

fn (Context) draw_pixels #

fn (ctx &Context) draw_pixels(points []f32, c Color, params DrawPixelConfig)

draw_pixels draws pixels from an array of points [x, y, x2, y2, etc...]

NOTE calling this function frequently is very inefficient, for drawing shapes it's recommended to draw whole primitives with functions like draw_rect_empty or draw_triangle_empty etc.

fn (Context) draw_poly_empty #

fn (ctx &Context) draw_poly_empty(points []f32, c Color)

draw_poly_empty draws the outline of a polygon, given an array of points, and a color. NOTE that the points must be given in clockwise winding order.

fn (Context) draw_polygon_filled #

fn (ctx &Context) draw_polygon_filled(x f32, y f32, size f32, edges int, rotation f32, c Color)

draw_polygon_filled draws a filled polygon. x,y defines the center of the polygon. size defines the size of the polygon. edges defines number of edges in the polygon. rotation defines rotation of the polygon. c is the fill color.

fn (Context) draw_rect #

fn (ctx &Context) draw_rect(p DrawRectParams)

fn (Context) draw_rect_empty #

fn (ctx &Context) draw_rect_empty(x f32, y f32, w f32, h f32, c Color)

draw_rect_empty draws the outline of a rectangle. x,y is the top-left corner of the rectangle. w is the width, h is the height and c is the color of the outline.

Note: it is much more efficient to draw lots of empty rectangles one after the other, without filled rectangles between them, than to draw a mix.

fn (Context) draw_rect_empty_no_context #

fn (ctx &Context) draw_rect_empty_no_context(x f32, y f32, w f32, h f32, c Color)

draw_rect_empty_no_context draws the outline of a rectangle, but without saving/restoring the context. It is intended to be used in loops, where you do manually: sgl.begin_lines() before the loop, then draw many rectangles, then call manually sgl.end() after the loop. x,y is the top-left corner of the rectangle. w is the width, h is the height and c is the color of the outline.

Note: it is much more efficient to draw lots of empty rectangles one after the other, without filled rectangles between them, than to draw a mix.

fn (Context) draw_rect_filled #

fn (ctx &Context) draw_rect_filled(x f32, y f32, w f32, h f32, c Color)

draw_rect_filled draws a filled rectangle. x,y is the top-left corner of the rectangle. w is the width, h is the height and c is the color of the fill.

Note: it is much more efficient to draw lots of filled rectangles one after the other, without empty rectangles between them, than to draw a mix.

fn (Context) draw_rect_filled_no_context #

fn (ctx &Context) draw_rect_filled_no_context(x f32, y f32, w f32, h f32, c Color)

draw_rect_filled_no_context draws a filled rectangle, but without saving/restoring the context. It is intended to be used in loops, where you do manually: sgl.begin_quads() before the loop, then draw many rectangles, then call manually sgl.end() after the loop. x,y is the top-left corner of the rectangle. w is the width, h is the height and c is the color of the fill.

Note: it is much more efficient to draw lots of filled rectangles one after the other, without empty rectangles between them, than to draw a mix.

fn (Context) draw_rounded_rect_border #

fn (ctx &Context) draw_rounded_rect_border(x f32, y f32, w f32, h f32, r f32, border_w f32, border_c Color, bg Color)

draw_rounded_rect_border draws a rounded rectangle with a border using the given parameters. when border width < 1 or the color is transparent, draws a borderless filled rounded rectangle. when the background is transparent, draws a hollow rounded rectangle with only a border. x,y is the top-left corner of the rectangle. w is the width, h is the height. r is the radius of the corner-rounding in pixels. border_w is the width of the border,This implementation uses the mainstream inner border scheme (extending inward). border_c is the color of the border. bg is the background or fill color of the rounded rectangle,supporting transparent colors.

fn (Context) draw_rounded_rect_empty #

fn (ctx &Context) draw_rounded_rect_empty(x f32, y f32, w f32, h f32, radius f32, c Color)

draw_rounded_rect_empty draws the outline of a rounded rectangle with a thickness of 1 px. x,y is the top-left corner of the rectangle. w is the width, h is the height. radius is the radius of the corner-rounding in pixels. c is the color of the outline.

fn (Context) draw_rounded_rect_filled #

fn (ctx &Context) draw_rounded_rect_filled(x f32, y f32, w f32, h f32, radius f32, c Color)

draw_rounded_rect_filled draws a filled rounded rectangle. x,y is the top-left corner of the rectangle. w is the width, h is the height . radius is the radius of the corner-rounding in pixels. c is the color of the filled. it divides the rounded rectangle into 2 shapes, the top rounded part and the bottom rounded part which are connected at both extremes.

fn (Context) draw_slice_empty #

fn (ctx &Context) draw_slice_empty(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int,
	c Color)

draw_slice_empty draws the outline of a circle slice/pie

fn (Context) draw_slice_filled #

fn (ctx &Context) draw_slice_filled(x f32, y f32, radius f32, start_angle f32, end_angle f32, segments int,
	c Color)

draw_slice_filled draws a filled circle slice/pie x,y defines the end point of the slice (center of the circle that the slice is part of). radius defines the radius ("length") of the slice. start_angle is the angle in radians at which the slice starts. end_angle is the angle in radians at which the slice ends. segments affects how smooth/round the slice is. c is the fill color.

fn (Context) draw_square_empty #

fn (ctx &Context) draw_square_empty(x f32, y f32, s f32, c Color)

draw_square_empty draws the outline of a square. x,y is the top-left corner of the square. s is the length of each side of the square. c is the color of the outline.

fn (Context) draw_square_filled #

fn (ctx &Context) draw_square_filled(x f32, y f32, s f32, c Color)

draw_square_filled draws a filled square. x,y is the top-left corner of the square. s is the length of each side of the square. c is the fill color.

fn (Context) draw_text #

fn (ctx &Context) draw_text(x int, y int, text_ string, cfg TextCfg)

draw_text draws the string in text_ starting at top-left position x,y. Text settings can be provided with cfg.

fn (Context) draw_text2 #

fn (ctx &Context) draw_text2(p DrawTextParams)

fn (Context) draw_text_def #

fn (ctx &Context) draw_text_def(x int, y int, text string)

draw_text draws the string in text_ starting at top-left position x,y using default text settings.

fn (Context) draw_text_default #

fn (ctx &Context) draw_text_default(x int, y int, text string)

default draw_text (draw_text_def but without set_text_cfg)

fn (Context) draw_triangle_empty #

fn (ctx &Context) draw_triangle_empty(x f32, y f32, x2 f32, y2 f32, x3 f32, y3 f32, c Color)

draw_triangle_empty draws the outline of a triangle. x,y defines the first point x2,y2 defines the second point x3,y3 defines the third point c is the color of the outline.

fn (Context) draw_triangle_filled #

fn (ctx &Context) draw_triangle_filled(x f32, y f32, x2 f32, y2 f32, x3 f32, y3 f32, c Color)

draw_triangle_filled draws a filled triangle. x,y defines the first point x2,y2 defines the second point x3,y3 defines the third point c is the color of the outline.

fn (Context) end #

fn (ctx &Context) end(options EndOptions)

end finishes all the drawing for the context ctx. All accumulated draw calls before ctx.end(), will be done in a separate Sokol pass.

Note: each Sokol pass, has a limit on the number of draw calls, that can be done in it.Once that limit is reached, the whole pass will not draw anything, which can be frustrating.

To overcome this limitation, you may use several passes, when you want to make thousands of draw calls (for example, if you need to draw thousands of circles/rectangles/sprites etc), where each pass will render just a limited amount of primitives.

In the context of the gg module (without dropping to using sgl and gfx directly), it means, that you will need a new pair of ctx.begin() and ctx.end() calls, surrounding all the draw calls, that should be done in each pass.

The default ctx.end() is equivalent to ctx.end(how:.clear). It will erase the existing rendered content with the background color, before drawing anything else. You can call ctx.end(how:.passthru) for a pass, that will not erase the previously rendered content in the context.

fn (Context) get_cached_image_by_idx #

fn (mut ctx Context) get_cached_image_by_idx(image_idx int) &Image

get_cached_image_by_idx returns a cached Image identified by image_idx. If image not found, returns Image{ok: false}

See also: cache_image See also: remove_cached_image_by_idx

fn (Context) has_text_style #

fn (ctx &Context) has_text_style() bool

empty function

fn (Context) is_key_down #

fn (mut ctx Context) is_key_down(k KeyCode) bool

is_key_down returns whether the given key is currently pressed. You can use this, if you do not want to implement your own key event handling.

fn (Context) new_streaming_image #

fn (mut ctx Context) new_streaming_image(w int, h int, channels int, sicfg StreamingImageConfig) int

new_streaming_image returns a cached image_idx of a special image, that can be updated each frame by calling: gg.update_pixel_data(image_idx, buf) ... where buf is a pointer to the actual pixel data for the image.

Note: you still need to call app.gg.draw_image after that, to actually draw it.

Note: Sokol needs to be setup, before calling this function. In practice, this often means, that you have to call it once in the init_fn callback of gg.new_context, or gg.start, and then store the result in your app instance.

fn (Context) quit #

fn (ctx &Context) quit()

quit closes the context window and exits the event loop for it

fn (Context) record_frame #

fn (mut ctx Context) record_frame()

record_frame records the current frame to a file or stdout. record_frame acts according to settings specified in gg.recorder_settings.

fn (Context) refresh_ui #

fn (mut ctx Context) refresh_ui()

refresh_ui requests a complete re-draw of the window contents.

fn (Context) remove_cached_image_by_idx #

fn (mut ctx Context) remove_cached_image_by_idx(image_idx int)

remove_cached_image_by_idx removes an Image identified by image_idx from the image cache.

See also: cache_image See also: get_cached_image_by_idx

fn (Context) resize #

fn (mut ctx Context) resize(width int, height int)

Resize the context's Window

fn (Context) run #

fn (mut ctx Context) run()

run starts the main loop of the context.

fn (Context) scissor_rect #

fn (ctx &Context) scissor_rect(x int, y int, w int, h int)

required for ui.DrawDevice interface (with &gg.Context as an instance)

fn (Context) set_bg_color #

fn (mut ctx Context) set_bg_color(c Color)

set_bg_color sets the color of the window background to c.

fn (Context) set_text_cfg #

fn (ctx &Context) set_text_cfg(cfg TextCfg)

set_text_cfg sets the current text configuration

fn (Context) set_text_style #

fn (ctx &Context) set_text_style(font_name string, font_path string, size int, color Color, align int,
	vertical_align int)

empty function

fn (Context) show_fps #

fn (ctx &Context) show_fps()

fn (Context) text_height #

fn (ctx &Context) text_height(s string) int

text_height returns the height of the string s in pixels.

fn (Context) text_size #

fn (ctx &Context) text_size(s string) (int, int)

text_size returns the width and height of the string s in pixels.

fn (Context) text_width #

fn (ctx &Context) text_width(s string) int

text_width returns the width of the string s in pixels.

fn (Context) text_width_f #

fn (ctx &Context) text_width_f(s string) f32

text_width returns the width of the string s in pixels.

fn (Context) update_pixel_data #

fn (mut ctx Context) update_pixel_data(cached_image_idx int, buf &u8)

update_pixel_data is a helper for working with image streams (i.e. images, that are updated dynamically by the CPU on each frame)

fn (Context) window_size #

fn (ctx Context) window_size() Size

window_size returns the current dimensions of the window.

struct DrawImageConfig #

struct DrawImageConfig {
pub mut:
	flip_x    bool // set to true, if you need to flip the image horizontally (around a vertical axis), <- will become ->
	flip_y    bool // set to true, if you need to flip the image vertically (around a horizontal axiz), -\/- will become -/\-
	img       &Image = unsafe { nil }
	img_id    int
	img_rect  Rect // defines the size and position on image when rendering to the screen
	part_rect Rect // defines the size and position of part of the image to use when rendering
	z         f32
	color     Color       = white
	effect    ImageEffect = .alpha

	rotation f32 // the amount to rotate the image in degrees, counterclockwise. Use a negative value, to rotate it clockwise.
}

DrawImageConfig struct defines the various options that can be used to draw an image onto the screen

struct DrawPixelConfig #

@[params]
struct DrawPixelConfig {
pub mut:
	size f32 = 1.0
}

struct DrawRectParams #

@[params]
struct DrawRectParams {
pub:
	x          f32
	y          f32
	w          f32
	h          f32
	color      Color      = black
	style      PaintStyle = .fill
	is_rounded bool
	radius     f32
}

struct DrawTextParams #

@[params]
struct DrawTextParams {
pub:
	x    int
	y    int
	text string

	color          Color           = black
	size           int             = 16
	align          HorizontalAlign = .left
	vertical_align VerticalAlign   = .top
	max_width      int
	family         string
	bold           bool
	mono           bool
	italic         bool
}

struct EndOptions #

@[params]
struct EndOptions {
pub:
	how EndEnum
}

struct Event #

struct Event {
pub mut:
	frame_count        u64
	typ                sapp.EventType
	key_code           KeyCode
	char_code          u32
	key_repeat         bool
	modifiers          u32
	mouse_button       MouseButton
	mouse_x            f32
	mouse_y            f32
	mouse_dx           f32
	mouse_dy           f32
	scroll_x           f32
	scroll_y           f32
	num_touches        int
	touches            [8]TouchPoint
	window_width       int
	window_height      int
	framebuffer_width  int
	framebuffer_height int
}

struct FPSConfig #

struct FPSConfig {
pub mut:
	x                int  // horizontal position on screen
	y                int  // vertical position on screen
	width            int  // minimum width
	height           int  // minimum height
	show             bool // do not show by default, use `-d show_fps` or set it manually in your app to override with: `app.gg.fps.show = true`
	text_config      TextCfg = TextCfg{
		color:          yellow
		size:           20
		align:          .center
		vertical_align: .middle
	}
	background_color Color = Color{
		r: 0
		g: 0
		b: 0
		a: 128
	}
}

struct FT #

struct FT {
pub:
	fons        &fontstash.Context = unsafe { nil }
	font_normal int
	font_bold   int
	font_mono   int
	font_italic int
pub mut:
	fonts_map map[string]int // for storing custom fonts, provided via cfg.family in draw_text()
	scale     f32 = 1.0
}

fn (FT) flush #

fn (ft &FT) flush()

flush prepares the font for use.

struct Image #

@[heap]
@[markused]
struct Image {
pub mut:
	id             int
	width          int
	height         int
	nr_channels    int
	nr_mipmaps     int
	ok             bool
	data           voidptr
	ext            string
	simg_ok        bool
	simg           gfx.Image
	ssmp           gfx.Sampler
	path           string
	texture_filter TextureFilter = .linear
}

Image holds the fields and data needed to represent a bitmap/pixel based image in memory.

fn (Image) init_sokol_image #

fn (mut img Image) init_sokol_image() &Image

init_sokol_image initializes this Image for use with the sokol graphical backend system.

fn (Image) update_pixel_data #

fn (mut img Image) update_pixel_data(buf &u8)

update_pixel_data updates the sokol specific pixel data associated with this Image.

struct ImageConfig #

@[params]
struct ImageConfig {
pub:
	texture_filter ?TextureFilter
	max_mipmaps    int = 1 // a value below 1 means as many as possible
}

struct NativeWindowLease #

struct NativeWindowLease {
	app          &App = unsafe { nil }
	app_instance u64
	window       WindowId
	lease_epoch  u64
	backend      MultiWindowBackend
	primary      voidptr
	secondary    u64
}

NativeWindowLease is an opaque, callback-bounded native-service seam.

fn (NativeWindowLease) with_appkit #

fn (mut lease NativeWindowLease) with_appkit(f AppKitNativeWindowFn) !

with_appkit exposes the borrowed NSWindow pointer only during f.

fn (NativeWindowLease) with_wayland #

fn (mut lease NativeWindowLease) with_wayland(f WaylandNativeWindowFn) !

with_wayland exposes borrowed wl_display and wl_surface pointers only during f.

fn (NativeWindowLease) with_win32 #

fn (mut lease NativeWindowLease) with_win32(f Win32NativeWindowFn) !

with_win32 exposes the borrowed HWND only during f.

fn (NativeWindowLease) with_x11 #

fn (mut lease NativeWindowLease) with_x11(f X11NativeWindowFn) !

with_x11 exposes borrowed Display and Window handles only during f.

struct PenConfig #

struct PenConfig {
pub:
	color     Color
	line_type PenLineType = .solid
	thickness f32         = 1
}

struct PipelineContainer #

@[heap]
struct PipelineContainer {
pub mut:
	alpha sgl.Pipeline
	add   sgl.Pipeline
}

struct PortalParentLeaseId #

struct PortalParentLeaseId {
	app_instance u64
	serial       u64
}

PortalParentLeaseId identifies a portal parent export until release or window/app teardown invalidates it.

fn (PortalParentLeaseId) str #

fn (id PortalParentLeaseId) str() string

str returns a diagnostic portal-parent lease identity.

struct PortalParentRequestId #

struct PortalParentRequestId {
	app_instance u64
	serial       u64
}

PortalParentRequestId identifies one accepted native-parent request.

fn (PortalParentRequestId) str #

fn (id PortalParentRequestId) str() string

str returns a diagnostic portal-parent request identity.

struct PortalParentResult #

struct PortalParentResult {
pub:
	id         PortalParentRequestId
	window     WindowId
	status     WindowServiceStatus
	lease      PortalParentLeaseId
	identifier string
	error      string
}

PortalParentResult is the terminal result matched to PortalParentRequestId. A ready event already queued before teardown can carry a stale lease.

struct Rect #

struct Rect {
pub mut:
	x      f32
	y      f32
	width  f32
	height f32
}

Rect represents a rectangular shape in gg.

struct RunConfig #

@[params]
struct RunConfig {
pub:
	frame_fn                AppFrameFn           = unsafe { nil }
	event_fn                AppEventFn           = unsafe { nil }
	input_fn                AppInputFn           = unsafe { nil }
	window_service_fn       WindowServiceFn      = unsafe { nil }
	app_resource_init_fn    AppResourceInitFn    = unsafe { nil }
	app_resource_frame_fn   AppResourceFrameFn   = unsafe { nil }
	app_resource_cleanup_fn AppResourceCleanupFn = unsafe { nil }
	readback_fn             WindowReadbackFn     = unsafe { nil }
	max_pending_jobs        int                  = 64
}

RunConfig configures the gg.App loop. event_fn, input_fn, window_service_fn, and readback_fn receive the four canonical queue families in global order. An error from any of those callbacks reinserts the current event and untouched suffix in the same order, so all four handlers must be idempotent. Use event_fn without frame_fn for lifecycle-only loops without a renderer.

struct SSRecorderSettings #

@[heap]
struct SSRecorderSettings {
pub mut:
	stop_at_frame     i64 = -1
	screenshot_frames []u64
	screenshot_folder string
	screenshot_prefix string
	screenshot_output ScreenshotOutput = .file
}

struct Size #

@[markused]
struct Size {
pub mut:
	width  int
	height int
}

struct StreamingImageConfig #

struct StreamingImageConfig {
pub:
	pixel_format gfx.PixelFormat = .rgba8
	wrap_u       gfx.Wrap        = .clamp_to_edge
	wrap_v       gfx.Wrap        = .clamp_to_edge
	min_filter   gfx.Filter      = .linear
	mag_filter   gfx.Filter      = .linear
	num_mipmaps  int             = 1
	num_slices   int             = 1
}

struct TextCfg #

@[markused]
@[params]
struct TextCfg {
pub:
	color          Color           = black
	size           int             = 16
	align          HorizontalAlign = .left
	vertical_align VerticalAlign   = .top
	max_width      int
	family         string
	bold           bool
	mono           bool
	italic         bool
}

fn (TextCfg) to_css_string #

fn (cfg &TextCfg) to_css_string() string

to_css_string returns a CSS compatible string of the TextCfg cfg. For example: 'mono 14px serif'.

struct WindowAttachmentsConfig #

struct WindowAttachmentsConfig {
pub:
	colors        []WindowImageId
	resolves      []WindowImageId
	depth_stencil ?WindowImageId
}

WindowAttachmentsConfig names managed image ids used by an offscreen pass.

struct WindowAttachmentsId #

struct WindowAttachmentsId {
	app_instance u64
	slot         int
	generation   u32
	window       WindowId
}

WindowAttachmentsId is a generation-checked managed attachments identity.

struct WindowBindings #

struct WindowBindings {
pub:
	vertex_buffers []WindowBufferBinding
	index_buffer   ?WindowBufferBinding
	vs             WindowStageBindings
	fs             WindowStageBindings
}

WindowBindings is the managed binding set accepted by WindowPassContext.

struct WindowBufferBinding #

struct WindowBufferBinding {
pub:
	slot   int
	buffer WindowBufferId
	offset int
}

WindowBufferBinding binds a managed buffer at one graphics slot.

struct WindowBufferId #

struct WindowBufferId {
	app_instance u64
	slot         int
	generation   u32
	window       WindowId
}

WindowBufferId is a generation-checked managed buffer identity.

struct WindowCleanupContext #

struct WindowCleanupContext {
	app            &App = unsafe { nil }
	app_instance   u64
	lease_epoch    u64
	info           WindowFrameInfo
	cleanup_reason WindowCleanupReason
	has_graphics   bool
}

WindowCleanupContext is a callback-bounded window cleanup lease.

fn (WindowCleanupContext) graphics_available #

fn (context &WindowCleanupContext) graphics_available() bool

graphics_available reports whether managed graphics teardown is still permitted.

fn (WindowCleanupContext) metrics #

fn (context &WindowCleanupContext) metrics() WindowMetrics

metrics returns the final immutable metrics snapshot supplied to cleanup.

fn (WindowCleanupContext) reason #

fn (context &WindowCleanupContext) reason() WindowCleanupReason

reason identifies why the window's render lifetime is ending.

fn (WindowCleanupContext) render_target_info #

fn (context &WindowCleanupContext) render_target_info() WindowRenderTargetInfo

render_target_info returns the final render-target contract supplied to cleanup.

fn (WindowCleanupContext) window_id #

fn (context &WindowCleanupContext) window_id() WindowId

window_id identifies the window that owns this cleanup callback.

fn (WindowCleanupContext) with_native_window #

fn (mut context WindowCleanupContext) with_native_window(f NativeWindowBorrowFn) !

with_native_window borrows the backend's live native window for the duration of the callback.

fn (WindowCleanupContext) with_resources #

fn (mut context WindowCleanupContext) with_resources(f WindowResourceFn) !

with_resources grants managed resource teardown authority during cleanup.

struct WindowConfig #

@[params]
struct WindowConfig {
pub:
	title        string = 'A GG Window'
	width        int    = 800
	height       int    = 600
	min_width    int
	min_height   int
	resizable    bool = true
	visible      bool = true
	high_dpi     bool = true
	borderless   bool
	fullscreen   bool
	clear_color  Color = Color{
		a: 0
	}
	sample_count int              = 1
	redraw_mode  WindowRedrawMode = .on_demand
	init_fn      WindowInitFn     = unsafe { nil }
	frame_fn     WindowFrameFn    = unsafe { nil }
	cleanup_fn   WindowCleanupFn  = unsafe { nil }
	owner        ?WindowId
	modal        bool
}

WindowConfig describes one window at creation time. A modal window must name a live same-app owner; ownerless modal configurations are rejected pre-allocation.

struct WindowContext #

struct WindowContext {
	app                        &App = unsafe { nil }
	app_instance               u64
	lease_epoch                u64
	info                       WindowFrameInfo
	compatibility_capabilities Capabilities
}

WindowContext is a callback-bounded window frame lease.

fn (WindowContext) capabilities #

fn (context &WindowContext) capabilities() Capabilities

capabilities reports the app backend capabilities captured for this context.

fn (WindowContext) draw_rect_empty #

fn (context &WindowContext) draw_rect_empty(x f32, y f32, w f32, h f32, color Color)

draw_rect_empty is available when compiling with -d gg_multiwindow.

fn (WindowContext) draw_rect_filled #

fn (context &WindowContext) draw_rect_filled(x f32, y f32, w f32, h f32, color Color)

draw_rect_filled is available when compiling with -d gg_multiwindow.

fn (WindowContext) exists #

fn (context &WindowContext) exists() bool

exists reports whether this context still targets a live window.

fn (WindowContext) frame_info #

fn (context &WindowContext) frame_info() WindowFrameInfo

frame_info returns the immutable window and target snapshot bound to this frame callback.

fn (WindowContext) framebuffer_size #

fn (context &WindowContext) framebuffer_size() Size

framebuffer_size returns the current render target size in pixels.

fn (WindowContext) logical_bounds #

fn (context &WindowContext) logical_bounds() WindowLogicalRect

logical_bounds returns the current logical drawable rectangle with an origin of zero.

fn (WindowContext) logical_size #

fn (context &WindowContext) logical_size() WindowLogicalSize

logical_size returns the current drawable size in logical coordinates.

fn (WindowContext) logical_to_pixel_rect #

fn (context &WindowContext) logical_to_pixel_rect(rect WindowLogicalRect) WindowPixelRect

logical_to_pixel_rect converts a logical rectangle using this frame's admitted metrics.

fn (WindowContext) pixel_bounds #

fn (context &WindowContext) pixel_bounds() WindowPixelRect

pixel_bounds returns the current framebuffer rectangle with an origin of zero.

fn (WindowContext) pixel_to_logical_rect #

fn (context &WindowContext) pixel_to_logical_rect(rect WindowPixelRect) WindowLogicalRect

pixel_to_logical_rect converts a framebuffer rectangle using this frame's admitted metrics.

fn (WindowContext) request_image_readback #

fn (mut context WindowContext) request_image_readback(id WindowImageId, config WindowReadbackConfig) !WindowReadbackId

request_image_readback queues an asynchronous full-image or bounded-region readback of a managed single-sample 2D image created with render_target: true. The result is terminal and ordered.

fn (WindowContext) size #

fn (context &WindowContext) size() Size

size returns the current draw size. Logical scaling will be added with native DPI routing.

fn (WindowContext) window_id #

fn (context &WindowContext) window_id() WindowId

window_id returns the id routed to this draw context.

fn (WindowContext) with_offscreen #

fn (mut context WindowContext) with_offscreen(config WindowOffscreenPassConfig, f WindowPassFn) !

with_offscreen runs a managed render pass against managed offscreen attachments.

fn (WindowContext) with_offscreen_sgl #

fn (mut context WindowContext) with_offscreen_sgl(config WindowOffscreenPassConfig, f WindowSglFn) !

with_offscreen_sgl runs scoped SGL drawing against managed offscreen attachments.

fn (WindowContext) with_resources #

fn (mut context WindowContext) with_resources(f WindowResourceFn) !

with_resources grants managed resource authority scoped to the current frame callback.

fn (WindowContext) with_swapchain #

fn (mut context WindowContext) with_swapchain(action gfx.PassAction, f WindowPassFn) !

with_swapchain runs a managed render pass against the current window swapchain.

fn (WindowContext) with_swapchain_sgl #

fn (mut context WindowContext) with_swapchain_sgl(action gfx.PassAction, f WindowSglFn) !

with_swapchain_sgl runs scoped SGL drawing against the current window swapchain.

struct WindowEvent #

struct WindowEvent {
pub:
	kind   WindowEventKind
	window WindowId
	// width and height are meaningful for .window_created and .window_resized events.
	width  int
	height int
}

WindowEvent is the multi-window event wrapper. The existing gg.Event remains the legacy single-window gg.Context event type.

struct WindowFrameInfo #

struct WindowFrameInfo {
pub:
	window          WindowId
	frame_serial    u64
	submitted_frame u64
	metrics         WindowMetrics
	target          WindowRenderTargetInfo
}

WindowFrameInfo binds one callback to a window, frame, metrics, and target snapshot.

struct WindowId #

struct WindowId {
	app_instance u64
}

WindowId identifies a window managed by gg.App.

fn (WindowId) str #

fn (id WindowId) str() string

str returns a diagnostic representation of a WindowId.

struct WindowImageBinding #

struct WindowImageBinding {
pub:
	slot  int
	image WindowImageId
}

WindowImageBinding binds a managed image at one graphics slot.

struct WindowImageId #

struct WindowImageId {
	app_instance u64
	slot         int
	generation   u32
	window       WindowId
}

WindowImageId is a generation-checked managed image identity.

struct WindowInfo #

struct WindowInfo {
pub:
	id                 WindowId
	title              string
	width              int
	height             int
	min_width          int
	min_height         int
	resizable          bool
	visible            bool
	high_dpi           bool
	borderless         bool
	fullscreen         bool
	native_decorations bool
}

WindowInfo is a snapshot of a live gg.App window.

struct WindowInitContext #

struct WindowInitContext {
	app          &App = unsafe { nil }
	app_instance u64
	lease_epoch  u64
	info         WindowFrameInfo
}

WindowInitContext is a callback-bounded window initialization lease.

fn (WindowInitContext) metrics #

fn (context &WindowInitContext) metrics() WindowMetrics

metrics returns the immutable window metrics admitted for initialization.

fn (WindowInitContext) render_target_info #

fn (context &WindowInitContext) render_target_info() WindowRenderTargetInfo

render_target_info returns the render-target contract admitted for initialization.

fn (WindowInitContext) window_id #

fn (context &WindowInitContext) window_id() WindowId

window_id identifies the window that owns this initialization callback.

fn (WindowInitContext) with_resources #

fn (mut context WindowInitContext) with_resources(f WindowResourceFn) !

with_resources grants managed resource authority scoped to the initialization callback.

struct WindowInputEvent #

struct WindowInputEvent {
pub:
	window        WindowId
	event         Event
	dropped_files []string
}

WindowInputEvent routes a normal gg.Event to a specific gg.App window.

struct WindowKnownRect #

struct WindowKnownRect {
pub:
	known bool
	value WindowRect
}

WindowKnownRect distinguishes an unavailable monitor rectangle from zeroes.

struct WindowKnownScale #

struct WindowKnownScale {
pub:
	known bool
	value f32
}

WindowKnownScale distinguishes an unavailable scale from zero.

struct WindowLogicalRect #

struct WindowLogicalRect {
pub:
	x      f32
	y      f32
	width  f32
	height f32
}

WindowLogicalRect is a region in logical coordinates.

struct WindowLogicalSize #

struct WindowLogicalSize {
pub:
	width  f32
	height f32
}

WindowLogicalSize is a drawable size in logical coordinates.

struct WindowMetrics #

struct WindowMetrics {
pub:
	logical_size     WindowLogicalSize
	framebuffer_size WindowPixelSize
	dpi_scale        f32
	metrics_sequence u64
	submitted_frame  u64
}

WindowMetrics is an immutable accepted logical/framebuffer metrics snapshot.

struct WindowMonitorId #

struct WindowMonitorId {
	app_instance u64
	slot         int
	generation   u32
}

WindowMonitorId is an opaque generation-checked monitor identity.

fn (WindowMonitorId) str #

fn (id WindowMonitorId) str() string

str returns a diagnostic monitor identity without exposing mutable fields.

struct WindowMonitorInfo #

struct WindowMonitorInfo {
pub:
	id        WindowMonitorId
	name      string
	geometry  WindowKnownRect
	work_area WindowKnownRect
	scale     WindowKnownScale
	primary   WindowObservedBool
	available bool
	sequence  u64
}

WindowMonitorInfo is an immutable observation for one monitor generation. Names are descriptive; WindowMonitorId is the identity.

struct WindowOffscreenPassConfig #

struct WindowOffscreenPassConfig {
pub:
	attachments WindowAttachmentsId
	action      gfx.PassAction
}

WindowOffscreenPassConfig selects managed attachments and the action used to begin an offscreen pass.

struct WindowOperationCapability #

struct WindowOperationCapability {
pub:
	support              WindowSupportLevel
	asynchronous         bool
	requires_user_action bool
	state_observable     bool
}

WindowOperationCapability is the authoritative per-window runtime answer for one optional operation. asynchronous does not promise a later queued result; state_observable says whether callers can rely on a resulting state observation. Conditional operations can still require user action.

struct WindowPassContext #

struct WindowPassContext {
	app          &App = unsafe { nil }
	app_instance u64
	window       WindowId
	lease_epoch  u64
	pass_epoch   u64
	info         WindowFrameInfo
}

WindowPassContext bounds draw recording to one managed pass.

fn (WindowPassContext) apply_bindings #

fn (mut pass WindowPassContext) apply_bindings(bindings WindowBindings) !

apply_bindings binds managed buffers, images, and samplers for this pass.

fn (WindowPassContext) apply_pipeline #

fn (mut pass WindowPassContext) apply_pipeline(id WindowPipelineId) !

apply_pipeline selects a managed pipeline for subsequent draw calls in this pass.

fn (WindowPassContext) apply_scissor #

fn (mut pass WindowPassContext) apply_scissor(rect WindowPixelRect) !

apply_scissor sets the framebuffer-space scissor rectangle for the active managed pass.

fn (WindowPassContext) apply_uniforms #

fn (mut pass WindowPassContext) apply_uniforms(stage gfx.ShaderStage, block int, data &gfx.Range) !

apply_uniforms uploads one shader-stage uniform block for this pass.

fn (WindowPassContext) apply_viewport #

fn (mut pass WindowPassContext) apply_viewport(rect WindowPixelRect) !

apply_viewport sets the framebuffer-space viewport for the active managed pass.

fn (WindowPassContext) draw #

fn (mut pass WindowPassContext) draw(base_element int, num_elements int, num_instances int) !

draw submits indexed or non-indexed geometry through the active managed pass.

struct WindowPipelineId #

struct WindowPipelineId {
	app_instance u64
	slot         int
	generation   u32
	window       WindowId
}

WindowPipelineId is a generation-checked managed pipeline identity.

struct WindowPixelRect #

struct WindowPixelRect {
pub:
	x      int
	y      int
	width  int
	height int
}

WindowPixelRect is a region in framebuffer coordinates.

struct WindowPixelSize #

struct WindowPixelSize {
pub:
	width  int
	height int
}

WindowPixelSize is a drawable size in framebuffer pixels.

struct WindowPosition #

struct WindowPosition {
pub:
	known bool
	x     int
	y     int
}

WindowPosition carries a native position only when known is true.

struct WindowQueuedEvent #

struct WindowQueuedEvent {
pub:
	kind      WindowQueuedEventKind
	sequence  u64
	lifecycle WindowEvent
	input     WindowInputEvent
	service   WindowServiceEvent
	readback  WindowReadbackResult
}

WindowQueuedEvent is the canonical ordered delivery envelope for lifecycle, input, service, and readback events. sequence preserves global admission order.

struct WindowReadbackCapabilities #

struct WindowReadbackCapabilities {
pub:
	offscreen_image bool
	window_capture  bool
}

WindowReadbackCapabilities reports current per-window path availability. Each request revalidates app ownership, same-window image scope, render-target/sample eligibility, and rectangle bounds.

struct WindowReadbackConfig #

struct WindowReadbackConfig {
pub:
	rect ?WindowPixelRect
}

WindowReadbackConfig selects a framebuffer-pixel region. A missing rect requests the full target; a present rect must be positive and fully contained.

struct WindowReadbackId #

struct WindowReadbackId {
	app_instance u64
	slot         int
	generation   u32
	window       WindowId
	serial       u64
}

WindowReadbackId identifies one asynchronous terminal readback request.

struct WindowReadbackResult #

struct WindowReadbackResult {
pub:
	id              WindowReadbackId
	window          WindowId
	status          WindowReadbackStatus
	submitted_frame u64
	width           int
	height          int
	stride          int
	pixels_rgba8    []u8
	error           string
}

WindowReadbackResult is admitted and enqueued once with a terminal status. Dispatch can replay it until callback acknowledgment, so handlers must be idempotent. Ready results own top-left RGBA8 bytes and an explicit stride.

struct WindowRect #

struct WindowRect {
pub:
	x      int
	y      int
	width  int
	height int
}

WindowRect is an integer native monitor rectangle.

struct WindowRenderTargetInfo #

struct WindowRenderTargetInfo {
pub:
	color_format gfx.PixelFormat
	depth_format gfx.PixelFormat
	sample_count int
}

WindowRenderTargetInfo describes a managed window target without exposing it.

struct WindowResourceContext #

struct WindowResourceContext {
	app          &App = unsafe { nil }
	app_instance u64
	window       WindowId
	lease_epoch  u64
	batch_epoch  u64
	phase        MultiWindowRenderPhase
	scope        MultiWindowResourceScope
}

WindowResourceContext bounds managed resource operations to a callback lease.

fn (WindowResourceContext) append_buffer #

fn (mut resources WindowResourceContext) append_buffer(id WindowBufferId, data &gfx.Range) !int

append_buffer appends data to a managed streaming buffer and returns its byte offset.

fn (WindowResourceContext) make_attachments #

fn (mut resources WindowResourceContext) make_attachments(config WindowAttachmentsConfig) !WindowAttachmentsId

make_attachments creates attachments owned by the resource context's scope from managed images.

fn (WindowResourceContext) make_buffer #

fn (mut resources WindowResourceContext) make_buffer(desc &gfx.BufferDesc) !WindowBufferId

make_buffer creates a buffer owned by the resource context's scope.

fn (WindowResourceContext) make_image #

fn (mut resources WindowResourceContext) make_image(desc &gfx.ImageDesc) !WindowImageId

make_image creates an image owned by the resource context's scope.

fn (WindowResourceContext) make_pipeline #

fn (mut resources WindowResourceContext) make_pipeline(desc &gfx.PipelineDesc, shader WindowShaderId) !WindowPipelineId

make_pipeline creates a pipeline owned by the resource context's scope using a managed shader.

fn (WindowResourceContext) make_sampler #

fn (mut resources WindowResourceContext) make_sampler(desc &gfx.SamplerDesc) !WindowSamplerId

make_sampler creates a sampler owned by the resource context's scope.

fn (WindowResourceContext) make_sgl_pipeline #

fn (mut resources WindowResourceContext) make_sgl_pipeline(desc &gfx.PipelineDesc) !WindowSglPipelineId

make_sgl_pipeline creates an SGL pipeline owned by the resource context's scope.

fn (WindowResourceContext) make_sgl_pipeline_with_shader #

fn (mut resources WindowResourceContext) make_sgl_pipeline_with_shader(desc &gfx.PipelineDesc, shader WindowShaderId) !WindowSglPipelineId

make_sgl_pipeline_with_shader creates an SGL pipeline owned by the resource context's scope using a managed shader.

fn (WindowResourceContext) make_shader #

fn (mut resources WindowResourceContext) make_shader(desc &gfx.ShaderDesc) !WindowShaderId

make_shader creates a shader owned by the resource context's scope.

fn (WindowResourceContext) replace_image #

fn (mut resources WindowResourceContext) replace_image(id WindowImageId, desc &gfx.ImageDesc) !WindowImageId

replace_image recreates a managed image and returns the replacement generation.

fn (WindowResourceContext) retire_attachments #

fn (mut resources WindowResourceContext) retire_attachments(id WindowAttachmentsId) !

retire_attachments releases managed attachments and invalidates their identifier.

fn (WindowResourceContext) retire_buffer #

fn (mut resources WindowResourceContext) retire_buffer(id WindowBufferId) !

retire_buffer releases a managed buffer and invalidates its identifier.

fn (WindowResourceContext) retire_image #

fn (mut resources WindowResourceContext) retire_image(id WindowImageId) !

retire_image releases a managed image and invalidates its identifier.

fn (WindowResourceContext) retire_pipeline #

fn (mut resources WindowResourceContext) retire_pipeline(id WindowPipelineId) !

retire_pipeline releases a managed pipeline and invalidates its identifier.

fn (WindowResourceContext) retire_sampler #

fn (mut resources WindowResourceContext) retire_sampler(id WindowSamplerId) !

retire_sampler releases a managed sampler and invalidates its identifier.

fn (WindowResourceContext) retire_sgl_pipeline #

fn (mut resources WindowResourceContext) retire_sgl_pipeline(id WindowSglPipelineId) !

retire_sgl_pipeline releases a managed SGL pipeline and invalidates its identifier.

fn (WindowResourceContext) retire_shader #

fn (mut resources WindowResourceContext) retire_shader(id WindowShaderId) !

retire_shader releases a managed shader and invalidates its identifier.

fn (WindowResourceContext) update_buffer #

fn (mut resources WindowResourceContext) update_buffer(id WindowBufferId, data &gfx.Range) !

update_buffer replaces the contents of a managed buffer.

fn (WindowResourceContext) update_image #

fn (mut resources WindowResourceContext) update_image(id WindowImageId, data &gfx.ImageData) !

update_image replaces the uploaded contents of a managed image.

struct WindowSamplerBinding #

struct WindowSamplerBinding {
pub:
	slot    int
	sampler WindowSamplerId
}

WindowSamplerBinding binds a managed sampler at one graphics slot.

struct WindowSamplerId #

struct WindowSamplerId {
	app_instance u64
	slot         int
	generation   u32
	window       WindowId
}

WindowSamplerId is a generation-checked managed sampler identity.

struct WindowServiceEvent #

struct WindowServiceEvent {
pub:
	kind          WindowServiceEventKind
	window        WindowId
	sequence      u64
	state         WindowState
	metrics       WindowMetrics
	operation     WindowOperation
	capability    WindowOperationCapability
	monitor       WindowMonitorInfo
	monitors      []WindowMonitorInfo
	clipboard     ClipboardResult
	portal_parent PortalParentResult
}

WindowServiceEvent carries one native service observation or terminal result. kind selects the meaningful payload field.

struct WindowSglContext #

struct WindowSglContext {
	app          &App = unsafe { nil }
	app_instance u64
	window       WindowId
	lease_epoch  u64
	pass_epoch   u64
	target_key   string
}

WindowSglContext bounds immediate-mode recording to one managed pass.

fn (WindowSglContext) begin_line_strip #

fn (mut context WindowSglContext) begin_line_strip()

begin_line_strip starts a connected-line batch that must be closed with end.

fn (WindowSglContext) begin_lines #

fn (mut context WindowSglContext) begin_lines()

begin_lines starts an independent-line batch that must be closed with end.

fn (WindowSglContext) begin_points #

fn (mut context WindowSglContext) begin_points()

begin_points starts a point primitive batch that must be closed with end.

fn (WindowSglContext) begin_quads #

fn (mut context WindowSglContext) begin_quads()

begin_quads starts a quad batch that must be closed with end.

fn (WindowSglContext) begin_triangle_strip #

fn (mut context WindowSglContext) begin_triangle_strip()

begin_triangle_strip starts a connected-triangle batch that must be closed with end.

fn (WindowSglContext) begin_triangles #

fn (mut context WindowSglContext) begin_triangles()

begin_triangles starts an independent-triangle batch that must be closed with end.

fn (WindowSglContext) c1i #

fn (mut context WindowSglContext) c1i(rgba u32)

c1i sets a packed RGBA color for subsequently emitted vertices.

fn (WindowSglContext) c3b #

fn (mut context WindowSglContext) c3b(red u8, green u8, blue u8)

c3b sets a byte RGB color for subsequently emitted vertices.

fn (WindowSglContext) c3f #

fn (mut context WindowSglContext) c3f(red f32, green f32, blue f32)

c3f sets a floating-point RGB color for subsequently emitted vertices.

fn (WindowSglContext) c4b #

fn (mut context WindowSglContext) c4b(red u8, green u8, blue u8, alpha u8)

c4b sets a byte RGBA color for subsequently emitted vertices.

fn (WindowSglContext) c4f #

fn (mut context WindowSglContext) c4f(red f32, green f32, blue f32, alpha f32)

c4f sets a floating-point RGBA color for subsequently emitted vertices.

fn (WindowSglContext) default_pipeline #

fn (mut context WindowSglContext) default_pipeline()

default_pipeline selects SGL's built-in pipeline through the legacy alias.

fn (WindowSglContext) defaults #

fn (mut context WindowSglContext) defaults()

defaults restores SGL's default drawing state for this window context.

fn (WindowSglContext) disable_texture #

fn (mut context WindowSglContext) disable_texture()

disable_texture disables texture sampling for subsequent SGL vertices.

fn (WindowSglContext) enable_texture #

fn (mut context WindowSglContext) enable_texture()

enable_texture enables sampling from the texture selected on this window context.

fn (WindowSglContext) end #

fn (mut context WindowSglContext) end()

end closes the current primitive batch and records it for this window's SGL pass.

fn (WindowSglContext) frustum #

fn (mut context WindowSglContext) frustum(left f32, right f32, bottom f32, top f32, near_plane f32, far_plane f32)

frustum multiplies the selected SGL matrix by a perspective frustum projection.

fn (WindowSglContext) load_default_pipeline #

fn (mut context WindowSglContext) load_default_pipeline()

load_default_pipeline selects SGL's built-in pipeline for subsequent drawing.

fn (WindowSglContext) load_identity #

fn (mut context WindowSglContext) load_identity()

load_identity replaces the selected SGL matrix with the identity matrix.

fn (WindowSglContext) load_matrix #

fn (mut context WindowSglContext) load_matrix(matrix []f32)

load_matrix replaces the selected SGL matrix with a column-major matrix.

fn (WindowSglContext) load_pipeline #

fn (mut context WindowSglContext) load_pipeline(id WindowSglPipelineId) !

load_pipeline selects a window-owned SGL pipeline for subsequent drawing.

fn (WindowSglContext) load_transpose_matrix #

fn (mut context WindowSglContext) load_transpose_matrix(matrix []f32)

load_transpose_matrix replaces the selected SGL matrix with the transpose of matrix.

fn (WindowSglContext) lookat #

fn (mut context WindowSglContext) lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32, up_z f32)

lookat multiplies the selected SGL matrix by a camera view transform.

fn (WindowSglContext) matrix_mode_modelview #

fn (mut context WindowSglContext) matrix_mode_modelview()

matrix_mode_modelview selects the model-view matrix stack for subsequent operations.

fn (WindowSglContext) matrix_mode_projection #

fn (mut context WindowSglContext) matrix_mode_projection()

matrix_mode_projection selects the projection matrix stack for subsequent operations.

fn (WindowSglContext) matrix_mode_texture #

fn (mut context WindowSglContext) matrix_mode_texture()

matrix_mode_texture selects the texture matrix stack for subsequent operations.

fn (WindowSglContext) mult_matrix #

fn (mut context WindowSglContext) mult_matrix(matrix []f32)

mult_matrix multiplies the selected SGL matrix by a column-major matrix.

fn (WindowSglContext) mult_transpose_matrix #

fn (mut context WindowSglContext) mult_transpose_matrix(matrix []f32)

mult_transpose_matrix multiplies the selected SGL matrix by the transpose of matrix.

fn (WindowSglContext) ortho #

fn (mut context WindowSglContext) ortho(left f32, right f32, bottom f32, top f32, near_plane f32, far_plane f32)

ortho multiplies the selected SGL matrix by an orthographic projection.

fn (WindowSglContext) perspective #

fn (mut context WindowSglContext) perspective(fov_y f32, aspect f32, z_near f32, z_far f32)

perspective multiplies the selected SGL matrix by a perspective projection.

fn (WindowSglContext) point_size #

fn (mut context WindowSglContext) point_size(size f32)

point_size sets the rasterized size of subsequently emitted points.

fn (WindowSglContext) pop_matrix #

fn (mut context WindowSglContext) pop_matrix()

pop_matrix restores the selected SGL matrix from its current stack.

fn (WindowSglContext) pop_pipeline #

fn (mut context WindowSglContext) pop_pipeline()

pop_pipeline restores the previous SGL pipeline selection from its stack.

fn (WindowSglContext) push_matrix #

fn (mut context WindowSglContext) push_matrix()

push_matrix saves the selected SGL matrix on its current stack.

fn (WindowSglContext) push_pipeline #

fn (mut context WindowSglContext) push_pipeline()

push_pipeline saves the current SGL pipeline selection on its stack.

fn (WindowSglContext) rotate #

fn (mut context WindowSglContext) rotate(angle_rad f32, x f32, y f32, z f32)

rotate applies an axis-angle rotation to the selected SGL matrix.

fn (WindowSglContext) scale #

fn (mut context WindowSglContext) scale(x f32, y f32, z f32)

scale applies a three-axis scale to the selected SGL matrix.

fn (WindowSglContext) scissor_rect #

fn (mut context WindowSglContext) scissor_rect(x int, y int, width int, height int, origin_top_left bool)

scissor_rect sets an integer framebuffer scissor for subsequent SGL drawing.

fn (WindowSglContext) scissor_rectf #

fn (mut context WindowSglContext) scissor_rectf(x f32, y f32, width f32, height f32, origin_top_left bool)

scissor_rectf sets a floating-point framebuffer scissor for subsequent SGL drawing.

fn (WindowSglContext) t2f #

fn (mut context WindowSglContext) t2f(u f32, v f32)

t2f sets the texture coordinates attached to subsequently emitted vertices.

fn (WindowSglContext) texture #

fn (mut context WindowSglContext) texture(image WindowImageId, sampler WindowSamplerId) !

texture selects a window-owned image and sampler for subsequent textured primitives.

fn (WindowSglContext) translate #

fn (mut context WindowSglContext) translate(x f32, y f32, z f32)

translate applies a three-axis translation to the selected SGL matrix.

fn (WindowSglContext) v2f #

fn (mut context WindowSglContext) v2f(x f32, y f32)

v2f emits a 2D vertex using the current color and texture coordinates.

fn (WindowSglContext) v2f_c1i #

fn (mut context WindowSglContext) v2f_c1i(x f32, y f32, rgba u32)

v2f_c1i emits a 2D vertex with a packed RGBA color.

fn (WindowSglContext) v2f_c3b #

fn (mut context WindowSglContext) v2f_c3b(x f32, y f32, red u8, green u8, blue u8)

v2f_c3b emits a 2D vertex with a byte RGB color.

fn (WindowSglContext) v2f_c3f #

fn (mut context WindowSglContext) v2f_c3f(x f32, y f32, red f32, green f32, blue f32)

v2f_c3f emits a 2D vertex with a floating-point RGB color.

fn (WindowSglContext) v2f_c4b #

fn (mut context WindowSglContext) v2f_c4b(x f32, y f32, red u8, green u8, blue u8, alpha u8)

v2f_c4b emits a 2D vertex with a byte RGBA color.

fn (WindowSglContext) v2f_c4f #

fn (mut context WindowSglContext) v2f_c4f(x f32, y f32, red f32, green f32, blue f32, alpha f32)

v2f_c4f emits a 2D vertex with a floating-point RGBA color.

fn (WindowSglContext) v2f_t2f #

fn (mut context WindowSglContext) v2f_t2f(x f32, y f32, u f32, v f32)

v2f_t2f emits a 2D vertex with explicit texture coordinates and the current color.

fn (WindowSglContext) v2f_t2f_c1i #

fn (mut context WindowSglContext) v2f_t2f_c1i(x f32, y f32, u f32, v f32, rgba u32)

v2f_t2f_c1i emits a 2D vertex with texture coordinates and a packed RGBA color.

fn (WindowSglContext) v2f_t2f_c3b #

fn (mut context WindowSglContext) v2f_t2f_c3b(x f32, y f32, u f32, v f32, red u8, green u8, blue u8)

v2f_t2f_c3b emits a 2D vertex with texture coordinates and a byte RGB color.

fn (WindowSglContext) v2f_t2f_c3f #

fn (mut context WindowSglContext) v2f_t2f_c3f(x f32, y f32, u f32, v f32, red f32, green f32, blue f32)

v2f_t2f_c3f emits a 2D vertex with texture coordinates and a floating-point RGB color.

fn (WindowSglContext) v2f_t2f_c4b #

fn (mut context WindowSglContext) v2f_t2f_c4b(x f32, y f32, u f32, v f32, red u8, green u8, blue u8, alpha u8)

v2f_t2f_c4b emits a 2D vertex with texture coordinates and a byte RGBA color.

fn (WindowSglContext) v2f_t2f_c4f #

fn (mut context WindowSglContext) v2f_t2f_c4f(x f32, y f32, u f32, v f32, red f32, green f32, blue f32, alpha f32)

v2f_t2f_c4f emits a 2D vertex with texture coordinates and a floating-point RGBA color.

fn (WindowSglContext) v3f #

fn (mut context WindowSglContext) v3f(x f32, y f32, z f32)

v3f emits a 3D vertex using the current color and texture coordinates.

fn (WindowSglContext) v3f_c1i #

fn (mut context WindowSglContext) v3f_c1i(x f32, y f32, z f32, rgba u32)

v3f_c1i emits a 3D vertex with a packed RGBA color.

fn (WindowSglContext) v3f_c3b #

fn (mut context WindowSglContext) v3f_c3b(x f32, y f32, z f32, red u8, green u8, blue u8)

v3f_c3b emits a 3D vertex with a byte RGB color.

fn (WindowSglContext) v3f_c3f #

fn (mut context WindowSglContext) v3f_c3f(x f32, y f32, z f32, red f32, green f32, blue f32)

v3f_c3f emits a 3D vertex with a floating-point RGB color.

fn (WindowSglContext) v3f_c4b #

fn (mut context WindowSglContext) v3f_c4b(x f32, y f32, z f32, red u8, green u8, blue u8, alpha u8)

v3f_c4b emits a 3D vertex with a byte RGBA color.

fn (WindowSglContext) v3f_c4f #

fn (mut context WindowSglContext) v3f_c4f(x f32, y f32, z f32, red f32, green f32, blue f32, alpha f32)

v3f_c4f emits a 3D vertex with a floating-point RGBA color.

fn (WindowSglContext) v3f_t2f #

fn (mut context WindowSglContext) v3f_t2f(x f32, y f32, z f32, u f32, v f32)

v3f_t2f emits a 3D vertex with explicit texture coordinates and the current color.

fn (WindowSglContext) v3f_t2f_c1i #

fn (mut context WindowSglContext) v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32)

v3f_t2f_c1i emits a 3D vertex with texture coordinates and a packed RGBA color.

fn (WindowSglContext) v3f_t2f_c3b #

fn (mut context WindowSglContext) v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, red u8, green u8, blue u8)

v3f_t2f_c3b emits a 3D vertex with texture coordinates and a byte RGB color.

fn (WindowSglContext) v3f_t2f_c3f #

fn (mut context WindowSglContext) v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, red f32, green f32, blue f32)

v3f_t2f_c3f emits a 3D vertex with texture coordinates and a floating-point RGB color.

fn (WindowSglContext) v3f_t2f_c4b #

fn (mut context WindowSglContext) v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, red u8, green u8, blue u8, alpha u8)

v3f_t2f_c4b emits a 3D vertex with texture coordinates and a byte RGBA color.

fn (WindowSglContext) v3f_t2f_c4f #

fn (mut context WindowSglContext) v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, red f32, green f32, blue f32, alpha f32)

v3f_t2f_c4f emits a 3D vertex with texture coordinates and a floating-point RGBA color.

fn (WindowSglContext) viewport #

fn (mut context WindowSglContext) viewport(x int, y int, width int, height int, origin_top_left bool)

viewport sets the framebuffer viewport used by subsequent SGL drawing.

struct WindowSglPipelineId #

struct WindowSglPipelineId {
	app_instance u64
	slot         int
	generation   u32
	window       WindowId
}

WindowSglPipelineId is a generation-checked managed SGL pipeline identity.

struct WindowShaderId #

struct WindowShaderId {
	app_instance u64
	slot         int
	generation   u32
	window       WindowId
}

WindowShaderId is a generation-checked managed shader identity.

struct WindowStageBindings #

struct WindowStageBindings {
pub:
	images          []WindowImageBinding
	samplers        []WindowSamplerBinding
	storage_buffers []WindowBufferBinding
}

WindowStageBindings groups managed resource bindings for one shader stage.

struct WindowState #

struct WindowState {
pub:
	mapping      WindowMappingState
	visibility   WindowVisibilityState
	active       WindowObservedBool
	focused      WindowObservedBool
	minimized    WindowObservedBool
	maximized    WindowObservedBool
	fullscreen   WindowObservedBool
	mouse_locked WindowObservedBool
	position     WindowPosition
	monitor_ids  []WindowMonitorId
	// monitor_membership_observed distinguishes an observed empty membership
	// from a partial state observation which did not report monitors.
	monitor_membership_observed bool
	sequence                    u64
}

WindowState is the latest native observation for one live window. Unknown fields were not reported by the backend; sequence orders accepted updates.