texture

package
v0.0.0-...-4934c46 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Overview

Package texture uploads images to the GPU and draws them. It interoperates with the standard library's image package: see FromImage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	ID      string
	Tex     *Texture
	Size    imgui.Vec2
	OnClick func()
	// contains filtered or unexported fields
}

Button draws a clickable image button. ID must be unique.

func NewButton

func NewButton(id string, tex *Texture, size imgui.Vec2) *Button

NewButton returns an image button for tex.

func (*Button) Display

func (b *Button) Display()

Display draws the image button.

func (*Button) Pressed

func (b *Button) Pressed() bool

Pressed reports whether the button was clicked during the last Display.

type Image

type Image struct {
	Tex  *Texture
	Size imgui.Vec2
}

Image draws a Texture at the given size (zero uses the texture's full size).

func NewImage

func NewImage(tex *Texture, size imgui.Vec2) *Image

NewImage returns an image widget for tex.

func (*Image) Display

func (i *Image) Display()

Display draws the image.

type Texture

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

Texture is a GPU texture handle.

func FromImage

func FromImage(img image.Image) *Texture

FromImage uploads any image.Image as a texture, converting it to RGBA as needed. A GL context must be current (it is during an app.Run frame).

func FromReader

func FromReader(r io.Reader) (*Texture, error)

FromReader decodes an image from r and uploads it as a texture. A GL context must be current (it is during an app.Run frame).

func NewRGBA

func NewRGBA(width, height int, pix []byte) *Texture

NewRGBA uploads tightly-packed RGBA8 pixels (len(pix) == width*height*4) as a texture. A GL context must be current.

func (*Texture) Close

func (t *Texture) Close() error

Close releases the texture immediately. It is optional; an unused texture is freed automatically. Close is safe to call more than once.

Jump to

Keyboard shortcuts

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