glw

package
v0.0.0-...-8a12d84 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 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 (
	Assets embed.FS
)
View Source
var DefaultAnimatorDuration = 1000 * time.Millisecond
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 ExpDrive

func ExpDrive(t float64) float64

func Interp

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

func MustOpen

func MustOpen(name string) fs.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 Ntou

func Ntou(n float32) float32

Ntou converts norm to unit.

func Quat

func Quat(angle float32, axis f32.Vec3) f32.Vec4

func QuatConj

func QuatConj(a f32.Vec4) f32.Vec4

func QuatMul

func QuatMul(a, b f32.Vec4) f32.Vec4

func QuatRot3f

func QuatRot3f(r f32.Vec4, x, y, z float32) f32.Vec3

func RGBA

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

func RotateBy

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

func RotateTo

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

func ScaleBy

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

func ScaleTo

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

func ShearBy

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

func ShearTo

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

func TextureFilter

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

func TextureWrap

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

func To

func To(t Transform) func(Transformer)

func TranslateBy

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

func TranslateTo

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

func Uton

func Uton(u float32) float32

Uton converts unit to norm.

func With

func With(glctx gl.Context3) gl.Context3

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 struct {
	// contains filtered or unexported fields
}

func NewAnimator

func NewAnimator(options ...func(*Animator)) *Animator

func (*Animator) Apply

func (a *Animator) Apply(options ...func(*Animator))

func (*Animator) Cancel

func (a *Animator) Cancel()

func (*Animator) Done

func (a *Animator) Done()

func (*Animator) Duration

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

func (*Animator) Interp

func (a *Animator) Interp(fn func(float64) float64)

func (*Animator) Pt

func (a *Animator) Pt() Transform

func (*Animator) RotateBy

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

func (*Animator) RotateTo

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

func (*Animator) ScaleBy

func (a *Animator) ScaleBy(v f32.Vec3)

func (*Animator) ScaleTo

func (a *Animator) ScaleTo(v f32.Vec3)

func (*Animator) ShearBy

func (a *Animator) ShearBy(v f32.Vec3)

func (*Animator) ShearTo

func (a *Animator) ShearTo(v f32.Vec3)

func (*Animator) Stage

func (a *Animator) Stage(epoch time.Time, transforms ...func(Transformer))

TODO this cancels anything in progress but doesn't allow independent transforms to continue e.g. trigger 1s rotate, 0.5 seconds elapse, trigger 1s translate, 0.5 second elapse and rotate finishes, 0.5 seconds elapse and translate finishes what's actually desireable here? I think I'd want things to finish independently which suggests a different kind of layout

func (*Animator) Step

func (a *Animator) Step(now time.Time) (ok bool)

func (*Animator) To

func (a *Animator) To(t Transform)

func (*Animator) TranslateBy

func (a *Animator) TranslateBy(v f32.Vec3)

func (*Animator) TranslateTo

func (a *Animator) TranslateTo(v f32.Vec3)

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) Blit

func (buf *FrameBuffer) Blit(sz image.Point)

Blit to default framebuffer

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.Vec3
	Shear     f32.Vec3
	Scale     f32.Vec3
	Rotate    f32.Vec4
}

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

func TransformIdent

func TransformIdent() (a Transform)

func (Transform) Eval16fv

func (a Transform) Eval16fv() (m f32.Mat4)

func (Transform) Lerp

func (a Transform) Lerp(b Transform, t float32) Transform

func (Transform) Lerp4

func (a Transform) Lerp4(b Transform, t, u, v, w float32) 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.Vec3)

func (*Transform) ScaleTo

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

func (*Transform) ShearBy

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

func (*Transform) ShearTo

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

func (*Transform) To

func (a *Transform) To(b Transform)

func (*Transform) TranslateBy

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

func (*Transform) TranslateTo

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

type Transformer

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

type U16fv

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

func (U16fv) Animator

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

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) 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))

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) Stage

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

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

	// Transform applies given transforms instantly.
	Transform(transforms ...func(Transformer))

	// 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)
}

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
	Size   int
	Stride int
	Offset int
}

abstraction for drawing point data

func (*VertexArray) Bind

func (vert *VertexArray) Bind()

func (*VertexArray) Create

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

TODO deprecate

should change uses as follows basically:

// x, y, z, u, v
obj.Vert.Floats.Create(gl.STATIC_DRAW, []float32{
	-1, -1, -1, 1, 1,
	-1, +1, -1, 1, 0,
	+1, +1, -1, 0, 0,
	+1, -1, -1, 0, 1,
})
obj.Vert.Uints.Create(gl.STATIC_DRAW, []uint32{0, 1, 2, 0, 2, 3})
obj.Vert.StepSize(3, 5, 0)
obj.Vert.Bind()

obj.TexCoord.Floats = obj.Vert.Floats
obj.TexCoord.StepSize(2, 5, 3)
obj.TexCoord.Bind()

func (VertexArray) Delete

func (vert VertexArray) Delete()

func (VertexArray) Draw

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

func (*VertexArray) StepSize

func (vert *VertexArray) StepSize(size, stride, offset int)

func (VertexArray) Unbind

func (vert VertexArray) Unbind()

func (*VertexArray) Update

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

TODO deprecate

type VertexElement

type VertexElement struct {
	gl.Attrib
	Floats FloatBuffer
	Uints  UintBuffer
	Size   int
	Stride int
	Offset int
}

abstraction for drawing indexed point data

func (*VertexElement) Bind

func (vert *VertexElement) Bind()

func (*VertexElement) Create

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

TODO deprecate

func (VertexElement) Delete

func (vert VertexElement) Delete()

func (VertexElement) Draw

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

func (*VertexElement) StepSize

func (vert *VertexElement) StepSize(size, stride, offset int)

func (VertexElement) Unbind

func (vert VertexElement) Unbind()

func (*VertexElement) Update

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

TODO deprecate

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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