renderer

package
v0.0.0-...-5b12917 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2017 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const VertexStride = 12

Variables

This section is empty.

Functions

func AlignedOrientation

func AlignedOrientation(width float32, vector mgl32.Vec3) mgl32.Mat4

CreateBeam - creates a square prism oriented along the vector

Types

type Camera

type Camera struct {
	Translation, Lookat, Up mgl32.Vec3
	Angle, Near, Far        float32
	Ortho                   bool
}

The camera Entity

func CreateCamera

func CreateCamera() *Camera

func (*Camera) CameraContainsSphere

func (c *Camera) CameraContainsSphere(windowSize mgl32.Vec2, radius float32, point mgl32.Vec3) bool

CameraContainsSphere - determines if a sphere in contained in the frustrum given by the camera. sphere is given by point and radius

func (*Camera) FrustrumContainsSphere

func (c *Camera) FrustrumContainsSphere(windowSize, start, end mgl32.Vec2, radius float32, point mgl32.Vec3) bool

FrustrumContainsSphere - determines if a sphere in contained in the frustrum given by start/end vectors on the screen. sphere is given by point and radius

func (*Camera) GetDirection

func (c *Camera) GetDirection() mgl32.Vec3

func (*Camera) GetMouseVector

func (c *Camera) GetMouseVector(windowSize, mouse mgl32.Vec2) mgl32.Vec3

GetMouseVector - Returns a normal vector given by the mouse position

func (*Camera) GetWindowVector

func (c *Camera) GetWindowVector(windowSize mgl32.Vec2, point mgl32.Vec3) mgl32.Vec3

GetWindowVector - Returns the screen position of the given world vector

func (*Camera) SetOrientation

func (c *Camera) SetOrientation(orientation mgl32.Quat)

func (*Camera) SetScale

func (c *Camera) SetScale(scale mgl32.Vec3)

func (*Camera) SetTranslation

func (c *Camera) SetTranslation(translation mgl32.Vec3)

type CubeMap

type CubeMap struct {
	Id     uint32
	Lod    bool
	Loaded bool

	Right, Left, Top, Bottom, Back, Front image.Image
}

func NewCubemap

func NewCubemap(baseImage image.Image, lod bool) *CubeMap

func (*CubeMap) Destroy

func (cm *CubeMap) Destroy(renderer Renderer)

type Entity

type Entity interface {
	SetScale(scale mgl32.Vec3)
	SetTranslation(translation mgl32.Vec3)
	SetOrientation(orientation mgl32.Quat)
}

An Entity is something that can be scaled, positioned and rotated (orientation)

type FPSMeter

type FPSMeter struct {
	FpsCap    float64
	FrameTime float64
	// contains filtered or unexported fields
}

func CreateFPSMeter

func CreateFPSMeter(sampleTime float64) *FPSMeter

func (*FPSMeter) UpdateFPSMeter

func (fps *FPSMeter) UpdateFPSMeter() float64

func (*FPSMeter) Value

func (fps *FPSMeter) Value() float64

type Geometry

type Geometry struct {
	VboId, IboId uint32
	Loaded       bool
	VboDirty     bool

	Indicies  []uint32
	Verticies []float32
	// contains filtered or unexported fields
}

Geometry

func CreateBeam

func CreateBeam(width float32, vector mgl32.Vec3) *Geometry

CreateBeam - creates a square prism oriented along the vector

func CreateBox

func CreateBox(width, height float32) *Geometry

Primitives

func CreateBoxWithOffset

func CreateBoxWithOffset(width, height, offsetX, offsetY float32) *Geometry

func CreateCube

func CreateCube() *Geometry

func CreateGeometry

func CreateGeometry(indicies []uint32, verticies []float32) *Geometry

vericies format : x,y,z, nx,ny,nz, u,v, r,g,b,a indicies format : f1,f2,f3 (triangles)

func CreateSkyBox

func CreateSkyBox() *Geometry

func (*Geometry) BoundingRadius

func (geometry *Geometry) BoundingRadius() float32

func (*Geometry) Center

func (geometry *Geometry) Center() mgl32.Vec3

func (*Geometry) ClearBuffers

func (geometry *Geometry) ClearBuffers()

func (*Geometry) Copy

func (geometry *Geometry) Copy() *Geometry

func (*Geometry) Destroy

func (geometry *Geometry) Destroy(renderer Renderer)

func (*Geometry) Draw

func (geometry *Geometry) Draw(renderer Renderer, transform mgl32.Mat4)

func (*Geometry) MaximalPointFromGeometry

func (geometry *Geometry) MaximalPointFromGeometry() mgl32.Vec3

Gets the furthest point from the origin in this geometry

func (*Geometry) Optimize

func (geometry *Geometry) Optimize(destination *Geometry, transform mgl32.Mat4)

load the verts/indicies of geometry into destination Geometry

func (*Geometry) OrthoOrder

func (geometry *Geometry) OrthoOrder() int

func (*Geometry) RayIntersect

func (geometry *Geometry) RayIntersect(start, direction mgl32.Vec3) (point mgl32.Vec3, ok bool)

func (*Geometry) SetColor

func (geometry *Geometry) SetColor(color color.Color)

func (*Geometry) SetParent

func (geometry *Geometry) SetParent(parent *Node)

func (*Geometry) SetUVs

func (geometry *Geometry) SetUVs(uvs ...float32)

func (*Geometry) Transform

func (geometry *Geometry) Transform(transform mgl32.Mat4)

type Light

type Light struct {
	LightType
	Color     [3]float32 //RGB
	Position  mgl32.Vec3
	Direction mgl32.Vec3
}

func NewLight

func NewLight(lightType LightType) *Light

func (*Light) SetOrientation

func (l *Light) SetOrientation(orientation mgl32.Quat)

func (*Light) SetScale

func (l *Light) SetScale(scale mgl32.Vec3)

func (*Light) SetTranslation

func (l *Light) SetTranslation(translation mgl32.Vec3)

type LightType

type LightType int
const (
	POINT LightType
	DIRECTIONAL
	AMBIENT
)

type Material

type Material struct {
	Textures []*Texture
}

func NewMaterial

func NewMaterial(textures ...*Texture) *Material

func (*Material) Destroy

func (m *Material) Destroy(renderer Renderer)

type Node

type Node struct {
	Transform   mgl32.Mat4
	Scale       mgl32.Vec3
	Translation mgl32.Vec3
	Orientation mgl32.Quat

	FrustrumCulling bool
	OrthoOrderValue int
	Shader          *Shader
	Material        *Material
	CubeMap         *CubeMap
	RendererParams  *RendererParams
	// contains filtered or unexported fields
}

Node

func NewNode

func NewNode() *Node

func (*Node) Add

func (node *Node) Add(spatial Spatial)

func (*Node) BoundingRadius

func (node *Node) BoundingRadius() float32

func (*Node) Center

func (node *Node) Center() mgl32.Vec3

func (*Node) Destroy

func (node *Node) Destroy(renderer Renderer)

func (*Node) Draw

func (node *Node) Draw(renderer Renderer, transform mgl32.Mat4)

func (*Node) DrawChild

func (node *Node) DrawChild(renderer Renderer, transform mgl32.Mat4, child Spatial)

func (*Node) Optimize

func (node *Node) Optimize(geometry *Geometry, transform mgl32.Mat4)

func (*Node) OptimizeNode

func (node *Node) OptimizeNode() *Geometry

func (*Node) OrthoOrder

func (node *Node) OrthoOrder() int

func (*Node) RayIntersect

func (node *Node) RayIntersect(start, direction mgl32.Vec3) (point mgl32.Vec3, ok bool)

func (*Node) RelativePosition

func (node *Node) RelativePosition(n *Node) (mgl32.Vec3, error)

RelativePosition - find the position of n relative to node (n must be a child of node)

func (*Node) Remove

func (node *Node) Remove(spatial Spatial, destroy bool)

func (*Node) RemoveAll

func (node *Node) RemoveAll(destroy bool)

func (*Node) SetFrustrumCullingRecursive

func (node *Node) SetFrustrumCullingRecursive(enable bool)

func (*Node) SetOrientation

func (node *Node) SetOrientation(orientation mgl32.Quat)

func (*Node) SetParent

func (node *Node) SetParent(parent *Node)

func (*Node) SetRotation

func (node *Node) SetRotation(angle float32, axis mgl32.Vec3)

func (*Node) SetScale

func (node *Node) SetScale(scale mgl32.Vec3)

func (*Node) SetTranslation

func (node *Node) SetTranslation(translation mgl32.Vec3)

type Renderer

type Renderer interface {
	SetInit(callback func())
	SetUpdate(callback func())
	SetRender(callback func())
	SetCamera(camera *Camera)
	Camera() *Camera
	Start()

	BackGroundColor(r, g, b, a float32)
	WindowDimensions() mgl32.Vec2
	LockCursor(lock bool)
	UseRendererParams(params RendererParams)

	DrawGeometry(geometry *Geometry, transform mgl32.Mat4)
	DestroyGeometry(geometry *Geometry)

	UseMaterial(material *Material)
	DestroyMaterial(material *Material)

	UseCubeMap(cubeMap *CubeMap)
	DestroyCubeMap(cubeMap *CubeMap)

	UseShader(shader *Shader)

	CreatePostEffect(shader *Shader)
	DestroyPostEffects(shader *Shader)

	AddLight(light *Light)
	RemoveLight(light *Light)
}

type RendererParams

type RendererParams struct {
	CullBackface bool
	DepthTest    bool
	DepthMask    bool
	Unlit        bool
	Transparency
}

func DefaultRendererParams

func DefaultRendererParams() RendererParams

func NewRendererParams

func NewRendererParams() *RendererParams

type SceneGraph

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

func CreateSceneGraph

func CreateSceneGraph() *SceneGraph

factory

func (*SceneGraph) Add

func (sceneGraph *SceneGraph) Add(spatial Spatial)

func (*SceneGraph) AddTransparent

func (sceneGraph *SceneGraph) AddTransparent(spatial Spatial)

func (*SceneGraph) Remove

func (sceneGraph *SceneGraph) Remove(spatial Spatial, destroy bool)

func (*SceneGraph) RemoveTransparent

func (sceneGraph *SceneGraph) RemoveTransparent(spatial Spatial, destroy bool)

func (*SceneGraph) RenderScene

func (sceneGraph *SceneGraph) RenderScene(renderer Renderer, cameraLocation mgl32.Vec3)

type Shader

type Shader struct {
	Program uint32
	Loaded  bool

	Uniforms          map[string]interface{}
	FragDataLocations []string
	InputBuffers      int

	TextureUnits map[string]int32

	FragSrc, VertSrc, GeoSrc string
	// contains filtered or unexported fields
}

func NewShader

func NewShader() *Shader

func (*Shader) AddTexture

func (shader *Shader) AddTexture(textureName string) int32

AddTexture - allocates a texture unit to the shader

func (*Shader) Copy

func (shader *Shader) Copy() (copy *Shader)

type Spatial

type Spatial interface {
	Draw(renderer Renderer, transform mgl32.Mat4)
	Optimize(geometry *Geometry, transform mgl32.Mat4)
	Destroy(renderer Renderer)
	Center() mgl32.Vec3
	BoundingRadius() float32
	OrthoOrder() int
	SetParent(parent *Node)
}

A Spatial is something that can be Added to scenegraph nodes

type Texture

type Texture struct {
	TextureId   uint32
	TextureName string
	Img         image.Image
	Lod         bool
	Loaded      bool
}

func NewTexture

func NewTexture(name string, img image.Image, lod bool) *Texture

type Transparency

type Transparency int
const (
	NON_EMISSIVE Transparency
	EMISSIVE
)

Jump to

Keyboard shortcuts

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