graphics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShaderSrcImageCount = 4

	// PreservedUniformVariablesCount represents the number of preserved uniform variables.
	// Any shaders in Ebitengine must have these uniform variables.
	PreservedUniformVariablesCount = 1 +
		1 +
		1 +
		1 +
		1 +
		1 +
		1 // the projection matrix

	ProjectionMatrixUniformVariableIndex = 6

	PreservedUniformDwordCount = 2 +
		2*ShaderSrcImageCount +
		2 +
		2 +
		2*ShaderSrcImageCount +
		2*ShaderSrcImageCount +
		16 // the projection matrix

	ProjectionMatrixUniformDwordIndex = 2 +
		2*ShaderSrcImageCount +
		2 +
		2 +
		2*ShaderSrcImageCount +
		2*ShaderSrcImageCount
)
View Source
const (
	VertexFloatCount = 12
)

Variables

This section is empty.

Functions

func CalcSourceHash

func CalcSourceHash(fragmentSrc []byte) (shaderir.SourceHash, error)

func CompileShader

func CompileShader(fragmentSrc []byte) (*shaderir.Program, error)

func InternalImageSize

func InternalImageSize(x int) int

InternalImageSize returns a nearest appropriate size as an internal image.

func QuadIndices

func QuadIndices() []uint32

func QuadVerticesFromDstAndSrc

func QuadVerticesFromDstAndSrc(dst []float32, dx0, dy0, dx1, dy1, sx0, sy0, sx1, sy1, cr, cg, cb, ca float32)

QuadVerticesFromDstAndSrc sets a float32 slice for a quadrangle.

func QuadVerticesFromSrcAndMatrix

func QuadVerticesFromSrcAndMatrix(dst []float32, sx0, sy0, sx1, sy1 float32, a, b, c, d, tx, ty float32, cr, cg, cb, ca float32)

QuadVerticesFromSrcAndMatrix sets a float32 slice for a quadrangle.

Types

type ManagedBytes

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

ManagedBytes is a managed byte slice. The internal byte alice are managed in a pool. ManagedBytes is useful when its lifetime is explicit, as the underlying byte slice can be reused for another ManagedBytes later. This can reduce allocations and GCs.

func NewManagedBytes

func NewManagedBytes(size int, f func([]byte)) *ManagedBytes

NewManagedBytes returns a managed byte slice initialized by the given constructor f.

The byte slice is not zero-cleared at the constructor.

func (*ManagedBytes) Clone

func (m *ManagedBytes) Clone() *ManagedBytes

Clone creates a new ManagedBytes with the same content.

func (*ManagedBytes) GetAndRelease

func (m *ManagedBytes) GetAndRelease() ([]byte, func())

GetAndRelease returns the raw byte slice and a finalizer. A finalizer should be called when you can ensure that the slice is no longer used, e.g. when a graphics command using this slice is sent and executed.

After GetAndRelease is called, the underlying byte slice is no longer available.

func (*ManagedBytes) Len

func (m *ManagedBytes) Len() int

Len returns the length of the slice.

func (*ManagedBytes) Read

func (m *ManagedBytes) Read(dst []byte, from, to int)

Read reads the byte slice's content to dst.

func (*ManagedBytes) Release

func (m *ManagedBytes) Release()

Release releases the underlying byte slice.

After Release is called, the underlying byte slice is no longer available.

Jump to

Keyboard shortcuts

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