gameblocks

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

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

Go to latest
Published: Feb 14, 2016 License: MIT Imports: 20 Imported by: 0

README

go-gameblocks

Game engine toolkit for Go.

Status: Alpha. (No stability guarantee)

Some good stuff in here, but fairly specific to my own projects at the moment. It may generalize more over time. Largely factored out of shazow/linerage3d.

Some things that already work well:

  • Cameras (Quat and Euler based, with lerping)
  • Shader managing (with reloading support)
  • Scene managing (basic for now, need to flesh it out into a tree-based thing)
  • Control key binding

Goals

  • Multiple rendering backends

    • Support golang.com/x/mobile backend
    • Support additional backends (glfw)
  • More non-rendering things, maybe?

  • More docs, examples.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeObjects

func EncodeObjects(offset int, length int, objects ...DimSlicer) []byte

EncodeObjects converts float32 vertices into a LittleEndian byte array. Offset and length are based on the number of rows per dimension. TODO: Replace with https://github.com/lunixbochs/struc?

func MultiMul

func MultiMul(matrices ...*mgl.Mat4) mgl.Mat4

MultiMul multiplies every non-nil Mat4 reference and returns the result. If none are given, then it returns the identity matrix.

func Quad

func Quad(a mgl.Vec3, b mgl.Vec3) []float32

func RandomParticle

func RandomParticle(origin mgl.Vec3, force float32) *particle

func StartMobile

func StartMobile(engine Engine)

StartMobile launches the Engine using the x/mobile backend, should be run from the main thread.

func Upvote

func Upvote(tip mgl.Vec3, size float32) []float32

Types

type DimSlicer

type DimSlicer interface {
	Slice(int, int) interface{}
	Dim() int
	String() string
}

func NewDimSlice

func NewDimSlice(dim int, slice interface{}) DimSlicer

type DrawContext

type DrawContext struct {
	GL        gl.Context
	Camera    camera.Camera
	Shader    loader.Shader
	Transform *mgl.Mat4
}

type Drawable

type Drawable interface {
	Draw(DrawContext)
	Transform(*mgl.Mat4) mgl.Mat4
	Shader() loader.Shader
}

func NewFloor

func NewFloor(shader loader.Shader, reflected ...Drawable) Drawable

func NewSkybox

func NewSkybox(shader loader.Shader, texture gl.Texture) Drawable

type DynamicShape

type DynamicShape struct {
	StaticShape
}

func NewDynamicShape

func NewDynamicShape(glctx gl.Context, bufSize int) *DynamicShape

func (*DynamicShape) Buffer

func (shape *DynamicShape) Buffer(offset int)

type Emitter

type Emitter interface {
	Shape
	Tick(time.Duration)
	MoveTo(mgl.Vec3)
}

func ParticleEmitter

func ParticleEmitter(glctx gl.Context, origin mgl.Vec3, num int, rate float32) Emitter

type Engine

type Engine interface {
	Draw()
	Start(glctx gl.Context) error
	Stop()

	// Event handlers
	Touch(t touch.Event)
	Press(t key.Event)
	Resize(sz size.Event)
}

func NewEngine

func NewEngine(w World) Engine

type Floor

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

func (*Floor) Draw

func (scene *Floor) Draw(ctx DrawContext)

type FrameContext

type FrameContext struct {
	GL     gl.Context
	Camera camera.Camera
	// contains filtered or unexported fields
}

func (*FrameContext) DrawContext

func (ctx *FrameContext) DrawContext(shader loader.Shader) DrawContext

type Light

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

func (*Light) MoveTo

func (light *Light) MoveTo(position mgl.Vec3)

type Node

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

TODO: node tree with transforms

func (*Node) Draw

func (node *Node) Draw(ctx DrawContext)

func (*Node) Shader

func (node *Node) Shader() loader.Shader

func (*Node) String

func (node *Node) String() string

func (*Node) Transform

func (node *Node) Transform(parent *mgl.Mat4) mgl.Mat4

type Point

type Point struct {
	X, Y float32
}

type Scene

type Scene interface {
	Add(Drawable)
	Draw(FrameContext)
	String() string
}

func NewScene

func NewScene() Scene

type Shape

type Shape interface {
	Close() error
	Stride() int
	Len() int
	Draw(DrawContext)
}

type Skybox

type Skybox struct {
	Node
}

func (*Skybox) Draw

func (node *Skybox) Draw(ctx DrawContext)

func (*Skybox) Shader

func (shape *Skybox) Shader() loader.Shader

func (*Skybox) Transform

func (shape *Skybox) Transform(parent *mgl.Mat4) mgl.Mat4

type StaticShape

type StaticShape struct {
	VBO     gl.Buffer
	IBO     gl.Buffer
	Texture gl.Texture
	// contains filtered or unexported fields
}

func NewStaticShape

func NewStaticShape(glctx gl.Context) *StaticShape

func (*StaticShape) Buffer

func (shape *StaticShape) Buffer()

func (*StaticShape) Bytes

func (shape *StaticShape) Bytes() []byte

func (*StaticShape) BytesOffset

func (shape *StaticShape) BytesOffset(n int) []byte

func (*StaticShape) Close

func (shape *StaticShape) Close() error

func (*StaticShape) Draw

func (shape *StaticShape) Draw(ctx DrawContext)

func (*StaticShape) Len

func (s *StaticShape) Len() int

func (*StaticShape) Stride

func (shape *StaticShape) Stride() int

type Vector

type Vector interface {
	Position() mgl.Vec3
	Direction() mgl.Vec3
}

func FixedVector

func FixedVector(position mgl.Vec3, direction mgl.Vec3) Vector

type World

type World interface {
	Scene

	Reset()
	Tick(time.Duration) error
	Focus() Vector

	Start(WorldContext) error
}

func StubWorld

func StubWorld(scene Scene) World

type WorldContext

type WorldContext struct {
	Bindings control.Bindings
	Shaders  loader.Shaders
	Textures loader.Textures
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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