Documentation ¶
Overview ¶
Package gfx is a thin abstraction layer for OpenGL.
Index ¶
- Variables
- func Do(f func())
- func HorizontalFOV(angle float64) float32
- func Init(ctx gl.Context)
- func InvalidateFramebuffer(fb, reset gl.Framebuffer, attachments ...gl.Enum)
- func NextFrame() bool
- func PixelSize() (w, h int)
- func Release()
- func SetSize(e size.Event)
- func Size() (w, h int)
- func StatRecordBufferData(count int)
- func StatRecordTextureUse(tex *AssetTexture)
- func StatRecordTriangleBatch(points int)
- func TexStorage2D(target gl.Enum, levels int, format, ty, sizedformat gl.Enum, width, height int)
- type AssetTexture
- func BlankAssetTexture() *AssetTexture
- func DummyAssetTexture(name string, tex gl.Texture) *AssetTexture
- func NewAssetTexture(name string, nearest, noMip bool) *AssetTexture
- func NewCachedAssetTexture(name string) *AssetTexture
- func NewEmbeddedTexture(name string, nearest, noMip bool, data []byte, mimeType string, ...) *AssetTexture
- type Attrib
- type Camera
- type CustomInit
- type ErrShaderLink
- type GPUPowerLevel
- type Matrix
- func (m *Matrix) Determinant() float32
- func (m *Matrix) FunHouse(x, y, divisor, falloff, offX, offY, scale, hover float32)
- func (m *Matrix) Identity()
- func (m *Matrix) Inverse(m0 *Matrix) bool
- func (m *Matrix) Multiply(m0, m1 *Matrix)
- func (m *Matrix) Perspective(fov, aspect, nearZ, farZ float32)
- func (m *Matrix) RotationX(r float32)
- func (m *Matrix) RotationXYZ(x, y, z float32)
- func (m *Matrix) RotationY(r float32)
- func (m *Matrix) RotationZ(r float32)
- func (m *Matrix) Scale(x, y, z float32)
- func (m *Matrix) Translation(x, y, z float32)
- type Program
- type StaticBuffer
- type Texture
- type Uniform
- type Vector
Constants ¶
This section is empty.
Variables ¶
var ( // FrameSync is an internal variable. FrameSync = make(chan chan struct{}, 1) )
var GL gl.Context
GL is the OpenGL context.
var Lock sync.Mutex
Lock should be held whenever an operation depends on or modifies global OpenGL state.
Functions ¶
func HorizontalFOV ¶ added in v0.3.12
func InvalidateFramebuffer ¶ added in v0.3.24
func InvalidateFramebuffer(fb, reset gl.Framebuffer, attachments ...gl.Enum)
func PixelSize ¶ added in v0.3.6
func PixelSize() (w, h int)
PixelSize returns the screen size without compensation for pixel density.
func Release ¶ added in v0.2.70
func Release()
Release is an internal function that shuts down the context.
func StatRecordBufferData ¶ added in v0.3.4
func StatRecordBufferData(count int)
func StatRecordTextureUse ¶ added in v0.3.4
func StatRecordTextureUse(tex *AssetTexture)
func StatRecordTriangleBatch ¶ added in v0.3.4
func StatRecordTriangleBatch(points int)
Types ¶
type AssetTexture ¶ added in v0.2.72
type AssetTexture struct { Name string DownScale int NoClamp bool // contains filtered or unexported fields }
AssetTexture is a lazy-loaded texture.
func BlankAssetTexture ¶ added in v0.2.75
func BlankAssetTexture() *AssetTexture
BlankAssetTexture returns a 1x1 white square.
func DummyAssetTexture ¶ added in v0.3.5
func DummyAssetTexture(name string, tex gl.Texture) *AssetTexture
func NewAssetTexture ¶ added in v0.2.72
func NewAssetTexture(name string, nearest, noMip bool) *AssetTexture
NewAssetTexture creates a lazy-loaded texture from an asset.
func NewCachedAssetTexture ¶ added in v0.2.75
func NewCachedAssetTexture(name string) *AssetTexture
NewCachedAssetTexture creates a lazy-loaded texture from an asset.
func NewEmbeddedTexture ¶ added in v0.2.75
func NewEmbeddedTexture(name string, nearest, noMip bool, data []byte, mimeType string, premultiplyAlpha bool) *AssetTexture
NewEmbeddedTexture creates an AssetTexture that loads from memory.
func (*AssetTexture) LazyTexture ¶ added in v0.2.73
func (a *AssetTexture) LazyTexture(def gl.Texture) gl.Texture
LazyTexture loads the texture and returns the texture handle.
func (*AssetTexture) Preload ¶ added in v0.2.72
func (a *AssetTexture) Preload() error
Preload loads the texture and returns any error encountered.
func (*AssetTexture) Ready ¶ added in v0.3.10
func (a *AssetTexture) Ready() bool
func (*AssetTexture) Release ¶ added in v0.2.73
func (a *AssetTexture) Release()
Release deletes the texture handle.
func (*AssetTexture) StartPreload ¶ added in v0.3.7
func (a *AssetTexture) StartPreload()
StartPreload is a convenience function that calls Preload in a new goroutine.
func (*AssetTexture) Texture ¶ added in v0.2.72
func (a *AssetTexture) Texture() gl.Texture
Texture loads the texture and returns the texture handle.
type Camera ¶
type Camera struct { Offset Matrix Rotation Matrix Position Matrix Perspective Matrix Invert bool // contains filtered or unexported fields }
Camera tracks the position and orientation of the 3D camera.
func (*Camera) PopTransform ¶
func (c *Camera) PopTransform()
PopTransform removes the last transform added via PushTransform.
func (*Camera) PushTransform ¶
PushTransform adds a transform to the transform stack.
func (*Camera) PushTranslation ¶ added in v0.3.7
PushTranslation is a helper function to push a translation-based transform to the stack.
func (*Camera) SetDefaults ¶
func (c *Camera) SetDefaults()
SetDefaults sets the Matrix fields in Camera to default values.
type CustomInit ¶ added in v0.2.70
type CustomInit struct { Name string // contains filtered or unexported fields }
CustomInit is a custom OpenGL init/release function pair.
func Custom ¶ added in v0.2.70
func Custom(name string, init, release func()) *CustomInit
Custom registers a CustomInit.
type ErrShaderLink ¶ added in v0.3.7
type ErrShaderLink struct { Name string Vert string Frag string Link string Message string Extra string }
func (ErrShaderLink) Error ¶ added in v0.3.7
func (err ErrShaderLink) Error() string
type GPUPowerLevel ¶ added in v0.3.18
type GPUPowerLevel int
const ( GPULow GPUPowerLevel = 0 GPUMedium GPUPowerLevel = 1 GPUHigh GPUPowerLevel = 2 )
Constants for GPUPowerLevel.
var GPULevel GPUPowerLevel = -1
GPULevel is 0, 1, or 2, for low-, medium-, or high-powered GPUs.
type Matrix ¶
type Matrix [16]float32
Matrix is a 4x4 transformation matrix.
func (*Matrix) Determinant ¶ added in v0.3.22
func (*Matrix) Identity ¶ added in v0.3.7
func (m *Matrix) Identity()
Identity returns the identity matrix.
func (*Matrix) Inverse ¶ added in v0.3.22
Inverse computes the inverse of the matrix.
This function's implementation is based on the implementation from Mesa3D, contributed by Jacques Leroy.
func (*Matrix) Perspective ¶ added in v0.3.7
Perspective constructs a perspective matrix.
func (*Matrix) RotationXYZ ¶ added in v0.3.22
RotationXYZ constructs a rotation matrix over euler angles.
func (*Matrix) Translation ¶ added in v0.3.7
Translation constructs translation matrix.
type Program ¶ added in v0.2.70
Program is an OpenGL shader.
type StaticBuffer ¶
type StaticBuffer struct { Name string Data gl.Buffer Element gl.Buffer VAO gl.VertexArray Count int SetPointers func() DisableAttribs func() // contains filtered or unexported fields }
StaticBuffer is a convenience layer for OpenGL vertex buffer objects.
func NewStaticBuffer ¶
func NewStaticBuffer(name string, data, elements []uint8, elementSize int, setPointers, disableAttribs func()) *StaticBuffer
NewStaticBuffer creates a StaticBuffer.
func (*StaticBuffer) Bind ¶ added in v0.3.19
func (sb *StaticBuffer) Bind()
func (*StaticBuffer) Delete ¶
func (sb *StaticBuffer) Delete()
Delete frees the GPU memory held by StaticBuffer and removes it from the list of buffers.
func (*StaticBuffer) Unbind ¶ added in v0.3.19
func (sb *StaticBuffer) Unbind()
type Texture ¶ added in v0.2.70
Texture is an OpenGL texture.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package crt renders a screen-space CRT monitor effect.
|
Package crt renders a screen-space CRT monitor effect. |
Package sprites handles loading and rendering sprites.
|
Package sprites handles loading and rendering sprites. |