Documentation ¶
Index ¶
- Variables
- func GetPixels(img image.Image, rowPitch int) ([]uint8, error)
- func SliceUint32(data []byte) []uint32
- type Configuration
- type Destroyable
- type Instance
- type InstanceConfiguration
- type PhysicalDeviceInfo
- type Renderer
- type RendererConfiguration
- type ResourceHandle
- type ResourceInstance
- type Shader
- type ShaderType
- type Time
- type TimeConfiguration
- type VulkanInstance
- func (v VulkanInstance) AvailableDevices() []vk.PhysicalDevice
- func (v VulkanInstance) Destroy()
- func (v VulkanInstance) Extensions() []string
- func (v *VulkanInstance) Instance() interface{}
- func (v VulkanInstance) PhysicalDevicesInfo() []PhysicalDeviceInfo
- func (v *VulkanInstance) SetSurface(pSurface unsafe.Pointer)
- func (v VulkanInstance) Surface() vk.Surface
- type VulkanRenderer
- func (v *VulkanRenderer) Destroy()
- func (v *VulkanRenderer) DeviceIsSuitable(device vk.PhysicalDevice) (bool, string)
- func (v *VulkanRenderer) Draw() error
- func (v *VulkanRenderer) Initialise() error
- func (v *VulkanRenderer) Present() error
- func (v *VulkanRenderer) ResourceDelete(handle ResourceHandle)
- func (v *VulkanRenderer) ResourceHandle() ResourceHandle
- func (v *VulkanRenderer) ResourceUpdate(handle ResourceHandle, instance ResourceInstance) <-chan struct{}
- type VulkanShader
Constants ¶
This section is empty.
Variables ¶
var DefaultVulkanApplicationInfo = &vk.ApplicationInfo{ SType: vk.StructureTypeApplicationInfo, ApiVersion: vk.MakeVersion(1, 2, 131), ApplicationVersion: vk.MakeVersion(1, 0, 0), PApplicationName: safeString("Koru3D"), PEngineName: safeString("Koru3D"), }
DefaultVulkanApplicationInfo application info describes a Vulkan application
Functions ¶
func GetPixels ¶
GetPixels transforms a given image into right arrangement of pixels by drawing the decoded image onto a controlled RGBA canvas
func SliceUint32 ¶
SliceUint32 reslices bytes into a uint32, that is used to sumbit vulkan shaders for processing
Types ¶
type Configuration ¶
type Configuration struct { Time TimeConfiguration Instance InstanceConfiguration Renderer RendererConfiguration }
Configuration defines a global engine configuration setting
type Destroyable ¶
type Destroyable interface {
// Destroy is used to dismantle the struct in question
Destroy()
}
Destroyable defines a structure which needs to be dismantled
type Instance ¶
type Instance interface { Destroyable // PhysicalDevicesInfo returns a struct for each Physical Device // along with info about those devices PhysicalDevicesInfo() []PhysicalDeviceInfo // AvailableDevices returns handles of Physical Devices // from the Vulkan API AvailableDevices() []vk.PhysicalDevice // SetSurface sets the window surface for rendering SetSurface(unsafe.Pointer) // Surface returns the window surface, if it's not set // it should return a valid but empty surface Surface() vk.Surface // Instance returns the underlying API instance Instance() interface{} // Extensions returns available instance extensions Extensions() []string }
Instance describes a Vulkan instance and supporting methods. Once created it is ready to use.
func NewVulkanInstance ¶
func NewVulkanInstance(appInfo *vk.ApplicationInfo, window unsafe.Pointer, cfg InstanceConfiguration) (Instance, error)
NewVulkanInstance creates a Vulkan instance
type InstanceConfiguration ¶
InstanceConfiguration contains the rendering engine instacne config
type PhysicalDeviceInfo ¶
type PhysicalDeviceInfo struct { ID int VendorID int DriverVersion int Name string Invalid bool Extensions []string Layers []string Memory uint }
PhysicalDeviceInfo describes available physical properties of a rendering device
type Renderer ¶
type Renderer interface { Destroyable // Initialise sets up the configured rendering pipeline Initialise() error // ResourceHandle requests for a unique handle for use with the renderer. // Every entity that wishes to be rendered needs to get a unique handle. ResourceHandle() ResourceHandle // Update updates the current rendering queue at given handle ResourceUpdate(ResourceHandle, ResourceInstance) <-chan struct{} // ResourceDelete removes the resource from rendering queue ResourceDelete(ResourceHandle) // Draw draws the frame Draw() error // Present submits current frame for display Present() error // DeviceIsSuitable checks if the device given is suitable // for the rendering pipeline. If not suitable string contains the reason DeviceIsSuitable(vk.PhysicalDevice) (bool, string) }
Renderer describes the rendering machinery. It's created only with internal values set, it needs to be initialised with Initialise() before use.
func NewVulkanRenderer ¶
func NewVulkanRenderer(instance Instance, cfg RendererConfiguration) (Renderer, error)
NewVulkanRenderer creates a not yet initialised Vulkan API renderer
type RendererConfiguration ¶
type RendererConfiguration struct { SwapchainSize uint32 DeviceExtensions []string ScreenWidth uint32 ScreenHeight uint32 ShaderDirectory string }
RendererConfiguration is used to configure the renderer
type ResourceHandle ¶
type ResourceHandle uint32
ResourceHandle identifies the resource instance in the renderer
type ResourceInstance ¶
type ResourceInstance struct { // ResourceID tells the renderer which resource to load from packages ResourceID string // Position matrix for the Resource Position glm.Mat4 // Rotation matrix for the Resource Rotation glm.Mat4 }
ResourceInstance represents an instance in the renderer. Contains all the data, should be updated all at once.
type Shader ¶
type Shader interface { Destroyable // Shader is the internal API shader instance ShaderModule() interface{} // Type returns the type of shader in question Type() ShaderType // Name Shader name Name() string }
Shader is an abstraction for shader modules. It is safe to destroy after the rendering pipeline is created.
func NewVulkanShader ¶
NewVulkanShader creates a Vulkan specific shader wrapper
type ShaderType ¶
type ShaderType int
ShaderType represents the type of shader thats loaded
const ( VertexShaderType ShaderType = iota FragmentShaderType UnknownShaderType )
Identifies shader objects with their types
type Time ¶
type Time struct {
// contains filtered or unexported fields
}
Time contains all the time services and tickers
func (*Time) EventTicker ¶
EventTicker gets the initialized event ticker for the event loop
type TimeConfiguration ¶
type TimeConfiguration struct { // FramesPerSecond caps frames per second that is put out // To unlimit, set to 0 FramesPerSecond int // EventPollDelay configures the event loop with this delay // in milliseconds EventPollDelay int }
TimeConfiguration is used to configure time services
type VulkanInstance ¶
type VulkanInstance struct { Destroyable // contains filtered or unexported fields }
VulkanInstance describes a Vulkan API Instance
func (VulkanInstance) AvailableDevices ¶
func (v VulkanInstance) AvailableDevices() []vk.PhysicalDevice
AvailableDevices implements interface
func (VulkanInstance) Extensions ¶
func (v VulkanInstance) Extensions() []string
Extensions implements interface
func (*VulkanInstance) Instance ¶
func (v *VulkanInstance) Instance() interface{}
Instance returns internal vk.Instance
func (VulkanInstance) PhysicalDevicesInfo ¶
func (v VulkanInstance) PhysicalDevicesInfo() []PhysicalDeviceInfo
PhysicalDevicesInfo implements interface
func (*VulkanInstance) SetSurface ¶
func (v *VulkanInstance) SetSurface(pSurface unsafe.Pointer)
SetSurface implements interface
func (VulkanInstance) Surface ¶
func (v VulkanInstance) Surface() vk.Surface
Surface implements interface
type VulkanRenderer ¶
type VulkanRenderer struct { Destroyable Renderer // contains filtered or unexported fields }
VulkanRenderer is a Vulkan API renderer
func (*VulkanRenderer) DeviceIsSuitable ¶
func (v *VulkanRenderer) DeviceIsSuitable(device vk.PhysicalDevice) (bool, string)
DeviceIsSuitable implements interface
func (*VulkanRenderer) Initialise ¶
func (v *VulkanRenderer) Initialise() error
Initialise implements interface
func (*VulkanRenderer) Present ¶
func (v *VulkanRenderer) Present() error
Present implements interface
func (*VulkanRenderer) ResourceDelete ¶
func (v *VulkanRenderer) ResourceDelete(handle ResourceHandle)
ResourceDelete implements interface
func (*VulkanRenderer) ResourceHandle ¶
func (v *VulkanRenderer) ResourceHandle() ResourceHandle
ResourceHandle implements interface
func (*VulkanRenderer) ResourceUpdate ¶
func (v *VulkanRenderer) ResourceUpdate(handle ResourceHandle, instance ResourceInstance) <-chan struct{}
ResourceUpdate implements interface
type VulkanShader ¶
type VulkanShader struct { Destroyable Shader // contains filtered or unexported fields }
VulkanShader is a Vulkan specific shader
func (VulkanShader) ShaderModule ¶
func (v VulkanShader) ShaderModule() interface{}
ShaderModule is an accssor to the internal vk.ShaderModule