Documentation ¶
Index ¶
- func LightsToBytes(lights []Light, bytes []byte) []byte
- func M4ToBytes(m *lin.M4, bytes []byte) []byte
- func U8ToBytes(val uint8, bytes []byte) []byte
- func V4S32ToBytes(x, y, z, w float32, bytes []byte) []byte
- func V4SToBytes(x, y, z, w float64, bytes []byte) []byte
- func V4ToBytes(v *lin.V4, bytes []byte) []byte
- type Context
- func (c *Context) Dispose()
- func (c *Context) Draw(passes []Pass, dt time.Duration) (err error)
- func (c *Context) DropInstanceData(iid uint32)
- func (c *Context) DropMesh(mid uint32)
- func (c *Context) DropTexture(tid uint32)
- func (c *Context) LoadInstanceData(data []load.Buffer) (iid uint32, err error)
- func (c *Context) LoadMesh(msh load.MeshData) (mid uint32, err error)
- func (c *Context) LoadShader(config *load.Shader) (sid uint16, err error)
- func (c *Context) LoadTexture(img *load.ImageData) (tid uint32, err error)
- func (c *Context) Resize(width, height uint32)
- func (c *Context) SetClearColor(r, g, b, a float32)
- func (c *Context) Size() (width, height uint32)
- type Light
- type Loader
- type Packet
- type Packets
- type Pass
- type PassID
- type RenderAPI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LightsToBytes ¶ added in v0.20.0
LightsToBytes converts a slice of lights to bytes. The given byte slice is zeroed and returned filled with the given light data.
func M4ToBytes ¶ added in v0.20.0
M4ToBytes returns a byte slice of float32 for the given float64 matrix. The given byte slice is zeroed and returned filled with the matrix bytes.
func U8ToBytes ¶ added in v0.20.0
U8ToBytes returns a byte slice containing the given uint8 because the smallest uniform is an int. The given byte slice is zeroed and returned filled with the uint8.
func V4S32ToBytes ¶ added in v0.20.0
V4S32ToBytes returns a byte slice of float32 for the given float64s The given byte slice is zeroed and returned filled with the float bytes.
func V4SToBytes ¶ added in v0.20.0
V4SToBytes returns a byte slice of float32 for the given float64s The given byte slice is zeroed and returned filled with the vector bytes.
Types ¶
type Context ¶ added in v0.8.0
type Context struct {
// contains filtered or unexported fields
}
Context holds data for the rendering system and wraps the API specific renderers, ie: Vulkan, DX12, Metal.
func (*Context) Dispose ¶ added in v0.20.0
func (c *Context) Dispose()
Dispose releases renderer resources.
func (*Context) Draw ¶ added in v0.20.0
Draw renders the given render passes for one frame. Expected to be called many times per second.
func (*Context) DropInstanceData ¶ added in v0.20.0
DropInstanced discards the instanced resources.
func (*Context) DropTexture ¶ added in v0.20.0
DropTexture removes the GPU texture resources for the given texture ID.
func (*Context) LoadInstanceData ¶ added in v0.20.0
LoadInstanceData allocates GPU resources for the instanced mesh data.
func (*Context) LoadShader ¶ added in v0.20.0
LoadShader prepare the GPU indicated GPU shader for rendering.
func (*Context) LoadTexture ¶ added in v0.20.0
LoadTexture creates GPU texture resources and uploads texture data to the GPU.
func (*Context) Resize ¶ added in v0.20.0
Resize updates the graphics resources to the given size. Expected to be called when the user resizes the app window.
func (*Context) SetClearColor ¶ added in v0.20.0
SetClearColor sets the color that is used to clear the display.
type Light ¶ added in v0.20.0
type Light struct {
X, Y, Z, W float32 // location - W is 1 for point light, 0 for directional.
R, G, B float32 // color
Intensity float32 // light intensity
}
Light holds the location and color for a directional light. Effectively 2 float32 vec4 for 32 bytes.
type Loader ¶ added in v0.20.0
type Loader interface { LoadTexture(img *load.ImageData) (tid uint32, err error) LoadMesh(mdata load.MeshData) (mid uint32, err error) LoadShader(config *load.Shader) (mid uint16, err error) }
The render context implements this interface. It allows engine tests to mock this part of the render context.
type Packet ¶ added in v0.20.0
type Packet struct { ShaderID uint16 // GPU shader reference MeshID uint32 // GPU mesh reference. TextureIDs []uint32 // GPU texture references. // packet (model) uniform data. Data map[load.PacketUniform][]byte // used to draw instanced meshes. IsInstanced bool // true for instanced models. InstanceID uint32 // GPU instance data reference. InstanceCount uint32 // instance count for instanced models. // Rendering hints. Tag uint32 // Application tag (entity ID) for debugging. Bucket uint64 // Used to sort packets. Lower buckets rendered first. }
Packet holds the GPU references, shader uniforms, and the model-view-projection transforms needed to draw a model in a single draw call.
type Packets ¶ added in v0.20.0
type Packets []Packet // variable number of packets.
Packets is a list of packets that is used to allocates render models. Packets are intended to be reused each render loop.
type Pass ¶ added in v0.20.0
type Pass struct { // Packets are a reusable list of packets, one per model. Packets Packets Data map[load.PassUniform][]byte // Scene uniform data // Light position and color information. // Lights are reused to generate scene light uniform data. Lights []Light // max 3 scene lights. }
Pass contains a group of Packets for rendering in this render pass.
type PassID ¶ added in v0.20.0
type PassID uint8 // upto 256 passes should be sufficient.
PassID identifies a render.Pass. Lower number render passes are rendered before higher numbers.
type RenderAPI ¶ added in v0.20.0
type RenderAPI int
RenderAPI enumerates the possible render backends.
const ( VULKAN_RENDERER RenderAPI = iota // windows, linux, android DX12_RENDERER // FUTURE: xbox METAL_RENDERER // FUTURE: iOS, macOS, tvOS, watchOS, visionOS )
Vulkan is currently the only supported render API There are no plans to support OpenGL or any DirectX versions before DX12. Unlikely futures include:
- Nintendo NVN - proprietary...unlikely to ship golang to this platform.
- Playstation GNM - proprietary...unlikely to ship golang to this platform.