glgpu

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferMgr

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

BufferMgr maintains VectorsBuffer and IndexesBuffer and also the critical VAO (Vertex Array Object) for OpenGL which holds these active buffer pointers. A typical Shape / Object / Geom will just have this. TheGPU.NewBufferMgr() returns a new buffer manager.

func (*BufferMgr) Activate

func (bm *BufferMgr) Activate()

Activate binds buffers as active and configures as needed

func (*BufferMgr) AddIndexesBuffer

func (bm *BufferMgr) AddIndexesBuffer(usg gpu.VectorUsages) gpu.IndexesBuffer

AddIndexesBuffer makes a new IndexesBuffer to contain Indexes.

func (*BufferMgr) AddVectorsBuffer

func (bm *BufferMgr) AddVectorsBuffer(usg gpu.VectorUsages) gpu.VectorsBuffer

AddVectorsBuffer makes a new VectorsBuffer to contain Vectors.

func (*BufferMgr) Delete

func (bm *BufferMgr) Delete()

Delete deletes the GPU resources associated with this buffer (requires Activate to re-establish a new one). Should be called prior to Go object being deleted (ref counting can be done externally).

func (*BufferMgr) Handle

func (bm *BufferMgr) Handle() uint32

Handle returns the unique handle for this buffer manager -- only valid after Activate() this is the VAO

func (*BufferMgr) IndexesBuffer

func (bm *BufferMgr) IndexesBuffer() gpu.IndexesBuffer

IndexesBuffer returns the IndexesBuffer for this mgr

func (*BufferMgr) TransferAll

func (bm *BufferMgr) TransferAll()

TransferAll transfers all buffer data to GPU (e.g., for initial upload). Activate must have been called with no other such buffers activated in between.

func (*BufferMgr) TransferIndexes

func (bm *BufferMgr) TransferIndexes()

TransferIndexes transfers indexes buffer data to GPU -- if indexes data has changed. Activate must have been called with no other such buffers activated in between.

func (*BufferMgr) TransferVectors

func (bm *BufferMgr) TransferVectors()

TransferVectors transfers vectors buffer data to GPU -- if vector data has changed. Activate must have been called with no other such buffers activated in between.

func (*BufferMgr) VectorsBuffer

func (bm *BufferMgr) VectorsBuffer() gpu.VectorsBuffer

VectorsBuffer returns the VectorsBuffer for this mgr

type Drawing

type Drawing struct {
}

Drawing provides commonly-used GPU drawing functions All operate on the current context with current program, target, etc

func (*Drawing) Clear

func (dr *Drawing) Clear(color, depth bool)

Clear clears the given properties of the current render target

func (*Drawing) ClearColor

func (dr *Drawing) ClearColor(r, g, b float32)

ClearColor sets the color to draw when clear is called

func (*Drawing) CullFace

func (dr *Drawing) CullFace(front, back, ccw bool)

CullFace sets face culling, for front and / or back faces (back typical). If you don't do this, rendering of standard Phong model will not work.

func (*Drawing) DepthTest

func (dr *Drawing) DepthTest(on bool)

DepthTest turns on / off depth testing

func (*Drawing) Flush

func (dr *Drawing) Flush()

Flush ensures that all rendering is pushed to current render target. Especially useful for rendering to framebuffers (Window SwapBuffer automatically does a flush)

func (*Drawing) Multisample

func (dr *Drawing) Multisample(on bool)

Multisample turns on or off multisampling (antialiasing)

func (*Drawing) Op

func (dr *Drawing) Op(op draw.Op)

Op sets the blend function based on go standard draw operation Src disables blending, and Over uses alpha-blending

func (*Drawing) StencilTest

func (dr *Drawing) StencilTest(on bool)

StencilTest turns on / off stencil testing

func (*Drawing) TriangleStrips

func (dr *Drawing) TriangleStrips(start, count int)

TriangleStrips uses all existing settings to draw TriangleStrip (non-indexed)

func (*Drawing) TriangleStripsIndexed

func (dr *Drawing) TriangleStripsIndexed(start, count int)

TriangleStripsIndexed uses all existing settings to draw Triangle Strips Indexed. You must have activated an IndexesBuffer that supplies the indexes, and start + count determine range of such indexes to use, and must be within bounds for that.

func (*Drawing) Triangles

func (dr *Drawing) Triangles(start, count int)

Triangles uses all existing settings to draw Triangles (non-indexed)

func (*Drawing) TrianglesIndexed

func (dr *Drawing) TrianglesIndexed(start, count int)

TrianglesIndexed uses all existing settings to draw Triangles Indexed. You must have activated an IndexesBuffer that supplies the indexes, and start + count determine range of such indexes to use, and must be within bounds for that.

func (*Drawing) Viewport

func (dr *Drawing) Viewport(rect image.Rectangle)

Viewport sets the rendering viewport to given rectangle. It is important to update this for each render -- cannot assume it.

func (*Drawing) Wireframe added in v0.9.11

func (dr *Drawing) Wireframe(on bool)

Wireframe sets the rendering to lines instead of fills if on = true

type Framebuffer

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

Framebuffer is an offscreen render target. gi3d renders exclusively to a Framebuffer, which is then copied to the overall oswin.Window.WinTex texture that backs the window for final display to the user.

func (*Framebuffer) Activate

func (fb *Framebuffer) Activate() error

Activate establishes the GPU resources and handle for the framebuffer and all other associated buffers etc (if not already done). It then sets this as the current rendering target for subsequent gpu drawing commands.

func (*Framebuffer) Bounds

func (fb *Framebuffer) Bounds() image.Rectangle

Bounds returns the bounds of the framebuffer's image. It is equal to image.Rectangle{Max: t.Size()}.

func (*Framebuffer) Delete

func (fb *Framebuffer) Delete()

Delete deletes the GPU resources associated with this framebuffer (requires Activate to re-establish a new one). Should be called prior to Go object being deleted (ref counting can be done externally). Does NOT delete any Texture set by SetTexture -- must be done externally.

func (*Framebuffer) DepthAll added in v0.9.9

func (fb *Framebuffer) DepthAll() []float32

DepthAll returns the entire depth buffer as a slice of float32 values of same size as framebuffer. This slice is pointer to internal reused value -- copy to retain values or modify. Must be called with a valid gpu context and on proper thread for that context, with framebuffer active.

func (*Framebuffer) DepthAt added in v0.9.9

func (fb *Framebuffer) DepthAt(x, y int) float32

DepthAt returns the depth-buffer value at given x,y coordinate in framebuffer coordinates (i.e., Y = 0 is at bottom). Must be called with a valid gpu context and on proper thread for that context, with framebuffer active.

func (*Framebuffer) Handle

func (fb *Framebuffer) Handle() uint32

Handle returns the GPU handle for the framebuffer -- only valid after Activate.

func (*Framebuffer) Name

func (fb *Framebuffer) Name() string

Name returns the name of the framebuffer

func (*Framebuffer) Rendered added in v0.9.9

func (fb *Framebuffer) Rendered()

Rendered should be called after rendering to the framebuffer, to ensure the update of data transferred from the framebuffer (texture, depth buffer)

func (*Framebuffer) Samples

func (fb *Framebuffer) Samples() int

Samples returns the number of multi-sample samples

func (*Framebuffer) SetName

func (fb *Framebuffer) SetName(name string)

SetName sets the name of the framebuffer

func (*Framebuffer) SetSamples

func (fb *Framebuffer) SetSamples(samples int)

SetSamples sets the number of samples to use for multi-sample anti-aliasing. When using as a primary 3D render target, the recommended number is 4 to produce much better-looking results. If just using as an intermediate render buffer, then you may want to turn off by setting to 0. Setting to a number > 0 automatically disables use of external Texture2D that might have previously been set by SetTexture -- must call Texture() to get downsampled texture instead.

func (*Framebuffer) SetSize

func (fb *Framebuffer) SetSize(size image.Point)

SetSize sets the size of the framebuffer. If framebuffer has been Activate'd, then this resizes the GPU side as well, and if a texture has been linked to this Framebuffer with SetTexture then it is also resized with SetSize.

func (*Framebuffer) SetTexture

func (fb *Framebuffer) SetTexture(tex gpu.Texture2D)

SetTexture sets an existing Texture2D to serve as the color buffer target for this framebuffer. This also implies SetSamples(0), and that the Texture() method just directly returns the texture set here. If we have a non-zero size, then the texture is automatically resized to the size of the framebuffer, otherwise the fb inherits size of texture.

func (*Framebuffer) Size

func (fb *Framebuffer) Size() image.Point

Size returns the size of the framebuffer

func (*Framebuffer) Texture

func (fb *Framebuffer) Texture() gpu.Texture2D

Texture returns the current contents of the framebuffer as a Texture2D. Returns nil if not activated. For Samples() > 0 this reduces the optimized internal render buffer to a standard 2D texture -- the return texture is owned and managed by the framebuffer, and re-used every time Texture() is called. If SetTexture was called, then it just returns that texture which was directly rendered to.

type IndexesBuffer

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

IndexesBuffer manages a buffer of indexes for index-based rendering (i.e., GL_ELEMENT_ARRAY_BUFFER for glDrawElements calls in OpenGL).

func (*IndexesBuffer) Activate

func (ib *IndexesBuffer) Activate()

Activate binds buffer as active one

func (*IndexesBuffer) Delete

func (ib *IndexesBuffer) Delete()

Delete deletes the GPU resources associated with this buffer (requires Activate to re-establish a new one). Should be called prior to Go object being deleted (ref counting can be done externally).

func (*IndexesBuffer) Handle

func (ib *IndexesBuffer) Handle() uint32

Handle returns the unique handle for this buffer -- only valid after Activate()

func (*IndexesBuffer) Indexes

func (ib *IndexesBuffer) Indexes() mat32.ArrayU32

Returns the indexes (direct copy of internal buffer -- can be modified)

func (*IndexesBuffer) Len

func (ib *IndexesBuffer) Len() int

Len returns the number of indexes in bufer

func (*IndexesBuffer) Set

func (ib *IndexesBuffer) Set(idxs mat32.ArrayU32)

Set sets the indexes by copying given data

func (*IndexesBuffer) SetLen

func (ib *IndexesBuffer) SetLen(ln int)

SetLen sets the number of indexes in buffer

func (*IndexesBuffer) Transfer

func (ib *IndexesBuffer) Transfer()

Transfer transfers data to GPU -- Activate must have been called with no other such buffers activated in between. Automatically uses re-specification strategy per: https://www.khronos.org/opengl/wiki/Buffer_Object_Streaming so it is safe if buffer was still being used from prior GL rendering call.

type Pipeline

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

Pipeline manages a sequence of Programs that can be activated in an appropriate order to achieve some overall step of rendering. A new Pipeline can be created in TheGPU.NewPipeline().

func (*Pipeline) AddProgram

func (pl *Pipeline) AddProgram(name string) gpu.Program

AddProgram adds program with given name to the pipeline

func (*Pipeline) Delete

func (pl *Pipeline) Delete()

func (*Pipeline) Name

func (pl *Pipeline) Name() string

Name returns name of this pipeline

func (*Pipeline) ProgramByName

func (pl *Pipeline) ProgramByName(name string) gpu.Program

ProgramByName returns Program by name. Returns nil if not found (error auto logged).

func (*Pipeline) Programs

func (pl *Pipeline) Programs() []gpu.Program

Programs returns list (slice) of Programs in pipeline

func (*Pipeline) SetName

func (pl *Pipeline) SetName(name string)

SetName sets name of this pipeline

type Program

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

Program manages a set of shaders and associated variables and uniforms. Multiple programs can be assembled into a Pipeline, which can create new Programs. GPU.NewProgram() can also create standalone Programs. All uniforms must be added before compiling program.

func (*Program) Activate

func (pr *Program) Activate()

Activate activates this as the active Program -- must have been Compiled first.

func (*Program) AddInput

func (pr *Program) AddInput(name string, typ gpu.VectorType, role gpu.VectorRoles) gpu.Vectors

AddInput adds a Vectors input variable to the Program -- name must = 'in' var name. This input will get bound to variable and handle updated when Program is compiled.

func (*Program) AddOutput

func (pr *Program) AddOutput(name string, typ gpu.VectorType, role gpu.VectorRoles) gpu.Vectors

AddOutput adds a Vectors output variable to the Program -- name must = 'out' var name. This output will get bound to variable and handle updated when Program is compiled.

func (*Program) AddShader

func (pr *Program) AddShader(typ gpu.ShaderTypes, name string, src string) (gpu.Shader, error)

AddShader adds shader of given type, unique name and source code. Any array Uniform's will add their #define NAME_LEN's to the top of the source code automatically, so the source can assume those exist when compiled.

func (*Program) AddUniform

func (pr *Program) AddUniform(name string, typ gpu.UniType, ary bool, ln int) gpu.Uniform

AddUniform adds an individual standalone Uniform variable to the Program of given type. Must add all Uniform variables before compiling, as they add to source.

func (*Program) AddUniforms

func (pr *Program) AddUniforms(unis gpu.Uniforms)

AddUniforms adds an existing Uniforms collection of Uniform variables to this Program. Uniforms will be bound etc when the Program is compiled.

func (*Program) Compile

func (pr *Program) Compile(showSrc bool) error

Compile compiles all the shaders and links the Program, binds the Uniforms and input / output vector variables, etc. This must be called after setting the lengths of any array Uniforms (e.g., the number of lights). showSrc arg prints out the final compiled source, including automatic defines etc at the top, even if there are no errors, which can be useful for debugging.

func (*Program) Delete

func (pr *Program) Delete()

Delete deletes the GPU resources associated with this Program (requires Compile and Activate to re-establish a new one). Should be called prior to Go object being deleted (ref counting can be done externally).

func (*Program) Handle

func (pr *Program) Handle() uint32

Handle returns the handle for the Program -- only valid after a Compile call

func (*Program) InputByName

func (pr *Program) InputByName(name string) gpu.Vectors

InputByName returns given input Vectors by name. Returns nil if not found (error auto logged)

func (*Program) InputByRole

func (pr *Program) InputByRole(role gpu.VectorRoles) gpu.Vectors

InputByRole returns given input Vectors by role. Returns nil if not found (error auto logged)

func (*Program) Inputs

func (pr *Program) Inputs() []gpu.Vectors

Inputs returns a list (slice) of all the input ('in') Vectors defined for this Program.

func (*Program) Name

func (pr *Program) Name() string

Name returns name of Program

func (*Program) NewUniforms

func (pr *Program) NewUniforms(name string) gpu.Uniforms

NewUniforms makes a new named set of Uniforms (i.e,. a Uniform Buffer Object) These Uniforms can be bound to Programs -- first add all the Uniform variables and then AddUniforms to each Program that uses it (already added to this one). Uniforms will be bound etc when the Program is compiled.

func (*Program) OutputByName

func (pr *Program) OutputByName(name string) gpu.Vectors

OutputByName returns given output Vectors by name. Returns nil if not found (error auto logged)

func (*Program) OutputByRole

func (pr *Program) OutputByRole(role gpu.VectorRoles) gpu.Vectors

OutputByRole returns given input Vectors by role. Returns nil if not found (error auto logged)

func (*Program) Outputs

func (pr *Program) Outputs() []gpu.Vectors

Outputs returns a list (slice) of all the output ('out') Vectors defined for this Program.

func (*Program) SetFragDataVar

func (pr *Program) SetFragDataVar(name string)

SetFragDataVar sets the variable name to use for the fragment shader's output

func (*Program) SetName

func (pr *Program) SetName(name string)

SetName sets name of program

func (*Program) ShaderByName

func (pr *Program) ShaderByName(name string) gpu.Shader

ShaderByName returns shader by its unique name

func (*Program) ShaderByType

func (pr *Program) ShaderByType(typ gpu.ShaderTypes) gpu.Shader

ShaderByType returns shader by its type

func (*Program) UniformByName

func (pr *Program) UniformByName(name string) gpu.Uniform

UniformByName returns a Uniform based on unique name -- this could be in a collection of Uniforms (i.e., a Uniform Buffer Object in GL) or standalone Returns nil if not found (error auto logged)

func (*Program) UniformsByName

func (pr *Program) UniformsByName(name string) gpu.Uniforms

UniformsByName returns Uniforms collection of given name Returns nil if not found (error auto logged)

type Shader

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

Shader manages a single Shader program

func (*Shader) Compile

func (sh *Shader) Compile(src string) error

Compile compiles given source code for the Shader, of given type and unique name. Currently, source must be GLSL version 410, which is the supported version of OpenGL. The source does not need to be null terminated (with \x00 code) but that will be more efficient, skipping the extra step of adding the null terminator. Context must be set.

func (*Shader) Delete

func (sh *Shader) Delete()

Delete deletes the Shader

func (*Shader) GPUType

func (sh *Shader) GPUType(typ gpu.ShaderTypes) uint32

GPUType returns the GPU type id of the given Shader type

func (*Shader) Handle

func (sh *Shader) Handle() uint32

Handle returns the GPU handle for this Shader

func (*Shader) Name

func (sh *Shader) Name() string

Name returns the unique name of this Shader

func (*Shader) OrigSource

func (sh *Shader) OrigSource() string

OrigSource returns the original user-supplied source code excluding the null terminator (for display purposes)

func (*Shader) Source

func (sh *Shader) Source() string

Source returns the actual final source code for the Shader excluding the null terminator (for display purposes). This includes extra auto-generated code from the Program.

func (*Shader) Type

func (sh *Shader) Type() gpu.ShaderTypes

Type returns the type of the Shader

type Uniform

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

Uniform represents a single uniform variable, which can be contained within a Uniform Buffer Object or used as a separate independent uniform. This can be an array of values as well, in which case a NAME_LEN macro is always defined to reflect the length of the array. These uniforms are used directly to generate the shader code. See Program.AddUniform to create a new standalone one, and Program.NewUniforms to create a new set of them (i.e., Uniform Buffer Object)

func (*Uniform) Array

func (un *Uniform) Array() bool

Array returns true if this is an array Uniform. If so, then it automatically generates a #define NAME_LEN <Len> definition prior to the Uniform definition, and if Len == 0 then it is *not* defined at all. All code referencing this Uniform should use #if NAME_LEN>0 wrapper.

func (*Uniform) Handle

func (un *Uniform) Handle() int32

Handle() returns the unique id for this Uniform. if in a UBO, then this is the index of the item within the list of UBO's

func (*Uniform) Len

func (un *Uniform) Len() int

Len returns number of array elements, if an Array (can be 0)

func (*Uniform) LenDefine

func (un *Uniform) LenDefine() string

LenDefine returns the #define NAME_LEN source code for this Uniform, empty if not an array

func (*Uniform) Name

func (un *Uniform) Name() string

Name returns name of the Uniform

func (*Uniform) Offset

func (un *Uniform) Offset() int

Offset returns byte-wise offset into the UBO where this Uniform starts (only for UBO's)

func (*Uniform) SetLen

func (un *Uniform) SetLen(ln int)

SetLen sets the number of array elements -- if this is changed, then the associated Shader program needs to be re-generated and recompiled. Unless this is in a Uniforms, must be recompiled before calling SetValue

func (*Uniform) SetValue

func (un *Uniform) SetValue(val interface{}) error

SetValue sets the value of the Uniform to given value, which must be of the corresponding elemental or mat32.Vector or mat32.Matrix type. Proper context must be bound, etc.

func (*Uniform) SetValueImpl

func (un *Uniform) SetValueImpl(val interface{}) error

func (*Uniform) Size

func (un *Uniform) Size() int

Size() returns actual byte-wise size of this uniform raw data (c.f., StdSize)

func (*Uniform) StdSize

func (un *Uniform) StdSize() int

StdSize() returns byte-wise size of this uniform, *including padding* for representation on the GPU -- e.g., as determined by the std140 standard opengl layout

func (*Uniform) Type

func (un *Uniform) Type() gpu.UniType

Type returns type of the Uniform

type Uniforms

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

Uniforms is a set of Uniform objects that are all organized together (i.e., a UniformBufferObject in OpenGL)

func (*Uniforms) Activate

func (un *Uniforms) Activate() error

Activate generates the Uniform Buffer Object structure and reserves the binding point

func (*Uniforms) AddUniform

func (un *Uniforms) AddUniform(name string, typ gpu.UniType, ary bool, ln int) gpu.Uniform

AddUniform adds a Uniform variable to this collection of Uniforms of given type

func (*Uniforms) Bind

func (un *Uniforms) Bind(prog gpu.Program) error

Bind binds the Uniform Buffer Object structure to given program Activate must be called first

func (*Uniforms) BindingPoint

func (un *Uniforms) BindingPoint() uint32

BindingPoint returns the unique binding point for this set of Uniforms -- needed for connecting to Programs

func (*Uniforms) Handle

func (un *Uniforms) Handle() uint32

Handle returns the handle for the Program -- only valid after a Compile call

func (*Uniforms) LenDefines

func (un *Uniforms) LenDefines() string

LenDefines returns the #define NAME_LEN source code for all Uniforms, empty if no arrays

func (*Uniforms) Name

func (un *Uniforms) Name() string

Name returns the name of this set of Uniforms

func (*Uniforms) Resize

func (un *Uniforms) Resize() error

Resize resizes the buffer if needed -- call if any of the member uniforms might have been resized. Calls Activate if not already activated.

func (*Uniforms) SetName

func (un *Uniforms) SetName(name string)

SetName sets the name of this set of uniforms

func (*Uniforms) UniformByName

func (un *Uniforms) UniformByName(name string) gpu.Uniform

UniformByName returns a Uniform based on unique name -- this could be in a collection of Uniforms (i.e., a Uniform Buffer Object in GL) or standalone

type Vectors

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

Vectors manages arrays of vectors that are processed as inputs to a shader program and received as outputs from compute shaders. i.e., a Vertex Buffer Object in OpenGL. It is created by Program.AddInputs, .AddOutputs, and stores the Handle into that program's variable. This handle is then bound to a buffer in VectorsBuffer.

func (*Vectors) Handle

func (ve *Vectors) Handle() uint32

Handle returns the unique handle for these Vectors within the program where it is used

func (*Vectors) Name

func (ve *Vectors) Name() string

Name returns the name of the Vectors (i.e., as it is referred to in the shader program)

func (*Vectors) Role

func (ve *Vectors) Role() gpu.VectorRoles

Role returns the functional role of these Vectors

func (*Vectors) Set

func (ve *Vectors) Set(name string, handle uint32, typ gpu.VectorType, role gpu.VectorRoles)

Set sets all the parameters of the Vectors, and flags it as init -- when created for predefined locations.

func (*Vectors) Type

func (ve *Vectors) Type() gpu.VectorType

Type returns the vector data type

type VectorsBuffer

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

VectorsBuffer represents a buffer with multiple Vectors elements, which can be either interleaved (contiguous from the start only) or appended seqeuentially. All elements must be Float32, not Float64! Need a different buffer type that handles 64bit. It is created in BufferMgr.AddVectorsBuffer -- the Mgr is essential for managing buffers. The buffer maintains its own internal memory storage (mat32.ArrayF32) which can be operated upon or set from external sources. Note: all arrangement data is in *float* units, not *byte* units -- multiply * 4 to get bytes.

func (*VectorsBuffer) Activate

func (vb *VectorsBuffer) Activate()

Activate binds buffer as active one, and configures it per all existing settings

func (*VectorsBuffer) AddVectors

func (vb *VectorsBuffer) AddVectors(vec gpu.Vectors, interleave bool)

AddVectors adds a Vectors to this buffer, all interleaved Vectors must be added first, before any non-interleaved (error will be logged if not). Vectors are created in a Program, and connected to this buffer here. All Vectors in a given Program must be stored in a SINGLE buffer. Add all Vectors before setting the length, which then computes offset and strides for each vector.

func (*VectorsBuffer) AllData

func (vb *VectorsBuffer) AllData() mat32.ArrayF32

AllData returns the raw buffer data. This is the pointer to the internal data -- if you modify it, you modify the internal data! copy first if needed.

func (*VectorsBuffer) ByteOffset

func (vb *VectorsBuffer) ByteOffset(vec gpu.Vectors) int

ByteOffset returns the starting offset of given Vectors in buffer

func (*VectorsBuffer) ByteStride

func (vb *VectorsBuffer) ByteStride(vec gpu.Vectors) int

ByteStride returns the byte-wise stride of given Vectors

func (*VectorsBuffer) Delete

func (vb *VectorsBuffer) Delete()

Delete deletes the GPU resources associated with this buffer (requires Activate to re-establish a new one). Should be called prior to Go object being deleted (ref counting can be done externally).

func (*VectorsBuffer) DeleteAllVectors

func (vb *VectorsBuffer) DeleteAllVectors()

DeleteAllVectors deletes all Vectors defined for this buffer (calls Delete first)

func (*VectorsBuffer) DeleteVectorsByName

func (vb *VectorsBuffer) DeleteVectorsByName(name string)

DeleteVectorsByName deletes Vectors of given name (calls Delete first)

func (*VectorsBuffer) DeleteVectorsByRole

func (vb *VectorsBuffer) DeleteVectorsByRole(role gpu.VectorRoles)

DeleteVectorsByRole deletes Vectors of given role (calls Delete first)

func (*VectorsBuffer) GPUUsage

func (vb *VectorsBuffer) GPUUsage(usg gpu.VectorUsages) uint32

func (*VectorsBuffer) Handle

func (vb *VectorsBuffer) Handle() uint32

Handle returns the unique handle for this buffer -- only valid after Activate()

func (*VectorsBuffer) IsActive

func (vb *VectorsBuffer) IsActive() bool

IsActive returns true if buffer has already been Activate'd and thus exists on the GPU

func (*VectorsBuffer) Len

func (vb *VectorsBuffer) Len() int

Len returns the number of elements in the buffer.

func (*VectorsBuffer) NumVectors

func (vb *VectorsBuffer) NumVectors() int

NumVectors returns number of vectors in the buffer

func (*VectorsBuffer) Offset

func (vb *VectorsBuffer) Offset(vec gpu.Vectors) int

Offset returns the float element wise starting offset of given Vectors in buffer

func (*VectorsBuffer) SetAllData

func (vb *VectorsBuffer) SetAllData(data mat32.ArrayF32)

SetAllData sets all of the data in the buffer copying from given source

func (*VectorsBuffer) SetLen

func (vb *VectorsBuffer) SetLen(ln int)

SetLen sets the number of elements in the buffer -- must be same number for each Vectors type in buffer. Also triggers computation of offsets and strides for each vector -- call after having added all Vectors.

func (*VectorsBuffer) SetUsage

func (vb *VectorsBuffer) SetUsage(usg gpu.VectorUsages)

SetUsage sets the usage of the buffer

func (*VectorsBuffer) SetVecData

func (vb *VectorsBuffer) SetVecData(vec gpu.Vectors, data mat32.ArrayF32)

SetVecData sets data for given Vectors -- handles interleaving etc

func (*VectorsBuffer) Stride

func (vb *VectorsBuffer) Stride(vec gpu.Vectors) int

Stride returns the float-element-wise stride of given Vectors

func (*VectorsBuffer) Transfer

func (vb *VectorsBuffer) Transfer()

Transfer transfers data to GPU -- Activate must have been called with no other such buffers activated in between. Automatically uses re-specification strategy per: https://www.khronos.org/opengl/wiki/Buffer_Object_Streaming so it is safe if buffer was still being used from prior GL rendering call.

func (*VectorsBuffer) TransferVec

func (vb *VectorsBuffer) TransferVec(vec gpu.Vectors)

TransferVec transfers only data for given vector to GPU -- only valid if Activate() and Transfer() have been called already, and only for non-interleaved Vectors.

func (*VectorsBuffer) Usage

func (vb *VectorsBuffer) Usage() gpu.VectorUsages

Usage returns whether this is dynamic or static etc

func (*VectorsBuffer) Vec3Func

func (vb *VectorsBuffer) Vec3Func(vec gpu.Vectors, fun func(vec *mat32.Vec3) bool)

Vec3Func iterates over all values of given vec3 vector and calls the specified callback function with a pointer to each item as a Vec3. Modifications to vec will be applied to the buffer at each iteration. The callback function returns false to break or true to continue.

func (*VectorsBuffer) VecData

func (vb *VectorsBuffer) VecData(vec gpu.Vectors) mat32.ArrayF32

VecData returns data for given Vectors -- this is a copy for interleaved data and a direct sub-slice for non-interleaved.

func (*VectorsBuffer) Vectors

func (vb *VectorsBuffer) Vectors() []gpu.Vectors

Vectors returns a list (slice) of all the Vectors in the buffer, in order.

func (*VectorsBuffer) VectorsByName

func (vb *VectorsBuffer) VectorsByName(name string) gpu.Vectors

VectorsByName returns given Vectors by name. Returns nil if not found (error auto logged)

func (*VectorsBuffer) VectorsByRole

func (vb *VectorsBuffer) VectorsByRole(role gpu.VectorRoles) gpu.Vectors

VectorsByRole returns given Vectors by role. Returns nil if not found (error auto logged)

Jump to

Keyboard shortcuts

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