core

package
v0.0.0-...-73aabcd Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: BSD-3-Clause Imports: 16 Imported by: 7

Documentation

Overview

Package core contains the scenegraph core types and behaviours. It is imported by sister packages and defines the common types for all components.

Index

Examples

Constants

View Source
const (
	// MaxInstances is the maximum number of modelMatrices in a mesh instance attribute buffer
	MaxInstances = 2000

	// InstanceDataLen is the byte size of an InstanceData value
	InstanceDataLen = (2*16 + 4*4) * 4
)

Variables

This section is empty.

Functions

func AABBRenderTechnique

func AABBRenderTechnique(camera *Camera, materialBuckets map[*protos.State][]*Node)

AABBRenderTechnique draws AABBs for all nodes

func Clamp

func Clamp(val, c0, c1 float64) float64

Clamp constrains the passed value to lie between two other values

func DebugRenderTechnique

func DebugRenderTechnique(camera *Camera, materialBuckets map[*protos.State][]*Node)

DebugRenderTechnique runs the default render path followed by AABBs

func DefaultRenderTechnique

func DefaultRenderTechnique(camera *Camera, materialBuckets map[*protos.State][]*Node)

DefaultRenderTechnique does z pre-pass, diffuse pass, transparency pass

func HashStringToU32

func HashStringToU32(x string) uint32

HashStringToU32 computes an unsigned 32 bit hash value for the given parameter

func HashU32

func HashU32(x uint32) uint32

HashU32 computes an unsigned 32 bit hash value for the given parameter

func IMGUIRenderTechnique

func IMGUIRenderTechnique(camera *Camera, materialBuckets map[*protos.State][]*Node)

IMGUIRenderTechnique does z pre-pass, diffuse pass, transparency pass

func MakeFrustum

func MakeFrustum(p, v mgl64.Mat4) (f [6]mgl64.Vec4)

MakeFrustum creates a frustum's 6 planes from a projection and view matrix

func Mat4DoubleToFloat

func Mat4DoubleToFloat(d mgl64.Mat4) mgl32.Mat4

Mat4DoubleToFloat converts an mgl64.Mat4 into an mgl32.Mat4

func RenderBatch

func RenderBatch(camera *Camera, nodes []*Node)

RenderBatch renders a batch of drawables sharing the same state and descriptors

func RenderBatchedNodes

func RenderBatchedNodes(camera *Camera, nodes []*Node)

RenderBatchedNodes splits a list of nodes into batched items per buffers and streams draw calls It assumes all batches share materials and should be used long with Mater

func SetAudioSystem

func SetAudioSystem(a AudioSystem)

SetAudioSystem should be called by implementations on their init function. It registers the implementation as the active audio system.

func SetIMGUISystem

func SetIMGUISystem(is IMGUISystem)

SetIMGUISystem is meant to be called from IMGUISystem implementations on their init method

func SetPhysicsSystem

func SetPhysicsSystem(ps PhysicsSystem)

SetPhysicsSystem is meant to be called from PhysicsSystem implementations on their init method

func SetRenderSystem

func SetRenderSystem(rs RenderSystem)

SetRenderSystem is meant to be called from RenderSystem implementations on their init method to cause the side-effect of setting the core RenderSystem to their provided one.

func SmoothStep

func SmoothStep(from, to, t float64) float64

SmoothStep performs hermite interpolation between two values

func Vec2DoubleToFloat

func Vec2DoubleToFloat(d mgl64.Vec2) mgl32.Vec2

Vec2DoubleToFloat converts an mgl64.Vec2 into an mgl32.Vec2

func Vec3DoubleToFloat

func Vec3DoubleToFloat(d mgl64.Vec3) mgl32.Vec3

Vec3DoubleToFloat converts an mgl64.Vec3 into an mgl32.Vec3

func Vec4DoubleToFloat

func Vec4DoubleToFloat(d mgl64.Vec4) mgl32.Vec4

Vec4DoubleToFloat converts an mgl64.Vec4 into an mgl32.Vec4

Types

type AABB

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

AABB defines the smallest enclosing box for a given set of points

func NewAABB

func NewAABB() *AABB

NewAABB returns a ready to use AABB which contains no volume

func (*AABB) Center

func (a *AABB) Center() mgl64.Vec3

Center returns the center point of the AABB

func (*AABB) ContainsBox

func (a *AABB) ContainsBox(ib *AABB) bool

ContainsBox returns whether the bounding volume fully contains the volume defined by the given bounding box

func (*AABB) ContainsPoint

func (a *AABB) ContainsPoint(ip mgl64.Vec3) bool

ContainsPoint returns whether the bounding volume contains the given point

func (*AABB) DistanceToPoint

func (a *AABB) DistanceToPoint(p mgl64.Vec3) (float64, float64)

DistanceToPoint returns the minimum distance from a point to any of the AABBs corners

func (*AABB) ExtendWithBox

func (a *AABB) ExtendWithBox(ib *AABB)

ExtendWithBox extends the bounding box to contain the volume defined by the given bounding box

func (*AABB) ExtendWithPoint

func (a *AABB) ExtendWithPoint(ip mgl64.Vec3)

ExtendWithPoint extends the bounding box to contain the given point

func (*AABB) InFrustum

func (a *AABB) InFrustum(planes [6]mgl64.Vec4) bool

InFrustum returns whether the bounding volume is contained in the frustum defined by the given planes

func (*AABB) Max

func (a *AABB) Max() mgl64.Vec3

Max returns the min point

func (*AABB) Min

func (a *AABB) Min() mgl64.Vec3

Min returns the min point

func (*AABB) Reset

func (a *AABB) Reset()

Reset returns the AABB to its initial state

func (*AABB) Size

func (a *AABB) Size() mgl64.Vec3

Size returns the size of the AABB

func (*AABB) String

func (a *AABB) String() string

String implements the stringer interface

func (*AABB) Transformed

func (a *AABB) Transformed(m mgl64.Mat4) *AABB

Transformed returns a new ABB which contains the volume specified by the eight corners or the original AABB when multiplied by the passed transform. This can be used, for example, to transform an AABB in object space (OBB) to an AABB in world space.

Example
var a AABB

a.ExtendWithPoint(mgl64.Vec3{-10.0, -10.0, -10.0})
a.ExtendWithPoint(mgl64.Vec3{10.0, 10.0, 10.0})

transform := mgl64.QuatRotate(1.5, mgl64.Vec3{0.0, 1.0, 0.0}).Mat4()
fmt.Println(transform)
Output:

type AlwaysPassCuller

type AlwaysPassCuller struct{}

AlwaysPassCuller implements a scenegraph culler by always adding the node to the bucket

func (*AlwaysPassCuller) Run

func (apcc *AlwaysPassCuller) Run(scene *Scene, camera *Camera, node *Node)

Run implements the Culler interface

type Application

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

Application is the top-level runnable gosg App

func (*Application) Start

func (app *Application) Start(acConstructor func() ClientApplication)

Start starts the application runloop by calling all systems/managers Start methods, and calling the ClientApp constructor. On runloop termination, the Stop methods are called in reverse order.

type AudioSystem

type AudioSystem interface {
	// Start starts the audio system. This is where implementations should detect
	// hardware devices and initialize them.
	Start()

	// Step is called by the application runloop update.
	Step()

	// Stop is called by the application after its main loop returns. Implementations
	// should call their termination/cleanup logic here.
	Stop()
}

AudioSystem is the interface that wraps all audio processing logic.

func GetAudioSystem

func GetAudioSystem() AudioSystem

GetAudioSystem returns the registered window system

type BindDescriptorsCommand

type BindDescriptorsCommand struct {
	Descriptors *Descriptors
}

BindDescriptorsCommand bids the passed descriptors

type BindStateCommand

type BindStateCommand struct {
	State *protos.State
}

BindStateCommand binds the passed state

type BindUniformBufferCommand

type BindUniformBufferCommand struct {
	Name          string
	UniformBuffer UniformBuffer
}

BindUniformBufferCommand binds the passed uniform buffer

type BoundsCallbackFn

type BoundsCallbackFn func(n *Node) *AABB

BoundsCallbackFn is called if set to allow the user to specify logic to customise a node's bounds. The bounds will have been grown to include any mesh or children. It's/ up to the user to decide whether to return the same bounds or a new AABB.

type Camera

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

A Camera represents a scenegraph camera object. It wraps data which holds its transforms (projection and view matrices), clear information, whether it should perform auto reshape on window resizes, a pointer to its node on the scenegraph, as well as clipping distances (near, far planes) and render ordering, target and techniques.

func NewCamera

func NewCamera(name string, projType ProjectionType) *Camera

NewCamera creates and returns a Camera with the given name and projection type.

func (*Camera) AddNodeToRenderBuckets

func (c *Camera) AddNodeToRenderBuckets(n *Node)

AddNodeToRenderBuckets adds a node to the camera's renderbuckets for the next render loop

func (*Camera) ClearColor

func (c *Camera) ClearColor() mgl32.Vec4

ClearColor returns the camera's clear color.

func (*Camera) ClearDepth

func (c *Camera) ClearDepth() float64

ClearDepth returns the camera's clear depth.

func (*Camera) ClearMode

func (c *Camera) ClearMode() ClearMode

ClearMode returns the camera's clear mode.

func (*Camera) Framebuffer

func (c *Camera) Framebuffer() Framebuffer

Framebuffer returns the camera's render target.

func (*Camera) Frustum

func (c *Camera) Frustum() [6]mgl64.Vec4

Frustum returns the camera's frustum, which is a set of 6 planes.

func (*Camera) Name

func (c *Camera) Name() string

Name returns the camera's name.

func (*Camera) Node

func (c *Camera) Node() *Node

Node returns the camera's scenegraph Node

func (*Camera) ProjectionMatrix

func (c *Camera) ProjectionMatrix() mgl64.Mat4

ProjectionMatrix returns the camera's projection matrix.

func (*Camera) RenderOrder

func (c *Camera) RenderOrder() uint8

RenderOrder order returns the camera's render order.

func (*Camera) Reshape

func (c *Camera) Reshape(windowSize mgl32.Vec2)

Reshape reshapes the camera's viewport and transforms according to a given window size.

func (*Camera) Scene

func (c *Camera) Scene() *Node

Scene returns the camera's scene root. This is the node that it will start culling traversals on. To render an entire scene you would set this to the scene's root node. To render subtrees you would set this to the subtree root node. This allows you to split your scene into subgroups and have cameras render them separately.

func (*Camera) SetAutoFrustum

func (c *Camera) SetAutoFrustum(af bool)

SetAutoFrustum sets whether the camera should auto set its near/far clip planes

func (*Camera) SetAutoReshape

func (c *Camera) SetAutoReshape(autoReshape bool)

SetAutoReshape sets whether the camera should reshape its viewport and transforms when the window is resized.

func (*Camera) SetClearColor

func (c *Camera) SetClearColor(cc mgl32.Vec4)

SetClearColor sets the camera's clear color.

func (*Camera) SetClearDepth

func (c *Camera) SetClearDepth(d float64)

SetClearDepth sets the camera's clear depth.

func (*Camera) SetClearMode

func (c *Camera) SetClearMode(cm ClearMode)

SetClearMode sets the camera's clear mode.

func (*Camera) SetClipDistance

func (c *Camera) SetClipDistance(cd mgl64.Vec2)

SetClipDistance sets the camera's near and far clipping planes.

func (*Camera) SetFramebuffer

func (c *Camera) SetFramebuffer(rt Framebuffer)

SetFramebuffer sets the camera's render target.

func (*Camera) SetProjectionMatrix

func (c *Camera) SetProjectionMatrix(m mgl64.Mat4)

SetProjectionMatrix sets the camera's projection matrix.

func (*Camera) SetProjectionType

func (c *Camera) SetProjectionType(projType ProjectionType)

SetProjectionType sets the camera's projection type.

func (*Camera) SetRenderOrder

func (c *Camera) SetRenderOrder(o uint8)

SetRenderOrder sets the camera's render order.

func (*Camera) SetRenderTechnique

func (c *Camera) SetRenderTechnique(r CameraRenderFn)

SetRenderTechnique sets the camera's render technique.

func (*Camera) SetScene

func (c *Camera) SetScene(s *Node)

SetScene sets the camera's scene root. See Scene() for more information on what this is.

func (*Camera) SetVerticalFieldOfView

func (c *Camera) SetVerticalFieldOfView(vfov float64)

SetVerticalFieldOfView sets the camera's vertical field of view. This is ignored for orthographic projections.

func (*Camera) SetViewMatrix

func (c *Camera) SetViewMatrix(m mgl64.Mat4)

SetViewMatrix sets the camera's view matrix.

func (*Camera) SetViewport

func (c *Camera) SetViewport(vp mgl32.Vec4)

SetViewport sets the camera's viewport.

func (*Camera) ViewMatrix

func (c *Camera) ViewMatrix() mgl64.Mat4

ViewMatrix returns the camera's view matrix.

func (*Camera) Viewport

func (c *Camera) Viewport() mgl32.Vec4

Viewport returns the camera's viewport.

type CameraRenderFn

type CameraRenderFn func(*Camera, map[*protos.State][]*Node)

CameraRenderFn implements a specific drawing method for a slice of nodes viewed by a camera.

type CamerasByRenderOrder

type CamerasByRenderOrder []*Camera

CamerasByRenderOrder is used to sort cameras by the render order field.

func (CamerasByRenderOrder) Len

func (a CamerasByRenderOrder) Len() int

Len implements the sort.Interface interface.

func (CamerasByRenderOrder) Less

func (a CamerasByRenderOrder) Less(i, j int) bool

Less implements the sort.Interface interface.

func (CamerasByRenderOrder) Swap

func (a CamerasByRenderOrder) Swap(i, j int)

Swap implements the sort.Interface interface.

type ClearCommand

type ClearCommand struct {
	ClearMode  ClearMode
	ClearColor mgl32.Vec4
	ClearDepth float64
}

ClearCommand clears the current framebuffer

type ClearMode

type ClearMode uint8

ClearMode is used to express the type of framebuffer clearing which will be executed before the rendering logic is called.

const (
	// ClearColor is used to signal whether a framebuffer's color buffer should be cleared.
	ClearColor ClearMode = 1 << 0

	// ClearDepth is used to signal whether a framebuffer's color buffer should be cleared.
	ClearDepth ClearMode = 1 << 1
)

type ClientApplication

type ClientApplication interface {
	InputComponent() ClientApplicationInputComponent
	Stop()
	Done() bool
}

ClientApplication is the client app, provided by the user

type ClientApplicationCommand

type ClientApplicationCommand interface {
	Run(ac ClientApplication)
}

ClientApplicationCommand is a single runnable command

type ClientApplicationInputComponent

type ClientApplicationInputComponent interface {
	Run() []ClientApplicationCommand
}

ClientApplicationInputComponent checks the input system state and triggers commands

type CollisionShape

type CollisionShape interface {
	// AddChildShape adds a child collision shape to this shape.
	AddChildShape(childshape CollisionShape, position mgl64.Vec3, orientation mgl64.Quat)

	// AddVertex adds a single vertex. Used for convex hull shapes.
	AddVertex(mgl64.Vec3)
}

CollisionShape is an interface which wraps information used to compute object collisions.

type Culler

type Culler interface {
	// Run culls a scenegraph node. A scene and camera are provided for visibility/frustum checks.
	// If the policy dictates the node is to be drawn, then it should be added to the nodeBucket.
	Run(*Scene, *Camera, *Node)
}

Culler is an interface that wraps culling of a scenegraph.

type DebugCommand

type DebugCommand struct {
	Message string
}

DebugCommand logs a message

type DefaultCuller

type DefaultCuller struct{}

DefaultCuller implements a scenegraph culler. The policy for this culler is to mark all nodes in frustum for drawing. The node's modelMatrix state uniform is also set from the nodes worldtransform. This may change as we transition away from individual uniforms for instanced/indirect drawing.

func (*DefaultCuller) Run

func (cc *DefaultCuller) Run(scene *Scene, camera *Camera, node *Node)

Run implements the CullComponent interface

type DefaultLightExtractor

type DefaultLightExtractor struct{}

DefaultLightExtractor is a LightExtractor which adds a nodes's light to the bucket if the node is active.

func (*DefaultLightExtractor) Run

func (lc *DefaultLightExtractor) Run(node *Node, lightBucket *[]*Light)

Run implements the LightExtractor interface

type DefaultPhysicsComponent

type DefaultPhysicsComponent struct{}

DefaultPhysicsComponent is a utility physics component which adds all nodes containing a rigid body to the bucket.

func NewDefaultPhysicsComponent

func NewDefaultPhysicsComponent(active bool) *DefaultPhysicsComponent

NewDefaultPhysicsComponent returns a new DefaultPhysicsComponent.

func (*DefaultPhysicsComponent) Run

func (p *DefaultPhysicsComponent) Run(n *Node, nodeBucket *[]*Node)

Run implements the PhysicsComponent interface

type Descriptors

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

Descriptors contains material properties for a specific drawable

func NewDescriptors

func NewDescriptors() Descriptors

NewDescriptors returns a new MaterialData

func (*Descriptors) InstanceData

func (s *Descriptors) InstanceData() [4]mgl32.Vec4

InstanceData returns the descriptor per instance data

func (*Descriptors) SetInstanceDataField

func (s *Descriptors) SetInstanceDataField(index int, v mgl32.Vec4)

SetInstanceDataField returns the descriptor per instance data

func (*Descriptors) SetTexture

func (s *Descriptors) SetTexture(name string, t Texture)

SetTexture sets the material's texture named `name` to the provided texture

func (*Descriptors) Texture

func (s *Descriptors) Texture(name string) Texture

Texture returns the material texture with the specified name

func (*Descriptors) Textures

func (s *Descriptors) Textures() map[string]Texture

Textures returns the material's textures

func (*Descriptors) Uniform

func (s *Descriptors) Uniform(name string) Uniform

Uniform returns the uniform with the given name.

func (*Descriptors) UniformBuffer

func (s *Descriptors) UniformBuffer(name string) UniformBuffer

UniformBuffer returns the uniform buffer with the given name

func (*Descriptors) UniformBuffers

func (s *Descriptors) UniformBuffers() map[string]UniformBuffer

UniformBuffers returns the state's uniform buffers

func (*Descriptors) Uniforms

func (s *Descriptors) Uniforms() map[string]Uniform

Uniforms returns the state's uniform map.

type DrawCommand

type DrawCommand struct {
	Mesh Mesh
}

DrawCommand draws a mesh

type DrawIMGUICommand

type DrawIMGUICommand struct {
}

DrawIMGUICommand draws an IMGUI

type DrawInstancedCommand

type DrawInstancedCommand struct {
	Mesh          Mesh
	InstanceCount int
	InstanceData  unsafe.Pointer
}

DrawInstancedCommand draws a mesh using instancing

type Framebuffer

type Framebuffer interface {
	// SetColorAttachment sets the color attachment at the specified index.
	SetColorAttachment(index int, attachment Texture)

	// ColorAttachments returns the framebuffer color attachments.
	ColorAttachments() map[int]Texture

	// ColorAttachment returns the color attachment at the specified index.
	ColorAttachment(index int) Texture

	// SetDepthAttachment sets the depth attachment.
	SetDepthAttachment(attachment Texture)

	// DepthAttachment returns the framebuffer depth attachment
	DepthAttachment() Texture
}

Framebuffer is an interface which wraps a render target. This contains information about depth and color attachments, dimensions.

type IMGUICommand

type IMGUICommand struct {
	ElementCount int
	ClipRect     [4]float32
	TextureID    unsafe.Pointer
}

IMGUICommand represents an individual draw command for the RenderSystem to present a part of the UI.

type IMGUICommandList

type IMGUICommandList struct {
	CmdBufferSize    int
	VertexBufferSize int
	IndexBufferSize  int
	VertexPointer    unsafe.Pointer
	IndexPointer     unsafe.Pointer
	Commands         []IMGUICommand
}

IMGUICommandList returns a list of draw commands for the RenderSystem to present the entire UI.

type IMGUIDrawData

type IMGUIDrawData interface {
	CommandListCount() int
	GetCommandList(int) *IMGUICommandList
}

IMGUIDrawData is an interface which exposes methods for retrieving command lists from implementations.

type IMGUISystem

type IMGUISystem interface {
	// Start is called at application startup. This is where implementations should check
	// for fonts, create their textures, etc.
	Start()

	// Stop is called at application shutdown. Implementations will want to perform cleanup here.
	Stop()

	// StartFrame is called at the draw stage of the runloop.
	StartFrame(dt float64)

	// EndFrame is called at the end of the draw stage of the runloop.
	EndFrame()

	// Begin creates a new widget and returns whether it is visible.
	Begin(name string, flags WindowFlags) bool

	// End closes the current active widget.
	End()

	// DisplaySize returns the current display size.
	DisplaySize() mgl32.Vec2

	// SetDisplaySize sets the display size. This is called by the application on every
	// iteration of the runloop. Implementations should check this for window resizes.
	SetDisplaySize(mgl32.Vec2)

	// SetNextWindowPos is used to request a position for the next window that gets created.
	SetNextWindowPos(mgl32.Vec2)

	// SetNextWindowSize is used to request a size for the next window that gets created.
	SetNextWindowSize(mgl32.Vec2)

	// GetDrawData returns IMGUIDrawData which is used by the RenderSystem to present the UI on screen.
	GetDrawData() IMGUIDrawData

	// CollapsingHeader returns a widget with a collapsing header.
	CollapsingHeader(name string) bool

	//PlotHistogram draws a histogram on a widget using the passed name and values. minScale and maxScale set
	// the Y axis scale and size sets the widgets width and height.
	PlotHistogram(name string, values []float32, minScale, maxScale float32, size mgl32.Vec2)

	// Image draws a texture on a widget with the provided size.
	Image(texture Texture, size mgl32.Vec2)

	// Text displays a text box
	Text(data string)
}

IMGUISystem is the interface that wraps an immediate mode GUI component.

func GetIMGUISystem

func GetIMGUISystem() IMGUISystem

GetIMGUISystem returns the IMGUISystem, thereby exposing it to any package importing core.

type InputComponent

type InputComponent interface {
	// Run returns commands from a given node to itself.
	Run(node *Node) []NodeCommand
}

InputComponent is an interface which returns NodeCommands from nodes. Each node may have its own input component which checks the manager for input and determines what commands should be output.

type InputManager

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

InputManager wraps global input state. WindowSystem implementations use the manager to expose input state to the system.

func GetInputManager

func GetInputManager() *InputManager

GetInputManager returns the manager.

func (*InputManager) KeyCallback

func (i *InputManager) KeyCallback(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey)

KeyCallback is called by windowsystems to register key events.

func (*InputManager) MouseButtonCallback

func (i *InputManager) MouseButtonCallback(window *glfw.Window, button glfw.MouseButton, action glfw.Action, mods glfw.ModifierKey)

MouseButtonCallback is called by windowsystems to register mouse button events.

func (*InputManager) MouseMoveCallback

func (i *InputManager) MouseMoveCallback(window *glfw.Window, x, y float64)

MouseMoveCallback is called by windowsystems to register mouse move events.

func (*InputManager) MouseScrollCallback

func (i *InputManager) MouseScrollCallback(window *glfw.Window, x, y float64)

MouseScrollCallback is called by windowsystems to register mouse scroll events.

func (*InputManager) State

func (i *InputManager) State() *InputState

State returns the manager's input state.

type InputState

type InputState struct {
	Mouse MouseState
	Keys  KeyState
}

InputState wraps mouse and keys input state.

func (*InputState) SetKeysValid

func (i *InputState) SetKeysValid(valid bool)

SetKeysValid sets the key state as valid. It will not be processed unless this is set.

func (*InputState) SetMouseValid

func (i *InputState) SetMouseValid(valid bool)

SetMouseValid sets the mouse state as valid. It will not be processed unless this is set.

type InstanceData

type InstanceData struct {
	ModelMatrix               mgl32.Mat4
	ModelViewProjectionMatrix mgl32.Mat4
	Custom                    [4]mgl32.Vec4
}

InstanceData holds the per-instance-data when using instanced drawing. It is automatically populated by all the included RenderTechniques. Use node.GetInstanceData() to change its custom values

type KeyState

type KeyState struct {
	Valid    bool
	Mods     map[glfw.Key]bool
	Active   map[glfw.Key]bool
	Released map[glfw.Key]bool
}

KeyState holds key input state.

type Light

type Light struct {
	Block    LightBlock
	Shadower Shadower
}

Light represents a light. It contains a properties block and an optional shadower.

type LightBlock

type LightBlock struct {
	VPMatrix [maxCascades]mgl32.Mat4
	ZCuts    [maxCascades]mgl32.Vec4
	Position mgl32.Vec4
	Color    mgl32.Vec4
}

LightBlock holds a light's properties. It is embedded in a sceneblock and passed to every program.

type LightExtractor

type LightExtractor interface {
	// Run extracts light from a node and adds it to lightBucket.
	Run(node *Node, lightBucket *[]*Light)
}

LightExtractor is an interface which extracts a light from a node and adds it to a bucket.

type Mesh

type Mesh interface {
	SetPrimitiveType(PrimitiveType)

	SetPositions(positions []float32)
	SetNormals(normals []float32)
	SetTextureCoordinates(coordinates []float32)
	SetIndices(indices []uint16)

	SetName(name string)
	Name() string
	Draw()
	DrawInstanced(int, unsafe.Pointer)

	Bounds() *AABB

	Lt(Mesh) bool
	Gt(Mesh) bool
}

Mesh is an interface which wraps handling of geometry.

func AABBMesh

func AABBMesh() Mesh

AABBMesh returns a normalized cube centered at the origin. This is used to draw bounding boxes by translating and scaling it according to node bounds.

func NewScreenQuadMesh

func NewScreenQuadMesh(width, height float32) Mesh

NewScreenQuadMesh returns a mesh to be drawn by an orthographic projection camera.

type MouseButtonState

type MouseButtonState struct {
	Valid  bool
	Active map[glfw.MouseButton]bool
	Action int
}

MouseButtonState holds the mouse button state.

type MouseCameraInputComponent

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

MouseCameraInputComponent is a utility inputcomponent for simple camera movement.

func NewMouseCameraInputComponent

func NewMouseCameraInputComponent() *MouseCameraInputComponent

NewMouseCameraInputComponent returns a default inputcomponent for use with camera nodes which uses the mouse wheel to set the camera's velocity on 10x increments (world units/second).

func (*MouseCameraInputComponent) Run

func (ic *MouseCameraInputComponent) Run(node *Node) []NodeCommand

Run implements the InputComponent interface.

type MouseCameraMoveCommand

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

MouseCameraMoveCommand is a utility command for simple camera movement.

func (MouseCameraMoveCommand) Run

func (mc MouseCameraMoveCommand) Run(node *Node)

Run implements the NodeCommand interface

type MouseCameraRotateCommand

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

MouseCameraRotateCommand is a utility command for simple camera movement.

func (MouseCameraRotateCommand) Run

func (rc MouseCameraRotateCommand) Run(node *Node)

Run implements the NodeCommand interface

type MousePositionState

type MousePositionState struct {
	Valid bool
	X     float64
	Y     float64
	DistX float64
	DistY float64
}

MousePositionState holds the mouse position information.

type MouseScrollState

type MouseScrollState struct {
	Valid bool
	X     float64
	Y     float64
}

MouseScrollState holds the mouse scroll state.

type MouseState

type MouseState struct {
	Valid    bool
	Position MousePositionState
	Scroll   MouseScrollState
	Buttons  MouseButtonState
}

MouseState holds mouse input state.

type Node

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

Node represents a scenegraph node.

func LoadModel

func LoadModel(name string, res []byte) *Node

LoadModel parses model data from a raw resource and returns a node ready to insert into the screnegraph

func NewNode

func NewNode(name string) *Node

NewNode returns a new node named `name`.

func (*Node) Active

func (n *Node) Active() bool

Active returns whether the node is active.

func (*Node) AddChild

func (n *Node) AddChild(c *Node)

AddChild adds a child to the node

func (*Node) Bounds

func (n *Node) Bounds() *AABB

Bounds returns the node's bounds in object-space

func (*Node) Children

func (n *Node) Children() []*Node

Children returns the node's children.

func (*Node) Copy

func (n *Node) Copy() *Node

Copy deep copies a node.

func (*Node) CullComponent

func (n *Node) CullComponent() Culler

CullComponent returns the node's culler

func (*Node) InputComponent

func (n *Node) InputComponent() InputComponent

InputComponent returns the node's input component.

func (*Node) InverseWorldTransform

func (n *Node) InverseWorldTransform() mgl64.Mat4

InverseWorldTransform returns the node's inverse world transform.

func (*Node) Light

func (n *Node) Light() *Light

Light returns the node's light.

func (*Node) MaterialData

func (n *Node) MaterialData() *Descriptors

MaterialData returns the node's state

func (*Node) Mesh

func (n *Node) Mesh() Mesh

Mesh returns the node's mesh.

func (*Node) Name

func (n *Node) Name() string

Name returns the node's name.

func (*Node) Parent

func (n *Node) Parent() *Node

Parent returns the node's parent.

func (*Node) PhysicsComponent

func (n *Node) PhysicsComponent() PhysicsComponent

PhysicsComponent returns the node's physics component.

func (*Node) RemoveChild

func (n *Node) RemoveChild(c *Node)

RemoveChild removes a node's child.

func (*Node) RemoveChildren

func (n *Node) RemoveChildren()

RemoveChildren removes all of a node's children.

func (*Node) RigidBody

func (n *Node) RigidBody() RigidBody

RigidBody returns the node's rigid body

func (*Node) Rotate

func (n *Node) Rotate(eulerAngle float64, axis mgl64.Vec3)

Rotate rotates the node by `eulerAngle` degrees around `axis`.

func (*Node) Scale

func (n *Node) Scale(s mgl64.Vec3)

Scale scales a node.

func (*Node) SetActive

func (n *Node) SetActive(active bool)

SetActive marks the node as active.

func (*Node) SetBoundsCallback

func (n *Node) SetBoundsCallback(f BoundsCallbackFn)

SetBoundsCallback sets a boundsCallback function

func (*Node) SetChildrenActive

func (n *Node) SetChildrenActive(active bool)

SetChildrenActive marks all of the nodes's children as active.

func (*Node) SetCullComponent

func (n *Node) SetCullComponent(cc Culler)

SetCullComponent sets the node's culler.

func (*Node) SetInputComponent

func (n *Node) SetInputComponent(ic InputComponent)

SetInputComponent sets the node's input component.

func (*Node) SetLight

func (n *Node) SetLight(l *Light)

SetLight set's the node's light

func (*Node) SetMesh

func (n *Node) SetMesh(m Mesh)

SetMesh sets the node's mesh.

func (*Node) SetRigidBody

func (n *Node) SetRigidBody(r RigidBody)

SetRigidBody sets the node's rigid body.

func (*Node) SetState

func (n *Node) SetState(s *protos.State)

SetState sets the node's pipeline state

func (*Node) SetUpdateComponent

func (n *Node) SetUpdateComponent(uc Updater)

SetUpdateComponent sets the node's update component.

func (*Node) SetWorldTransform

func (n *Node) SetWorldTransform(transform mgl64.Mat4)

SetWorldTransform sets the node's world transform. It also sets the node's transform appropriately.

func (*Node) State

func (n *Node) State() *protos.State

State returns the node's state

func (*Node) Transform

func (n *Node) Transform() mgl64.Mat4

Transform returns the node's transform

func (*Node) Translate

func (n *Node) Translate(vec mgl64.Vec3)

Translate translates a node.

func (*Node) UpdateComponent

func (n *Node) UpdateComponent() Updater

UpdateComponent returns the node's update component.

func (*Node) WorldBounds

func (n *Node) WorldBounds() *AABB

WorldBounds returns the node's bounds in world-space

func (*Node) WorldDistance

func (n *Node) WorldDistance(n2 *Node) float64

WorldDistance returns the distance between this node and the passed node, computed using node centerpoints/world position

func (*Node) WorldPosition

func (n *Node) WorldPosition() mgl64.Vec3

WorldPosition returns the node's world position

func (*Node) WorldTransform

func (n *Node) WorldTransform() mgl64.Mat4

WorldTransform returns the node's world transform.

type NodeCommand

type NodeCommand interface {
	Run(node *Node)
}

NodeCommand is an interface which wraps logic for running a command against a node.

type NodesByCameraDistanceNearToFar

type NodesByCameraDistanceNearToFar struct {
	Nodes   []*Node
	RefNode *Node
}

NodesByCameraDistanceNearToFar is used to sort nodes according to camera distance from near to far.

func (NodesByCameraDistanceNearToFar) Len

Len implements the sort.Interface interface.

func (NodesByCameraDistanceNearToFar) Less

Less implements the sort.Interface interface.

func (NodesByCameraDistanceNearToFar) Swap

func (a NodesByCameraDistanceNearToFar) Swap(i, j int)

Swap implements the sort.Interface interface.

type NodesByMaterial

type NodesByMaterial []*Node

NodesByMaterial is used to sort nodes according to material.

func (NodesByMaterial) Len

func (a NodesByMaterial) Len() int

Len implements the sort.Interface interface

func (NodesByMaterial) Less

func (a NodesByMaterial) Less(i, j int) bool

Less implements the sort.Interface interface.

func (NodesByMaterial) Swap

func (a NodesByMaterial) Swap(i, j int)

Swap implements the sort.Interface interface.

type NodesByName

type NodesByName struct {
	Nodes []*Node
}

NodesByName is used to sort nodes by alphabetic name order.

func (NodesByName) Len

func (a NodesByName) Len() int

Len implements the sort.Interface interface.

func (NodesByName) Less

func (a NodesByName) Less(i, j int) bool

Less implements the sort.Interface interface.

func (NodesByName) Swap

func (a NodesByName) Swap(i, j int)

Swap implements the sort.Interface interface.

type PhysicsComponent

type PhysicsComponent interface {
	// Run is called on each node which should determine whether it should be added to the simulation step or not.
	Run(node *Node, nodeBucket *[]*Node)
}

PhysicsComponent is an interface which wraps physics handling logic for a scenegraph node

type PhysicsSystem

type PhysicsSystem interface {
	// Start is called by the application at startup time. Implementations should perform bootstapping here.
	Start()

	// Stop is called by the application at shutdown time. Implementations should perform cleanup here.
	Stop()

	// Update is called at every cycle of the application runloop with a list of nodes and a time delta from the
	// previous iteration. Implementations will want to perform all their computation here.
	Update(dt float64, nodes []*Node)

	// SetGravity sets the global gravity vector. This is for testing purposes and will be removed.
	SetGravity(g mgl64.Vec3)

	// AddRigidBody adds a rigid body to the physics world.
	AddRigidBody(RigidBody)

	// RemoveRigidBody removed a rigid body from the physics world.
	RemoveRigidBody(RigidBody)

	// CreateRigidBody creates a new rigid body which can be attached to a scenegraph node.
	CreateRigidBody(mass float32, collisionShape CollisionShape) RigidBody

	// DeleteRigidBody deletes a rigid body
	DeleteRigidBody(RigidBody)

	// NewStaticPlaneShape returns a collision shape.
	NewStaticPlaneShape(normal mgl64.Vec3, constant float64) CollisionShape

	// NewSphereShape returns a collision shape.
	NewSphereShape(radius float64) CollisionShape

	// NewBoxShape returns a collision shape.
	NewBoxShape(mgl64.Vec3) CollisionShape

	// NewCapsuleShape returns a collision shape.
	NewCapsuleShape(radius float64, height float64) CollisionShape

	// NewConeShape returns a collision shape.
	NewConeShape(radius float64, height float64) CollisionShape

	// NewCylinderShape returns a collision shape.
	NewCylinderShape(radius float64, height float64) CollisionShape

	// NewCompoundSphereShape returns a collision shape.
	NewCompoundShape() CollisionShape

	// NewConvexHullShape returns a collision shape.
	NewConvexHullShape() CollisionShape

	// NewStaticTriangleMeshShape returns a collision shape.
	NewStaticTriangleMeshShape(Mesh) CollisionShape

	// DeleteShape deletes a collision shape.
	DeleteShape(CollisionShape)
}

PhysicsSystem is an interface which wraps all physics related logic.

func GetPhysicsSystem

func GetPhysicsSystem() PhysicsSystem

GetPhysicsSystem returns the renderSystem, thereby exposing it to any package importing core.

type Platform

type Platform uint8

Platform is an OS

const (
	PlatformDarwin  Platform = iota
	PlatformLinux   Platform = iota
	PlatformWindows Platform = iota
)

Supported platforms

func GetPlatform

func GetPlatform() Platform

GetPlatform returns the current platform.

type PrimitiveType

type PrimitiveType uint8

PrimitiveType is a raster primitive type.

const (
	PrimitiveTypeTriangles PrimitiveType = iota
	PrimitiveTypePoints
	PrimitiveTypeLines
)

Supported primitive types

type Program

type Program interface {
	Name() string
}

Program is an interface which wraps a GPU program (OpenGL, etc). This will be removed soon and programs will be accessed by name handle via the resource system or abstracted in opaque material definitions.

type ProjectionType

type ProjectionType uint8

ProjectionType is used to express projection types (ie: perspective, orthographic).

const (
	// PerspectiveProjection represents a perspective projection.
	PerspectiveProjection ProjectionType = iota

	// OrthographicProjection represents an orthographic projection.
	OrthographicProjection
)

type RenderCommand

type RenderCommand interface{}

RenderCommand is a generic render command item

type RenderSystem

type RenderSystem interface {
	// PrepareWindow initializes a new window
	PreMakeWindow()
	PostMakeWindow(cfg WindowConfig, window *glfw.Window)

	// NewMesh retuns a new mesh.
	NewMesh() Mesh

	// ProgramExtension exposes the resource extension of program definitions for the implementation.
	ProgramExtension() string

	// NewProgram creates a new program from a list of subprogram source files.
	NewProgram(name string, data []byte) Program

	// NewTexture creates a new texture from a byte buffer containing an image file, not raw bitmap.
	// This always generates RGBA, unsigned byte and will generate mipmaps levels from
	// smallest dimension, ie: 2048x1024 = 10 mipmap levels; log2(1024)
	// It also defaults to ClampEdge and mipmapped filtering.
	NewTextureFromImageData(r []byte, d TextureDescriptor) Texture

	// NewUniform creates a new empty uniform
	NewUniform() Uniform

	// NewUniformBuffer creates a new empty uniform buffer
	NewUniformBuffer() UniformBuffer

	// NewRawTexture creates a new texture and allocates storage for it
	NewTexture(descriptor TextureDescriptor, data []byte) Texture

	// NewFramebuffer returns a newly created framebuffer
	NewFramebuffer() Framebuffer

	// Dispatch runs a rendercommand
	Dispatch(RenderCommand)

	// CanBatch returns whether two nodes can be batched in the same drawcall
	CanBatch(a *Descriptors, b *Descriptors) bool

	// RenderLog returns a log of the render plan
	RenderLog() string
}

RenderSystem is an interface which wraps all logic related to rendering and memory management of GPU buffers.

func GetRenderSystem

func GetRenderSystem() RenderSystem

GetRenderSystem returns the renderSystem, thereby exposing it to any package importing core.

type ResourceManager

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

ResourceManager wraps a resourcesystem and contains configuration about the location of each resource type.

func GetResourceManager

func GetResourceManager() *ResourceManager

GetResourceManager returns the resource manager. Used by client applications to load assets.

func (*ResourceManager) Model

func (r *ResourceManager) Model(name string) *Node

Model returns a scenegraph node with a subtree of nodes containing meshes which represent a complex model.

func (*ResourceManager) Program

func (r *ResourceManager) Program(name string) Program

Program returns a GPU program.

func (*ResourceManager) ProgramData

func (r *ResourceManager) ProgramData(name string) []byte

ProgramData returns source file contents for a given program or subprogram This is meant to be used by rendersystem implementations to load subresources for a program spec

func (*ResourceManager) SetSystem

func (r *ResourceManager) SetSystem(s ResourceSystem)

SetSystem sets the resource manager's resource system

func (*ResourceManager) State

func (r *ResourceManager) State(name string) *protos.State

State returns a State

type ResourceSystem

type ResourceSystem interface {
	// Model returns a byte array representing a model.
	Model(string) []byte

	// Texture returns a byte array representing a texture.
	Texture(string) []byte

	// Program returns a byte array representing a program.
	Program(string) []byte

	// State returns a byte array representing a raster state
	State(string) []byte

	// ProgramData returns a byte array representing program data.
	ProgramData(string) []byte
}

ResourceSystem is an interface which wraps all resource management logic.

type RigidBody

type RigidBody interface {
	// GetTransform returns the rigid body world transform.
	GetTransform() mgl64.Mat4

	// SetTransform sets the rigid body world transform.
	SetTransform(mgl64.Mat4)

	// ApplyImpulse applies `impulse` on the rigid body at its position `localPosition`.
	ApplyImpulse(impulse mgl64.Vec3, localPosition mgl64.Vec3)
}

RigidBody is an interface which wraps a physics rigid body. It contains position, orientation, momentum and collision shape information.

type Scene

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

Scene represents a scenegraph and contains information about how it should be composed with other scenes on a scene stack. Scenes are not meant to be wrapped by users, but to be data configured for the expected behaviour.

func NewIMGUIScene

func NewIMGUIScene(name string, inputComponent InputComponent) *Scene

NewIMGUIScene returns a Scene which draws a UI. Users will want to use this to display a UI on top of other scenes.

func NewScene

func NewScene(name string) *Scene

NewScene returns a new scene.

func (*Scene) Active

func (s *Scene) Active() bool

Active returns whether this scene is active or not

func (*Scene) AddCamera

func (s *Scene) AddCamera(node *Node, camera *Camera)

AddCamera adds a camera to the scene by attaching it to the given node.

func (*Scene) Camera

func (s *Scene) Camera(name string) *Camera

Camera returns a scene camera by name

func (*Scene) Cameras

func (s *Scene) Cameras() []*Camera

Cameras returns the scene's cameras

func (*Scene) Name

func (s *Scene) Name() string

Name returns the scene's name

func (*Scene) Root

func (s *Scene) Root() *Node

Root returns the scene's root node

func (*Scene) SetActive

func (s *Scene) SetActive(active bool)

SetActive sets the 'active' state of this scene

func (*Scene) SetRoot

func (s *Scene) SetRoot(root *Node)

SetRoot returns the scene's root node

type SceneManager

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

SceneManager manages a stack of scenes

func GetSceneManager

func GetSceneManager() *SceneManager

GetSceneManager returns the scene manager.

func (*SceneManager) FrontScene

func (sm *SceneManager) FrontScene() *Scene

FrontScene returns the front scene.

func (*SceneManager) PopScene

func (sm *SceneManager) PopScene() *Scene

PopScene pops a scene from the stack

func (*SceneManager) PushScene

func (sm *SceneManager) PushScene(s *Scene)

PushScene pushes a scene to the stack.

type SetFramebufferCommand

type SetFramebufferCommand struct {
	Framebuffer Framebuffer
}

SetFramebufferCommand sets the current framebuffer

type SetViewportCommand

type SetViewportCommand struct {
	Viewport mgl32.Vec4
}

SetViewportCommand sets the current viewport

type ShadowMap

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

ShadowMap is a utility implementation of the Shadower interface which renders shadows by using a cascading shadow map.

func NewShadowMap

func NewShadowMap(size uint32) *ShadowMap

NewShadowMap returns a new ShadowMap

func (*ShadowMap) Render

func (s *ShadowMap) Render(light *Light, cam *Camera)

Render implements the Shadower interface

func (*ShadowMap) Textures

func (s *ShadowMap) Textures() []Texture

Textures implements the Shadower interface

type Shadower

type Shadower interface {
	// Textures returns the shadow textures used by this shadower
	Textures() []Texture

	// Render calls the shadower render implementation by assing a light and a scene camera.
	Render(*Light, *Camera)
}

Shadower is an interface which wraps logic to implement shadowing of a light

type Texture

type Texture interface {
	Descriptor() TextureDescriptor

	Handle() unsafe.Pointer

	// Lt is used for sorting
	Lt(Texture) bool

	// Gt
	Gt(Texture) bool

	// SetFilter
	SetFilter(TextureFilter)

	// SetWrapMode
	SetWrapMode(TextureWrapMode)
}

Texture is an interface which wraps both a texture and settings for samplers sampling it

type TextureComponentType

type TextureComponentType int

TextureComponentType specifies the texture component storage type

const (
	TextureComponentTypeUNSIGNEDBYTE TextureComponentType = iota
	TextureComponentTypeFLOAT
)

These are the supported texture component storate types

type TextureDescriptor

type TextureDescriptor struct {
	Width         uint32
	Height        uint32
	Mipmaps       bool
	Target        TextureTarget
	Format        TextureFormat
	SizedFormat   TextureSizedFormat
	ComponentType TextureComponentType
	Filter        TextureFilter
	WrapMode      TextureWrapMode
}

TextureDescriptor contains the full description of a texture and its sampling parameters It is used as input to texture creation functions and at runtime inside rendersystems to setup samplers and memory allocation

type TextureFilter

type TextureFilter int

TextureFilter specifies the type of interpolation a sampler of this texture will use

const (
	TextureFilterNearest TextureFilter = iota
	TextureFilterLinear
	TextureFilterMipmapLinear
)

These are the supported texture filtering modes

type TextureFormat

type TextureFormat int

TextureFormat holds the texture component layout

const (
	TextureFormatR TextureFormat = iota
	TextureFormatRG
	TextureFormatRGB
	TextureFormatRGBA
	TextureFormatDEPTH
)

These are the several supported texture component layouts

type TextureSizedFormat

type TextureSizedFormat int

TextureSizedFormat specified the format and size of a texture's components

const (
	TextureSizedFormatR8 TextureSizedFormat = iota
	TextureSizedFormatR16F
	TextureSizedFormatR32F
	TextureSizedFormatRG8
	TextureSizedFormatRG16F
	TextureSizedFormatRG32F
	TextureSizedFormatRGB8
	TextureSizedFormatRGB16F
	TextureSizedFormatRGB32F
	TextureSizedFormatRGBA8
	TextureSizedFormatRGBA16F
	TextureSizedFormatRGBA32F
	TextureSizedFormatDEPTH32F
)

These are the several supportex texture component sizes

type TextureTarget

type TextureTarget int

TextureTarget specifies a texture target type (1D, 2D, 2DArray, Cubemap, etc)

const (
	TextureTarget1D TextureTarget = iota
	TextureTarget1DArray
	TextureTarget2D
	TextureTarget2DArray
	TextureTargetCubemapXPositive
	TextureTargetCubemapXNegative
	TextureTargetCubemapYPositive
	TextureTargetCubemapYNegative
	TextureTargetCubemapZPositive
	TextureTargetCubemapZNegative
)

TextureTargetXXX are the different texture types

type TextureWrapMode

type TextureWrapMode int

TextureWrapMode specifies the type of wrap around a sampler of this texture will use

const (
	TextureWrapModeClampEdge TextureWrapMode = iota
	TextureWrapModeClampBorder
	TextureWrapModeRepeat
)

These are the supported texture wrap modes

type TimerHistogram

type TimerHistogram struct {
	Values []float32
	Min    float32
	Max    float32
}

TimerHistogram is a generic histogram of values with a min/max range.

type TimerManager

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

TimerManager wraps the system's high resolution timer

func GetTimerManager

func GetTimerManager() *TimerManager

GetTimerManager returns the timer manager.

func (*TimerManager) AvgFPS

func (ts *TimerManager) AvgFPS() float64

AvgFPS returns a smoothed average of FPS.

func (*TimerManager) Dt

func (ts *TimerManager) Dt() float64

Dt returns the system time delta.

func (*TimerManager) FPS

func (ts *TimerManager) FPS() float64

FPS returns the current FPS rate.

func (*TimerManager) FrameStartTime

func (ts *TimerManager) FrameStartTime() float64

FrameStartTime returns the time at which the current frame started in number of seconds since application startup.

func (*TimerManager) Histogram

func (ts *TimerManager) Histogram() TimerHistogram

Histogram returns the frame duration histogram.

func (*TimerManager) Pause

func (ts *TimerManager) Pause()

Pause pauses the system timer.

func (*TimerManager) Paused

func (ts *TimerManager) Paused() bool

Paused returns whether the system timer is paused.

func (*TimerManager) SetDt

func (ts *TimerManager) SetDt(dt float64)

SetDt is called by windowsystem implementations to set the time elapsed since last refreshed.

func (*TimerManager) Start

func (ts *TimerManager) Start()

Start starts/resumes the system timer.

func (*TimerManager) Time

func (ts *TimerManager) Time() float64

Time returns the system time in number of seconds since application startup.

type Uniform

type Uniform interface {

	// Value returns the Uniform's value
	Value() interface{}

	// Set sets the Uniform's value
	Set(interface{})

	// Copy returns a copy of the Uniform
	Copy() Uniform
}

Uniform is an interface which wraps program Uniforms

type UniformBuffer

type UniformBuffer interface {
	Set(unsafe.Pointer, int)

	// Lt is used for sorting
	Lt(UniformBuffer) bool

	// Gt
	Gt(UniformBuffer) bool
}

UniformBuffer is an interface which wraps program UniformBuffers

type Updater

type Updater interface {
	// Run updates a scenegraph node.
	Run(*Node)
}

Updater is an interface that wraps updating a node.

type WindowConfig

type WindowConfig struct {
	Name              string
	Monitor           *glfw.Monitor
	Width, Height, Hz int
	Fullscreen        bool
	Vsync             int
}

WindowConfig is used by client applications to request a specific video mode from a monitor by calling InitWindow and passing it as an argument.

type WindowFlags

type WindowFlags int32

WindowFlags holds a set of properties for window layout.

const (
	// WindowFlagsNoTitleBar hides the window title bar/
	WindowFlagsNoTitleBar WindowFlags = 1 << iota

	// WindowFlagsNoResize disallows window resizing.
	WindowFlagsNoResize

	//WindowFlagsNoMove disallows moving the window.
	WindowFlagsNoMove

	// WindowFlagsNoScrollbar hides the scrollbar.
	WindowFlagsNoScrollbar

	// WindowFlagsNoScrollWithMouse disallows using wheel for scrolling.
	WindowFlagsNoScrollWithMouse

	// WindowFlagsNoCollapse disables window collapsing.
	WindowFlagsNoCollapse

	// WindowFlagsAlwaysAutoResize enables window auto resizing.
	WindowFlagsAlwaysAutoResize

	// WindowFlagsShowBorders shows the window border.
	WindowFlagsShowBorders

	// WindowFlagsNoSavedSettings disabled saving/using saved window settings.
	WindowFlagsNoSavedSettings

	// WindowFlagsNoInputs disables input handling.
	WindowFlagsNoInputs

	// WindowFlagsMenuBar enables a menubar on the window.
	WindowFlagsMenuBar

	// WindowFlagsHorizontalScrollbar enables horizontal scrolling.
	WindowFlagsHorizontalScrollbar

	// WindowFlagsNoFocusOnAppearing disables auto focus when displayed.
	WindowFlagsNoFocusOnAppearing

	// WindowFlagsNoBringToFrontOnFocus disables moving window to front when focused.
	WindowFlagsNoBringToFrontOnFocus
)

type WindowManager

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

WindowManager exposes windowing to client applications

func GetWindowManager

func GetWindowManager() *WindowManager

GetWindowManager Returns the global WindowManager

func (*WindowManager) CursorPosition

func (w *WindowManager) CursorPosition() (float64, float64)

CursorPosition reports the current cursor position in window coordinates

func (*WindowManager) MakeWindow

func (w *WindowManager) MakeWindow()

MakeWindow created the window manager's window using the previously passed config

func (*WindowManager) SetWindowConfig

func (w *WindowManager) SetWindowConfig(cfg WindowConfig)

SetWindowConfig Sets the config for WindowManager created windows

func (*WindowManager) ShouldClose

func (w *WindowManager) ShouldClose() bool

ShouldClose whether a stop signal is being processed

func (*WindowManager) WindowSize

func (w *WindowManager) WindowSize() mgl32.Vec2

WindowSize the window size

Jump to

Keyboard shortcuts

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