glwidget

package
v0.0.0-...-e7e105d Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: BSD-3-Clause Imports: 6 Imported by: 4

Documentation

Overview

Package glwidget provides a widget containing a GL ES framebuffer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GL

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

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.

Jump to

Keyboard shortcuts

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