mobile: golang.org/x/mobile/exp/gl/glutil Index | Files

package glutil

import "golang.org/x/mobile/exp/gl/glutil"

Package glutil implements OpenGL utility functions.

Index

Package Files

context_x11.go doc.go glimage.go glutil.go

func CreateProgram

func CreateProgram(glctx gl.Context, vertexSrc, fragmentSrc string) (gl.Program, error)

CreateProgram creates, compiles, and links a gl.Program.

type Image

type Image struct {
    RGBA *image.RGBA
    // contains filtered or unexported fields
}

Image bridges between an *image.RGBA and an OpenGL texture.

The contents of the *image.RGBA can be uploaded as a texture and drawn as a 2D quad.

The number of active Images must fit in the system's OpenGL texture limit. The typical use of an Image is as a texture atlas.

func (*Image) Draw

func (img *Image) Draw(sz size.Event, topLeft, topRight, bottomLeft geom.Point, srcBounds image.Rectangle)

Draw draws the srcBounds part of the image onto a parallelogram, defined by three of its corners, in the current GL framebuffer.

func (*Image) Release

func (img *Image) Release()

Release invalidates the Image and removes any underlying data structures. The Image cannot be used after being deleted.

func (*Image) Upload

func (img *Image) Upload()

Upload copies the host image data to the GL device.

type Images

type Images struct {
    // contains filtered or unexported fields
}

Images maintains the shared state used by a set of *Image objects.

func NewImages

func NewImages(glctx gl.Context) *Images

NewImages creates an *Images.

func (*Images) NewImage

func (p *Images) NewImage(w, h int) *Image

NewImage creates an Image of the given size.

Both a host-memory *image.RGBA and a GL texture are created.

func (*Images) Release

func (p *Images) Release()

Release releases any held OpenGL resources. All *Image objects must be released first, or this function panics.

Package glutil imports 10 packages (graph) and is imported by 15 packages. Updated 6 days ago. Refresh now. Tools for package owners.