Documentation
¶
Overview ¶
Package gfx boots a 2D window on the GoGPU stack.
Layout:
gogpu — window, input, lifecycle gg — 2D drawing (via ggcanvas → surface) wgpu — pulled in transitively (GPU API)
g3d is intentionally not wired here; add it when a 3D game needs it.
Build with CGO disabled (Pure Go backend):
CGO_ENABLED=0 go run ./examples/hello2d
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is a thin gogpu + ggcanvas host for 2D games and tools.
func (*App) EventSource ¶
func (a *App) EventSource() gpucontext.EventSource
EventSource returns the gogpu event source (keys, pointer, …).
func (*App) Native ¶
Native returns the underlying gogpu.App for advanced use (input polling, animation tokens, multi-window, etc.).
func (*App) RequestRedraw ¶
func (a *App) RequestRedraw()
RequestRedraw schedules another frame when Continuous is false.
type Config ¶
type Config struct {
Title string
Width int
Height int
// Continuous keeps redrawing every frame (game loops).
// When false, redraw only on RequestRedraw / input (power-friendly).
Continuous bool
}
Config configures the window. Zero values get sensible defaults.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a 1280×720 continuous game window titled "Gomag".
type Letterbox ¶ added in v0.0.5
Letterbox maps a fixed virtual (playfield) size into a window while preserving aspect ratio, with black bars on the unused sides.
func Fit ¶ added in v0.0.5
Fit computes a letterbox for virtual size (virtW×virtH) inside winW×winH. Degenerate sizes yield Scale=0 and zero offsets.
func (Letterbox) Apply ¶ added in v0.0.5
Apply pushes a transform so subsequent drawing uses virtual coordinates. Caller must dc.Pop() when finished (typically via defer).