glc

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BUF_STREAM_DRAW = gl.STREAM_DRAW
	BUF_STREAM_READ = gl.STREAM_READ
	BUF_STREAM_COPY = gl.STREAM_COPY

	BUF_STATIC_DRAW = gl.STATIC_DRAW
	BUF_STATIC_READ = gl.STATIC_READ
	BUF_STATIC_COPY = gl.STATIC_COPY

	BUF_DYNAMIC_DRAW = gl.DYNAMIC_DRAW
	BUF_DYNAMIC_READ = gl.DYNAMIC_READ
	BUF_DYNAMIC_COPY = gl.DYNAMIC_COPY
)

buffer usage hint those are passed to the GPU driver to help optimizer when NewBuffer/LoadBuffer is called see https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBufferData.xhtml

View Source
const (
	MAP_READ       = gl.MAP_READ_BIT
	MAP_WRITE      = gl.MAP_WRITE_BIT
	MAP_PERSISTENT = gl.MAP_PERSISTENT_BIT
	MAP_COHERENT   = gl.MAP_COHERENT_BIT

	MAP_INVALIDATE_RANGE  = gl.MAP_INVALIDATE_RANGE_BIT
	MAP_INVALIDATE_BUFFER = gl.MAP_INVALIDATE_BUFFER_BIT
	MAP_FLUSH_EXPLICIT    = gl.MAP_FLUSH_EXPLICIT_BIT
	MAP_UNSYNCHRONIZED    = gl.MAP_UNSYNCHRONIZED_BIT
)

access flags

Variables

This section is empty.

Functions

func Barrier

func Barrier()

memory barrier

func Flush

func Flush()

waits for instruction pipeline to be empty

func Init

func Init()

Init OpenGL context must be called before calling any other function from glc this function calls glInit()

func Sync

func Sync()

wait until al GPU tasks are done and returns when memory is synchronized

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Wrapper for OpenGL buffer objects

func LoadBufferAtomic

func LoadBufferAtomic(sourceSlicePtr interface{}, usageHint uint32) *Buffer

func LoadBufferStorage

func LoadBufferStorage(sourceSlicePtr interface{}, usageHint uint32) *Buffer

func LoadBufferUniform

func LoadBufferUniform(sourceSlicePtr interface{}, usageHint uint32) *Buffer

func NewBufferAtomic

func NewBufferAtomic(length int, elemSize uintptr, usageHint uint32) *Buffer

Allocates a buffer object for usage as atomic counters

func NewBufferStorage

func NewBufferStorage(length int, elemSize uintptr, usageHint uint32) *Buffer

Allocates a buffer object for storage (mapped R/W access by shaders)

func NewBufferUniform

func NewBufferUniform(length int, elemSize uintptr, usageHint uint32) *Buffer

Allocates a buffer object for usage as shader uniform parameter

func (*Buffer) Bind

func (b *Buffer) Bind(slot uint32)

Bind the buffer to a shader binding point see https://www.khronos.org/opengl/wiki/GLAPI/glBindBufferBase

func (*Buffer) Delete

func (b *Buffer) Delete()

Free GPU memory

func (*Buffer) Download

func (b *Buffer) Download(slicePtr interface{})

fetch buffer from GPU

func (*Buffer) Map

func (b *Buffer) Map(slicePtr interface{}, accessFlags uint32)

pass a slice buffer then Map will ma it point to the memory-mapped address of the buffer in GPU memory

func (*Buffer) MapRange

func (b *Buffer) MapRange(slicePtr interface{}, offset, length int, accessFlags uint32)

Map for a subset of the buffer

func (*Buffer) Ready

func (b *Buffer) Ready() bool

Returns true if the buffer object is ready to be used by opengl

func (*Buffer) Unmap

func (b *Buffer) Unmap() bool

func (*Buffer) Upload

func (b *Buffer) Upload(slicePtr interface{})

send buffer from CPU to GPU

type Program

type Program struct {
	// contains filtered or unexported fields
}

Hight-level wrapper for shader programs

func LoadProgram

func LoadProgram(path string) *Program

init a program then link it with a shader copiled from the source file passed as argument

func NewProgram

func NewProgram() *Program

returns a new empty program it must be linked with a shader before it can be used

func (Program) Call

func (p Program) Call(x, y, z uint32, args ...*Buffer)

bind the list of buffers passed in ascending order then calls glDispatchCompute ie. p.Call(a, b, c, buf1, nil, buf2) is equivalent to buf1.Bind(0) buf2.Bind(2) p.Dispacth(a, b, c)

func (*Program) Delete

func (p *Program) Delete()

free GPU memory

func (Program) Dispatch

func (p Program) Dispatch(x, y, z uint32)

calls glDispatchCompute()

func (*Program) LinkShader

func (p *Program) LinkShader(shader *Shader) error

func (*Program) LoadSrc

func (p *Program) LoadSrc(path string) error

compiles a shader from a file and links it with program

func (*Program) Ready

func (p *Program) Ready() bool

returns true if the buiffer is ready to be used

type Shader

type Shader struct {
	// contains filtered or unexported fields
}

wrapper for shaders not necessary since Program handles the creation/deletion of shaders

func NewShader

func NewShader() *Shader

func (*Shader) CompileFile

func (s *Shader) CompileFile(path string) error

func (*Shader) CompileStr

func (s *Shader) CompileStr(source string) error

func (*Shader) Delete

func (s *Shader) Delete()

func (*Shader) Ready

func (s *Shader) Ready() bool

Jump to

Keyboard shortcuts

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