Documentation ¶
Index ¶
- func NewOrthographicCamera(left, right, bottom, top, near, far float32) *orthographicCamera
- func NewPerspectiveCamera(fovy, aspect, near, far float32) *perspectiveCamera
- func NewScreenSpaceCamera(width, height int, near, far float32) *screenSpaceCamera
- func Rand(min, max float32) float32
- type Application
- type Attribute
- type AttributeBuffer
- func (ab *AttributeBuffer) GetX(index int) (x float32)
- func (ab *AttributeBuffer) GetXY(index int) (x, y float32)
- func (ab *AttributeBuffer) GetXYZ(index int) (x, y, z float32)
- func (ab *AttributeBuffer) GetXYZW(index int) (x, y, z, w float32)
- func (ab *AttributeBuffer) Init(name string, size int, NumComponents int)
- func (ab *AttributeBuffer) InitFromData(name string, data []float32, NumComponents int)
- func (ab *AttributeBuffer) Len() int
- func (ab *AttributeBuffer) SetX(index int, x float32)
- func (ab *AttributeBuffer) SetXY(index int, x, y float32)
- func (ab *AttributeBuffer) SetXYZ(index int, x, y, z float32)
- func (ab *AttributeBuffer) SetXYZW(index int, x, y, z, w float32)
- type BaseCamera
- type BaseMaterial
- type Blending
- type BlendingFunc
- type BlendingMode
- type Camera
- type Color
- func (color *Color) FromHSL(h, s, l float32)
- func (color *Color) FromRGB(r, g, b float32)
- func (color *Color) FromRGBA(r, g, b, a float32)
- func (color *Color) FromRGBAu8(r, g, b, a uint8)
- func (color *Color) FromRGBu8(r, g, b uint8)
- func (color *Color) ToHSL() (h, s, l float32)
- func (color *Color) Vec4() math.Vec4
- type DepthTest
- type DepthTestFunc
- type Drawer
- type FragmentShader
- type Framebuffer
- type Getter
- type Grapher
- type IndexBuffer
- type Material
- type Mesh
- func (m *Mesh) AddAttribute(name string, data []float32, NumComponents int)
- func (m *Mesh) AddAttributeBuffer(buffer *AttributeBuffer)
- func (m *Mesh) AddIndices(data []uint)
- func (m *Mesh) GetAttribute(name string) *AttributeBuffer
- func (m *Mesh) GetVertexMode() VertexMode
- func (m *Mesh) HasIndices() bool
- func (m *Mesh) SetVertexMode(mode VertexMode)
- type MeshRenderer
- type Mesher
- type MouseButton
- type Namer
- type Node
- func (n *Node) AddChild(child Grapher)
- func (n *Node) AddChildren(children ...Grapher)
- func (n *Node) AddComponent(c interface{}) *Node
- func (n *Node) GetChildren() []Grapher
- func (n *Node) GetParent() Grapher
- func (n *Node) GetPosition() *math.Vec3
- func (n *Node) GetRotation() *math.Quaternion
- func (n *Node) GetScale() *math.Vec3
- func (n *Node) GetTransform() *math.Mat4
- func (n *Node) Init()
- func (n *Node) RotateAroundAxis(axis *math.Vec3, angle float32)
- func (n *Node) RotateX(angle float32)
- func (n *Node) RotateY(angle float32)
- func (n *Node) RotateZ(angle float32)
- func (n *Node) Scale(sx, sy, sz float32)
- func (n *Node) ScaleV(s *math.Vec3)
- func (n *Node) ScaleX(sx float32)
- func (n *Node) ScaleY(sy float32)
- func (n *Node) ScaleZ(sz float32)
- func (n *Node) SetPosition(x, y, z float32)
- func (n *Node) SetPositionV(position *math.Vec3)
- func (n *Node) SetRotation(q *math.Quaternion)
- func (n *Node) SetScale(sx, sy, sz float32)
- func (n *Node) SetScaleV(s *math.Vec3)
- func (n *Node) Translate(tx, ty, tz float32)
- func (n *Node) TranslateV(t *math.Vec3)
- func (n *Node) TranslateX(tx float32)
- func (n *Node) TranslateY(ty float32)
- func (n *Node) TranslateZ(tz float32)
- type Polyline
- type Scene
- func (s *Scene) BackgroundColor() *Color
- func (s *Scene) CreateActor(mesher Mesher, material Material) *Node
- func (s *Scene) Draw(fb Framebuffer)
- func (s *Scene) OnKeyPressed()
- func (s *Scene) OnKeyReleased()
- func (s *Scene) OnMouseButtonPressed(button MouseButton, x, y float32)
- func (s *Scene) OnMouseButtonReleased(button MouseButton, x, y float32)
- func (s *Scene) OnMouseMoved(x, y float32)
- func (s *Scene) OnResize(fb Framebuffer, width, height int)
- func (s *Scene) OnRuneEntered(r rune)
- func (s *Scene) SetBackgroundColor(r, g, b, a float32)
- func (s *Scene) SetCamera(camera Camera)
- func (s *Scene) Setup()
- func (s *Scene) TearDown()
- func (s *Scene) Update(time float64)
- type SceneGraph
- type Scener
- type Setter
- type Uniform
- type Updater
- type VariableKind
- type VertexMode
- type VertexShader
- type Window
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewOrthographicCamera ¶
func NewOrthographicCamera(left, right, bottom, top, near, far float32) *orthographicCamera
func NewPerspectiveCamera ¶
func NewPerspectiveCamera(fovy, aspect, near, far float32) *perspectiveCamera
func NewScreenSpaceCamera ¶
Types ¶
type Application ¶
type Application struct { Name string // contains filtered or unexported fields }
Application object is the top level object from which everything else in DaX is derived.
func NewApplication ¶
func NewApplication(name string) *Application
NewApplication creates a new Application. This is a singleton.
func (*Application) CreateWindow ¶
func (app *Application) CreateWindow(name string, width, height int) *Window
CreateWindow creates a window on which scene will be drawn.
type Attribute ¶
type Attribute struct {
// contains filtered or unexported fields
}
Attribute is per-vertex data as input to the vertex shader.
type AttributeBuffer ¶
AttributeBuffer holds per-vertex attribute. There is one AttributeBuffer per kind of data we want to keep with each vertex.
func NewAttributeBuffer ¶
func NewAttributeBuffer(name string, size int, NumComponents int) *AttributeBuffer
func (*AttributeBuffer) GetX ¶
func (ab *AttributeBuffer) GetX(index int) (x float32)
func (*AttributeBuffer) GetXY ¶
func (ab *AttributeBuffer) GetXY(index int) (x, y float32)
func (*AttributeBuffer) GetXYZ ¶
func (ab *AttributeBuffer) GetXYZ(index int) (x, y, z float32)
func (*AttributeBuffer) GetXYZW ¶
func (ab *AttributeBuffer) GetXYZW(index int) (x, y, z, w float32)
func (*AttributeBuffer) Init ¶
func (ab *AttributeBuffer) Init(name string, size int, NumComponents int)
func (*AttributeBuffer) InitFromData ¶
func (ab *AttributeBuffer) InitFromData(name string, data []float32, NumComponents int)
func (*AttributeBuffer) Len ¶
func (ab *AttributeBuffer) Len() int
Len returns the number of elements in the AttributeBuffer. Because each element has a number of components, the length of the Data array is then Len() * NumComponents.
func (*AttributeBuffer) SetX ¶
func (ab *AttributeBuffer) SetX(index int, x float32)
func (*AttributeBuffer) SetXY ¶
func (ab *AttributeBuffer) SetXY(index int, x, y float32)
func (*AttributeBuffer) SetXYZ ¶
func (ab *AttributeBuffer) SetXYZ(index int, x, y, z float32)
func (*AttributeBuffer) SetXYZW ¶
func (ab *AttributeBuffer) SetXYZW(index int, x, y, z, w float32)
type BaseCamera ¶
type BaseCamera struct { Node // contains filtered or unexported fields }
BaseCamera is a struct that can be embedded to make creating custom cameras easier. ScreenSpaceCamera, OrthographicCamera and PerspectiveCamera embed this type and can be used as examples.
func (*BaseCamera) AsNode ¶
func (c *BaseCamera) AsNode() *Node
func (*BaseCamera) GetProjection ¶
func (c *BaseCamera) GetProjection() *math.Mat4
func (*BaseCamera) Init ¶
func (c *BaseCamera) Init()
Init initializes the BaseCamera. Call this function first before anything else.
func (*BaseCamera) LookAt ¶
func (c *BaseCamera) LookAt(target *math.Vec3)
LookAt rotates the camera to look at the target
type BaseMaterial ¶
BaseMaterial holds the common material state and can be used to implement custom materials.
func (*BaseMaterial) GetBlending ¶
func (m *BaseMaterial) GetBlending() *Blending
GetBlending is part of the Material interface.
func (*BaseMaterial) GetDepthTest ¶
func (m *BaseMaterial) GetDepthTest() *DepthTest
GetDepthTest is part of the Material interface.
func (*BaseMaterial) GetFragmentShader ¶
func (m *BaseMaterial) GetFragmentShader() *FragmentShader
GetFragmentShader is part of the Material interface.
type Blending ¶
type Blending struct { Enabled bool ModeRGB BlendingMode ModeAlpha BlendingMode SrcRGB BlendingFunc DstRGB BlendingFunc SrcAlpha BlendingFunc DstAlpha BlendingFunc Color Color }
Blending holds the entire blending state of a Material.
type BlendingFunc ¶
type BlendingFunc int
BlendingFunc is the blending function of a Material.
const ( BlendingOne BlendingFunc = iota BlendingZero BlendingSrcColor BlendingDstColor BlendingOneMinusSrcColor BlendingOneMinusDstColor BlendingSrcAlpha BlendingDstAlpha BlendingOneMinusSrcAlpha BlendingOneMinusDstAlpha BlendingConstantColor BlendingOneMinusConstantColor BlendingConstantAlpha BlendingOneMinusConstantAlpha )
type BlendingMode ¶
type BlendingMode int
BlendingMode is the blending mode of a Material.
const ( BlendingAdd BlendingMode = iota BlendingSubstract BlendingReverseSubstract BlendingMin BlendingMax )
type Color ¶
type Color struct {
R, G, B, A float32
}
Color represents a color encoded in RGBA.
func (*Color) FromHSL ¶
FromHSL initializes a color from (h,s,l) values. h, s, l are between 0 and 1. Conversion formula is adapted from: http://en.wikipedia.org/wiki/HSL_color_space
func (*Color) FromRGB ¶
FromRGB initializes a color from (r,g,b) values. Components should be between 0 and 1. The alpha is initiazed to 1 (fully opaque).
func (*Color) FromRGBA ¶
FromRGBA initializes a color from (r,g,b,a) values. Components should be between 0 and 1.
func (*Color) FromRGBAu8 ¶
FromRGBAu8 initializes a color from (r,g,b,a) values. Components should be between 0 and 255.
func (*Color) FromRGBu8 ¶
FromRGBu8 initializes a color from (r,g,b) values. Components should be between 0 and 255. The alpha is initiazed to 1 (ie 255, fully opaque).
func (*Color) ToHSL ¶
ToHSL converts a color to HSL. Returned (h,s,l) components are between 0 and 1. Conversion formula adapted from: http://en.wikipedia.org/wiki/HSL_color_space.
type DepthTest ¶
type DepthTest struct { Enabled bool Write bool Func DepthTestFunc }
DepthTest holds the entire depth test state of a Material.
type DepthTestFunc ¶
type DepthTestFunc int
DepthTestFunc is the depth test function of a Material.
const ( DepthTestNever DepthTestFunc = iota DepthTestLess DepthTestGreater DepthTestEqual DepthTestAlways DepthTestLessOrEqual DepthTestGreaterOrEqual DepthTestNotEqual )
type Drawer ¶
type Drawer interface {
Draw(fb Framebuffer)
}
Drawer is an object that can draw on a Framebuffer.
type FragmentShader ¶
type FragmentShader struct {
// contains filtered or unexported fields
}
FragmentShader is a program that runs for each fragment.
func NewFragmentShader ¶
func NewFragmentShader(source string) *FragmentShader
NewFragmentShader creates a fragment shader.
func (*FragmentShader) AddUniform ¶
func (s *FragmentShader) AddUniform(kind VariableKind, name string) Uniform
AddUniform adds a uniform to a shader.
type Framebuffer ¶
type IndexBuffer ¶
type IndexBuffer struct {
// contains filtered or unexported fields
}
func (*IndexBuffer) Init ¶
func (ib *IndexBuffer) Init(size int)
func (*IndexBuffer) InitFromData ¶
func (ib *IndexBuffer) InitFromData(data []uint)
func (*IndexBuffer) Len ¶
func (ib *IndexBuffer) Len() int
func (*IndexBuffer) Set ¶
func (ib *IndexBuffer) Set(nth int, index uint)
type Material ¶
type Material interface { // ID is the material ID. This must be unique across all materials. ID() string // GetFragmentShader returns the fragment shader used by this Material. GetFragmentShader() *FragmentShader // GetBlending returns the blending state of the Material. GetBlending() *Blending // GetDepthTest returns the depth test state of the Material. GetDepthTest() *DepthTest }
Material is used to paint geometries.
type Mesh ¶
type Mesh struct {
// contains filtered or unexported fields
}
func (*Mesh) AddAttribute ¶
func (*Mesh) AddAttributeBuffer ¶
func (m *Mesh) AddAttributeBuffer(buffer *AttributeBuffer)
func (*Mesh) AddIndices ¶
func (*Mesh) GetAttribute ¶
func (m *Mesh) GetAttribute(name string) *AttributeBuffer
func (*Mesh) GetVertexMode ¶
func (m *Mesh) GetVertexMode() VertexMode
GetVertexMode returns how vertices in the Mesh are interpreted. New meshes default to VertexModeTriangles.
func (*Mesh) HasIndices ¶
func (*Mesh) SetVertexMode ¶
func (m *Mesh) SetVertexMode(mode VertexMode)
SetVertexMode sets how vertices in the should be interpreted.
type MeshRenderer ¶
type MeshRenderer struct {
// contains filtered or unexported fields
}
MeshRenderer is a component rendering a Mesh with a Material.
func NewMeshRenderer ¶
func NewMeshRenderer(mesher Mesher, material Material) *MeshRenderer
NewMeshRenderer creates a new MeshRenderer.
func (*MeshRenderer) Update ¶
func (mr *MeshRenderer) Update(time float64)
Update implements Updater for MeshRenderer.
type Mesher ¶
type Mesher interface {
GetMesh() *Mesh
}
Mesher is an object that can produce a Mesh.
type MouseButton ¶
type MouseButton glfw.MouseButton
const ( MouseButton1 MouseButton = MouseButton(glfw.MouseButton1) MouseButton2 MouseButton = MouseButton(glfw.MouseButton2) MouseButton3 MouseButton = MouseButton(glfw.MouseButton3) MouseButton4 MouseButton = MouseButton(glfw.MouseButton4) MouseButton5 MouseButton = MouseButton(glfw.MouseButton5) MouseButton6 MouseButton = MouseButton(glfw.MouseButton6) MouseButton7 MouseButton = MouseButton(glfw.MouseButton7) MouseButton8 MouseButton = MouseButton(glfw.MouseButton8) MouseButtonLast MouseButton = MouseButton(glfw.MouseButtonLast) MouseButtonLeft MouseButton = MouseButton(glfw.MouseButtonLeft) MouseButtonRight MouseButton = MouseButton(glfw.MouseButtonRight) MouseButtonMiddle MouseButton = MouseButton(glfw.MouseButtonMiddle) )
Mouse buttons
func (MouseButton) String ¶
func (b MouseButton) String() string
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) AddChildren ¶
AddChildren adds a number of children to the node n.
func (*Node) AddComponent ¶
func (*Node) GetChildren ¶
GetChildren returns the list of children for the node n.
func (*Node) GetPosition ¶
func (*Node) GetRotation ¶
func (n *Node) GetRotation() *math.Quaternion
func (*Node) GetTransform ¶
func (*Node) SetPosition ¶
func (*Node) SetPositionV ¶
func (*Node) SetRotation ¶
func (n *Node) SetRotation(q *math.Quaternion)
func (*Node) TranslateV ¶
func (*Node) TranslateX ¶
func (*Node) TranslateY ¶
func (*Node) TranslateZ ¶
type Polyline ¶
type Polyline struct {
// contains filtered or unexported fields
}
func NewPolyline ¶
func NewPolyline() *Polyline
func NewPolylineWithSize ¶
func (*Polyline) Draw ¶
func (p *Polyline) Draw(fb Framebuffer)
type Scene ¶
type Scene struct {
// contains filtered or unexported fields
}
func (*Scene) BackgroundColor ¶
func (*Scene) CreateActor ¶
CreateActor creates a new node that renders a mesh with a material. This function is a convenience function that creates a Node and adds a MeshRenderer component to it.
func (*Scene) Draw ¶
func (s *Scene) Draw(fb Framebuffer)
func (*Scene) OnKeyPressed ¶
func (s *Scene) OnKeyPressed()
func (*Scene) OnKeyReleased ¶
func (s *Scene) OnKeyReleased()
func (*Scene) OnMouseButtonPressed ¶
func (s *Scene) OnMouseButtonPressed(button MouseButton, x, y float32)
func (*Scene) OnMouseButtonReleased ¶
func (s *Scene) OnMouseButtonReleased(button MouseButton, x, y float32)
func (*Scene) OnMouseMoved ¶
func (*Scene) OnResize ¶
func (s *Scene) OnResize(fb Framebuffer, width, height int)
func (*Scene) OnRuneEntered ¶
func (*Scene) SetBackgroundColor ¶
type SceneGraph ¶
type SceneGraph struct {
Node
}
func NewSceneGraph ¶
func NewSceneGraph() *SceneGraph
func (*SceneGraph) Draw ¶
func (sg *SceneGraph) Draw(fb Framebuffer)
func (*SceneGraph) Init ¶
func (sg *SceneGraph) Init()
func (*SceneGraph) Traverse ¶
func (sg *SceneGraph) Traverse() <-chan Grapher
Depth-first pre-order traversal of the SceneGraph
func (*SceneGraph) Update ¶
func (sg *SceneGraph) Update(time float64)
type Scener ¶
type Scener interface { Setup() TearDown() // XXX: Shouldn't probably be part of the interface, but needed to // generically clear the framebuffer BackgroundColor() *Color Updater Drawer // events OnResize(fb Framebuffer, width, height int) OnKeyPressed() OnKeyReleased() OnMouseMoved(x, y float32) OnMouseButtonPressed(button MouseButton, x, y float32) OnMouseButtonReleased(button MouseButton, x, y float32) OnRuneEntered(r rune) }
type Uniform ¶
type Uniform interface { Namer Kind() VariableKind Getter Setter }
Uniform is a shader parameter, constant per draw call.
type Updater ¶
type Updater interface {
Update(time float64)
}
Updater is an object that would like to be updated at very frame
type VariableKind ¶
type VariableKind int
VariableKind defines the type of a variable in a shader.
const ( // VariableKindFloat is a float uniform. VariableKindFloat VariableKind = iota // VariableKindVec2 is a vec2 uniform. VariableKindVec2 // VariableKindVec3 is a vec3 uniform. VariableKindVec3 // VariableKindVec4 is a vec4 uniform. VariableKindVec4 // VariableKindMat4 is a 4x4 matrix uniform. VariableKindMat4 )
type VertexMode ¶
type VertexMode int
VertexMode defines how vertices should be interpreted by the draw call.
const ( // VertexModePoints draws a single dot for each vertex. VertexModePoints VertexMode = iota VertexModeLineStrip VertexModeLineLoop VertexModeLines VertexModeTriangleStrip VertexModeTriangleFan VertexModeTriangles )
type VertexShader ¶
type VertexShader struct {
// contains filtered or unexported fields
}
VertexShader is a program that runs for each vertex.
func NewVertexShader ¶
func NewVertexShader(source string) *VertexShader
NewVertexShader creates a vertex shader.
func (*VertexShader) AddAttribute ¶
func (vs *VertexShader) AddAttribute(kind VariableKind, name string) *Attribute
AddAttribute adds an attribute to a vertex shader.
func (*VertexShader) AddUniform ¶
func (s *VertexShader) AddUniform(kind VariableKind, name string) Uniform
AddUniform adds a uniform to a shader.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}