render

package module
v0.0.0-...-5233882 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2013 License: MIT Imports: 18 Imported by: 2

README

go-glutil

Utilities for working with OpenGL in Go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Red   = Color{1, 0, 0, 1}
	Green = Color{0, 1, 0, 1}
	Blue  = Color{0, 0, 1, 1}

	Black = Color{0, 0, 0, 1}
	White = Color{1, 1, 1, 1}

	Orange  = Color{1, 0.5, 0, 1}
	Pink    = Color{1, 0, 0.5, 1}
	Lime    = Color{0.5, 1, 0, 1}
	Aqua    = Color{0, 1, 0.5, 1}
	Purple  = Color{0.5, 0, 1, 1}
	SkyBlue = Color{0, 0.5, 1, 1}

	Yellow  = Color{1, 1, 0, 1}
	Cyan    = Color{0, 1, 1, 1}
	Magenta = Color{1, 0, 1, 1}

	SoftRed   = Color{0.8, 0.2, 0.2, 1}
	SoftGreen = Color{0.2, 0.8, 0.2, 1}
	SoftBlue  = Color{0.2, 0.2, 0.8, 1}

	SoftWhite = Color{0.8, 0.8, 0.8, 1}
	SoftBlack = Color{0.2, 0.2, 0.2, 1}

	DebugPallet = ColorPallet{
		SoftRed, SoftGreen, SoftBlue, Orange, Pink, Lime, Aqua, Purple, Yellow, Cyan, Magenta,
	}
)

Functions

func ArrayPtr

func ArrayPtr(data interface{}) (gl.Pointer, gl.Sizeiptr)

func AttachTexture

func AttachTexture(location gl.UniformLocation, textureEnum gl.Enum, target gl.Enum, texture gl.Texture)

func Bind

func Bind(bindings interface{})

func BindArrayData

func BindArrayData(buffer gl.Buffer, data interface{})

func BindProgramLocations

func BindProgramLocations(program gl.Program, bindings interface{})

func Cross3D

func Cross3D(a, b glm.Vec4d) glm.Vec3d

func Cross3Dv

func Cross3Dv(a, b glm.Vec4d) glm.Vec4d

func DrawGeometry

func DrawGeometry(geo *Geometry, vertexAttribute gl.AttributeLocation, vao gl.VertexArrayObject)

func DrawModel

func DrawModel(mv glm.Mat4d, model *Model, modelview gl.UniformLocation, vertexAttribute gl.AttributeLocation, vao gl.VertexArrayObject)

func ImageData

func ImageData(img image.Image) (gl.Sizei, gl.Sizei, gl.Enum, gl.Enum, gl.Pointer)

func LoadConfiguration

func LoadConfiguration(confFile string, constants interface{}, bindings *ControlBindings, receiver interface{}) error

func LoadFragmentShaderSource

func LoadFragmentShaderSource(shader gl.FragmentShader, filename string) error

func LoadProgram

func LoadProgram(program gl.Program, vertexShader gl.VertexShader, fragmentShader gl.FragmentShader) error

func LoadShader

func LoadShader(shader gl.Uint, filename string) error

func LoadTexture

func LoadTexture(texture gl.Texture, filename string) error

func LoadVertexShaderSource

func LoadVertexShaderSource(shader gl.VertexShader, filename string) error

func MatArray

func MatArray(d glm.Mat4d) *gl.Float

func MouseCoord

func MouseCoord(window *glfw.Window, xpos, ypos float64) glm.Vec2d

func NearZero

func NearZero(v glm.Vec4d) bool

func NodeTransform

func NodeTransform(node *collada.Node) glm.Mat4d

func PanicOnError

func PanicOnError()

func Quaternion

func Quaternion(m glm.Mat3d) glm.Quatd

func Rotation

func Rotation(angle float64, axis glm.Vec4d) glm.Mat4d

func RotationBetweenNormals

func RotationBetweenNormals(n1, n2 glm.Vec4d) glm.Mat4d

func RotationComponent

func RotationComponent(m glm.Mat4d) glm.Mat3d

func ToHomogVec4D

func ToHomogVec4D(v glm.Vec3d) glm.Vec4d

func ToVec3D

func ToVec3D(v glm.Vec4d) glm.Vec3d

func Translate

func Translate(v glm.Vec4d) glm.Mat4d

func V3

func V3(v glm.Vec4d) glm.Vec3d

Types

type Action

type Action func()

func FindActionMethod

func FindActionMethod(v reflect.Value, name string) Action

type Color

type Color [4]gl.Float

type ColorPallet

type ColorPallet []Color

func (ColorPallet) Pick

func (pallet ColorPallet) Pick(n int) *Color

type ControlBindings

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

func (*ControlBindings) Apply

func (c *ControlBindings) Apply(receiver interface{}, bindings map[string]string)

func (*ControlBindings) BindKeyPress

func (c *ControlBindings) BindKeyPress(key glfw.Key, press Action, release Action)

func (*ControlBindings) BindMouseClick

func (c *ControlBindings) BindMouseClick(button glfw.MouseButton, press Action, release Action)

func (*ControlBindings) BindMouseMovement

func (c *ControlBindings) BindMouseMovement(action MouseMoveAction)

func (*ControlBindings) BindScroll

func (c *ControlBindings) BindScroll(action ScrollAction)

func (*ControlBindings) DoKeyAction

func (c *ControlBindings) DoKeyAction(key glfw.Key, keyAction glfw.Action)

func (*ControlBindings) DoMouseButtonAction

func (c *ControlBindings) DoMouseButtonAction(button glfw.MouseButton, mouseAction glfw.Action)

func (*ControlBindings) DoMouseMoveAction

func (c *ControlBindings) DoMouseMoveAction(window *glfw.Window, xpos, ypos float64)

func (*ControlBindings) DoScrollAction

func (c *ControlBindings) DoScrollAction(xoff, yoff float64)

func (*ControlBindings) FindClickAction

func (c *ControlBindings) FindClickAction(button glfw.MouseButton, buttonAction glfw.Action) (Action, bool)

func (*ControlBindings) FindKeyAction

func (c *ControlBindings) FindKeyAction(key glfw.Key, keyAction glfw.Action) (Action, bool)

func (*ControlBindings) FindMouseMovementAction

func (c *ControlBindings) FindMouseMovementAction() (MouseMoveAction, bool)

func (*ControlBindings) FindScrollAction

func (c *ControlBindings) FindScrollAction() (ScrollAction, bool)

func (*ControlBindings) ResetBindings

func (c *ControlBindings) ResetBindings()

func (*ControlBindings) UnbindKeyPress

func (c *ControlBindings) UnbindKeyPress(key glfw.Key)

func (*ControlBindings) UnbindMouseClick

func (c *ControlBindings) UnbindMouseClick(button glfw.MouseButton)

func (*ControlBindings) UnbindMouseMovement

func (c *ControlBindings) UnbindMouseMovement()

func (*ControlBindings) UnbindScroll

func (c *ControlBindings) UnbindScroll()

type DrawElements

type DrawElements struct {
	Buffer   gl.Buffer
	DrawType gl.Enum
	Count    int
}

func MakeElements

func MakeElements(elementMap map[gl.Enum][]int16) []*DrawElements

func NewDrawElements

func NewDrawElements(elements []int16, drawType gl.Enum) *DrawElements

type Geometry

type Geometry struct {
	Name         string
	VertexBuffer gl.Buffer
	NormalBuffer gl.Buffer
	Elements     []*DrawElements
}

func Grid

func Grid(n int) *Geometry

func NewGeometry

func NewGeometry(name string, verticies, normals []float64, elements []*DrawElements) *Geometry

func Sphere

func Sphere() *Geometry

func Wheel

func Wheel() *Geometry

func (*Geometry) AddDrawElements

func (geometry *Geometry) AddDrawElements(drawElements *DrawElements)

type Index

type Index struct {
	Collada     *collada.Collada
	Id          map[collada.Id]interface{}
	Data        map[collada.Id]interface{}
	Mesh        map[collada.Id]*Mesh
	Transforms  map[collada.Id]glm.Mat4d
	VisualScene *collada.VisualScene
}

func NewIndex

func NewIndex(c *collada.Collada) (*Index, error)

func (*Index) AddId

func (index *Index) AddId(id collada.Id, obj interface{})

func (*Index) ReadOffsets

func (index *Index) ReadOffsets(inputs []*collada.InputShared, verticies map[string]collada.Id) (int, []float64, int, []float64, int)

type IndexPair

type IndexPair struct {
	V int
	N int
}

type Mesh

type Mesh struct {
	VerticesId string
	Polylist   []*Polylist
}

type Model

type Model struct {
	Name          string
	Transform     glm.Mat4d
	BaseTransform glm.Mat4d
	Geometry      []*Geometry
	Children      []*Model
	Parent        *Model
}

func EmptyModel

func EmptyModel(name string) *Model

func LoadModel

func LoadModel(index *Index, node *collada.Node, geometryTemplates map[collada.Id][]*Geometry) (*Model, bool)

func LoadSceneAsModel

func LoadSceneAsModel(filename string) (*Model, error)

func NewModel

func NewModel(name string, children []*Model, geometry []*Geometry, transform glm.Mat4d) *Model

func NewSingleModel

func NewSingleModel(name string, verticies, normals []float64, elements []int16, drawType gl.Enum, transform glm.Mat4d) *Model

func (*Model) AddChild

func (model *Model) AddChild(child *Model)

func (*Model) AddGeometry

func (model *Model) AddGeometry(geometry ...*Geometry) *Model

func (*Model) FindModelWithName

func (model *Model) FindModelWithName(name string) (*Model, bool)

func (*Model) SetTransform

func (model *Model) SetTransform(m glm.Mat4d) *Model

func (*Model) WorldTransform

func (model *Model) WorldTransform() glm.Mat4d

type MouseMoveAction

type MouseMoveAction func(position, delta glm.Vec2d)

func FindMouseMoveActionMethod

func FindMouseMoveActionMethod(v reflect.Value, name string) MouseMoveAction

type Polylist

type Polylist struct {
	VertexData       []float64
	NormalData       []float64
	TriangleElements []int16
}

type ScrollAction

type ScrollAction func(xoff, yoff float64)

type ShaderLibrary

type ShaderLibrary struct {
	FragmentShaders map[string]gl.FragmentShader
	VertexShaders   map[string]gl.VertexShader
	Programs        map[string]gl.Program
}

func NewShaderLibrary

func NewShaderLibrary() ShaderLibrary

func (*ShaderLibrary) BindProgramLocations

func (lib *ShaderLibrary) BindProgramLocations(tag string, obj interface{})

func (*ShaderLibrary) GetProgram

func (lib *ShaderLibrary) GetProgram(tag string) (gl.Program, bool)

func (*ShaderLibrary) LoadFragmentShader

func (lib *ShaderLibrary) LoadFragmentShader(tag, filename string)

func (*ShaderLibrary) LoadProgram

func (lib *ShaderLibrary) LoadProgram(tag, vsfilename, fsfilename string)

func (*ShaderLibrary) LoadVertexShader

func (lib *ShaderLibrary) LoadVertexShader(tag, filename string)

func (*ShaderLibrary) UseProgram

func (lib *ShaderLibrary) UseProgram(tag string)

type StencilOp

type StencilOp struct {
}
var Stencil StencilOp

func (*StencilOp) Decrement

func (s *StencilOp) Decrement() *StencilOp

func (*StencilOp) Depth

func (s *StencilOp) Depth() *StencilOp

func (*StencilOp) DepthAlways

func (s *StencilOp) DepthAlways() *StencilOp

func (*StencilOp) DepthLE

func (s *StencilOp) DepthLE() *StencilOp

func (*StencilOp) DepthLT

func (s *StencilOp) DepthLT() *StencilOp

func (*StencilOp) DepthMask

func (s *StencilOp) DepthMask() *StencilOp

func (*StencilOp) Disable

func (s *StencilOp) Disable() *StencilOp

func (*StencilOp) Draw

func (s *StencilOp) Draw() *StencilOp

func (*StencilOp) Enable

func (s *StencilOp) Enable() *StencilOp

func (*StencilOp) Increment

func (s *StencilOp) Increment() *StencilOp

func (*StencilOp) Keep

func (s *StencilOp) Keep() *StencilOp

func (*StencilOp) Mask

func (s *StencilOp) Mask(level int) *StencilOp

func (*StencilOp) NoDepth

func (s *StencilOp) NoDepth() *StencilOp

func (*StencilOp) NoDepthMask

func (s *StencilOp) NoDepthMask() *StencilOp

func (*StencilOp) NoDraw

func (s *StencilOp) NoDraw() *StencilOp

func (*StencilOp) Replace

func (s *StencilOp) Replace() *StencilOp

func (*StencilOp) Unmask

func (s *StencilOp) Unmask(level int) *StencilOp

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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