Documentation ¶
Index ¶
- func ReflectValueMatchesUniformBufferField(v reflect.Value, ubField *UniformBufferField) bool
- func Write32BitIntegerSliceToByteBufWithAlignment[T uint32 | int32](buf []byte, startIndex *int, alignmentPerField int, vals []T)
- func Write32BitIntegerToByteBuf[T uint32 | int32](buf []byte, startIndex *int, val T)
- func WriteF32SliceToByteBuf(buf []byte, startIndex *int, vals []float32)
- func WriteF32SliceToByteBufWithAlignment(buf []byte, startIndex *int, alignmentPerField int, vals []float32)
- func WriteF32ToByteBuf(buf []byte, startIndex *int, val float32)
- func WriteMat2SliceToByteBufWithAlignment(buf []byte, startIndex *int, alignmentPerMatrix int, vals []gglm.Mat2)
- func WriteMat3SliceToByteBufWithAlignment(buf []byte, startIndex *int, alignmentPerMatrix int, vals []gglm.Mat3)
- func WriteMat4SliceToByteBufWithAlignment(buf []byte, startIndex *int, alignmentPerMatrix int, vals []gglm.Mat4)
- func WriteVec2SliceToByteBufWithAlignment(buf []byte, startIndex *int, alignmentPerVector int, vals []gglm.Vec2)
- func WriteVec3SliceToByteBufWithAlignment(buf []byte, startIndex *int, alignmentPerVector int, vals []gglm.Vec3)
- func WriteVec4SliceToByteBufWithAlignment(buf []byte, startIndex *int, alignmentPerVector int, vals []gglm.Vec4)
- type BufUsage
- type Element
- type ElementType
- type Framebuffer
- func (fbo *Framebuffer) Bind()
- func (fbo *Framebuffer) BindWithViewport()
- func (fbo *Framebuffer) Clear()
- func (fbo *Framebuffer) Delete()
- func (fbo *Framebuffer) HasColorAttachment() bool
- func (fbo *Framebuffer) HasDepthAttachment() bool
- func (fbo *Framebuffer) IsComplete() bool
- func (fbo *Framebuffer) NewColorAttachment(attachType FramebufferAttachmentType, ...)
- func (fbo *Framebuffer) NewDepthAttachment(attachType FramebufferAttachmentType, ...)
- func (fbo *Framebuffer) NewDepthCubemapArrayAttachment(attachFormat FramebufferAttachmentDataFormat, numCubemaps int32)
- func (fbo *Framebuffer) NewDepthStencilAttachment(attachType FramebufferAttachmentType, ...)
- func (fbo *Framebuffer) NewDepthTextureArrayAttachment(attachFormat FramebufferAttachmentDataFormat, numTextures int32)
- func (fbo *Framebuffer) SetCubemapArrayLayerFace(layerFace int32)
- func (fbo *Framebuffer) SetNoColorBuffer()
- func (fbo *Framebuffer) UnBind()
- func (fbo *Framebuffer) UnBindWithViewport(width, height uint32)
- type FramebufferAttachment
- type FramebufferAttachmentDataFormat
- func (f FramebufferAttachmentDataFormat) GlComponentType() uint32
- func (f FramebufferAttachmentDataFormat) GlFormat() uint32
- func (f FramebufferAttachmentDataFormat) GlInternalFormat() int32
- func (f FramebufferAttachmentDataFormat) IsColorFormat() bool
- func (f FramebufferAttachmentDataFormat) IsDepthFormat() bool
- type FramebufferAttachmentType
- type IndexBuffer
- type UniformBuffer
- func (ub *UniformBuffer) Bind()
- func (ub *UniformBuffer) SetBindPoint(bindPointIndex uint32)
- func (ub *UniformBuffer) SetFloat32(fieldId uint16, val float32)
- func (ub *UniformBuffer) SetInt32(fieldId uint16, val int32)
- func (ub *UniformBuffer) SetMat2(fieldId uint16, val *gglm.Mat2)
- func (ub *UniformBuffer) SetMat3(fieldId uint16, val *gglm.Mat3)
- func (ub *UniformBuffer) SetMat4(fieldId uint16, val *gglm.Mat4)
- func (ub *UniformBuffer) SetStruct(inputStruct any)
- func (ub *UniformBuffer) SetUint32(fieldId uint16, val uint32)
- func (ub *UniformBuffer) SetVec2(fieldId uint16, val *gglm.Vec2)
- func (ub *UniformBuffer) SetVec3(fieldId uint16, val *gglm.Vec3)
- func (ub *UniformBuffer) SetVec4(fieldId uint16, val *gglm.Vec4)
- func (ub *UniformBuffer) UnBind()
- type UniformBufferField
- type UniformBufferFieldInput
- type VertexArray
- type VertexBuffer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReflectValueMatchesUniformBufferField ¶ added in v0.28.0
func ReflectValueMatchesUniformBufferField(v reflect.Value, ubField *UniformBufferField) bool
func Write32BitIntegerSliceToByteBufWithAlignment ¶ added in v0.28.0
func Write32BitIntegerToByteBuf ¶ added in v0.28.0
func WriteF32SliceToByteBuf ¶ added in v0.28.0
func WriteF32SliceToByteBufWithAlignment ¶ added in v0.28.0
func WriteF32ToByteBuf ¶ added in v0.28.0
func WriteMat2SliceToByteBufWithAlignment ¶ added in v0.28.0
func WriteMat3SliceToByteBufWithAlignment ¶ added in v0.28.0
func WriteMat4SliceToByteBufWithAlignment ¶ added in v0.28.0
func WriteVec2SliceToByteBufWithAlignment ¶ added in v0.28.0
func WriteVec3SliceToByteBufWithAlignment ¶ added in v0.28.0
Types ¶
type BufUsage ¶
type BufUsage int
const ( BufUsage_Unknown BufUsage = iota //Buffer is set only once and used many times BufUsage_Static_Draw //Buffer is changed a lot and used many times BufUsage_Dynamic_Draw //Buffer is set only once and used by the GPU at most a few times BufUsage_Stream_Draw BufUsage_Static_Read BufUsage_Dynamic_Read BufUsage_Stream_Read BufUsage_Static_Copy BufUsage_Dynamic_Copy BufUsage_Stream_Copy )
Full docs for buffer usage can be found here: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBufferData.xhtml
type Element ¶ added in v0.0.3
type Element struct { Offset int ElementType }
Element represents an element that makes up a buffer (e.g. Vec3 at an offset of 12 bytes)
type ElementType ¶ added in v0.0.3
type ElementType uint8
ElementType is the type of an element thats makes up a buffer (e.g. Vec3)
const ( DataTypeUnknown ElementType = iota DataTypeUint32 DataTypeInt32 DataTypeFloat32 DataTypeVec2 DataTypeVec3 DataTypeVec4 DataTypeMat2 DataTypeMat3 DataTypeMat4 DataTypeStruct )
func (ElementType) CompCount ¶ added in v0.0.3
func (dt ElementType) CompCount() int32
CompCount returns the number of components in the element (e.g. for Vec2 its 2)
func (ElementType) CompSize ¶ added in v0.0.3
func (dt ElementType) CompSize() int32
CompSize returns the size in bytes for one component of the type (e.g. for Vec2 its 4). Bools return 1, although in layout=std140 its 4
func (ElementType) GLType ¶ added in v0.0.3
func (dt ElementType) GLType() uint32
func (ElementType) GlStd140AlignmentBoundary ¶ added in v0.28.0
func (dt ElementType) GlStd140AlignmentBoundary() uint16
func (ElementType) GlStd140SizeBytes ¶ added in v0.28.0
func (dt ElementType) GlStd140SizeBytes() uint8
func (ElementType) Size ¶ added in v0.0.3
func (dt ElementType) Size() int32
Size returns the total size in bytes (e.g. for vec3 its 3*4=12 bytes)
func (ElementType) String ¶ added in v0.28.0
func (dt ElementType) String() string
type Framebuffer ¶ added in v0.20.0
type Framebuffer struct { Id uint32 ClearFlags uint32 Attachments []FramebufferAttachment ColorAttachmentsCount uint32 Width uint32 Height uint32 }
func NewFramebuffer ¶ added in v0.20.0
func NewFramebuffer(width, height uint32) Framebuffer
func (*Framebuffer) Bind ¶ added in v0.20.0
func (fbo *Framebuffer) Bind()
func (*Framebuffer) BindWithViewport ¶ added in v0.20.0
func (fbo *Framebuffer) BindWithViewport()
func (*Framebuffer) Clear ¶ added in v0.21.0
func (fbo *Framebuffer) Clear()
Clear calls gl.Clear with the fbo's clear flags. Note that the fbo must be complete and bound. Calling this without a bound fbo will clear something else, like your screen.
func (*Framebuffer) Delete ¶ added in v0.20.0
func (fbo *Framebuffer) Delete()
func (*Framebuffer) HasColorAttachment ¶ added in v0.20.0
func (fbo *Framebuffer) HasColorAttachment() bool
func (*Framebuffer) HasDepthAttachment ¶ added in v0.20.0
func (fbo *Framebuffer) HasDepthAttachment() bool
func (*Framebuffer) IsComplete ¶ added in v0.20.0
func (fbo *Framebuffer) IsComplete() bool
IsComplete returns true if OpenGL reports that the fbo is complete/usable. Note that this function binds and then unbinds the fbo
func (*Framebuffer) NewColorAttachment ¶ added in v0.20.0
func (fbo *Framebuffer) NewColorAttachment( attachType FramebufferAttachmentType, attachFormat FramebufferAttachmentDataFormat, )
func (*Framebuffer) NewDepthAttachment ¶ added in v0.21.0
func (fbo *Framebuffer) NewDepthAttachment( attachType FramebufferAttachmentType, attachFormat FramebufferAttachmentDataFormat, )
func (*Framebuffer) NewDepthCubemapArrayAttachment ¶ added in v0.22.0
func (fbo *Framebuffer) NewDepthCubemapArrayAttachment( attachFormat FramebufferAttachmentDataFormat, numCubemaps int32, )
func (*Framebuffer) NewDepthStencilAttachment ¶ added in v0.20.0
func (fbo *Framebuffer) NewDepthStencilAttachment( attachType FramebufferAttachmentType, attachFormat FramebufferAttachmentDataFormat, )
func (*Framebuffer) NewDepthTextureArrayAttachment ¶ added in v0.23.0
func (fbo *Framebuffer) NewDepthTextureArrayAttachment( attachFormat FramebufferAttachmentDataFormat, numTextures int32, )
func (*Framebuffer) SetCubemapArrayLayerFace ¶ added in v0.22.0
func (fbo *Framebuffer) SetCubemapArrayLayerFace(layerFace int32)
SetCubemapArrayLayerFace 'binds' a single face of a cubemap from the cubemap array to the fbo, such that rendering only affects that one face and the others inaccessible.
If this is not called, the default is that the entire cubemap array and all the faces in it are bound and available for use when binding the fbo.
func (*Framebuffer) SetNoColorBuffer ¶ added in v0.21.0
func (fbo *Framebuffer) SetNoColorBuffer()
SetNoColorBuffer sets the read and draw buffers of this fbo to 'NONE', which tells the graphics driver that we don't want a color buffer for this fbo.
This is required because normally an fbo must have a color buffer to be considered complete, but by doing this we get marked as complete even without one.
Usually used when you only care about some other buffer, like a depth buffer.
func (*Framebuffer) UnBind ¶ added in v0.20.0
func (fbo *Framebuffer) UnBind()
func (*Framebuffer) UnBindWithViewport ¶ added in v0.20.0
func (fbo *Framebuffer) UnBindWithViewport(width, height uint32)
type FramebufferAttachment ¶ added in v0.20.0
type FramebufferAttachment struct { Id uint32 Type FramebufferAttachmentType Format FramebufferAttachmentDataFormat }
type FramebufferAttachmentDataFormat ¶ added in v0.20.0
type FramebufferAttachmentDataFormat int32
const ( FramebufferAttachmentDataFormat_Unknown FramebufferAttachmentDataFormat = iota FramebufferAttachmentDataFormat_R32Int FramebufferAttachmentDataFormat_RGBA8 FramebufferAttachmentDataFormat_RGBAF16 FramebufferAttachmentDataFormat_SRGBA FramebufferAttachmentDataFormat_DepthF32 FramebufferAttachmentDataFormat_Depth24Stencil8 )
func (FramebufferAttachmentDataFormat) GlComponentType ¶ added in v0.25.0
func (f FramebufferAttachmentDataFormat) GlComponentType() uint32
func (FramebufferAttachmentDataFormat) GlFormat ¶ added in v0.20.0
func (f FramebufferAttachmentDataFormat) GlFormat() uint32
func (FramebufferAttachmentDataFormat) GlInternalFormat ¶ added in v0.20.0
func (f FramebufferAttachmentDataFormat) GlInternalFormat() int32
func (FramebufferAttachmentDataFormat) IsColorFormat ¶ added in v0.20.0
func (f FramebufferAttachmentDataFormat) IsColorFormat() bool
func (FramebufferAttachmentDataFormat) IsDepthFormat ¶ added in v0.20.0
func (f FramebufferAttachmentDataFormat) IsDepthFormat() bool
type FramebufferAttachmentType ¶ added in v0.20.0
type FramebufferAttachmentType int32
const ( FramebufferAttachmentType_Unknown FramebufferAttachmentType = iota FramebufferAttachmentType_Texture FramebufferAttachmentType_Texture_Array FramebufferAttachmentType_Renderbuffer FramebufferAttachmentType_Cubemap FramebufferAttachmentType_Cubemap_Array )
func (FramebufferAttachmentType) IsValid ¶ added in v0.20.0
func (f FramebufferAttachmentType) IsValid() bool
type IndexBuffer ¶ added in v0.19.9
type IndexBuffer struct { Id uint32 // IndexBufCount is the number of elements in the index buffer. Updated in IndexBuffer.SetData IndexBufCount int32 }
func NewIndexBuffer ¶ added in v0.19.9
func NewIndexBuffer() IndexBuffer
func (*IndexBuffer) Bind ¶ added in v0.19.9
func (ib *IndexBuffer) Bind()
func (*IndexBuffer) SetData ¶ added in v0.19.9
func (ib *IndexBuffer) SetData(values []uint32)
func (*IndexBuffer) UnBind ¶ added in v0.19.9
func (ib *IndexBuffer) UnBind()
type UniformBuffer ¶ added in v0.28.0
type UniformBuffer struct { Id uint32 // Size is the allocated memory in bytes on the GPU for this uniform buffer Size uint32 Fields []UniformBufferField }
func NewUniformBuffer ¶ added in v0.28.0
func NewUniformBuffer(fields []UniformBufferFieldInput, usage BufUsage) UniformBuffer
func (*UniformBuffer) Bind ¶ added in v0.28.0
func (ub *UniformBuffer) Bind()
func (*UniformBuffer) SetBindPoint ¶ added in v0.28.0
func (ub *UniformBuffer) SetBindPoint(bindPointIndex uint32)
func (*UniformBuffer) SetFloat32 ¶ added in v0.28.0
func (ub *UniformBuffer) SetFloat32(fieldId uint16, val float32)
func (*UniformBuffer) SetInt32 ¶ added in v0.28.0
func (ub *UniformBuffer) SetInt32(fieldId uint16, val int32)
func (*UniformBuffer) SetMat2 ¶ added in v0.28.0
func (ub *UniformBuffer) SetMat2(fieldId uint16, val *gglm.Mat2)
func (*UniformBuffer) SetMat3 ¶ added in v0.28.0
func (ub *UniformBuffer) SetMat3(fieldId uint16, val *gglm.Mat3)
func (*UniformBuffer) SetMat4 ¶ added in v0.28.0
func (ub *UniformBuffer) SetMat4(fieldId uint16, val *gglm.Mat4)
func (*UniformBuffer) SetStruct ¶ added in v0.28.0
func (ub *UniformBuffer) SetStruct(inputStruct any)
func (*UniformBuffer) SetUint32 ¶ added in v0.28.0
func (ub *UniformBuffer) SetUint32(fieldId uint16, val uint32)
func (*UniformBuffer) SetVec2 ¶ added in v0.28.0
func (ub *UniformBuffer) SetVec2(fieldId uint16, val *gglm.Vec2)
func (*UniformBuffer) SetVec3 ¶ added in v0.28.0
func (ub *UniformBuffer) SetVec3(fieldId uint16, val *gglm.Vec3)
func (*UniformBuffer) SetVec4 ¶ added in v0.28.0
func (ub *UniformBuffer) SetVec4(fieldId uint16, val *gglm.Vec4)
func (*UniformBuffer) UnBind ¶ added in v0.28.0
func (ub *UniformBuffer) UnBind()
type UniformBufferField ¶ added in v0.28.0
type UniformBufferField struct { Id uint16 AlignedOffset uint16 // Count should be set in case this field is an array of type `[Count]Type`. // Count=0 is valid and is equivalent to Count=1, which means the type is NOT an array, but a single field. Count uint16 Type ElementType // Subfields is used when type is a struct, in which case it holds the fields of the struct. // Ids do not have to be unique across structs. Subfields []UniformBufferField }
type UniformBufferFieldInput ¶ added in v0.28.0
type UniformBufferFieldInput struct { Id uint16 Type ElementType // Count should be set in case this field is an array of type `[Count]Type`. // Count=0 is valid and is equivalent to Count=1, which means the type is NOT an array, but a single field. Count uint16 // Subfields is used when type is a struct, in which case it holds the fields of the struct. // Ids do not have to be unique across structs. Subfields []UniformBufferFieldInput }
type VertexArray ¶ added in v0.19.9
type VertexArray struct { Id uint32 Vbos []VertexBuffer IndexBuffer IndexBuffer }
func NewVertexArray ¶ added in v0.19.9
func NewVertexArray() VertexArray
func (*VertexArray) AddVertexBuffer ¶ added in v0.19.9
func (va *VertexArray) AddVertexBuffer(vbo VertexBuffer)
func (*VertexArray) Bind ¶ added in v0.19.9
func (va *VertexArray) Bind()
func (*VertexArray) SetIndexBuffer ¶ added in v0.19.9
func (va *VertexArray) SetIndexBuffer(ib IndexBuffer)
func (*VertexArray) UnBind ¶ added in v0.19.9
func (va *VertexArray) UnBind()
type VertexBuffer ¶ added in v0.19.9
func NewVertexBuffer ¶ added in v0.19.9
func NewVertexBuffer(layout ...Element) VertexBuffer
func (*VertexBuffer) Bind ¶ added in v0.19.9
func (vb *VertexBuffer) Bind()
func (*VertexBuffer) GetLayout ¶ added in v0.19.9
func (vb *VertexBuffer) GetLayout() []Element
func (*VertexBuffer) SetData ¶ added in v0.19.9
func (vb *VertexBuffer) SetData(values []float32, usage BufUsage)
func (*VertexBuffer) SetLayout ¶ added in v0.19.9
func (vb *VertexBuffer) SetLayout(layout ...Element)
func (*VertexBuffer) UnBind ¶ added in v0.19.9
func (vb *VertexBuffer) UnBind()