Documentation
¶
Overview ¶
Command gpu-triangle shows package gpu: a lit cube that turns, drawn by the program's own shader into a gpu.View with a depth buffer and 4x multisampling, inside a Material page. A slider sets the speed of the turn and a switch turns the multisampling on and off. The view draws at every frame (Continuous). The program uses only the public packages: gpu for the device, the buffers and the pipelines, and material for the page. The cube is drawn with Blinn-Phong shading by shaders/cube.wgsl, which `glutter-gen gpushaders` turned into shaders/shaders_gen.go; the matrices come from package vecmath (float64, reversed-Z).
Run it with: go run ./examples/gpu-triangle
It needs a GPU renderer (Vulkan on Linux and Android, Direct3D 12 on Windows, WebGPU on the web). With the OpenGL ES, WebGL or software renderer the view shows its fallback, a line of text.
On Windows: go run ./cmd/glutter-windows run ./examples/gpu-triangle. On the web: go run ./cmd/glutter-web serve ./examples/gpu-triangle. On Android: go run ./cmd/glutter-android run ./examples/gpu-triangle.
In debug builds the L key locks the pointer (the mouse look of a game; SPEC §27.6): the cursor is hidden and the mouse turns the cube. L, Alt+Tab or the end of the lock (Escape on the web) gives the pointer back.
Environment: GLUTTER_BACKEND=x11|wayland (Linux) or win32 (Windows), GLUTTER_RENDERER=vulkan|d3d12|webgpu, GLUTTER_SCREENSHOT=<file.png>, GLUTTER_SCREENSHOT_AFTER=<duration>.