gfx

package
v0.0.0-...-20810c9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Possible features

- render transparent back to front - render opaque front to back - stacking shaders - z-prepass (used when pixel shading is expensive - render scene with default pixel shader to generate depth buffer) - deferred rendering (lighting is done in later pass) - pre-pass lighting - forward + (tiled forward rendering)

Resources - https://tamats.com/learn/realtime-graphics/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeType

type AttributeType int
const (
	TypeVertex AttributeType = iota
	TypeColor
	TypeNormal
	TypeTexture
	TypeGeneric
)

type Blend

type Blend uint8
const (
	BlendAlpha Blend = iota
	BlendAlphaAdd
	BlendAdd
	BlendColor
	BlendMinus
	BlendPremultAlpha
	BlendModulate
	BlendXor
	BlendNone
)

type Buffer

type Buffer struct {
	Format   *BufferFormat
	Data     *data.Bytes
	Metadata any
}

type BufferAttribute

type BufferAttribute struct {
	Name     string
	Data     DataType
	Size     int
	Type     AttributeType
	Offset   int
	Location int
}

func (*BufferAttribute) SetName

func (ba *BufferAttribute) SetName(name string)

type BufferFormat

type BufferFormat struct {
	Attributes []BufferAttribute
	ByType     [5]*BufferAttribute
	Stride     int
	Frequency  Frequency
	Draw, Read bool
}

func (*BufferFormat) Add

func (f *BufferFormat) Add(data DataType, size int, attr AttributeType) *BufferAttribute

func (*BufferFormat) AddColor

func (f *BufferFormat) AddColor(data DataType, size int) *BufferAttribute

func (*BufferFormat) AddGeneric

func (f *BufferFormat) AddGeneric(data DataType, size int) *BufferAttribute

func (*BufferFormat) AddNormal

func (f *BufferFormat) AddNormal() *BufferAttribute

func (*BufferFormat) AddTexture

func (f *BufferFormat) AddTexture() *BufferAttribute

func (*BufferFormat) AddVertex

func (f *BufferFormat) AddVertex(data DataType, size int) *BufferAttribute

func (*BufferFormat) Create

func (f *BufferFormat) Create(capacity int) *Buffer

func (*BufferFormat) Get

type Coord

type Coord struct {
	X float32
	Y float32
}

func (Coord) Equals

func (mp Coord) Equals(other Coord) bool

func (Coord) IsZero

func (c Coord) IsZero() bool

func (Coord) Lerp

func (a Coord) Lerp(b Coord, delta float32) Coord

func (Coord) Max

func (c Coord) Max(other Coord) Coord

func (Coord) Min

func (c Coord) Min(other Coord) Coord

func (*Coord) Set

func (c *Coord) Set(x, y float32)

type DataType

type DataType int
const (
	Float DataType = iota
	Double
	Byte
	UByte
	Short
	UShort
	Int
	UInt
)

func (DataType) Bytes

func (d DataType) Bytes() int

func (DataType) Write

func (d DataType) Write(out *data.Bytes, v float32)

type Frequency

type Frequency int
const (
	Never Frequency = iota
	Sometimes
	Always
)

type Primitive

type Primitive uint8
const (
	PrimitiveTriangle Primitive = iota
	PrimitiveLine
	PrimitiveQuad
	PrimitiveNone
)

type Texel

type Texel interface {
	UV(tex *Texture) (u, v float32)
}

type TexelUV

type TexelUV Coord

func (TexelUV) UV

func (t TexelUV) UV(tex *Texture) (u, v float32)

type TexelXY

type TexelXY Coord

func (TexelXY) UV

func (t TexelXY) UV(tex *Texture) (u, v float32)

type Texture

type Texture struct {
	Name string
	Info TextureInfo
}

func (*Texture) Coord

func (tex *Texture) Coord(x, y float32) TextureCoord

func (*Texture) Frames

func (tex *Texture) Frames(width, height float32, topLeftCorners []Coord) []Tile

func (*Texture) Grid

func (tex *Texture) Grid(columns, rows, columnWidth, rowHeight, offsetX, offsetY int) [][]Tile

func (*Texture) IsDefined

func (tex *Texture) IsDefined() bool

func (*Texture) Texel

func (tex *Texture) Texel(x, y float32) Texel

func (*Texture) Tile

func (tex *Texture) Tile() Tile

type TextureCoord

type TextureCoord struct {
	Texture *Texture
	Texel
}

func (TextureCoord) Lerp

func (from TextureCoord) Lerp(to TextureCoord, delta float32) TextureCoord

func (TextureCoord) UV

func (tc TextureCoord) UV() (u, v float32)

type TextureInfo

type TextureInfo struct {
	Width, Height       int
	InvWidth, InvHeight float32
	Metadata            any
}

func (TextureInfo) IsDefined

func (info TextureInfo) IsDefined() bool

func (*TextureInfo) SetDimensions

func (td *TextureInfo) SetDimensions(width, height int)

type Tile

type Tile struct {
	Texture              *Texture
	TopLeft, BottomRight Texel
}

func (Tile) Coord

func (t Tile) Coord(dx, dy float32) TextureCoord

Jump to

Keyboard shortcuts

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