Back to / shiny / widget / glwidget

Package glwidget

Latest Go to latest

The latest major version is .

Published: Sep 24, 2020 | License: BSD-3-Clause | Module:


Package glwidget provides a widget containing a GL ES framebuffer.


type GL

type GL struct {

	Ctx gl.Context
	// contains filtered or unexported fields

GL is a widget that maintains an OpenGL ES context.

The Draw function is responsible for configuring the GL viewport and for publishing the result to the widget by calling the Publish method when the frame is complete. A typical draw function:

func(w *glwidget.GL) {
	w.Ctx.Viewport(0, 0, w.Rect.Dx(), w.Rect.Dy())
	w.Ctx.ClearColor(0, 0, 0, 1)
	// ... draw the frame

The GL context is separate from the one used by the gldriver to render the window, and is only used by the glwidget package during initialization and for the duration of the Publish call. This means a glwidget user is free to use Ctx as a background GL context concurrently with the primary UI drawing done by the gldriver.

func NewGL

func NewGL(drawFunc func(*GL)) *GL

NewGL creates a GL widget with a Draw function called when painted.

func (*GL) PaintBase

func (w *GL) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error

func (*GL) Publish

func (w *GL) Publish()

Publish renders the default framebuffer of Ctx onto the area of the window occupied by the widget.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier