Documentation
¶
Overview ¶
Package gorge contains mostly data only components
Index ¶
- Constants
- Variables
- func EachEntity(e Entity, fn func(e Entity))
- func EachParent(e Entity, fn func(e Entity) bool)
- func GetContext[T comparable](g *Context) (T, bool)
- func GetGPU(r any) any
- func HasParent(e Entity, parent Entity) bool
- func SetContext[T comparable](g *Context, c T) T
- func SetGPU(r, v any)
- func StringHash(str ...string) uint
- func TriggerInMain[T any](g gorger, e T)
- type AudioClip
- type AudioClipData
- type AudioFormat
- type AudioListener
- type AudioResource
- type AudioResourcer
- type AudioSource
- type Blend
- type BlendEnum
- type BlendEq
- type CameraComponent
- func (c *CameraComponent) CalcViewport(screenSize gm.Vec2) gm.Vec4
- func (c *CameraComponent) Camera() *CameraComponent
- func (c CameraComponent) Projection(screenSize gm.Vec2) gm.Mat4
- func (c CameraComponent) ProjectionWithAspect(aspect float32) gm.Mat4
- func (c *CameraComponent) SetAspectRatio(a float32)
- func (c *CameraComponent) SetClearColor(r, g, b float32)
- func (c *CameraComponent) SetClearFlag(clr ClearType)
- func (c *CameraComponent) SetCullMask(m CullMaskFlags)
- func (c *CameraComponent) SetOrder(n int)
- func (c *CameraComponent) SetOrtho(size, near, far float32)
- func (c *CameraComponent) SetPerspective(fov, near, far float32)
- func (c *CameraComponent) SetViewport(x, y, w, h float32)
- type ClearType
- type ColorTexture
- type ColorableComponent
- type Container
- type Context
- type Contexter
- type CullMaskFlags
- type CursorType
- type DepthMode
- type DrawMode
- type Entity
- type EntityContainer
- type EventAddEntity
- type EventAfterStart
- type EventCursor
- type EventCursorHidden
- type EventCursorRelative
- type EventDestroy
- type EventError
- type EventPostUpdate
- type EventPreUpdate
- type EventRemoveEntity
- type EventRender
- type EventResourceUpdate
- type EventStart
- type EventUpdate
- type EventWarn
- type FrontFacing
- type GPU
- type Gorge
- func (g *Gorge) Add(ents ...Entity)
- func (g *Gorge) Close()
- func (g *Gorge) CloseWithError(err error)
- func (g *Gorge) Error(err error)
- func (g *Gorge) HandleError(fn func(err error))
- func (g *Gorge) HandleUpdate(fn func(float32))
- func (g *Gorge) Remove(ents ...Entity)
- func (g *Gorge) Run() error
- func (g *Gorge) RunInMain(fn func())
- func (g *Gorge) ScreenSize() gm.Vec2
- func (g *Gorge) SetScreenSize(s gm.Vec2)
- func (g *Gorge) Start() error
- func (g *Gorge) Update(dt float32)
- func (g *Gorge) Wait() error
- type InitFunc
- type LightComponent
- func (l *LightComponent) Light() *LightComponent
- func (l *LightComponent) SetColor(r, g, b float32)
- func (l *LightComponent) SetDisableShadow(b bool)
- func (l *LightComponent) SetInnerConeCos(v float32)
- func (l *LightComponent) SetIntensity(v float32)
- func (l *LightComponent) SetOuterConeCos(v float32)
- func (l *LightComponent) SetRange(v float32)
- func (l *LightComponent) SetType(t LightType)
- type LightType
- type Material
- func (s *Material) Define(defs ...string)
- func (m *Material) Defines() map[string]string
- func (m *Material) DefinesHash() uint
- func (m *Material) Get(name string) any
- func (m *Material) GetTexture(name string) *Texture
- func (m *Material) Material() *Material
- func (s *Material) Props() map[string]any
- func (s *Material) ResetProps()
- func (m *Material) Resource() ShaderResource
- func (s *Material) Set(name string, v any)
- func (m *Material) SetBlend(v *Blend)
- func (m *Material) SetColorMask(r, g, b, a bool)
- func (m *Material) SetDepth(v DepthMode)
- func (m *Material) SetDisableShadow(v bool)
- func (m *Material) SetDoubleSided(v bool)
- func (s *Material) SetFloat32(name string, v float32)
- func (m *Material) SetQueue(v int)
- func (m *Material) SetStencil(s *Stencil)
- func (s *Material) SetTexture(name string, t Texturer)
- func (s *Material) SetVec3(name string, v1, v2, v3 float32)
- func (s *Material) SetVec4(name string, v1, v2, v3, v4 float32)
- func (m Material) String() string
- func (s *Material) Undefine(defs ...string)
- func (s *Material) Update()
- func (s *Material) Updates() int
- type Materialer
- type Matrixer
- type Mesh
- func (m *Mesh) Clone() *Mesh
- func (s *Mesh) Define(defs ...string)
- func (s *Mesh) Defines() map[string]string
- func (s Mesh) DefinesHash() uint
- func (s *Mesh) Get(name string) any
- func (m *Mesh) GetDrawMode() DrawMode
- func (s *Mesh) GetTexture(name string) *Texture
- func (m *Mesh) Mesh() *Mesh
- func (s *Mesh) Props() map[string]any
- func (m *Mesh) ReleaseData(g *Context)
- func (s *Mesh) ResetProps()
- func (m *Mesh) Resource() MeshResource
- func (s *Mesh) Set(name string, v any)
- func (s *Mesh) SetFloat32(name string, v float32)
- func (s *Mesh) SetTexture(name string, t Texturer)
- func (s *Mesh) SetVec3(name string, v1, v2, v3 float32)
- func (s *Mesh) SetVec4(name string, v1, v2, v3, v4 float32)
- func (m Mesh) String() string
- func (s *Mesh) Undefine(defs ...string)
- func (s *Mesh) Update()
- func (s *Mesh) Updates() int
- type MeshData
- type MeshRef
- type MeshResource
- type MeshResourcer
- type Mesher
- type ParentGetter
- type ParentSetter
- type ProjectionType
- type RenderableComponent
- type ShaderData
- type ShaderResource
- type ShaderResourcer
- type Stencil
- type StencilFunc
- type StencilOp
- type Texture
- func (t *Texture) GetFilterMode() TextureFilter
- func (t *Texture) GetWrap() (u, v, w TextureWrap)
- func (t *Texture) ReleaseData(g *Context)
- func (t *Texture) Resource() TextureResource
- func (t *Texture) SetFilterMode(f TextureFilter)
- func (t *Texture) SetWrapUVW(uvw ...TextureWrap)
- func (t *Texture) Texture() *Texture
- type TextureData
- type TextureFilter
- type TextureFormat
- type TextureRef
- type TextureResource
- type TextureResourcer
- type TextureWrap
- type Texturer
- type TransformComponent
- func (c *TransformComponent) Backward() gm.Vec3
- func (c *TransformComponent) Down() gm.Vec3
- func (c *TransformComponent) Forward() gm.Vec3
- func (c *TransformComponent) Inv() gm.Mat4
- func (c *TransformComponent) Left() gm.Vec3
- func (c *TransformComponent) LookAt(target Matrixer, v ...gm.Vec3)
- func (c *TransformComponent) LookAtPosition(target gm.Vec3, v ...gm.Vec3)
- func (c *TransformComponent) LookDir(dir gm.Vec3, v ...gm.Vec3)
- func (c *TransformComponent) Mat4() gm.Mat4
- func (c *TransformComponent) Parent() Matrixer
- func (c *TransformComponent) Right() gm.Vec3
- func (c *TransformComponent) Rotate(x, y, z float32)
- func (c *TransformComponent) Rotatev(angles gm.Vec3)
- func (c *TransformComponent) Set(position gm.Vec3, euler gm.Vec3, scale gm.Vec3)
- func (c *TransformComponent) SetEuler(x, y, z float32)
- func (c *TransformComponent) SetEulerv(angles gm.Vec3)
- func (c *TransformComponent) SetMat4Decompose(m gm.Mat4)
- func (c *TransformComponent) SetParent(p Matrixer)
- func (c *TransformComponent) SetPosition(x, y, z float32)
- func (c *TransformComponent) SetPositionv(pos gm.Vec3)
- func (c *TransformComponent) SetRotation(v gm.Quat)
- func (c *TransformComponent) SetScale(sz ...float32)
- func (c *TransformComponent) SetScalev(scale gm.Vec3)
- func (c *TransformComponent) Transform() *TransformComponent
- func (c *TransformComponent) Translate(x, y, z float32)
- func (c *TransformComponent) Translatev(axis gm.Vec3)
- func (c *TransformComponent) Up() gm.Vec3
- func (c *TransformComponent) Updated() bool
- func (c *TransformComponent) Updates() int
- func (c *TransformComponent) WorldPosition() gm.Vec3
- func (c *TransformComponent) WorldRotation() gm.Quat
- type Transformer
- type ValueTexture
- type VertexFormat
- type VertexFormatAttrib
Constants ¶
const ( ProjectionPerspective = ProjectionType(iota) ProjectionOrtho )
Projection types for camera.
const ( ClearColor = ClearType(iota) ClearDepthOnly ClearNothing ClearSkybox )
Clear types
const ( LightPoint = LightType(iota) LightDirectional LightSpot )
Light types
const ( DepthReadWrite = DepthMode(iota) DepthRead DepthNone )
Default deph modes
const ( BlendZero = BlendEnum(iota) BlendOne BlendSrcColor BlendOneMinusSrcColor BlendDstColor BlendOneMinusDstColor BlendSrcAlpha BlendOneMinusSrcAlpha BlendDstAlpha BlendOneMinusDstAlpha BlendConstantColor BlendOneMinusConstantColor BlendConstantAlpha BlendOneMinusConstantAlpha )
const ( BlendEqAdd = BlendEq(iota) BlendEqSub BlendEqRevSub BlendEqMin BlendEqMax )
const ( StencilFuncNever = StencilFunc(iota) StencilFuncLess StencilFuncLequal StencilFuncGreater StencilFuncGequal StencilFuncEqual StencilFuncNotequal StencilFuncAlways )
const ( StencilOpKeep = StencilOp(iota) StencilOpZero StencilOpReplace StencilOpIncr StencilOpDecr StencilOpInvert StencilOpIncrWrap StencilOpDecrWrap )
const ( DrawTriangles = DrawMode(iota) DrawTriangleStrip DrawTriangleFan DrawPoints DrawLines DrawLineLoop DrawLineStrip )
Mesh draw type
const ( FrontFacingCW = FrontFacing(0) FrontFacingCCW = FrontFacing(1) )
FrontFacing indicates the frontfacing property for the meshData vertices
const ( CullMaskDefault = CullMaskFlags(0xFF) CullMaskUI = CullMaskFlags(1 << 8) CullMaskUIDebug = CullMaskFlags(1 << 9) )
CullMask defaults
const ( TextureFormatRGBA = TextureFormat(iota) TextureFormatRGB TextureFormatGray TextureFormatGray16 TextureFormatRGB32F )
Known texture formats
const ( TextureWrapRepeat = TextureWrap(iota) TextureWrapClamp TextureWrapMirror )
Wrapmode consts
const ( TextureFilterLinear = TextureFilter(iota) TextureFilterPoint )
TextureFilter types
Variables ¶
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} )
var ( TransformBuilds = 0 TransformBuildSave = 0 )
TransformBuilds tracks the numbers of transforms for performance purposes
var ErrAlreadyStarted = errors.New("already started")
ErrAlreadyStarted is returned when Start is called more than once
Functions ¶
func EachEntity ¶
EachEntity solves entities containers and walk on every entity.
func GetContext ¶
func GetContext[T comparable](g *Context) (T, bool)
GetContext gets a system from a gorge context.
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 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 ¶
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 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 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 ¶
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 ¶
Add one ore more entities to Container it will loop existing elements to compare and avoid duplicates.
func (Container) GetEntities ¶
GetEntities implements the entitycontainer
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds a gorge system and is mostly used as a Prop.
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 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 EventUpdate ¶
type EventUpdate float32
EventUpdate type
func (EventUpdate) DeltaTime ¶
func (e EventUpdate) DeltaTime() float32
DeltaTime returns the float32 delta time for the event.
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 (*Gorge) CloseWithError ¶
CloseWithError closes with an error which will be sent on Wait() call
func (*Gorge) HandleError ¶
HandleError registers a function that filters events and calls fn if event is the EventError.
func (*Gorge) HandleUpdate ¶
HandleUpdate adds a listener that filters events and calls fn if it is the EventUpdate.
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 ¶
ScreenSize returns the previously set screensize
func (*Gorge) SetScreenSize ¶
SetScreenSize used by the gorgeapp to set the current screensize Might be changed in the future if we use multiple Display devices.
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 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) DefinesHash ¶
DefinesHash returns an hash based on the material defines.
func (*Material) Get ¶
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 ¶
GetTexture returns the texture for name
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) SetColorMask ¶
func (*Material) SetDisableShadow ¶
func (*Material) SetDoubleSided ¶
SetDoubleSided sets material double sided prop.
func (*Material) SetFloat32 ¶
SetFloat32 XXX testing sets a float32
func (*Material) SetQueue ¶
SetQueue sets the material target queue transparent materials should be in a higher queue
func (*Material) SetStencil ¶
SetStencil sets the stencil property for material.
func (*Material) SetTexture ¶
type Materialer ¶
type Materialer interface{ Material() *Material }
Materialer interface for material controllers.
type Mesh ¶
type Mesh struct { Resourcer MeshResourcer DrawMode DrawMode // contains filtered or unexported fields }
Mesh representation
func (Mesh) DefinesHash ¶
func (s Mesh) DefinesHash() uint
func (*Mesh) GetDrawMode ¶
GetDrawMode returns the mesh drawmode.
func (*Mesh) GetTexture ¶
func (*Mesh) ReleaseData ¶
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) SetFloat32 ¶
SetFloat32 XXX testing sets a float32
func (*Mesh) SetTexture ¶
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 ¶
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.
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 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 ¶
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 StencilFunc ¶
type StencilFunc int
func (StencilFunc) String ¶
func (f StencilFunc) 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 ¶
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
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 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) 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 ¶
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
Source Files
¶
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 |