render

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: MIT Imports: 0 Imported by: 9

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

This section is empty.

Variables

View Source
var (
	ColorMaskFalse = [4]bool{false, false, false, false}
	ColorMaskTrue  = [4]bool{true, true, true, true}
)

Functions

This section is empty.

Types

type API added in v0.4.0

type API interface {
	Capabilities() Capabilities

	DefaultFramebuffer() Framebuffer

	CreateFramebuffer(info FramebufferInfo) Framebuffer
	CreateColorTexture2D(info ColorTexture2DInfo) Texture
	CreateColorTextureCube(info ColorTextureCubeInfo) Texture
	CreateDepthTexture2D(info DepthTexture2DInfo) Texture
	CreateStencilTexture2D(info StencilTexture2DInfo) Texture
	CreateDepthStencilTexture2D(info DepthStencilTexture2DInfo) Texture
	CreateVertexShader(info ShaderInfo) Shader
	CreateFragmentShader(info ShaderInfo) Shader
	CreateProgram(info ProgramInfo) Program
	CreateVertexBuffer(info BufferInfo) Buffer
	CreateIndexBuffer(info BufferInfo) Buffer
	CreatePixelTransferBuffer(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()

	BindPipeline(pipeline Pipeline)
	Uniform1f(location UniformLocation, value float32)
	Uniform1i(location UniformLocation, value int)
	Uniform3f(location UniformLocation, values [3]float32)
	Uniform4f(location UniformLocation, values [4]float32)
	UniformMatrix4f(location UniformLocation, values [16]float32)
	TextureUnit(index int, texture Texture)
	Draw(vertexOffset, vertexCount, instanceCount int)
	DrawIndexed(indexOffset, indexCount, instanceCount int)
	CopyContentToTexture(info CopyContentToTextureInfo)
	SubmitQueue(queue CommandQueue)
	CreateFence() Fence
}

type Area added in v0.4.0

type Area struct {
	X      int
	Y      int
	Width  int
	Height int
}

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
	Update(info BufferUpdateInfo)
	Fetch(info BufferFetchInfo)
	Release()
}

type BufferFetchInfo added in v0.4.0

type BufferFetchInfo struct {
	Offset int
	Target []byte
}

type BufferInfo added in v0.4.0

type BufferInfo struct {
	Dynamic bool
	Data    []byte
	Size    int
}

type BufferObject added in v0.4.0

type BufferObject interface {
	// contains filtered or unexported methods
}

type BufferUpdateInfo added in v0.4.0

type BufferUpdateInfo struct {
	Data   []byte
	Offset int
}

type Capabilities added in v0.4.0

type Capabilities struct {
	Quality Quality
}

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 ColorTextureCubeInfo struct {
	Dimension       int
	Filtering       FilterMode
	Mipmapping      bool
	GammaCorrection bool
	Format          DataFormat
	FrontSideData   []byte
	BackSideData    []byte
	LeftSideData    []byte
	RightSideData   []byte
	TopSideData     []byte
	BottomSideData  []byte
}

type CommandQueue added in v0.4.0

type CommandQueue interface {
	BindPipeline(pipeline Pipeline)
	Uniform1f(location UniformLocation, value float32)
	Uniform1i(location UniformLocation, value int)
	Uniform3f(location UniformLocation, values [3]float32)
	Uniform4f(location UniformLocation, values [4]float32)
	UniformMatrix4f(location UniformLocation, values [16]float32)
	TextureUnit(index int, texture Texture)
	Draw(vertexOffset, vertexCount, instanceCount int)
	DrawIndexed(indexOffset, indexCount, instanceCount int)
	CopyContentToBuffer(info CopyContentToBufferInfo)
	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 Buffer
	X      int
	Y      int
	Width  int
	Height int
	Format DataFormat
	Offset int
}

type CopyContentToTextureInfo added in v0.4.0

type CopyContentToTextureInfo struct {
	Texture         Texture
	TextureLevel    int
	TextureX        int
	TextureY        int
	FramebufferX    int
	FramebufferY    int
	Width           int
	Height          int
	GenerateMipmaps bool
}

type CullMode added in v0.4.0

type CullMode uint8
const (
	CullModeNone CullMode = iota
	CullModeFront
	CullModeBack
	CullModeFrontAndBack
)

type DataFormat added in v0.4.0

type DataFormat int
const (
	DataFormatRGBA8 DataFormat = iota
	DataFormatRGBA16F
	DataFormatRGBA32F
)

type DepthStencilTexture2DInfo added in v0.4.0

type DepthStencilTexture2DInfo struct {
	Width  int
	Height int
}

type DepthTexture2DInfo added in v0.4.0

type DepthTexture2DInfo struct {
	Width  int
	Height int
}

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()
}

type FramebufferInfo added in v0.4.0

type FramebufferInfo struct {
	ColorAttachments       [4]Texture
	DepthAttachment        Texture
	StencilAttachment      Texture
	DepthStencilAttachment Texture
}

type FramebufferObject added in v0.4.0

type FramebufferObject interface {
	// contains filtered or unexported methods
}

type IndexFormat added in v0.4.0

type IndexFormat uint8
const (
	IndexFormatUnsignedShort IndexFormat = iota
	IndexFormatUnsignedInt
)

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
	UniformLocation(name string) UniformLocation
	Release()
}

type ProgramInfo added in v0.4.0

type ProgramInfo struct {
	VertexShader   Shader
	FragmentShader Shader
}

type ProgramObject added in v0.4.0

type ProgramObject interface {
	// contains filtered or unexported methods
}

type Quality added in v0.4.0

type Quality int
const (
	QualityLow Quality = iota
	QualityMedium
	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 Shader added in v0.4.0

type Shader interface {
	ShaderObject
	Release()
}

type ShaderInfo added in v0.4.0

type ShaderInfo struct {
	SourceCode string
}

type ShaderObject added in v0.4.0

type ShaderObject interface {
	// contains filtered or unexported methods
}

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 StencilTexture2DInfo struct {
	Width  int
	Height int
}

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 TextureObject added in v0.4.0

type TextureObject interface {
	// contains filtered or unexported methods
}

type Topology added in v0.4.0

type Topology uint8
const (
	TopologyPoints Topology = iota
	TopologyLineStrip
	TopologyLineLoop
	TopologyLines
	TopologyTriangleStrip
	TopologyTriangleFan
	TopologyTriangles
)

type UniformLocation added in v0.4.0

type UniformLocation interface{}

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 VertexArrayBindingInfo struct {
	VertexBuffer Buffer
	Stride       int
}

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
)

type WrapMode added in v0.4.0

type WrapMode int
const (
	WrapModeClamp WrapMode = iota
	WrapModeRepeat
	WrapModeMirroredRepeat
)

Jump to

Keyboard shortcuts

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