polyapp

package module
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: BSD-2-Clause Imports: 6 Imported by: 0

README

polyapp

Interface system for writing multiplatform apps

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoColor = ColorFA{ninf, ninf, ninf, ninf}
View Source
var NoExtra = VertExtra{}
View Source
var NoNorm = Vec3{ninf, ninf, ninf}
View Source
var NoUV = Vec2{ninf, ninf}
View Source
var NoVert = Vec3{ninf, ninf, ninf}
View Source
var NullVert = Vertex{Pos: NoVert, Norm: NoNorm, UV: NoUV, Color: NoColor, Extra: NoExtra}
View Source
var ZeroVec2 = Vec2{0, 0}
View Source
var ZeroVec3 = Vec3{0, 0, 0}

Functions

This section is empty.

Types

type App

type App struct {
	Init       func(options any)
	Teardown   func()
	Window     WindowProvider
	Graphics   GraphicsProvider
	Keyboard   KeyboardProvider
	Mouse      MouseProvider
	Touch      TouchProvider
	Controller ControllerProvider
	File       FileProvider
	Audio      AudioProvider
	Clipboard  ClipboardProvider
}

type AudioInterface

type AudioInterface interface {
}

type AudioProvider

type AudioProvider struct {
	AudioInterface
}

type BatchID added in v0.4.2

type BatchID uint8

type BatchShape added in v0.4.0

type BatchShape struct {
	BatchID     BatchID
	IndexZone   BufferZone
	VertexZone  BufferZone
	IndexCount  uint32
	VertexCount uint32
}

func (BatchShape) IdxLen added in v0.4.2

func (b BatchShape) IdxLen() uint32

func (BatchShape) VertLen added in v0.4.2

func (b BatchShape) VertLen() uint32

type BufferZone added in v0.4.2

type BufferZone struct {
	Start uint32
	End   uint32
}

func (BufferZone) Len added in v0.4.2

func (b BufferZone) Len() uint32

type BufferZoneLL added in v0.4.2

type BufferZoneLL struct {
	BufferZone
	Next *BufferZoneLL
}

func (*BufferZoneLL) Aquire added in v0.4.2

func (b *BufferZoneLL) Aquire(zoneSize uint32, last *BufferZoneLL) BufferZone

func (*BufferZoneLL) Insert added in v0.4.2

func (b *BufferZoneLL) Insert(zone BufferZone)

type ClipboardInterface

type ClipboardInterface interface {
	SetClipboardText(text string)
	GetClipboardText() string
}

type ClipboardProvider

type ClipboardProvider struct {
	ClipboardInterface
}

type Color16 added in v0.2.14

type Color16 = color.Color16

type Color24 added in v0.2.8

type Color24 = color.Color24

type Color32 added in v0.2.1

type Color32 = color.Color32

type Color48 added in v0.2.14

type Color48 = color.Color48

type Color64 added in v0.2.14

type Color64 = color.Color64

type Color8 added in v0.2.14

type Color8 = color.Color8

type ColorF added in v0.2.14

type ColorF = color.ColorF

type ColorFA added in v0.2.14

type ColorFA = color.ColorFA

type ControllerInterface

type ControllerInterface interface {
}

type ControllerProvider

type ControllerProvider struct {
	ControllerInterface
}

type DeepError added in v0.4.0

type DeepError = utils.DeepError

type FileInterface

type FileInterface interface {
	LoadFileBytes(name string) ([]byte, error)
	SaveFileBytes(name string, data []byte) error
}

type FileProvider

type FileProvider struct {
	FileInterface
}

func (FileProvider) LoadFileString

func (f FileProvider) LoadFileString(name string) (string, error)

func (FileProvider) SaveFileString

func (f FileProvider) SaveFileString(name string, content string) error

type GraphicsInterface

type GraphicsInterface interface {
	XRightYUpZAway() Vec3

	AddRenderer(vertexFlags VertexFlags, shaders []*Shader) (RendererID, DeepError)
	AddDrawBatch(vertexFlags VertexFlags, textureID TextureID, initialSize uint32) (BatchID, DeepError)
	AddTexture(texture *Texture) (TextureID, DeepError)
	AddDrawSurface(size IVec2, mipMaps uint32) (SurfaceID, TextureID, DeepError)

	ClearSurface(surfaceID SurfaceID, baseColor ColorFA) DeepError
	ClearSurfaceArea(surfaceID SurfaceID, baseColor ColorFA, area IRect2D) DeepError

	AllocateShapeInBatch(batchID BatchID, prototype ShapePrototype) (BatchShape, DeepError)
	UpdateVertexInShape(shape BatchShape, vertNumber uint32, vertex Vertex) DeepError
	HideShape(shape BatchShape) DeepError
	ShowShape(shape BatchShape) DeepError
	DeleteShape(shape BatchShape) DeepError

	DrawBatch(batchID BatchID, surfaceID SurfaceID, rendererID RendererID, forceRedraw bool) DeepError
	ClearBatch(batchID BatchID) DeepError
}

type GraphicsProvider

type GraphicsProvider struct {
	GraphicsInterface
}

func (GraphicsProvider) AddCircleAutoPoints2D

func (g GraphicsProvider) AddCircleAutoPoints2D(batchID BatchID, center Vertex, resolution float32, radius float32, uvRadius float32, uvRotation float32) (BatchShape, DeepError)

func (GraphicsProvider) AddCircleRingAutoPoints2D

func (g GraphicsProvider) AddCircleRingAutoPoints2D(batchID BatchID, center Vertex, resolution float32, innerRadius float32, outerRadius float32, uvInnerRadius float32, uvOuterRadius float32, uvRotation float32) (BatchShape, DeepError)

func (GraphicsProvider) AddLine2D

func (g GraphicsProvider) AddLine2D(batchID BatchID, a Vertex, b Vertex, thickness float32, uvThickness float32) (BatchShape, DeepError)

func (GraphicsProvider) AddQuad2D

func (g GraphicsProvider) AddQuad2D(batchID BatchID, quad Quad2D, color ColorFA, uvQuad Quad2D, extra VertExtra) (BatchShape, DeepError)

func (GraphicsProvider) AddQuadOutline2D

func (g GraphicsProvider) AddQuadOutline2D(batchID BatchID, quadInner Quad2D, quadOuter Quad2D, color ColorFA, uvQuadInner Quad2D, uvQuadOuter Quad2D, extra VertExtra) (BatchShape, DeepError)

func (GraphicsProvider) AddRect2D

func (g GraphicsProvider) AddRect2D(batchID BatchID, rect Rect2D, color ColorFA, uvRect Rect2D, extra VertExtra) (BatchShape, DeepError)

func (GraphicsProvider) AddRectOutline2D

func (g GraphicsProvider) AddRectOutline2D(batchID BatchID, rect Rect2D, thickness float32, color ColorFA, uvRect Rect2D, uvThickness float32, extra VertExtra) (BatchShape, DeepError)

func (GraphicsProvider) AddRegularPolygon2D

func (g GraphicsProvider) AddRegularPolygon2D(batchID BatchID, center Vertex, sides uint32, radius float32, shapeRotation float32, uvRadius float32, uvRotation float32) (BatchShape, DeepError)

func (GraphicsProvider) AddRegularPolygonRing2D

func (g GraphicsProvider) AddRegularPolygonRing2D(batchID BatchID, center Vertex, sides uint32, innerRadius float32, outerRadius float32, shapeRotation float32, uvInnerRadius float32, uvOuterRadius float32, uvRotation float32) (BatchShape, DeepError)

func (GraphicsProvider) AddTriangle2D added in v0.4.0

func (g GraphicsProvider) AddTriangle2D(batchID BatchID, a Vertex, b Vertex, c Vertex) (BatchShape, DeepError)

func (GraphicsProvider) UpdateCircleAutoPoints2D added in v0.2.14

func (g GraphicsProvider) UpdateCircleAutoPoints2D(shape BatchShape, center Vertex, resolution float32, radius float32, uvRadius float32, uvRotation float32) DeepError

func (GraphicsProvider) UpdateCircleRingAutoPoints2D added in v0.2.14

func (g GraphicsProvider) UpdateCircleRingAutoPoints2D(shape BatchShape, center Vertex, resolution float32, innerRadius float32, outerRadius float32, uvInnerRadius float32, uvOuterRadius float32, uvRotation float32) DeepError

func (GraphicsProvider) UpdateLine2D added in v0.2.14

func (g GraphicsProvider) UpdateLine2D(shape BatchShape, a Vertex, b Vertex, thickness float32, uvThickness float32) DeepError

func (GraphicsProvider) UpdateQuad2D added in v0.2.14

func (g GraphicsProvider) UpdateQuad2D(shape BatchShape, quad Quad2D, color ColorFA, uvQuad Quad2D, extra VertExtra) DeepError

func (GraphicsProvider) UpdateQuadOutline2D added in v0.2.14

func (g GraphicsProvider) UpdateQuadOutline2D(shape BatchShape, quadInner Quad2D, quadOuter Quad2D, color ColorFA, uvQuadInner Quad2D, uvQuadOuter Quad2D, extra VertExtra) DeepError

func (GraphicsProvider) UpdateRect2D added in v0.2.14

func (g GraphicsProvider) UpdateRect2D(shape BatchShape, rect Rect2D, color ColorFA, uvRect Rect2D, extra VertExtra) DeepError

func (GraphicsProvider) UpdateRectOutline2D added in v0.2.14

func (g GraphicsProvider) UpdateRectOutline2D(shape BatchShape, rect Rect2D, thickness float32, color ColorFA, uvRect Rect2D, uvThickness float32, extra VertExtra) DeepError

func (GraphicsProvider) UpdateRegularPolygon2D added in v0.2.14

func (g GraphicsProvider) UpdateRegularPolygon2D(shape BatchShape, center Vertex, sides uint32, radius float32, shapeRotation float32, uvRadius float32, uvRotation float32) DeepError

func (GraphicsProvider) UpdateRegularPolygonRing2D added in v0.2.14

func (g GraphicsProvider) UpdateRegularPolygonRing2D(shape BatchShape, center Vertex, sides uint32, innerRadius float32, outerRadius float32, shapeRotation float32, uvInnerRadius float32, uvOuterRadius float32, uvRotation float32) DeepError

func (GraphicsProvider) UpdateTriangle2D added in v0.4.0

func (g GraphicsProvider) UpdateTriangle2D(shape BatchShape, a Vertex, b Vertex, c Vertex) DeepError

type IQuad2D

type IQuad2D = vecs.I32Quad2

type IQuad3D

type IQuad3D = vecs.I32Quad3

type IRect2D

type IRect2D = vecs.I32AABB2

type IRect3D

type IRect3D = vecs.I32AABB3

type IVec2

type IVec2 = vecs.I32Vec2

type IVec3

type IVec3 = vecs.I32Vec3

type ImageType

type ImageType uint8
const (
	ImgUnknown ImageType = iota
	ImgPNG
	ImgBMP
	ImgWEBP
)

type InputAction

type InputAction uint8
const (
	InputUntouched InputAction = iota
	InputPressed
	InputHeld
	InputReleased
	InputHeldRepeat
)

type InputState

type InputState uint8
const (
	UpPosition InputState = iota
	DownPosition
)

type KeyboardInterface

type KeyboardInterface interface {
	GetKeyboardKeyState(key KeyboardKey) InputState
	SetCallbackOnRuneInput(op func(r rune))
	SetCallbackOnKeyPress(op func(key KeyboardKey, state InputAction, mods KeyboardMod))
}

type KeyboardKey

type KeyboardKey uint8
const (
	KeyUnknown KeyboardKey = iota
	KeySpace
	KeyEscape
	KeyEnter
	KeyTab
	KeyBackspace
	KeyInsert
	KeyDelete
	KeyRight
	KeyLeft
	KeyDown
	KeyUp
	KeyPageUp
	KeyPageDown
	KeyHome
	KeyEnd
	KeyCapsLock
	KeyScrollLock
	KeyNumLock
	KeyPrintScreen
	KeyPause
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyLeftShift
	KeyLeftControl
	KeyLeftAlt
	KeyLeftSuper
	KeyRightShift
	KeyRightControl
	KeyRightAlt
	KeyRightSuper
	KeyKbMenu
	KeyLeftBracket
	KeyBackSlash
	KeyRightBracket
	KeyGrave
	KeyKp0
	KeyKp1
	KeyKp2
	KeyKp3
	KeyKp4
	KeyKp5
	KeyKp6
	KeyKp7
	KeyKp8
	KeyKp9
	KeyKpDecimal
	KeyKpDivide
	KeyKpMultiply
	KeyKpSubtract
	KeyKpAdd
	KeyKpEnter
	KeyKpEqual
	KeyApostrophe
	KeyComma
	KeyMinus
	KeyPeriod
	KeySlash
	KeyZero
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
	KeySemicolon
	KeyEqual
	KeyA
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyG
	KeyH
	KeyI
	KeyJ
	KeyK
	KeyL
	KeyM
	KeyN
	KeyO
	KeyP
	KeyQ
	KeyR
	KeyS
	KeyT
	KeyU
	KeyV
	KeyW
	KeyX
	KeyY
	KeyZ
)

type KeyboardMod

type KeyboardMod uint8
const (
	ModShift KeyboardMod = 1 << iota
	ModControl
	ModAlt
	ModSuper
	ModCapsLock
	ModNumLock
)

type KeyboardProvider

type KeyboardProvider struct {
	KeyboardInterface
}

type Line2D

type Line2D = vecs.F32Line2

type Line3D

type Line3D = vecs.F32Line3

type MouseButton

type MouseButton uint8
const (
	Mouse1 MouseButton = iota
	Mouse2
	Mouse3
	Mouse4
	Mouse5
	Mouse6
	Mouse7
	Mouse8
	Mouse9
	Mouse10
	Mouse11
	Mouse12
	Mouse13
	Mouse14
	Mouse15
	Mouse16
	Mouse17
	Mouse18
	Mouse19
	Mouse20
	MouseWheelUp
	MouseWheelDown
)

type MouseInterface

type MouseInterface interface {
	GetMouseButtonState(button MouseButton) InputState
	GetMousePosition() Vec2
	SetCallbackOnMouseWheelScroll(op func(offset Vec2))
	SetCallbackOnMouseMove(op func(pos Vec2))
	SetCallbackOnMouseButton(op func(button MouseButton, state InputAction))
}

type MouseProvider

type MouseProvider struct {
	MouseInterface
}

type Quad2D

type Quad2D = vecs.F32Quad2

type Quad3D

type Quad3D = vecs.F32Quad3

type Rect2D

type Rect2D = vecs.F32AABB2

type Rect3D

type Rect3D = vecs.F32AABB3

type RendererID added in v0.4.2

type RendererID uint8

type Shader

type Shader struct {
	SType ShaderType
	Code  string
	Data  []byte
	File  string
}

type ShaderType

type ShaderType uint8
const (
	ShaderVertex ShaderType = iota
	ShaderTessControl
	ShaderTessEval
	ShaderGeometry
	ShaderFragment
	ShaderCompute
)

type ShapePrototype added in v0.4.2

type ShapePrototype struct {
	VertCount  uint32
	IndexCount uint32
	Indexes    []uint32
}

type SurfaceID added in v0.4.2

type SurfaceID uint8

type Texture

type Texture struct {
	Data    []byte
	File    string
	ImgType ImageType
	Size    IVec2
	MipMaps uint32
	ID      uint32
	TexUnit uint32
}

type TextureID added in v0.4.2

type TextureID uint8

type TouchInterface

type TouchInterface interface {
}

type TouchProvider

type TouchProvider struct {
	TouchInterface
}

type Vec2

type Vec2 = vecs.F32Vec2

type Vec3

type Vec3 = vecs.F32Vec3

type VertExtra added in v0.2.14

type VertExtra = [8]uint32

type Vertex added in v0.2.14

type Vertex struct {
	Pos   Vec3
	Norm  Vec3
	UV    Vec2
	Color ColorFA
	Extra VertExtra
}

type VertexFlags added in v0.2.14

type VertexFlags uint16

Describes the types of vertex attributes present on a draw batch or renderer.

Zero value defaults to: 2D Positions + 16 bit indexes + Traingle draw mode + No texture + No Color + No Extra data blocks + No Camera

Vertex attribute layout should follow this order: Position -> Normals -> UVs -> Color -> Extra

const (
	Pos2D   VertexFlags = 0  // 2D Vertex space
	Pos3D   VertexFlags = 1  // 3D Vertex space
	PosMask VertexFlags = 1  // Mask for checking vertex space
	Idx16   VertexFlags = 0  // Indexes are uint16
	Idx32   VertexFlags = 2  // Indexes ar uint32
	IdxMask VertexFlags = 2  // Mask for checking index size
	NoTex   VertexFlags = 0  // No texture (no UV coordinates)
	HasTex  VertexFlags = 4  // Uses Texture with UV coordinates
	TexMask VertexFlags = 4  // Mask for checking texture use
	NoCol   VertexFlags = 0  // No color channel (uniform color)
	Col8    VertexFlags = 8  // 2bit RGBA channels
	Col16   VertexFlags = 16 // 4bit RGBA channels
	Col24   VertexFlags = 24 // 8bit RGB channels
	Col32   VertexFlags = 32 // 8bit RGBA channels
	Col48   VertexFlags = 40 // 16bit RGB channels
	Col64   VertexFlags = 48 // 16bit RGBA channels
	ColF    VertexFlags = 56 // float32 RGB channels
	ColFA   VertexFlags = 64 // float32 RGBA channels

	ColMask VertexFlags = 120  // Mask for checking color mode
	NoEx    VertexFlags = 0    // No aditional 32bit data blocks
	Ex32    VertexFlags = 128  // 1 additional 32bit data block
	Ex64    VertexFlags = 256  // 2 additional 32bit data blocks
	Ex96    VertexFlags = 384  // 3 additional 32bit data blocks
	Ex128   VertexFlags = 512  // 4 additional 32bit data blocks
	Ex192   VertexFlags = 640  // 6 additional 32bit data blocks
	Ex224   VertexFlags = 768  // 7 additional 32bit data blocks
	Ex256   VertexFlags = 896  // 8 additional 32bit data blocks
	ExMask  VertexFlags = 896  // Mask for checking number of extra data blocks
	Tris    VertexFlags = 0    // Every 3 Vertices are an independant triangle
	Lines   VertexFlags = 1024 // Every 2 vertices are an independant line
	Pixels  VertexFlags = 2048 // Every vertex is an independant point

	DrawMask VertexFlags = 3072 // Mask for checking draw mode
	NoCam    VertexFlags = 0    // No Camera Projection (Draws as if draw surface IS the camera, no transform)
	Cam2D    VertexFlags = 4096 // 2D Camera projection
	Cam3D    VertexFlags = 8192 // 3D Camera projection

	CamMask   VertexFlags = 12288 // Mask for checking camera mode
	NoNorms   VertexFlags = 0     // No vertex Normals
	Norms     VertexFlags = 16384 // Includes Vertex normals
	NormsMask VertexFlags = 16384 // Mask for checking if uses vertex normals

	VertexAttributeMask  VertexFlags = PosMask | ColMask | IdxMask | TexMask | ExMask | NormsMask // Mask describing layout of vertex attributes and indexes
	UniformAttributeMask VertexFlags = CamMask | DrawMask                                         // Mask decribing rendering uniforms and draw mode
)

func (VertexFlags) ColorOffset added in v0.2.14

func (vf VertexFlags) ColorOffset() uint32

func (VertexFlags) ColorSize added in v0.2.14

func (vf VertexFlags) ColorSize() uint32

func (VertexFlags) ExOffset added in v0.2.14

func (vf VertexFlags) ExOffset() uint32

func (VertexFlags) ExSize added in v0.2.14

func (vf VertexFlags) ExSize() uint32

func (VertexFlags) NormalOffset added in v0.2.14

func (vf VertexFlags) NormalOffset() uint32

func (VertexFlags) NormalSize added in v0.2.14

func (vf VertexFlags) NormalSize() uint32

func (VertexFlags) PositionOffset added in v0.2.14

func (vf VertexFlags) PositionOffset() uint32

func (VertexFlags) PositionSize added in v0.2.14

func (vf VertexFlags) PositionSize() uint32

func (VertexFlags) SameAttributes added in v0.2.14

func (vf VertexFlags) SameAttributes(other VertexFlags) bool

func (VertexFlags) SameUniforms added in v0.2.14

func (vf VertexFlags) SameUniforms(other VertexFlags) bool

func (VertexFlags) Stride added in v0.2.14

func (vf VertexFlags) Stride() uint32

func (VertexFlags) UVOffset added in v0.2.14

func (vf VertexFlags) UVOffset() uint32

func (VertexFlags) UVSize added in v0.2.14

func (vf VertexFlags) UVSize() uint32

type WindowInterface added in v0.4.0

type WindowInterface interface {
	CreateWindow() (windowID uint8, err error)
	DestroyWindow(windowID uint8) (err error)
	RequestClose(windowID uint8) (err error)
	GetSize(windowID uint8) (size IVec2, err error)
	SetSize(windowID uint8, size IVec2) error
	GetPos(windowID uint8, size IVec2) error
	SetPos(windowID uint8, size IVec2) error
	SetOpacity(windowID uint8, opacity float32) error
	SetTitle(windowID uint8, title string) error
	SetIcon(windowID uint8, icon image.RGBA) error
	SetFocusCallback(windowID uint8, op func(focused bool)) error
	SetCloseCallback(windowID uint8, op func()) error
	SetMinimizeCallback(windowID uint8, op func(minimized bool)) error
	SetMaximizeCallback(windowID uint8, op func(maximized bool)) error
	SetPosCallback(windowID uint8, op func(pos IVec2)) error
	SetSizeCallback(windowID uint8, op func(size IVec2)) error
}

type WindowProvider added in v0.4.0

type WindowProvider struct {
	WindowInterface
}

Jump to

Keyboard shortcuts

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