Documentation
¶
Overview ¶
Package render exposes an abstraction API over the GPU so that various implementations (e.g. OpenGL 4.6, WebGL) can be substituted.
Index ¶
- Constants
- Variables
- func DetermineUniformBlockSize(api API, blockSize int) int
- type API
- type Area
- type BlendFactor
- type BlendOperation
- type Buffer
- type BufferFetchInfo
- type BufferInfo
- type BufferObject
- type BufferUpdateInfo
- type Capabilities
- type ColorAttachmentInfo
- type ColorTexture2DInfo
- type ColorTextureCubeInfo
- type CommandQueue
- type Comparison
- type CopyContentToBufferInfo
- type CopyContentToTextureInfo
- type CullMode
- type DataFormat
- type DepthStencilTexture2DInfo
- type DepthTexture2DInfo
- type FaceOrientation
- type Fence
- type FenceObject
- type FenceStatus
- type FilterMode
- type Framebuffer
- type FramebufferInfo
- type FramebufferObject
- type IndexFormat
- type Limits
- type LoadOperation
- type Pipeline
- type PipelineInfo
- type PipelineObject
- type Program
- type ProgramCode
- type ProgramCodeObject
- type ProgramInfo
- type ProgramObject
- type Quality
- type RenderPassInfo
- type StencilOperation
- type StencilOperationState
- type StencilTexture2DInfo
- type StoreOperation
- type Texture
- type TextureBinding
- type TextureObject
- type Topology
- type UniformBinding
- type VertexArray
- type VertexArrayAttributeInfo
- type VertexArrayBindingInfo
- type VertexArrayInfo
- type VertexArrayObject
- type VertexAttributeFormat
- type WrapMode
Constants ¶
const ( SizeU8 = 1 SizeU16 = 2 SizeU32 = 4 SizeF16 = 2 SizeF32 = 4 )
Variables ¶
Functions ¶
func DetermineUniformBlockSize ¶ added in v0.16.0
DetermineUniformBlockSize returns the size of the uniform block in case multiple ones need to be aligned inside a buffer.
Types ¶
type API ¶ added in v0.4.0
type API interface { // Limits returns information on the supported limits of the implementation. Limits() Limits // Capabilities returns the information on the supported features and // performance characteristics of the implementation. Capabilities() Capabilities // DefaultFramebuffer returns the default framebuffer that is provided // by the target window surface. DefaultFramebuffer() Framebuffer // DetermineContentFormat returns the format that should be used // with CopyContentToTexture and similar methods when dealing with // the specified Framebuffer. DetermineContentFormat(framebuffer Framebuffer) DataFormat // CreateFramebuffer creates a new Framebuffer object based on the // provided FramebufferInfo. CreateFramebuffer(info FramebufferInfo) Framebuffer // CreateProgram creates a new Program object based on the provided // ProgramInfo. CreateProgram(info ProgramInfo) Program CreateColorTexture2D(info ColorTexture2DInfo) Texture CreateColorTextureCube(info ColorTextureCubeInfo) Texture CreateDepthTexture2D(info DepthTexture2DInfo) Texture CreateStencilTexture2D(info StencilTexture2DInfo) Texture CreateDepthStencilTexture2D(info DepthStencilTexture2DInfo) Texture CreateVertexBuffer(info BufferInfo) Buffer CreateIndexBuffer(info BufferInfo) Buffer CreatePixelTransferBuffer(info BufferInfo) Buffer CreateUniformBuffer(info BufferInfo) Buffer CreateVertexArray(info VertexArrayInfo) VertexArray CreatePipeline(info PipelineInfo) Pipeline CreateCommandQueue() CommandQueue BeginRenderPass(info RenderPassInfo) EndRenderPass() // Invalidate indicates that the graphics state might have changed // from outside this API and any cached state by the API should // be discarded. // // Using this command will force a subsequent draw command to initialize // all graphics state (e.g. blend state, depth state, stencil state, etc.) Invalidate() CopyContentToTexture(info CopyContentToTextureInfo) SubmitQueue(queue CommandQueue) CreateFence() Fence }
API provides access to low-level graphics manipulation and rendering.
type BlendFactor ¶ added in v0.4.0
type BlendFactor uint8
const ( BlendFactorZero BlendFactor = iota BlendFactorOne BlendFactorSourceColor BlendFactorOneMinusSourceColor BlendFactorDestinationColor BlendFactorOneMinusDestinationColor BlendFactorSourceAlpha BlendFactorOneMinusSourceAlpha BlendFactorDestinationAlpha BlendFactorOneMinusDestinationAlpha BlendFactorConstantColor BlendFactorOneMinusConstantColor BlendFactorConstantAlpha BlendFactorOneMinusConstantAlpha BlendFactorSourceAlphaSaturate )
type BlendOperation ¶ added in v0.4.0
type BlendOperation uint8
const ( BlendOperationAdd BlendOperation = iota BlendOperationSubtract BlendOperationReverseSubtract BlendOperationMin BlendOperationMax )
type Buffer ¶ added in v0.4.0
type Buffer interface { BufferObject // Deprecated: Use queue commands. Update(info BufferUpdateInfo) // Deprecated: Use queue commands. Fetch(info BufferFetchInfo) Release() }
type BufferFetchInfo ¶ added in v0.4.0
type BufferInfo ¶ added in v0.4.0
type BufferObject ¶ added in v0.4.0
type BufferObject interface {
// contains filtered or unexported methods
}
type BufferUpdateInfo ¶ added in v0.4.0
type Capabilities ¶ added in v0.4.0
type Capabilities struct { // Quality indicates the performance capabilities of the implementation. Quality Quality }
Capabilities describes the capabilities of the implementation.
type ColorAttachmentInfo ¶ added in v0.4.0
type ColorAttachmentInfo struct { LoadOp LoadOperation StoreOp StoreOperation ClearValue [4]float32 }
type ColorTexture2DInfo ¶ added in v0.4.0
type ColorTexture2DInfo struct { Width int Height int Wrapping WrapMode Filtering FilterMode Mipmapping bool GammaCorrection bool Format DataFormat Data []byte }
type ColorTextureCubeInfo ¶ added in v0.4.0
type CommandQueue ¶ added in v0.4.0
type CommandQueue interface { BindPipeline(pipeline Pipeline) TextureUnit(index int, texture Texture) UniformBufferUnit(index int, buffer Buffer) UniformBufferUnitRange(index int, buffer Buffer, offset, size int) Draw(vertexOffset, vertexCount, instanceCount int) DrawIndexed(indexOffset, indexCount, instanceCount int) CopyContentToBuffer(info CopyContentToBufferInfo) // Deprecated: Upload directly through the Queue. UpdateBufferData(buffer Buffer, info BufferUpdateInfo) Release() }
type Comparison ¶ added in v0.4.0
type Comparison uint8
const ( ComparisonNever Comparison = iota ComparisonLess ComparisonEqual ComparisonLessOrEqual ComparisonGreater ComparisonNotEqual ComparisonGreaterOrEqual ComparisonAlways )
type CopyContentToBufferInfo ¶ added in v0.4.0
type CopyContentToBufferInfo struct { // Buffer is the pixel transfer buffer that should be updated with the // contents of the current framebuffer. Buffer Buffer // X is the X offset of the framebuffer that should be copied. X int // Y is the Y offset of the framebuffer that should be copied. Y int // Width is the width amount of the framebuffer that should be copied. Width int // Height is the height amount of the framebuffer that should be copied. Height int // Format is the format of the pixel transfer buffer. Format DataFormat // Offset is the offset into the pixel transfer buffer. Offset int }
CopyContentToBufferInfo describes the configuration of a copy operation from the current framebuffer to a pixel transfer buffer.
type CopyContentToTextureInfo ¶ added in v0.4.0
type CopyContentToTextureInfo struct { // Texture is the texture that should be updated with the contents of // the current framebuffer. Texture Texture // TextureLevel is the mipmap level of the texture that should be updated. TextureLevel int // TextureX is the X offset of the texture that should be updated. TextureX int // TextureY is the Y offset of the texture that should be updated. TextureY int // FramebufferX is the X offset of the framebuffer that should be copied. FramebufferX int // FramebufferY is the Y offset of the framebuffer that should be copied. FramebufferY int // Width is the width amount of the framebuffer that should be copied. Width int // Height is the height amount of the framebuffer that should be copied. Height int // GenerateMipmaps indicates whether or not mipmaps should be generated. GenerateMipmaps bool }
ColorTexture2DInfo describes the configuration of a copy operation from the current framebuffer to a texture.
type DataFormat ¶ added in v0.4.0
type DataFormat int
const ( DataFormatUnsupported DataFormat = iota DataFormatRGBA8 DataFormatRGBA16F DataFormatRGBA32F )
func (DataFormat) String ¶ added in v0.9.0
func (f DataFormat) String() string
type DepthStencilTexture2DInfo ¶ added in v0.4.0
type DepthTexture2DInfo ¶ added in v0.4.0
type FaceOrientation ¶ added in v0.4.0
type FaceOrientation uint8
const ( FaceOrientationCCW FaceOrientation = iota FaceOrientationCW )
type Fence ¶ added in v0.4.0
type Fence interface { FenceObject Status() FenceStatus Delete() }
type FenceObject ¶ added in v0.4.0
type FenceObject interface {
// contains filtered or unexported methods
}
type FenceStatus ¶ added in v0.4.0
type FenceStatus int
const ( FenceStatusNotReady FenceStatus = iota FenceStatusSuccess FenceStatusDeviceLost )
type FilterMode ¶ added in v0.4.0
type FilterMode int
const ( FilterModeNearest FilterMode = iota FilterModeLinear FilterModeAnisotropic )
type Framebuffer ¶ added in v0.4.0
type Framebuffer interface { FramebufferObject // Release releases the resources associated with the Framebuffer. Release() }
Framebuffer represents a combination of target textures to be rendered to.
type FramebufferInfo ¶ added in v0.4.0
type FramebufferInfo struct { // Label specifies a human-readable name for the Framebuffer. Intended // for debugging and logging purposes only. Label string // ColorAttachments is the list of color attachments that should be // attached to the Framebuffer. ColorAttachments [4]Texture // DepthAttachment is the depth attachment that should be attached to // the Framebuffer. DepthAttachment Texture // StencilAttachment is the stencil attachment that should be attached // to the Framebuffer. StencilAttachment Texture // DepthStencilAttachment is the depth+stencil attachment that should // be attached to the Framebuffer. DepthStencilAttachment Texture }
FramebufferInfo describes the configuration of a Framebuffer.
type FramebufferObject ¶ added in v0.4.0
type FramebufferObject interface {
// contains filtered or unexported methods
}
FramebufferObject marks a type as being a Framebuffer object.
type IndexFormat ¶ added in v0.4.0
type IndexFormat uint8
const ( IndexFormatUnsignedShort IndexFormat = iota IndexFormatUnsignedInt )
type Limits ¶ added in v0.16.0
type Limits interface { // UniformBufferOffsetAlignment returns the alignment requirement // for uniform buffer offsets. UniformBufferOffsetAlignment() int }
Limits describes the limits of the implementation.
type LoadOperation ¶ added in v0.4.0
type LoadOperation int
const ( LoadOperationDontCare LoadOperation = iota LoadOperationClear )
type Pipeline ¶ added in v0.4.0
type Pipeline interface { PipelineObject Release() }
type PipelineInfo ¶ added in v0.4.0
type PipelineInfo struct { Program Program VertexArray VertexArray Topology Topology Culling CullMode FrontFace FaceOrientation DepthTest bool DepthWrite bool DepthComparison Comparison StencilTest bool StencilFront StencilOperationState StencilBack StencilOperationState ColorWrite [4]bool BlendEnabled bool BlendColor [4]float32 BlendSourceColorFactor BlendFactor BlendDestinationColorFactor BlendFactor BlendSourceAlphaFactor BlendFactor BlendDestinationAlphaFactor BlendFactor BlendOpColor BlendOperation BlendOpAlpha BlendOperation }
type PipelineObject ¶ added in v0.4.0
type PipelineObject interface {
// contains filtered or unexported methods
}
type Program ¶ added in v0.4.0
type Program interface { ProgramObject // Release releases the resources used by the program. Release() }
Program represents a graphics program.
type ProgramCode ¶ added in v0.16.0
type ProgramCode interface { ProgramCodeObject }
ProgramCode represents the shader language source code for a program.
This can differ depending on the API implementation. It could be a single string or a struct with multiple strings for each shader stage.
type ProgramCodeObject ¶ added in v0.16.0
type ProgramCodeObject interface {
// contains filtered or unexported methods
}
ProgramCodeObject marks a type as being a ProgramCode.
type ProgramInfo ¶ added in v0.4.0
type ProgramInfo struct { // Label specifies a human-readable label for the program. Intended for // debugging and logging purposes only. Label string // SourceCode specifies the source code for the program. SourceCode ProgramCode // TextureBindings specifies the texture bindings for the program, in case // the implementation does not support shader-specified bindings. TextureBindings []TextureBinding // UniformBindings specifies the uniform bindings for the program, in case // the implementation does not support shader-specified bindings. UniformBindings []UniformBinding }
ProgramInfo represents the information needed to create a Program.
type ProgramObject ¶ added in v0.4.0
type ProgramObject interface {
// contains filtered or unexported methods
}
ProgramObject marks a type as being a Program.
type Quality ¶ added in v0.4.0
type Quality int
Quality is an enumeration of the supported render quality levels.
const ( // QualityLow indicates that the implementation is running on hardware // with low performance capabilities. QualityLow Quality = iota // QualityMedium indicates that the implementation is running on hardware // with medium performance capabilities. QualityMedium // QualityHigh indicates that the implementation is running on hardware // with high performance capabilities. QualityHigh )
type RenderPassInfo ¶ added in v0.4.0
type RenderPassInfo struct { Framebuffer Framebuffer Viewport Area DepthLoadOp LoadOperation DepthStoreOp StoreOperation DepthClearValue float32 StencilLoadOp LoadOperation StencilStoreOp StoreOperation StencilClearValue int Colors [4]ColorAttachmentInfo }
type StencilOperation ¶ added in v0.4.0
type StencilOperation uint8
const ( StencilOperationKeep StencilOperation = iota StencilOperationZero StencilOperationReplace StencilOperationIncrease StencilOperationIncreaseWrap StencilOperationDecrease StencilOperationDecreaseWrap StencilOperationInvert )
type StencilOperationState ¶ added in v0.4.0
type StencilOperationState struct { StencilFailOp StencilOperation DepthFailOp StencilOperation PassOp StencilOperation Comparison Comparison ComparisonMask uint32 Reference int32 WriteMask uint32 }
type StencilTexture2DInfo ¶ added in v0.4.0
type StoreOperation ¶ added in v0.4.0
type StoreOperation int
const ( StoreOperationDontCare StoreOperation = iota StoreOperationStore )
type Texture ¶ added in v0.4.0
type Texture interface { TextureObject Release() }
type TextureBinding ¶ added in v0.9.0
type TextureBinding struct { // Name specifies the name of the texture in the shader. Name string // Index specifies the binding index. Index int }
TextureBinding represents a texture binding for a program.
func NewTextureBinding ¶ added in v0.9.0
func NewTextureBinding(name string, index int) TextureBinding
NewTextureBinding creates a new TextureBinding with the specified name and index.
type TextureObject ¶ added in v0.4.0
type TextureObject interface {
// contains filtered or unexported methods
}
type UniformBinding ¶ added in v0.9.0
type UniformBinding struct { // Name specifies the name of the uniform object in the shader. Name string // Index specifies the binding index. Index int }
UniformBinding represents a uniform binding for a program.
func NewUniformBinding ¶ added in v0.9.0
func NewUniformBinding(name string, index int) UniformBinding
NewUniformBinding creates a new UniformBinding with the specified name and index.
type VertexArray ¶ added in v0.4.0
type VertexArray interface { VertexArrayObject Release() }
type VertexArrayAttributeInfo ¶ added in v0.4.0
type VertexArrayAttributeInfo struct { Binding int Location int Format VertexAttributeFormat Offset int }
type VertexArrayBindingInfo ¶ added in v0.4.0
type VertexArrayInfo ¶ added in v0.4.0
type VertexArrayInfo struct { Bindings []VertexArrayBindingInfo Attributes []VertexArrayAttributeInfo IndexFormat IndexFormat IndexBuffer Buffer }
type VertexArrayObject ¶ added in v0.4.0
type VertexArrayObject interface {
// contains filtered or unexported methods
}
type VertexAttributeFormat ¶ added in v0.4.0
type VertexAttributeFormat uint8
const ( VertexAttributeFormatR32F VertexAttributeFormat = iota VertexAttributeFormatRG32F VertexAttributeFormatRGB32F VertexAttributeFormatRGBA32F VertexAttributeFormatR16F VertexAttributeFormatRG16F VertexAttributeFormatRGB16F VertexAttributeFormatRGBA16F VertexAttributeFormatR16S VertexAttributeFormatRG16S VertexAttributeFormatRGB16S VertexAttributeFormatRGBA16S VertexAttributeFormatR16SN VertexAttributeFormatRG16SN VertexAttributeFormatRGB16SN VertexAttributeFormatRGBA16SN VertexAttributeFormatR16U VertexAttributeFormatRG16U VertexAttributeFormatRGB16U VertexAttributeFormatRGBA16U VertexAttributeFormatR16UN VertexAttributeFormatRG16UN VertexAttributeFormatRGB16UN VertexAttributeFormatRGBA16UN VertexAttributeFormatR8S VertexAttributeFormatRG8S VertexAttributeFormatRGB8S VertexAttributeFormatRGBA8S VertexAttributeFormatR8SN VertexAttributeFormatRG8SN VertexAttributeFormatRGB8SN VertexAttributeFormatRGBA8SN VertexAttributeFormatR8U VertexAttributeFormatRG8U VertexAttributeFormatRGB8U VertexAttributeFormatRGBA8U VertexAttributeFormatR8UN VertexAttributeFormatRG8UN VertexAttributeFormatRGB8UN VertexAttributeFormatRGBA8UN VertexAttributeFormatR8IU VertexAttributeFormatRG8IU VertexAttributeFormatRGB8IU VertexAttributeFormatRGBA8IU )