gorge

package module
v0.0.0-...-6aa7f09 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 9 Imported by: 13

README

Gorge - WIP

gorge - go r? game engine

(reduced? rudimentary?)

A personal project that I am developing for learning purposes

Demos

Platforms

It was first created with wasm in mind, others were added later

  • wasm
  • glfw (linux, windows?, osx?)
  • mobile (golang.org/x/mobile - WIP)

Example

Packages

  • gorge - contains mostly core components as data (light, camera, renderable, material, texture, font, transform,...)
  • systems/resource - knows how to load gorge data (textures, mesh, material, fonts, ... ) and might eventually have custom importers
  • systems/render - knows how to render gorge components
  • systems/audio -
  • systems/input -

Copyrights

Documentation

Overview

Package gorge contains mostly data only components

Index

Constants

View Source
const (
	ProjectionPerspective = ProjectionType(iota)
	ProjectionOrtho
)

Projection types for camera.

View Source
const (
	ClearColor = ClearType(iota)
	ClearDepthOnly
	ClearNothing
	ClearSkybox
)

Clear types

View Source
const (
	LightPoint = LightType(iota)
	LightDirectional
	LightSpot
)

Light types

View Source
const (
	DepthReadWrite = DepthMode(iota)
	DepthRead
	DepthNone
)

Default deph modes

View Source
const (
	BlendZero = BlendEnum(iota)
	BlendOne
	BlendSrcColor
	BlendOneMinusSrcColor
	BlendDstColor
	BlendOneMinusDstColor
	BlendSrcAlpha
	BlendOneMinusSrcAlpha
	BlendDstAlpha
	BlendOneMinusDstAlpha
	BlendConstantColor
	BlendOneMinusConstantColor
	BlendConstantAlpha
	BlendOneMinusConstantAlpha
)
View Source
const (
	BlendEqAdd = BlendEq(iota)
	BlendEqSub
	BlendEqRevSub
	BlendEqMin
	BlendEqMax
)
View Source
const (
	StencilFuncNever = StencilFunc(iota)
	StencilFuncLess
	StencilFuncLequal
	StencilFuncGreater
	StencilFuncGequal
	StencilFuncEqual
	StencilFuncNotequal
	StencilFuncAlways
)
View Source
const (
	StencilOpKeep = StencilOp(iota)
	StencilOpZero
	StencilOpReplace
	StencilOpIncr
	StencilOpDecr
	StencilOpInvert
	StencilOpIncrWrap
	StencilOpDecrWrap
)
View Source
const (
	DrawTriangles = DrawMode(iota)
	DrawTriangleStrip
	DrawTriangleFan
	DrawPoints
	DrawLines
	DrawLineLoop
	DrawLineStrip
)

Mesh draw type

View Source
const (
	FrontFacingCW  = FrontFacing(0)
	FrontFacingCCW = FrontFacing(1)
)

FrontFacing indicates the frontfacing property for the meshData vertices

View Source
const (
	CullMaskDefault = CullMaskFlags(0xFF)
	CullMaskUI      = CullMaskFlags(1 << 8)
	CullMaskUIDebug = CullMaskFlags(1 << 9)
)

CullMask defaults

View Source
const (
	TextureFormatRGBA = TextureFormat(iota)
	TextureFormatRGB
	TextureFormatGray
	TextureFormatGray16
	TextureFormatRGB32F
)

Known texture formats

View Source
const (
	TextureWrapRepeat = TextureWrap(iota)
	TextureWrapClamp
	TextureWrapMirror
)

Wrapmode consts

View Source
const (
	TextureFilterLinear = TextureFilter(iota)
	TextureFilterPoint
)

TextureFilter types

Variables

View Source
var (
	// BlendOneOneMinusSrcAlpha - gl.ONE, gl.ONE_MINUS_SRC_ALPHA
	BlendOneOneMinusSrcAlpha = &Blend{
		Src: BlendOne,
		Dst: BlendOneMinusSrcAlpha,
		Eq:  BlendEqAdd,
	}
	// BlendOneOne - gl.ONE, gl.ONE
	BlendOneOne = &Blend{
		Src: BlendOne,
		Dst: BlendOne,
		Eq:  BlendEqAdd,
	}
	// BlendDisable - disable blending
	BlendDisable = &Blend{Disabled: true}
)
View Source
var (
	TransformBuilds    = 0
	TransformBuildSave = 0
)

TransformBuilds tracks the numbers of transforms for performance purposes

View Source
var ErrAlreadyStarted = errors.New("already started")

ErrAlreadyStarted is returned when Start is called more than once

Functions

func EachEntity

func EachEntity(e Entity, fn func(e Entity))

EachEntity solves entities containers and walk on every entity.

func EachParent

func EachParent(e Entity, fn func(e Entity) bool)

EachParent iterates parents

func GetContext

func GetContext[T comparable](g *Context) (T, bool)

GetContext gets a system from a gorge context.

func GetGPU

func GetGPU(r any) any

GetGPU returns gpu data from the resourceRef

func HasParent

func HasParent(e Entity, parent Entity) bool

HasParent verifies if the parent exists in e hierarchy

func SetContext

func SetContext[T comparable](g *Context, c T) T

SetContext to gorge context.

func SetGPU

func SetGPU(r, v any)

SetGPU sets gpu data in the resourceRef

func StringHash

func StringHash(str ...string) uint

StringHash builds an hash from a string

func TriggerInMain

func TriggerInMain[T any](g gorger, e T)

Types

type AudioClip

type AudioClip struct {
	Resourcer AudioResourcer
}

AudioClip is the resource controller for audio (similar to material, texture, mesh).

func NewAudioClip

func NewAudioClip(ref AudioResourcer) *AudioClip

NewAudioClip creates a New audio clip based on resource.

func (*AudioClip) Resource

func (a *AudioClip) Resource() AudioResource

Resource returns the current resource from resourcer.

type AudioClipData

type AudioClipData struct {
	Format  AudioFormat
	Data    []byte
	Updates int
}

AudioClipData base audio data.

func (*AudioClipData) Resource

func (d *AudioClipData) Resource() AudioResource

Resource implements the AudioResourcer interface.

type AudioFormat

type AudioFormat int

AudioFormat audio format for clipData.

type AudioListener

type AudioListener struct{}

AudioListener is where the audio will be listened usually set on cameras

func (*AudioListener) AudioListenerComponent

func (a *AudioListener) AudioListenerComponent() *AudioListener

AudioListenerComponent implements the component

type AudioResource

type AudioResource interface {
	// contains filtered or unexported methods
}

AudioResource audio resource.

type AudioResourcer

type AudioResourcer interface {
	Resource() AudioResource
}

AudioResourcer interface to return an audio resource.

type AudioSource

type AudioSource struct {
	Playing bool
	Loop    bool
	Clip    *AudioClip
	Updates int
}

AudioSource component.

func (*AudioSource) AudioSourceComponent

func (a *AudioSource) AudioSourceComponent() *AudioSource

AudioSourceComponent implements the component

func (*AudioSource) Play

func (a *AudioSource) Play(c *AudioClip)

Play sets the play state to playing

type Blend

type Blend struct {
	Disabled bool
	Src      BlendEnum
	Dst      BlendEnum
	Eq       BlendEq
}

func (Blend) String

func (b Blend) String() string

type BlendEnum

type BlendEnum int

func (BlendEnum) String

func (b BlendEnum) String() string

type BlendEq

type BlendEq int

func (BlendEq) String

func (e BlendEq) String() string

type CameraComponent

type CameraComponent struct {
	Name           string
	ProjectionType ProjectionType
	CullMask       CullMaskFlags

	Fov       float32
	OrthoSize float32

	AspectRatio float32
	Near        float32
	Far         float32

	ClearFlag     ClearType
	ClearMaterial *Material
	Order         int
	Viewport      gm.Vec4
	ClearColor    gm.Vec3
}

CameraComponent thing

func NewCameraComponent

func NewCameraComponent(name string) *CameraComponent

NewCameraComponent returns a new default camera Component

func (*CameraComponent) CalcViewport

func (c *CameraComponent) CalcViewport(screenSize gm.Vec2) gm.Vec4

CalcViewport gives the viewport in screen dimensions TODO: consider `ScreenViewport` name

func (*CameraComponent) Camera

func (c *CameraComponent) Camera() *CameraComponent

Camera returns camera component We actually only need Projection :/

func (CameraComponent) Projection

func (c CameraComponent) Projection(screenSize gm.Vec2) gm.Mat4

Projection returns the projection matrix with default aspect ratio based on registered size

func (CameraComponent) ProjectionWithAspect

func (c CameraComponent) ProjectionWithAspect(aspect float32) gm.Mat4

ProjectionWithAspect Sets the projection matrices with given aspect ratio

func (*CameraComponent) SetAspectRatio

func (c *CameraComponent) SetAspectRatio(a float32)

SetAspectRatio sets the camera aspect ratio

func (*CameraComponent) SetClearColor

func (c *CameraComponent) SetClearColor(r, g, b float32)

SetClearColor for the camera.

func (*CameraComponent) SetClearFlag

func (c *CameraComponent) SetClearFlag(clr ClearType)

SetClearFlag sets the clear flag and returns

func (*CameraComponent) SetCullMask

func (c *CameraComponent) SetCullMask(m CullMaskFlags)

SetCullMask for camera, only specific renderables that masks this cullmask will render with this camera.

func (*CameraComponent) SetOrder

func (c *CameraComponent) SetOrder(n int)

SetOrder camera rendering order, higher will render later.

func (*CameraComponent) SetOrtho

func (c *CameraComponent) SetOrtho(size, near, far float32)

SetOrtho sets ortho matrix

func (*CameraComponent) SetPerspective

func (c *CameraComponent) SetPerspective(fov, near, far float32)

SetPerspective resets projection matrix to perspective

func (*CameraComponent) SetViewport

func (c *CameraComponent) SetViewport(x, y, w, h float32)

SetViewport sets the viewport for camera, viewport is relative to screensize.

type ClearType

type ClearType int

ClearType method on how the camera clears.

func (ClearType) String

func (t ClearType) String() string

type ColorTexture

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

ColorTexture helper for a single color texture.

func NewColorTexture

func NewColorTexture(r, g, b, a float32) *ColorTexture

NewColorTexture returns a single pixel colored texture

func (*ColorTexture) SetColor

func (t *ColorTexture) SetColor(r, g, b, a float32)

SetColor sets color data for underlying texture.

type ColorableComponent

type ColorableComponent struct {
	Color gm.Vec4
}

ColorableComponent sets A Main color for geometry

func NewColorableComponent

func NewColorableComponent(r, g, b, a float32) *ColorableComponent

NewColorableComponent returns a new colorable

func (*ColorableComponent) Colorable

func (c *ColorableComponent) Colorable() *ColorableComponent

Colorable returns the colorable component

func (*ColorableComponent) GetColor

func (c *ColorableComponent) GetColor() gm.Vec4

GetColor returns the Color

func (*ColorableComponent) SetColor

func (c *ColorableComponent) SetColor(r, g, b, a float32)

SetColor sets the Color.

func (*ColorableComponent) SetColorv

func (c *ColorableComponent) SetColorv(v gm.Vec4)

SetColorv sets the Color from a vec4.

type Container

type Container []Entity

Container provides a way to multiplex entities by implementing EntityContainer interface.

func (*Container) Add

func (c *Container) Add(ents ...Entity)

Add one ore more entities to Container it will loop existing elements to compare and avoid duplicates.

func (Container) GetEntities

func (c Container) GetEntities() []Entity

GetEntities implements the entitycontainer

func (*Container) Remove

func (c *Container) Remove(ents ...Entity)

Remove entities from container it does not remove from the world.

func (Container) String

func (c Container) String() string

type Context

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

Context holds a gorge system and is mostly used as a Prop.

func (*Context) G

func (c *Context) G() *Context

Gorge context interface helper.

type Contexter

type Contexter interface {
	Add(...Entity)
	G() *Context
}

Contexter interface to return a context containing Gorge instance.

type CullMaskFlags

type CullMaskFlags uint32

CullMaskFlags flag type for culling masks.

type CursorType

type CursorType int
const (
	CursorArrow CursorType = iota
	CursorHand
)

type DepthMode

type DepthMode uint32

DepthMode handle depth R&W types on render

type DrawMode

type DrawMode int

DrawMode type of draw for the renderer

func (DrawMode) String

func (m DrawMode) String() string

type Entity

type Entity any

Entity can be anything but shouldn't be a func

type EntityContainer

type EntityContainer interface {
	GetEntities() []Entity
}

EntityContainer is an interface used while adding entity to solve EventAddEntity one container with 2 entities will trigger 2 EventAddEntity.

type EventAddEntity

type EventAddEntity struct {
	Entity
}

EventAddEntity is triggered when entities are added

type EventAfterStart

type EventAfterStart struct{}

EventAfterStart to attach stuff (wasm request animation frame workaround)

type EventCursor

type EventCursor CursorType

Core events are events handled by gorgeapp that will be handled by the platform.

type EventCursorHidden

type EventCursorHidden bool

EventCursorHidden turns true/false hidden cursor uppon triggering event.

type EventCursorRelative

type EventCursorRelative bool

EventCursorRelative turns true/false relative cursor mode uppin triggering event.

type EventDestroy

type EventDestroy struct{}

EventDestroy is called when system is shutting down

type EventError

type EventError struct{ Err error }

EventError contains an error

type EventPostUpdate

type EventPostUpdate float32

EventPostUpdate type

func (EventPostUpdate) DeltaTime

func (e EventPostUpdate) DeltaTime() float32

DeltaTime returns the float32 delta time for the event.

type EventPreUpdate

type EventPreUpdate float32

EventPreUpdate type

func (EventPreUpdate) DeltaTime

func (e EventPreUpdate) DeltaTime() float32

DeltaTime returns the float32 delta time for the event.

type EventRemoveEntity

type EventRemoveEntity struct {
	Entity
}

EventRemoveEntity is triggered when entities are destroyed

type EventRender

type EventRender float32

EventRender happens after pre,update and post update events

type EventResourceUpdate

type EventResourceUpdate struct {
	Resource any
}

EventResourceUpdate sends a resource through systems for aditional treatment i.e: uploading to gpu

type EventStart

type EventStart struct{}

EventStart fired when things starts

type EventUpdate

type EventUpdate float32

EventUpdate type

func (EventUpdate) DeltaTime

func (e EventUpdate) DeltaTime() float32

DeltaTime returns the float32 delta time for the event.

type EventWarn

type EventWarn string

EventWarn contains a warning

type FrontFacing

type FrontFacing int

FrontFacing type to setup rendering cull.

func (FrontFacing) String

func (f FrontFacing) String() string

type GPU

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

GPU reference for resources binded in renderer (texture,mesh)

type Gorge

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

Gorge main state manager and message bus

func New

func New(inits ...InitFunc) *Gorge

New create a new manager with default systems

func (*Gorge) Add

func (g *Gorge) Add(ents ...Entity)

Add adds an entity nolint: errcheck

func (*Gorge) Close

func (g *Gorge) Close()

Close closes the running instance.

func (*Gorge) CloseWithError

func (g *Gorge) CloseWithError(err error)

CloseWithError closes with an error which will be sent on Wait() call

func (*Gorge) Error

func (g *Gorge) Error(err error)

Error persists an error in the event system nolint: errcheck

func (*Gorge) HandleError

func (g *Gorge) HandleError(fn func(err error))

HandleError registers a function that filters events and calls fn if event is the EventError.

func (*Gorge) HandleUpdate

func (g *Gorge) HandleUpdate(fn func(float32))

HandleUpdate adds a listener that filters events and calls fn if it is the EventUpdate.

func (*Gorge) Remove

func (g *Gorge) Remove(ents ...Entity)

Remove an entity nolint: errcheck

func (*Gorge) Run

func (g *Gorge) Run() error

Run will initialize gorge, Start and wait.

func (*Gorge) RunInMain

func (g *Gorge) RunInMain(fn func())

RunInMain schedule a func to be run on main loop It will wait for the function to return

func (*Gorge) ScreenSize

func (g *Gorge) ScreenSize() gm.Vec2

ScreenSize returns the previously set screensize

func (*Gorge) SetScreenSize

func (g *Gorge) SetScreenSize(s gm.Vec2)

SetScreenSize used by the gorgeapp to set the current screensize Might be changed in the future if we use multiple Display devices.

func (*Gorge) Start

func (g *Gorge) Start() error

Start the systems nolint: errcheck

func (*Gorge) Update

func (g *Gorge) Update(dt float32)

Update just updates stuff right away nolint: errcheck

func (*Gorge) Wait

func (g *Gorge) Wait() error

Wait waits for execution to finish.

type InitFunc

type InitFunc func(*Context)

InitFunc type of function to initialize gorge.

type LightComponent

type LightComponent struct {
	Type      LightType // default point
	Intensity float32
	Color     gm.Vec3
	Range     float32

	InnerConeCos float32
	OuterConeCos float32

	DisableShadow bool
}

LightComponent component type of light and what nots type of light as in position and direction determined by transform Z direction

func NewLightComponent

func NewLightComponent() *LightComponent

NewLightComponent returns a New light component with some defaults (pointsLight)

func (*LightComponent) Light

func (l *LightComponent) Light() *LightComponent

Light method to satisfy component

func (*LightComponent) SetColor

func (l *LightComponent) SetColor(r, g, b float32)

SetColor sets light Color

func (*LightComponent) SetDisableShadow

func (l *LightComponent) SetDisableShadow(b bool)

SetCastShadows convinient accessor that sets the CastShadows field and returns self.

func (*LightComponent) SetInnerConeCos

func (l *LightComponent) SetInnerConeCos(v float32)

SetInnerConeCos sets the InnerConeCos for spot lights.

func (*LightComponent) SetIntensity

func (l *LightComponent) SetIntensity(v float32)

SetIntensity gets light intensity

func (*LightComponent) SetOuterConeCos

func (l *LightComponent) SetOuterConeCos(v float32)

SetOuterConeCos sets the OuterConeCos for spot lights.

func (*LightComponent) SetRange

func (l *LightComponent) SetRange(v float32)

SetRange sets Point or Spot light range

func (*LightComponent) SetType

func (l *LightComponent) SetType(t LightType)

SetType sets the light type Directional, Spot, Point.

type LightType

type LightType int

LightType type for lights

func (LightType) String

func (l LightType) String() string

type Material

type Material struct {
	Resourcer ShaderResourcer
	Name      string
	// Primitive stuff
	Queue       int
	Depth       DepthMode
	DoubleSided bool

	Blend *Blend

	DisableShadow bool

	/* New: stencil experiment */
	// Create stencil groups?!
	Stencil *Stencil

	// Extra stuff for enable and disable fragment rendering mask.
	ColorMask *[4]bool
	// contains filtered or unexported fields
}

Material the material

func NewMaterial

func NewMaterial() *Material

NewMaterial returns a material using the default gorge shader

func NewShaderMaterial

func NewShaderMaterial(r ShaderResourcer) *Material

NewShaderMaterial returns a new material based on shader data if ShaderData is nil it will use the default PBR material

func (*Material) Define

func (s *Material) Define(defs ...string)

Define add defines

func (*Material) Defines

func (m *Material) Defines() map[string]string

Defines override shaderProp defines with hierarchy

func (*Material) DefinesHash

func (m *Material) DefinesHash() uint

DefinesHash returns an hash based on the material defines.

func (*Material) Get

func (m *Material) Get(name string) any

Get returns the material property for name or if the material has a Parent material returns the property from parent else returns nil.

func (*Material) GetTexture

func (m *Material) GetTexture(name string) *Texture

GetTexture returns the texture for name

func (*Material) Material

func (m *Material) Material() *Material

Material implements the materialer interface.

func (*Material) Props

func (s *Material) Props() map[string]any

Props returns the properties of this material

func (*Material) ResetProps

func (s *Material) ResetProps()

ResetProps will reset uniforms and texture properties from material

func (*Material) Resource

func (m *Material) Resource() ShaderResource

Resource returns the current shader resource.

func (*Material) Set

func (s *Material) Set(name string, v any)

Set properties by name

func (*Material) SetBlend

func (m *Material) SetBlend(v *Blend)

SetBlend sets the blend type for material.

func (*Material) SetColorMask

func (m *Material) SetColorMask(r, g, b, a bool)

func (*Material) SetDepth

func (m *Material) SetDepth(v DepthMode)

SetDepth sets if material uses depth buffer.

func (*Material) SetDisableShadow

func (m *Material) SetDisableShadow(v bool)

func (*Material) SetDoubleSided

func (m *Material) SetDoubleSided(v bool)

SetDoubleSided sets material double sided prop.

func (*Material) SetFloat32

func (s *Material) SetFloat32(name string, v float32)

SetFloat32 XXX testing sets a float32

func (*Material) SetQueue

func (m *Material) SetQueue(v int)

SetQueue sets the material target queue transparent materials should be in a higher queue

func (*Material) SetStencil

func (m *Material) SetStencil(s *Stencil)

SetStencil sets the stencil property for material.

func (*Material) SetTexture

func (s *Material) SetTexture(name string, t Texturer)

func (*Material) SetVec3

func (s *Material) SetVec3(name string, v1, v2, v3 float32)

func (*Material) SetVec4

func (s *Material) SetVec4(name string, v1, v2, v3, v4 float32)

func (Material) String

func (m Material) String() string

func (*Material) Undefine

func (s *Material) Undefine(defs ...string)

Undefine removes definitions

func (*Material) Update

func (s *Material) Update()

func (*Material) Updates

func (s *Material) Updates() int

type Materialer

type Materialer interface{ Material() *Material }

Materialer interface for material controllers.

type Matrixer

type Matrixer interface {
	Mat4() gm.Mat4
}

Matrixer interface to mat4

type Mesh

type Mesh struct {
	Resourcer MeshResourcer
	DrawMode  DrawMode
	// contains filtered or unexported fields
}

Mesh representation

func NewMesh

func NewMesh(res MeshResourcer) *Mesh

NewMesh creates a new mesh with meshData

func (*Mesh) Clone

func (m *Mesh) Clone() *Mesh

Clone will clone the mesh and it's props.

func (*Mesh) Define

func (s *Mesh) Define(defs ...string)

Define add defines

func (*Mesh) Defines

func (s *Mesh) Defines() map[string]string

Defines declare some shader defines

func (Mesh) DefinesHash

func (s Mesh) DefinesHash() uint

func (*Mesh) Get

func (s *Mesh) Get(name string) any

Get return named property

func (*Mesh) GetDrawMode

func (m *Mesh) GetDrawMode() DrawMode

GetDrawMode returns the mesh drawmode.

func (*Mesh) GetTexture

func (s *Mesh) GetTexture(name string) *Texture

func (*Mesh) Mesh

func (m *Mesh) Mesh() *Mesh

Mesh implements mesher interface.

func (*Mesh) Props

func (s *Mesh) Props() map[string]any

Props returns the properties of this material

func (*Mesh) ReleaseData

func (m *Mesh) ReleaseData(g *Context)

ReleaseData change the data ref to a gpu only resource.

func (*Mesh) ResetProps

func (s *Mesh) ResetProps()

ResetProps will reset uniforms and texture properties from material

func (*Mesh) Resource

func (m *Mesh) Resource() MeshResource

Resource implements MeshResourcer.

func (*Mesh) Set

func (s *Mesh) Set(name string, v any)

Set properties by name

func (*Mesh) SetFloat32

func (s *Mesh) SetFloat32(name string, v float32)

SetFloat32 XXX testing sets a float32

func (*Mesh) SetTexture

func (s *Mesh) SetTexture(name string, t Texturer)

func (*Mesh) SetVec3

func (s *Mesh) SetVec3(name string, v1, v2, v3 float32)

func (*Mesh) SetVec4

func (s *Mesh) SetVec4(name string, v1, v2, v3, v4 float32)

func (Mesh) String

func (m Mesh) String() string

func (*Mesh) Undefine

func (s *Mesh) Undefine(defs ...string)

Undefine removes definitions

func (*Mesh) Update

func (s *Mesh) Update()

func (*Mesh) Updates

func (s *Mesh) Updates() int

type MeshData

type MeshData struct {
	GPU

	Source string

	FrontFacing FrontFacing
	// Describe format and indexes
	Format VertexFormat

	// TODO: This might need to be pure data instead of float32
	// Indices could be a byte we just need to tell gl to read as a byte
	// so we would have a field Indices "type"
	Vertices []float32
	// Indices can be one of []byte, []uint16, []uint32
	Indices any
	Updates int
}

MeshData raw mesh data

func (*MeshData) CalcBounds

func (d *MeshData) CalcBounds() (gm.Vec3, gm.Vec3)

CalcBounds calculate the bounding box for this mesh (slow)

func (*MeshData) Resource

func (d *MeshData) Resource() MeshResource

Resource implements the resourcer interface so MeshData can be used directly in the Mesh.

func (*MeshData) ScaleUV

func (d *MeshData) ScaleUV(s ...float32)

ScaleUV manipulate meshData directly

func (*MeshData) String

func (d *MeshData) String() string

type MeshRef

type MeshRef struct{ *GPU }

MeshRef implements a gpu only mesh resource

func (*MeshRef) Resource

func (r *MeshRef) Resource() MeshResource

type MeshResource

type MeshResource interface {
	// contains filtered or unexported methods
}

MeshResource is an interface to handle underlying mesh data.

type MeshResourcer

type MeshResourcer interface {
	Resource() MeshResource
}

MeshResourcer is an interface for mesh resource providers.

type Mesher

type Mesher interface{ Mesh() *Mesh }

Mesher interface for Mesh controller.

type ParentGetter

type ParentGetter interface{ Parent() Matrixer }

ParentGetter interface for a parent getter.

type ParentSetter

type ParentSetter interface{ SetParent(Matrixer) }

ParentSetter interface that Sets a parent.

type ProjectionType

type ProjectionType int

ProjectionType camera projection type.

func (ProjectionType) String

func (t ProjectionType) String() string

type RenderableComponent

type RenderableComponent struct {
	GPU
	Name string
	*Material
	*Mesh

	// Maybe move to material?!
	// Layering and Culling are usually per GameObject in unity.
	Order    int
	CullMask CullMaskFlags
}

RenderableComponent contains info for renderer material and mesh

func NewRenderableComponent

func NewRenderableComponent(mesh Mesher, mat Materialer) *RenderableComponent

NewRenderableComponent returns a new renderable component

func (*RenderableComponent) Renderable

func (r *RenderableComponent) Renderable() *RenderableComponent

Renderable returns the renderable component

func (*RenderableComponent) SetCullMask

func (r *RenderableComponent) SetCullMask(m CullMaskFlags)

SetCullMask will set the cull mask which is used in conjunction with camera mask to filter which renderables will render in each camera.

func (*RenderableComponent) SetMaterial

func (r *RenderableComponent) SetMaterial(m Materialer)

SetMaterial sets the material.

func (*RenderableComponent) SetMesh

func (r *RenderableComponent) SetMesh(m Mesher)

SetMesh sets the mesh.

func (*RenderableComponent) SetOrder

func (r *RenderableComponent) SetOrder(o int)

SetOrder sets the render order lower will render first.

type ShaderData

type ShaderData struct {
	GPU
	Name string
	Src  []byte
}

ShaderData contains shaders sources

func (*ShaderData) Resource

func (d *ShaderData) Resource() ShaderResource

Resource implements a resourcer.

func (*ShaderData) String

func (d *ShaderData) String() string

type ShaderResource

type ShaderResource interface {
	// contains filtered or unexported methods
}

ShaderResource is a shader resource interface.

type ShaderResourcer

type ShaderResourcer interface {
	Resource() ShaderResource
}

ShaderResourcer is the interface to return a shader resource.

type Stencil

type Stencil struct {
	// Func
	Ref      int
	Func     StencilFunc
	ReadMask uint32
	// Mask
	WriteMask uint32
	// Op
	Fail  StencilOp
	ZFail StencilOp
	ZPass StencilOp
}

func (*Stencil) String

func (s *Stencil) String() string

type StencilFunc

type StencilFunc int

func (StencilFunc) String

func (f StencilFunc) String() string

type StencilOp

type StencilOp int

func (StencilOp) String

func (o StencilOp) String() string

type Texture

type Texture struct {
	Resourcer  TextureResourcer
	Name       string // just for reference and debugging
	Wrap       [3]TextureWrap
	FilterMode TextureFilter
}

Texture reference

func NewTexture

func NewTexture(r TextureResourcer) *Texture

NewTexture returns a new texture based on resourcer.

func (*Texture) GetFilterMode

func (t *Texture) GetFilterMode() TextureFilter

GetFilterMode texture filter mode

func (*Texture) GetWrap

func (t *Texture) GetWrap() (u, v, w TextureWrap)

GetWrap get the components of TextureWrap UVW

func (*Texture) ReleaseData

func (t *Texture) ReleaseData(g *Context)

ReleaseData change underlying resourcer with a gpu only reference.

func (*Texture) Resource

func (t *Texture) Resource() TextureResource

func (*Texture) SetFilterMode

func (t *Texture) SetFilterMode(f TextureFilter)

SetFilterMode sets the filter mode POINT,LINEAR

func (*Texture) SetWrapUVW

func (t *Texture) SetWrapUVW(uvw ...TextureWrap)

SetWrapUVW texture wrap for U, V, W

func (*Texture) Texture

func (t *Texture) Texture() *Texture

Texture implements Texturer

type TextureData

type TextureData struct {
	GPU

	Source        string
	Format        TextureFormat
	Width, Height int
	PixelData     []byte
	Updates       int
}

TextureData is the data for the texture

func (*TextureData) CreateRef

func (d *TextureData) CreateRef(g *Context) *TextureRef

CreateRef creates a texture gpu reference.

func (*TextureData) Resource

func (d *TextureData) Resource() TextureResource

Resource implements TextureResourcer.

func (*TextureData) String

func (d *TextureData) String() string

type TextureFilter

type TextureFilter int

TextureFilter texture filter mode

type TextureFormat

type TextureFormat int

TextureFormat texture pixel format

func (TextureFormat) String

func (f TextureFormat) String() string

type TextureRef

type TextureRef struct{ *GPU }

TextureRef implements a gpu only texture resource.

func (*TextureRef) Resource

func (r *TextureRef) Resource() TextureResource

type TextureResource

type TextureResource interface {
	// contains filtered or unexported methods
}

TextureResource is an interface to handle underlying texture data.

type TextureResourcer

type TextureResourcer interface {
	Resource() TextureResource
}

type TextureWrap

type TextureWrap int

TextureWrap for texture

func (TextureWrap) String

func (m TextureWrap) String() string

type Texturer

type Texturer interface {
	Texture() *Texture
}

Texturer used to fetch a texture from a texture controller.

type TransformComponent

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

TransformComponent Thing

func NewTransformComponent

func NewTransformComponent() *TransformComponent

NewTransformComponent returns an initialized transform component

func TransformIdent

func TransformIdent() TransformComponent

TransformIdent returns a transform identity copy.

func (*TransformComponent) Backward

func (c *TransformComponent) Backward() gm.Vec3

Backward returns backward vector of the transform

func (*TransformComponent) Down

func (c *TransformComponent) Down() gm.Vec3

Down returns World Fown of the transform

func (*TransformComponent) Forward

func (c *TransformComponent) Forward() gm.Vec3

Forward returns World Forward vector of the transform

func (*TransformComponent) Inv

func (c *TransformComponent) Inv() gm.Mat4

Inv return the inverse matrix of the transform

func (*TransformComponent) Left

func (c *TransformComponent) Left() gm.Vec3

Left returns World left of the transform

func (*TransformComponent) LookAt

func (c *TransformComponent) LookAt(target Matrixer, v ...gm.Vec3)

LookAt resets the local rotation to lookAt if 1 param is used, we will Use default gm.Up() +Y vector

func (*TransformComponent) LookAtPosition

func (c *TransformComponent) LookAtPosition(target gm.Vec3, v ...gm.Vec3)

LookAtPosition resets the local rotation to lookAt if 1 param is used, we will Use default gm.Up() +Y vector

func (*TransformComponent) LookDir

func (c *TransformComponent) LookDir(dir gm.Vec3, v ...gm.Vec3)

LookDir looks at direction

func (*TransformComponent) Mat4

func (c *TransformComponent) Mat4() gm.Mat4

Mat4 returns the World gm.Mat4 from the transformations

func (*TransformComponent) Parent

func (c *TransformComponent) Parent() Matrixer

Parent returns the current parent.

func (*TransformComponent) Right

func (c *TransformComponent) Right() gm.Vec3

Right returns World right of the transform

func (*TransformComponent) Rotate

func (c *TransformComponent) Rotate(x, y, z float32)

Rotate axis

func (*TransformComponent) Rotatev

func (c *TransformComponent) Rotatev(angles gm.Vec3)

Rotatev axis by vector

func (*TransformComponent) Set

func (c *TransformComponent) Set(position gm.Vec3, euler gm.Vec3, scale gm.Vec3)

Set full transform

func (*TransformComponent) SetEuler

func (c *TransformComponent) SetEuler(x, y, z float32)

SetEuler convenient func

func (*TransformComponent) SetEulerv

func (c *TransformComponent) SetEulerv(angles gm.Vec3)

SetEulerv sets the euler angles as a vector

func (*TransformComponent) SetMat4Decompose

func (c *TransformComponent) SetMat4Decompose(m gm.Mat4)

SetMat4Decompose decomposes a 4x4 into position, rotation and scale. https://answers.unity.com/questions/402280/how-to-decompose-a-trs-matrix.html

func (*TransformComponent) SetParent

func (c *TransformComponent) SetParent(p Matrixer)

SetParent of the transform

func (*TransformComponent) SetPosition

func (c *TransformComponent) SetPosition(x, y, z float32)

SetPosition sets the current position on the world

func (*TransformComponent) SetPositionv

func (c *TransformComponent) SetPositionv(pos gm.Vec3)

SetPositionv sets the current position on the world with a vector

func (*TransformComponent) SetRotation

func (c *TransformComponent) SetRotation(v gm.Quat)

SetRotation set a quaternion

func (*TransformComponent) SetScale

func (c *TransformComponent) SetScale(sz ...float32)

SetScale will set scale 1 argument, will set all axis 2 arguments, will set only x and y and z to 1 3 arguments, will set all

func (*TransformComponent) SetScalev

func (c *TransformComponent) SetScalev(scale gm.Vec3)

SetScalev just sets the scale

func (*TransformComponent) Transform

func (c *TransformComponent) Transform() *TransformComponent

Transform component

func (*TransformComponent) Translate

func (c *TransformComponent) Translate(x, y, z float32)

Translate the thing

func (*TransformComponent) Translatev

func (c *TransformComponent) Translatev(axis gm.Vec3)

Translatev translate by vector

func (*TransformComponent) Up

func (c *TransformComponent) Up() gm.Vec3

Up returns World up of the transform

func (*TransformComponent) Updated

func (c *TransformComponent) Updated() bool

Updated returns true if the transform or relative parents were updated.

func (*TransformComponent) Updates

func (c *TransformComponent) Updates() int

Updates return the current number of udpates.

func (*TransformComponent) WorldPosition

func (c *TransformComponent) WorldPosition() gm.Vec3

WorldPosition returns world position

func (*TransformComponent) WorldRotation

func (c *TransformComponent) WorldRotation() gm.Quat

WorldRotation returns world rotation

type Transformer

type Transformer interface {
	Mat4() gm.Mat4
	Transform() *TransformComponent
}

Transformer interface for the transform component implementer.

type ValueTexture

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

ValueTexture helper for a single valued texture.

func NewValueTexture

func NewValueTexture(v float32) *ValueTexture

NewValueTexture returns a single pixel colored texture

func (*ValueTexture) SetValue

func (t *ValueTexture) SetValue(v float32)

SetValue sets the texture Value

type VertexFormat

type VertexFormat []VertexFormatAttrib

VertexFormat type for describing vertex formats.

func VertexFormatP

func VertexFormatP() VertexFormat

VertexFormatP default vertex with positioning only

func VertexFormatPN

func VertexFormatPN() VertexFormat

VertexFormatPN format for Position and Normal

func VertexFormatPNT

func VertexFormatPNT() VertexFormat

VertexFormatPNT format for Position Normal and Texture

func VertexFormatPT

func VertexFormatPT() VertexFormat

VertexFormatPT format for Position and TexCoord

func VertexFormatPTN

func VertexFormatPTN() VertexFormat

VertexFormatPTN format for Position Texture and Normal

func (VertexFormat) Size

func (f VertexFormat) Size() int

Size returns the data size for this vertex

type VertexFormatAttrib

type VertexFormatAttrib struct {
	Size   int
	Attrib string
	Define string
}

VertexFormatAttrib vertex format entry for interleaving vertex data in meshData.

func VertexAttrib

func VertexAttrib(sz int, attrib string, define string) VertexFormatAttrib

VertexAttrib return a vertex attribute definition

Directories

Path Synopsis
Package anim provides basic animation functions for gorge
Package anim provides basic animation functions for gorge
cmd
core
logger
Package logger overrides to Override the writer on log.SetOutput
Package logger overrides to Override the writer on log.SetOutput
setlist
Package setlist slice without duplication.
Package setlist slice without duplication.
Package debug builds status for gorge
Package debug builds status for gorge
Package gorgeapp initializes gorge with default systems for specific platform
Package gorgeapp initializes gorge with default systems for specific platform
glfw
Package glfw provides initialization for glfw lib
Package glfw provides initialization for glfw lib
Package gorgeutil provides certain things like premade lights, camera entity structs
Package gorgeutil provides certain things like premade lights, camera entity structs
math
gm
Package gm math and gl math for floats32 Contains code from github.com/go-gl/mathgl/mgl32 BSD-3 Copyright ©2013 The go-gl Authors.
Package gm math and gl math for floats32 Contains code from github.com/go-gl/mathgl/mgl32 BSD-3 Copyright ©2013 The go-gl Authors.
ray
Package ray implements some ray casting math
Package ray implements some ray casting math
Package primitive provides some basic geometry and entities
Package primitive provides some basic geometry and entities
Package static contains resources like default shaders, fonts
Package static contains resources like default shaders, fonts
systems
audio
Package audio implements audio system
Package audio implements audio system
audio/proc
Package proc audio processors
Package proc audio processors
gorgeui
Package gorgeui concept gorge UI
Package gorgeui concept gorge UI
input
Package input normalizes inputs from systems
Package input normalizes inputs from systems
render
Package render mostly agnostic gl renderer with a couple of exceptions due to some limitations
Package render mostly agnostic gl renderer with a couple of exceptions due to some limitations
render/bufutil
Package bufutil provides means to cache and write into underlying gpu buffers
Package bufutil provides means to cache and write into underlying gpu buffers
render/gl
nolint: revive
nolint: revive
render/renderpl
Package renderpl contains default rendering pipeline for gorge
Package renderpl contains default rendering pipeline for gorge
resource
Package resource handles resources
Package resource handles resources
Package text implements texture rendering from font texture map
Package text implements texture rendering from font texture map
x
gltf
Package gltf attempt to implement glft
Package gltf attempt to implement glft
gorxui
Package gorxui experimental XML to gorlet serializer.
Package gorxui experimental XML to gorlet serializer.
obj
Package obj preliminary obj loader outside of the package as we probably will load more than 1 mesh, we don't have concept of "objects" with several meshes yet
Package obj preliminary obj loader outside of the package as we probably will load more than 1 mesh, we don't have concept of "objects" with several meshes yet
pipeline
Package pipeline implements learnogl env mapping stuff
Package pipeline implements learnogl env mapping stuff

Jump to

Keyboard shortcuts

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