Documentation
¶
Overview ¶
Package webgl draws scenes with WebGL 2 into a canvas of a web page.
It draws what the Vulkan and Direct3D 11 renderers draw, with their shaders ported to GLSL ES 3.00 (see shaders.go). Each call into WebGL is a call from WebAssembly into JavaScript, so a frame makes few: the instances of the whole frame are written into one float texture with a single upload, and each batch of instances is then drawn with a uniform for where its instances start and one instanced draw. Vertex shaders read their instance with texelFetch, and there are no vertex buffers.
Index ¶
- Variables
- type Renderer
- func (r *Renderer) BeginFrame(width, height int, clear scene.Color) error
- func (r *Renderer) CaptureNextFrame(fn func(*image.RGBA, error))
- func (r *Renderer) Close()
- func (r *Renderer) Describe() string
- func (r *Renderer) DrawGlyphs(run scene.GlyphRun)
- func (r *Renderer) DrawImages(ims []scene.ImageDraw)
- func (r *Renderer) DrawQuads(qs []scene.Quad)
- func (r *Renderer) EndFrame() error
- func (r *Renderer) PopClip()
- func (r *Renderer) PushClip(c scene.Rect)
- func (r *Renderer) PushRoundedClip(c scene.Rect, radii scene.Corners)
- func (r *Renderer) Recreate() error
Constants ¶
This section is empty.
Variables ¶
var ErrNoWebGL2 = errors.New("webgl: the browser has no WebGL 2")
ErrNoWebGL2 is returned by New when the page cannot draw with WebGL 2.
Functions ¶
This section is empty.
Types ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer implements render.Renderer with WebGL 2 for one canvas.
func (*Renderer) BeginFrame ¶
func (*Renderer) CaptureNextFrame ¶
func (*Renderer) Close ¶
func (r *Renderer) Close()
Close releases the renderer's listeners. The context goes with the canvas.
func (*Renderer) DrawGlyphs ¶
DrawGlyphs draws a run's glyphs. A page has grayscale text only (see text.Atlas): a subpixel atlas is drawn as grayscale from its first channel.
func (*Renderer) DrawImages ¶
func (*Renderer) EndFrame ¶
EndFrame draws the frame. The browser shows it when the page's script returns to the event loop.