gfx

package
v0.0.0-...-df128bb Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Blank = &Sprite{
	Named: internal.Name("Blank"),
	Sheet: &Sheet{
		Named:     internal.Name("Blank"),
		Width:     1,
		Height:    1,
		unitPerPx: 1,
		tex:       blankTex,
		state:     stateReady,
	},
	X0: -1,
	X1: 1,
	Y0: -1,
	Y1: 1,
	S0: 0,
	S1: 1,
	T0: 0,
	T1: 1,
}

Functions

func HorizontalFOV

func HorizontalFOV(angle f32.Radian) f32.Radian

func Init

func Init(ctx gl.Context, nextFrame func()) error

func NextFrame

func NextFrame()

func OnSize

func OnSize(e size.Event)

func Raw

func Raw(f func(GL gl.Context))

func Size

func Size() size.Event

Types

type Batch

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

func (*Batch) Append

func (b *Batch) Append(s *Sprite, x, y, z, sx, sy float32, tint Color)

func (*Batch) AppendEx

func (b *Batch) AppendEx(s *Sprite, x, y, z, sx, sy float32, tint Color, flags RenderFlags, rx, ry, rz float32)

func (*Batch) Release

func (b *Batch) Release()

func (*Batch) Render

func (b *Batch) Render(cam *Camera)

func (*Batch) Reserve

func (b *Batch) Reserve(count int)

func (*Batch) Reset

func (b *Batch) Reset()

type Camera

type Camera struct {
	Perspective f32.Mat4
	// contains filtered or unexported fields
}

func (*Camera) Combined

func (c *Camera) Combined() *f32.Mat4

func (*Camera) Offset

func (c *Camera) Offset() *f32.Mat4

func (*Camera) Position

func (c *Camera) Position() *f32.Mat4

func (*Camera) Rotation

func (c *Camera) Rotation() *f32.Mat4

func (*Camera) SetDefaults

func (c *Camera) SetDefaults()

type Color

type Color struct {
	R, G, B, A uint8
}
var (
	Black Color = BlackAlpha(255)
	White Color = WhiteAlpha(255)
)

func BlackAlpha

func BlackAlpha(a uint8) Color

func WhiteAlpha

func WhiteAlpha(a uint8) Color
type ErrShaderLink struct {
	Vert string
	Frag string
	Link string

	Extra string
}

func (ErrShaderLink) Error

func (err ErrShaderLink) Error() string

type RenderFlags

type RenderFlags uint16
const (
	// FlagNoDiscard prevents samples with an alpha channel below 50% from
	// being discarded.
	FlagNoDiscard RenderFlags = 1 << 0
	// FlagBillboard makes the sprite orient itself towards the camera.
	FlagBillboard RenderFlags = 1 << 1
	// FlagMTSDF causes the texture to be interpreted as a multi-channel
	// transparent signed distance field.
	FlagMTSDF RenderFlags = 1 << 2
	// FlagType2 uses an alternate rendering path for the sprite. What this
	// actually means depends on other flags. Currently, the following flags
	// have defined alternate rendering paths:
	//
	// MTSDF: use the alpha channel to render a smooth border (as opposed
	// to the sharper main shape rendering)
	FlagType2 RenderFlags = 1 << 3
)

type Sheet

type Sheet struct {
	internal.Named
	Width  int
	Height int
	// contains filtered or unexported fields
}

func NewEmbeddedSheet

func NewEmbeddedSheet(name string, width, height int, unitPerPx float32, data []byte) *Sheet

func NewSheet

func NewSheet(name string, width, height int, unitPerPx float32) *Sheet

func (*Sheet) Sprite

func (s *Sheet) Sprite(x, y, w, h, px, py float32) *Sprite

func (*Sheet) StartPreload

func (s *Sheet) StartPreload()

type Sprite

type Sprite struct {
	internal.Named
	Sheet  *Sheet
	X0, X1 float32
	Y0, Y1 float32
	S0, S1 float32
	T0, T1 float32
	// contains filtered or unexported fields
}

func (*Sprite) Crop

func (s *Sprite) Crop(left, top, right, bottom float32) *Sprite

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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