Documentation
¶
Overview ¶
Example: gogpu/ui — Viewport3D Demo
Demonstrates the Viewport3D widget which provides a GPU-rendered viewport for 3D content, video, or custom shader output. The widget follows the Flutter Texture pattern: it owns an offscreen GPU texture that an external renderer draws into, and the Layer Tree compositor blits it to the surface.
This example shows Viewport3D integration into a standard widget layout. The OnRender callback receives a gpucontext.TextureView for GPU rendering. In production, a 3D engine (e.g., gogpu/g3d) would render into this texture.
Architecture:
Viewport3D widget → offscreen GPU texture → Layer Tree → surface blit
Rendering: event-driven (default since gogpu v0.43.0). 0% CPU when idle. The viewport re-renders only when explicitly invalidated or when Continuous(true) is set for real-time content.