glw

package module
v0.0.0-...-1e03496 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FilterNearest = TextureFilter(gl.NEAREST, gl.NEAREST)
	FilterLinear  = TextureFilter(gl.LINEAR, gl.LINEAR)
	WrapClamp     = TextureWrap(gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE)
	WrapRepeat    = TextureWrap(gl.REPEAT, gl.REPEAT)
)
View Source
var ErrNotZero = errors.New("Metric distance not zero")

Functions

func Context

func Context() gl.Context

func Duration

func Duration(d time.Duration) func(Animator)

func ExpDecay

func ExpDecay(t float64) float64

func Interp

func Interp(fn func(float64) float64) func(Animator)

func MustOpen

func MustOpen(name string) asset.File

func MustReadAll

func MustReadAll(filename string) []byte

MustReadAll reads the file named by filename from assets and returns the contents or panics on error.

func Notify

func Notify(p *uint32) func(Animator)

func Ntou

func Ntou(n float32) float32

Ntou converts norm to unit.

func RGBA

func RGBA(c color.Color) (r, g, b, a float32)

func RotateAt

func RotateAt(angle float32, axis f32.Vec3) func(Transformer)

func RotateBy

func RotateBy(angle float32, axis f32.Vec3) func(Transformer)

func RotateTo

func RotateTo(angle float32, axis f32.Vec3) func(Transformer)

func ScaleAt

func ScaleAt(v f32.Vec4) func(Transformer)

func ScaleBy

func ScaleBy(v f32.Vec4) func(Transformer)

func ScaleTo

func ScaleTo(v f32.Vec4) func(Transformer)

func ShearAt

func ShearAt(v f32.Vec4) func(Transformer)

func ShearBy

func ShearBy(v f32.Vec4) func(Transformer)

func ShearTo

func ShearTo(v f32.Vec4) func(Transformer)

func TextureFilter

func TextureFilter(min, mag int) func(*Texture)

func TextureWrap

func TextureWrap(s, t int) func(*Texture)

func Tick

func Tick(d time.Duration) func(Animator)

func To

func To(t Transform) func(Transformer)

func TranslateAt

func TranslateAt(v f32.Vec4) func(Transformer)

func TranslateBy

func TranslateBy(v f32.Vec4) func(Transformer)

func TranslateTo

func TranslateTo(v f32.Vec4) func(Transformer)

func Uton

func Uton(u float32) float32

Uton converts unit to norm.

func Vec2

func Vec2(v0, v1 float32) f32.Vec2

func Vec3

func Vec3(v0, v1, v2 float32) f32.Vec3

func Vec4

func Vec4(v0, v1, v2, v3 float32) f32.Vec4

func With

func With(glctx gl.Context) gl.Context

TODO allow package to be used by multiple contexts in parallel.

Types

type A2fv

type A2fv gl.Attrib

func (A2fv) Disable

func (a A2fv) Disable()

func (A2fv) Enable

func (a A2fv) Enable()

func (A2fv) Pointer

func (a A2fv) Pointer()

type A3fv

type A3fv gl.Attrib

func (A3fv) Disable

func (a A3fv) Disable()

func (A3fv) Enable

func (a A3fv) Enable()

func (A3fv) Pointer

func (a A3fv) Pointer()

type A4fv

type A4fv gl.Attrib

func (A4fv) Disable

func (a A4fv) Disable()

func (A4fv) Enable

func (a A4fv) Enable()

func (A4fv) Pointer

func (a A4fv) Pointer()

type Animator

type Animator interface {
	// Apply sets default options on animator. Any animation in progress is cancelled
	// first unless the length of options is zero, then this call has no effect.
	Apply(options ...func(Animator))

	Tick(time.Duration)

	Duration(time.Duration)

	// Interp defaults to exponential decay.
	Interp(func(float64) float64)

	Notify(*uint32)

	At() Transform

	Start(transforms ...func(Transformer))

	Stage(epoch time.Time, transforms ...func(Transformer))

	Step(now time.Time) bool

	Cancel()
}

type FPS

type FPS struct{ time.Time }

func (*FPS) Update

func (fps *FPS) Update(a time.Time)

type FloatBuffer

type FloatBuffer struct {
	gl.Buffer
	// contains filtered or unexported fields
}

func (*FloatBuffer) Bind

func (buf *FloatBuffer) Bind()

func (*FloatBuffer) Create

func (buf *FloatBuffer) Create(usage gl.Enum, data []float32)

func (FloatBuffer) Delete

func (buf FloatBuffer) Delete()

func (FloatBuffer) Draw

func (buf FloatBuffer) Draw(mode gl.Enum)

func (FloatBuffer) Unbind

func (buf FloatBuffer) Unbind()

func (*FloatBuffer) Update

func (buf *FloatBuffer) Update(data []float32)

type FragAsset

type FragAsset string

FragAsset is a filename in assets containing fragment shader source code.

func (FragAsset) Source

func (name FragAsset) Source() FragSrc

Source returns the contents of the named file in assets or panics on error.

type FragSrc

type FragSrc string

FragSrc is fragment shader source code.

func (FragSrc) Compile

func (src FragSrc) Compile() (gl.Shader, error)

Compile returns the compiled shader of src and error if any.

type FrameBuffer

type FrameBuffer struct {
	gl.Framebuffer
	// contains filtered or unexported fields
}

func (*FrameBuffer) Attach

func (buf *FrameBuffer) Attach()

func (*FrameBuffer) Create

func (buf *FrameBuffer) Create(options ...func(*Texture))

func (*FrameBuffer) Delete

func (buf *FrameBuffer) Delete()

func (*FrameBuffer) Detach

func (buf *FrameBuffer) Detach()

func (*FrameBuffer) RGBA

func (buf *FrameBuffer) RGBA() *image.RGBA

func (*FrameBuffer) Update

func (buf *FrameBuffer) Update(width, height int)

type Program

type Program struct{ gl.Program }

Program identifies a compiled shader program. The bool Program.Init can be used to check if valid.

func (Program) Attrib

func (prg Program) Attrib(name string) gl.Attrib

Attrib returns attribute location by name in program.

func (*Program) Build

func (prg *Program) Build(vsrc VertSrc, fsrc FragSrc) error

Build compiles shaders and links program.

func (*Program) BuildAssets

func (prg *Program) BuildAssets(vtag VertAsset, ftag FragAsset) error

BuildAssets is a helper that wraps Program.Build with asset file contents of filenames vtag and ftag.

func (Program) Delete

func (prg Program) Delete()

Delete frees the memory and invalidates the name associated with the program.

func (*Program) Install

func (prg *Program) Install(vsrc VertSrc, fsrc FragSrc) error

Install is a helper that wraps Program.Build and Program.Use.

func (*Program) MustBuild

func (prg *Program) MustBuild(vsrc VertSrc, fsrc FragSrc)

MustBuild is a helper that wraps Program.Build and panics on error.

func (*Program) MustBuildAssets

func (prg *Program) MustBuildAssets(vtag VertAsset, ftag FragAsset)

MustBuildAssets is a helper that wraps Program.BuildAssets and panics on error.

func (Program) Uniform

func (prg Program) Uniform(name string) gl.Uniform

Uniform returns uniform location by name in program.

func (Program) Unmarshal

func (prg Program) Unmarshal(dst interface{})

Unmarshal recursively sets fields of dst for recognized types.

func (Program) Use

func (prg Program) Use()

Use installs program as part of current rendering state.

type Sampler

type Sampler struct {
	Texture
	U1i
}

func (*Sampler) Bind

func (a *Sampler) Bind()

type Side

type Side int
const (
	Start Side = iota
	End
	Top
	Bottom
)

type T

type T struct {
}

func (*T) BottomAt

func (a *T) BottomAt(t T, d Side)

func (*T) EndAt

func (a *T) EndAt(t T, d Side)

func (*T) SetHeight

func (a *T) SetHeight(x int)

func (*T) SetWidth

func (a *T) SetWidth(x int)

func (*T) StartAt

func (a *T) StartAt(t T, d Side)

func (*T) TopAt

func (a *T) TopAt(t T, d Side)

type Texture

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

func (Texture) At

func (tex Texture) At(x, y int) color.Color

func (Texture) Bind

func (tex Texture) Bind()

func (Texture) Bounds

func (tex Texture) Bounds() image.Rectangle

func (Texture) ColorModel

func (tex Texture) ColorModel() color.Model

func (*Texture) Create

func (tex *Texture) Create(options ...func(*Texture))

func (*Texture) Delete

func (tex *Texture) Delete()

func (*Texture) DrawSrc

func (tex *Texture) DrawSrc(src *image.RGBA)

func (Texture) GenerateMipmap

func (tex Texture) GenerateMipmap()

func (Texture) Unbind

func (tex Texture) Unbind()

func (*Texture) Upload

func (tex *Texture) Upload(src *image.RGBA)

type Transform

type Transform struct {
	Translate f32.Vec4
	Shear     f32.Vec4
	Rotate    f32.Vec4
	Scale     f32.Vec4
}

TODO this is essentially type Sheet, but should vectors be tucked behind Transform type ???

func TransformIdent

func TransformIdent() (a Transform)

func (*Transform) RotateBy

func (a *Transform) RotateBy(angle float32, axis f32.Vec3)

func (*Transform) RotateTo

func (a *Transform) RotateTo(angle float32, axis f32.Vec3)

func (*Transform) ScaleBy

func (a *Transform) ScaleBy(v f32.Vec4)

func (*Transform) ScaleTo

func (a *Transform) ScaleTo(v f32.Vec4)

func (*Transform) ShearBy

func (a *Transform) ShearBy(v f32.Vec4)

func (*Transform) ShearTo

func (a *Transform) ShearTo(v f32.Vec4)

func (*Transform) TranslateBy

func (a *Transform) TranslateBy(v f32.Vec4)

func (*Transform) TranslateTo

func (a *Transform) TranslateTo(v f32.Vec4)

type Transformer

type Transformer interface {
	To(Transform)
	TranslateAt(f32.Vec4)
	TranslateBy(f32.Vec4)
	TranslateTo(f32.Vec4)
	ShearAt(f32.Vec4)
	ShearBy(f32.Vec4)
	ShearTo(f32.Vec4)
	RotateAt(angle float32, axis f32.Vec3)
	RotateBy(angle float32, axis f32.Vec3)
	RotateTo(angle float32, axis f32.Vec3)
	ScaleAt(f32.Vec4)
	ScaleBy(f32.Vec4)
	ScaleTo(f32.Vec4)
}

type U16fv

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

func (U16fv) Animator

func (u U16fv) Animator(options ...func(Animator)) Animator

func (U16fv) At

func (u U16fv) At() Transform

func (*U16fv) Inv2f

func (u *U16fv) Inv2f(nx, ny float32) (float32, float32)

func (*U16fv) Ortho

func (u *U16fv) Ortho(l, r float32, b, t float32, n, f float32)

func (U16fv) Stage

func (u U16fv) Stage(epoch time.Time, transforms ...func(Transformer))

func (U16fv) Step

func (u U16fv) Step(now time.Time) (ok bool)

func (U16fv) String

func (u U16fv) String() string

func (U16fv) Transform

func (u U16fv) Transform(transforms ...func(Transformer))

func (*U16fv) Update

func (u *U16fv) Update()

type U1f

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

func (U1f) Animator

func (u U1f) Animator(options ...func(Animator)) Animator

func (U1f) At

func (u U1f) At() Transform

func (U1f) Stage

func (u U1f) Stage(epoch time.Time, transforms ...func(Transformer))

func (U1f) Step

func (u U1f) Step(now time.Time) (ok bool)

func (U1f) Transform

func (u U1f) Transform(transforms ...func(Transformer))

func (*U1f) Update

func (u *U1f) Update()

type U1i

type U1i gl.Uniform

func (U1i) Set

func (u U1i) Set(v int)

type U2fv

type U2fv struct {
	gl.Uniform
	// contains filtered or unexported fields
}

func (*U2fv) Set

func (u *U2fv) Set(v f32.Vec2)

func (U2fv) Update

func (u U2fv) Update()

type U2i

type U2i gl.Uniform

func (U2i) Set

func (u U2i) Set(v0, v1 int)

type U3fv

type U3fv struct {
	gl.Uniform
	// contains filtered or unexported fields
}

func (U3fv) Set

func (u U3fv) Set(v f32.Vec3)

func (U3fv) Update

func (u U3fv) Update()

type U3i

type U3i gl.Uniform

func (U3i) Set

func (u U3i) Set(v0, v1, v2 int32)

type U4fv

type U4fv struct {
	gl.Uniform
	// contains filtered or unexported fields
}

func (*U4fv) Animator

func (u *U4fv) Animator(options ...func(Animator)) Animator

func (*U4fv) Set

func (u *U4fv) Set(v f32.Vec4)

func (*U4fv) Stage

func (u *U4fv) Stage(epoch time.Time, transforms ...func(Transformer))

func (*U4fv) Step

func (u *U4fv) Step(now time.Time) (ok bool)

func (*U4fv) Transform

func (u *U4fv) Transform(transforms ...func(Transformer))

func (U4fv) Update

func (u U4fv) Update()

type U4i

type U4i gl.Uniform

func (U4i) Set

func (u U4i) Set(v0, v1, v2, v3 int32)

type U9fv

type U9fv gl.Uniform

func (U9fv) Set

func (u U9fv) Set(m f32.Mat3)

type UintBuffer

type UintBuffer struct {
	gl.Buffer
	// contains filtered or unexported fields
}

func (*UintBuffer) Bind

func (buf *UintBuffer) Bind()

func (*UintBuffer) Create

func (buf *UintBuffer) Create(usage gl.Enum, data []uint32)

func (UintBuffer) Delete

func (buf UintBuffer) Delete()

func (UintBuffer) Draw

func (buf UintBuffer) Draw(mode gl.Enum)

func (UintBuffer) Unbind

func (buf UintBuffer) Unbind()

func (*UintBuffer) Update

func (buf *UintBuffer) Update(data []uint32)

type Uniform

type Uniform interface {
	// Animator allows setting additional options.
	Animator(options ...func(Animator)) Animator

	// Stage transforms to occur the next time Step is called.
	// Previously staged transforms or animations in progress
	// are cancelled with each call.
	Stage(epoch time.Time, transforms ...func(Transformer))

	// Step through staged transforms, returning true if work
	// was performed. The first false result returned performs
	// work to animate to final destination; subsequent calls
	// do not perform any work.
	Step(now time.Time) (ok bool)

	// Transform immediately starts an animation in a separate
	// goroutine, cancelling any staged transforms or animations
	// currently in progress.
	Transform(transforms ...func(Transformer))
}

type VertAsset

type VertAsset string

VertAsset is a filename in assets containing vertex shader source code.

func (VertAsset) Source

func (name VertAsset) Source() VertSrc

Source returns the contents of the named file in assets or panics on error.

type VertSrc

type VertSrc string

VertSrc is vertex shader source code.

func (VertSrc) Compile

func (src VertSrc) Compile() (gl.Shader, error)

Compile returns the compiled shader of src and error if any.

type VertexArray

type VertexArray struct {
	gl.Attrib
	Floats FloatBuffer
	// contains filtered or unexported fields
}

func (*VertexArray) Bind

func (vert *VertexArray) Bind()

func (*VertexArray) Create

func (vert *VertexArray) Create(usage gl.Enum, size int, floats []float32)

func (VertexArray) Delete

func (vert VertexArray) Delete()

func (VertexArray) Draw

func (vert VertexArray) Draw(mode gl.Enum)

func (VertexArray) Unbind

func (vert VertexArray) Unbind()

func (*VertexArray) Update

func (vert *VertexArray) Update(floats []float32)

type VertexElement

type VertexElement struct {
	gl.Attrib
	Floats FloatBuffer
	Uints  UintBuffer
	// contains filtered or unexported fields
}

func (*VertexElement) Bind

func (vert *VertexElement) Bind()

func (*VertexElement) Create

func (vert *VertexElement) Create(usage gl.Enum, size int, floats []float32, uints []uint32)

func (VertexElement) Delete

func (vert VertexElement) Delete()

func (VertexElement) Draw

func (vert VertexElement) Draw(mode gl.Enum)

func (VertexElement) Unbind

func (vert VertexElement) Unbind()

func (*VertexElement) Update

func (vert *VertexElement) Update(floats []float32, uints []uint32)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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