buffers

package
v0.0.0-...-d94cd9b Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufGLType

type BufGLType int
const (
	BufGLTypeUnknown BufGLType = 0
	//Generic array of data. Should be used for most data like vertex positions, vertex colors etc.
	BufGLTypeArray   BufGLType = gl.ARRAY_BUFFER
	BufGLTypeIndices BufGLType = gl.ELEMENT_ARRAY_BUFFER
)

type BufType

type BufType int
const (
	BufTypeUnknown BufType = iota
	BufTypeVertPos
	BufTypeColor
	BufTypeIndex
	BufTypeNormal
)

func (BufType) GetBufferGLType

func (bt BufType) GetBufferGLType() BufGLType

type BufUsage

type BufUsage int
const (
	//Buffer is set only once and used many times
	BufUsageStatic BufUsage = gl.STATIC_DRAW
	//Buffer is changed a lot and used many times
	BufUsageDynamic BufUsage = gl.DYNAMIC_DRAW
	//Buffer is set only once and used by the GPU at most a few times
	BufUsageStream BufUsage = gl.STREAM_DRAW
)

type Buffer

type Buffer struct {
	ID     uint32
	Type   BufType
	GLType BufGLType
	DataTypeInfo
}

func (*Buffer) Activate

func (b *Buffer) Activate()

func (*Buffer) Deactivate

func (b *Buffer) Deactivate()

type BufferObject

type BufferObject struct {
	VAOID      uint32
	VertPosBuf *Buffer
	NormalBuf  *Buffer
	ColorBuf   *Buffer
	IndexBuf   *Buffer
}

func NewBufferObject

func NewBufferObject() *BufferObject

func (*BufferObject) Activate

func (bo *BufferObject) Activate()

func (*BufferObject) Deactivate

func (bo *BufferObject) Deactivate()

func (*BufferObject) GenBuffer

func (bo *BufferObject) GenBuffer(data []float32, bufUsage BufUsage, bufType BufType, bufDataType DataType)

func (*BufferObject) GenBufferUint32

func (bo *BufferObject) GenBufferUint32(data []uint32, bufUsage BufUsage, bufType BufType, bufDataType DataType)

func (*BufferObject) SetBuffer

func (bo *BufferObject) SetBuffer(buf *Buffer)

type DataType

type DataType int
const (
	DataTypeUnknown DataType = iota
	DataTypeUint32
	DataTypeInt32
	DataTypeFloat32
	DataTypeFloat64

	DataTypeVec2
	DataTypeVec3
	DataTypeVec4
)

type DataTypeInfo

type DataTypeInfo struct {
	//ElementSize is size in bytes of one element (e.g. for vec3 its 4)
	ElementSize int32
	//ElementCount is number of elements (e.g. for vec3 its 3)
	ElementCount int32
	//ElementType is the type of each primitive (e.g. for vec3 its gl.FLOAT)
	ElementType uint32
	//GLType is the type of the variable represented (e.g. for vec3 its gl.FLOAT_VEC2)
	GLType uint32
}

func GetDataTypeInfo

func GetDataTypeInfo(dt DataType) DataTypeInfo

func (*DataTypeInfo) GetSize

func (dti *DataTypeInfo) GetSize() int32

GetSize returns the total size in bytes (e.g. for vec3 its 4*3)

Jump to

Keyboard shortcuts

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