render

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package render defines the framework-owned renderer contract.

Concrete GPU backends live in sub-packages (render/d3d11, ...). Only those sub-packages know about a GPU API; everything else talks to this interface.

Index

Constants

This section is empty.

Variables

View Source
var ErrDeviceLost = errors.New("render: GPU device lost")

ErrDeviceLost is returned, wrapped, by BeginFrame and EndFrame when the GPU device was removed or reset (a driver update or crash, a remote desktop switch, sleep and resume). Nothing can be drawn until the device and the window's surface are recreated; see the backend's Recover and Recreate.

Functions

func Draw

func Draw(r Renderer, s *scene.Scene, width, height int) error

Draw renders a whole scene as one frame.

Types

type Renderer

type Renderer interface {
	// BeginFrame starts a frame of the given size in physical pixels, cleared
	// to clear. A size change resizes the swap chain.
	BeginFrame(width, height int, clear scene.Color) error
	DrawQuads([]scene.Quad)
	DrawGlyphs(scene.GlyphRun)
	DrawImages([]scene.ImageDraw)
	PushClip(scene.Rect)
	PushRoundedClip(scene.Rect, scene.Corners)
	PopClip()
	// EndFrame submits the frame and presents it, waiting for vsync.
	EndFrame() error
	// CaptureNextFrame arranges for fn to receive a copy of the next frame
	// just before it is presented. It is a debugging aid (screenshots, visual
	// tests) and is slow.
	CaptureNextFrame(fn func(*image.RGBA, error))
	Close()
}

Renderer draws scene primitives into a window surface.

A frame is BeginFrame, any number of Draw*/PushClip/PopClip calls in paint order, then EndFrame. Slices passed to Draw* are only read during the call.

Directories

Path Synopsis
Package d3d11 is the Direct3D 11 backend for render.Renderer.
Package d3d11 is the Direct3D 11 backend for render.Renderer.
Package soft is a CPU renderer: it draws scene primitives into memory in pure Go, with no GPU and no system library.
Package soft is a CPU renderer: it draws scene primitives into memory in pure Go, with no GPU and no system library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL