Documentation ¶
Overview ¶
Package gpu provides a modern (Physical Based Rendering), high performance GPU renderer for Go.
Index ¶
- Variables
- func Open(hints ...string) error
- func RegisterDriver(name string, d Driver)
- func Render(model *Model, models []Model, transform *Transform)
- func Sync() error
- func Upload() error
- type Animation
- type Box
- type Buffer
- type Context
- type DrawMode
- type Driver
- type Frame
- type Frames
- type Joint
- type Light
- type Material
- type Mesh
- type Mode
- type Model
- type Texture
- type Transform
- type Vertices
Constants ¶
This section is empty.
Variables ¶
var ( Triangles = DrawMode{1} Lines = DrawMode{2} )
DrawModes
var Darkness color.Color
Darkness is the color of dark objects, things cannot get darker than this. AKA Ambient Light
var Origin = NewTransform()
Origin is the position 0,0,0
var Projection = Perspective(60, 1.3, 0.3, 1000)
Projection is the camera projection transform.
var Viewport = NewTransform()
Viewport is the transform of the camera view.
Functions ¶
func Open ¶
Open opens the GPU ready for uploading data and rendering. You can provide a hint to select the name of the driver to use.
func RegisterDriver ¶
RegisterDriver registers a new GPU driver.
Types ¶
type Animation ¶
type Animation struct { //Frame is the current frame for this instance of the animation. //Increment this to play the animation. Frame float32 // contains filtered or unexported fields }
Animation is a pointer to an animation on the GPU.
func NewAnimation ¶
NewAnimation creates a new animation on the GPU using the current GPU driver.
type Box ¶
type Box struct {
Width, Height, Depth float32
}
Box is a bounding box. Used for frustum culling.
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer that can be used to control what data is currently available to the GPU.
var Default Buffer
Default is the default GPU buffer.
func (Buffer) NewAnimation ¶
NewAnimation creates a new animation on the GPU using the current GPU driver.
func (Buffer) NewMaterial ¶
NewMaterial creates a new material on the GPU using the current GPU driver.
type Context ¶
type Context interface { //NewMesh schedules a mesh to be uploaded to the GPU and returns two internal values as a descriptor IE the index and vertex-count. NewMesh(Vertices) (index, count uint32) //NewMaterial schedules/uploads a material on the GPU and returns references to the four texture maps. NewMaterial(Texture) (albedo, physical, normal, emission uint64) //NewAnimation schedules an animation to be uploaded to the GPU and returns the index and frame count of the animation. NewAnimation(Frames) (index, count uint32) //Upload waits for any scheduled meshes, materials and/or animations to upload to the GPU. Upload() error //Render schedules rendering of the Model or Models with the given transform applied. Render(*Model, []Model, *Transform) //Sync waits for all scheduled render operations to complete. Sync() error }
Context provides an interface to a context on the GPU.
type DrawMode ¶
type DrawMode struct {
// contains filtered or unexported fields
}
DrawMode is a primitive draw mode.
type Driver ¶
Driver can open a new Context. If nil is returned once, it must continue to return nil.
type Joint ¶
type Joint struct {
Position, Rotation [3]float32
}
Joint defines a current joint transform.
type Light ¶
Light is either a spot light or point light depending on the cuttoff Angle of the light.
var Sun Light
Sun is the base directional light of the scene.
type Material ¶
type Material struct {
// contains filtered or unexported fields
}
Material is a Material on the GPU.
func NewMaterial ¶
NewMaterial creates a new material on the GPU using the current GPU driver.
type Mesh ¶
type Mesh struct { Mode // contains filtered or unexported fields }
Mesh is a group of vertices on the GPU.
type Mode ¶
type Mode struct { Draw DrawMode // contains filtered or unexported fields }
Mode describes a mode for rendering a mesh.
type Transform ¶
type Transform [16]float32
Transform describes the position, orientation and scale to apply to a target.
func NewTransform ¶
func NewTransform() Transform
NewTransform returns a new indentity transform that does not transform the target in any way.
func Perspective ¶
Perspective returns a new perspective transform.
func Position ¶
Position returns a new transform that translates the target to the given x,y,z coordinates.
func (*Transform) SetPosition ¶
SetPosition sets the transform to translate the target to the given x,y,z coordinates.
type Vertices ¶
type Vertices struct { //DrawMode for the vertices. Draw DrawMode //Vertices data. Vertices, Normals []float32 //Texture mapping data. UVs []float32 //Vertex color data. Colors []uint8 //Animation data. Weights []float32 Joints []uint8 //Indices of the vertices, when vertex data is shared. Indices []uint32 }
Vertices describes the components of a mesh.