exp: golang.org/x/exp/shiny/widget/glwidget Index | Files

package glwidget

import "golang.org/x/exp/shiny/widget/glwidget"

Package glwidget provides a widget containing a GL ES framebuffer.

Index

Package Files

glwidget.go

type GL Uses

type GL struct {
    node.LeafEmbed

    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)
	w.Ctx.Clear(gl.COLOR_BUFFER_BIT)
	// ... draw the frame
	w.Publish()
}

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 Uses

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

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

func (*GL) PaintBase Uses

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

func (*GL) Publish Uses

func (w *GL) Publish()

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

Package glwidget imports 6 packages (graph). Updated 2017-09-30. Refresh now. Tools for package owners.