Documentation ¶
Index ¶
- type BufferMgr
- func (bm *BufferMgr) Activate()
- func (bm *BufferMgr) AddIndexesBuffer(usg gpu.VectorUsages) gpu.IndexesBuffer
- func (bm *BufferMgr) AddVectorsBuffer(usg gpu.VectorUsages) gpu.VectorsBuffer
- func (bm *BufferMgr) Delete()
- func (bm *BufferMgr) Handle() uint32
- func (bm *BufferMgr) IndexesBuffer() gpu.IndexesBuffer
- func (bm *BufferMgr) TransferAll()
- func (bm *BufferMgr) TransferIndexes()
- func (bm *BufferMgr) TransferVectors()
- func (bm *BufferMgr) VectorsBuffer() gpu.VectorsBuffer
- type Drawing
- func (dr *Drawing) Clear(color, depth bool)
- func (dr *Drawing) ClearColor(r, g, b float32)
- func (dr *Drawing) CullFace(front, back, ccw bool)
- func (dr *Drawing) DepthTest(on bool)
- func (dr *Drawing) Flush()
- func (dr *Drawing) Multisample(on bool)
- func (dr *Drawing) Op(op draw.Op)
- func (dr *Drawing) StencilTest(on bool)
- func (dr *Drawing) TriangleStrips(start, count int)
- func (dr *Drawing) TriangleStripsIndexed(start, count int)
- func (dr *Drawing) Triangles(start, count int)
- func (dr *Drawing) TrianglesIndexed(start, count int)
- func (dr *Drawing) Viewport(rect image.Rectangle)
- func (dr *Drawing) Wireframe(on bool)
- type Framebuffer
- func (fb *Framebuffer) Activate()
- func (fb *Framebuffer) Bounds() image.Rectangle
- func (fb *Framebuffer) Delete()
- func (fb *Framebuffer) DepthAll() []float32
- func (fb *Framebuffer) DepthAt(x, y int) float32
- func (fb *Framebuffer) Handle() uint32
- func (fb *Framebuffer) Name() string
- func (fb *Framebuffer) Rendered()
- func (fb *Framebuffer) Samples() int
- func (fb *Framebuffer) SetName(name string)
- func (fb *Framebuffer) SetSamples(samples int)
- func (fb *Framebuffer) SetSize(size image.Point)
- func (fb *Framebuffer) SetTexture(tex gpu.Texture2D)
- func (fb *Framebuffer) Size() image.Point
- func (fb *Framebuffer) Texture() gpu.Texture2D
- type IndexesBuffer
- func (ib *IndexesBuffer) Activate()
- func (ib *IndexesBuffer) Delete()
- func (ib *IndexesBuffer) Handle() uint32
- func (ib *IndexesBuffer) Indexes() mat32.ArrayU32
- func (ib *IndexesBuffer) Len() int
- func (ib *IndexesBuffer) Set(idxs mat32.ArrayU32)
- func (ib *IndexesBuffer) SetLen(ln int)
- func (ib *IndexesBuffer) Transfer()
- type Pipeline
- type Program
- func (pr *Program) Activate()
- func (pr *Program) AddInput(name string, typ gpu.VectorType, role gpu.VectorRoles) gpu.Vectors
- func (pr *Program) AddOutput(name string, typ gpu.VectorType, role gpu.VectorRoles) gpu.Vectors
- func (pr *Program) AddShader(typ gpu.ShaderTypes, name string, src string) (gpu.Shader, error)
- func (pr *Program) AddUniform(name string, typ gpu.UniType, ary bool, ln int) gpu.Uniform
- func (pr *Program) AddUniforms(unis gpu.Uniforms)
- func (pr *Program) Compile(showSrc bool) error
- func (pr *Program) Delete()
- func (pr *Program) Handle() uint32
- func (pr *Program) InputByName(name string) gpu.Vectors
- func (pr *Program) InputByRole(role gpu.VectorRoles) gpu.Vectors
- func (pr *Program) Inputs() []gpu.Vectors
- func (pr *Program) Name() string
- func (pr *Program) NewUniforms(name string) gpu.Uniforms
- func (pr *Program) OutputByName(name string) gpu.Vectors
- func (pr *Program) OutputByRole(role gpu.VectorRoles) gpu.Vectors
- func (pr *Program) Outputs() []gpu.Vectors
- func (pr *Program) SetFragDataVar(name string)
- func (pr *Program) SetName(name string)
- func (pr *Program) ShaderByName(name string) gpu.Shader
- func (pr *Program) ShaderByType(typ gpu.ShaderTypes) gpu.Shader
- func (pr *Program) UniformByName(name string) gpu.Uniform
- func (pr *Program) UniformsByName(name string) gpu.Uniforms
- type Shader
- func (sh *Shader) Compile(src string) error
- func (sh *Shader) Delete()
- func (sh *Shader) GPUType(typ gpu.ShaderTypes) uint32
- func (sh *Shader) Handle() uint32
- func (sh *Shader) Name() string
- func (sh *Shader) OrigSource() string
- func (sh *Shader) Source() string
- func (sh *Shader) Type() gpu.ShaderTypes
- type Uniform
- func (un *Uniform) Array() bool
- func (un *Uniform) Handle() int32
- func (un *Uniform) Len() int
- func (un *Uniform) LenDefine() string
- func (un *Uniform) Name() string
- func (un *Uniform) Offset() int
- func (un *Uniform) SetLen(ln int)
- func (un *Uniform) SetValue(val interface{}) error
- func (un *Uniform) SetValueImpl(val interface{}) error
- func (un *Uniform) Size() int
- func (un *Uniform) StdSize() int
- func (un *Uniform) Type() gpu.UniType
- type Uniforms
- func (un *Uniforms) Activate() error
- func (un *Uniforms) AddUniform(name string, typ gpu.UniType, ary bool, ln int) gpu.Uniform
- func (un *Uniforms) Bind(prog gpu.Program) error
- func (un *Uniforms) BindingPoint() uint32
- func (un *Uniforms) Handle() uint32
- func (un *Uniforms) LenDefines() string
- func (un *Uniforms) Name() string
- func (un *Uniforms) Resize() error
- func (un *Uniforms) SetName(name string)
- func (un *Uniforms) UniformByName(name string) gpu.Uniform
- type Vectors
- type VectorsBuffer
- func (vb *VectorsBuffer) Activate()
- func (vb *VectorsBuffer) AddVectors(vec gpu.Vectors, interleave bool)
- func (vb *VectorsBuffer) AllData() mat32.ArrayF32
- func (vb *VectorsBuffer) ByteOffset(vec gpu.Vectors) int
- func (vb *VectorsBuffer) ByteStride(vec gpu.Vectors) int
- func (vb *VectorsBuffer) Delete()
- func (vb *VectorsBuffer) DeleteAllVectors()
- func (vb *VectorsBuffer) DeleteVectorsByName(name string)
- func (vb *VectorsBuffer) DeleteVectorsByRole(role gpu.VectorRoles)
- func (vb *VectorsBuffer) GPUUsage(usg gpu.VectorUsages) uint32
- func (vb *VectorsBuffer) Handle() uint32
- func (vb *VectorsBuffer) IsActive() bool
- func (vb *VectorsBuffer) Len() int
- func (vb *VectorsBuffer) NumVectors() int
- func (vb *VectorsBuffer) Offset(vec gpu.Vectors) int
- func (vb *VectorsBuffer) SetAllData(data mat32.ArrayF32)
- func (vb *VectorsBuffer) SetLen(ln int)
- func (vb *VectorsBuffer) SetUsage(usg gpu.VectorUsages)
- func (vb *VectorsBuffer) SetVecData(vec gpu.Vectors, data mat32.ArrayF32)
- func (vb *VectorsBuffer) Stride(vec gpu.Vectors) int
- func (vb *VectorsBuffer) Transfer()
- func (vb *VectorsBuffer) TransferVec(vec gpu.Vectors)
- func (vb *VectorsBuffer) Usage() gpu.VectorUsages
- func (vb *VectorsBuffer) Vec3Func(vec gpu.Vectors, fun func(vec *mat32.Vec3) bool)
- func (vb *VectorsBuffer) VecData(vec gpu.Vectors) mat32.ArrayF32
- func (vb *VectorsBuffer) Vectors() []gpu.Vectors
- func (vb *VectorsBuffer) VectorsByName(name string) gpu.Vectors
- func (vb *VectorsBuffer) VectorsByRole(role gpu.VectorRoles) gpu.Vectors
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 ¶
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) ClearColor ¶
ClearColor sets the color to draw when clear is called
func (*Drawing) CullFace ¶
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) 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 ¶
Multisample turns on or off multisampling (antialiasing)
func (*Drawing) Op ¶
Op sets the blend function based on go standard draw operation Src disables blending, and Over uses alpha-blending
func (*Drawing) StencilTest ¶
StencilTest turns on / off stencil testing
func (*Drawing) TriangleStrips ¶
TriangleStrips uses all existing settings to draw TriangleStrip (non-indexed)
func (*Drawing) TriangleStripsIndexed ¶
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) TrianglesIndexed ¶
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.
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()
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 ¶
AddProgram adds program with given name to the pipeline
func (*Pipeline) ProgramByName ¶
ProgramByName returns Program by name. Returns nil if not found (error auto logged).
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Handle returns the handle for the Program -- only valid after a Compile call
func (*Program) InputByName ¶
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 ¶
Inputs returns a list (slice) of all the input ('in') Vectors defined for this Program.
func (*Program) NewUniforms ¶
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 ¶
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 ¶
Outputs returns a list (slice) of all the output ('out') Vectors defined for this Program.
func (*Program) SetFragDataVar ¶
SetFragDataVar sets the variable name to use for the fragment shader's output
func (*Program) ShaderByName ¶
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 ¶
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)
type Shader ¶
type Shader struct {
// contains filtered or unexported fields
}
Shader manages a single Shader program
func (*Shader) Compile ¶
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) GPUType ¶
func (sh *Shader) GPUType(typ gpu.ShaderTypes) uint32
GPUType returns the GPU type id of the given Shader type
func (*Shader) OrigSource ¶
OrigSource returns the original user-supplied source code excluding the null terminator (for display purposes)
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 ¶
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 ¶
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) LenDefine ¶
LenDefine returns the #define NAME_LEN source code for this Uniform, empty if not an array
func (*Uniform) Offset ¶
Offset returns byte-wise offset into the UBO where this Uniform starts (only for UBO's)
func (*Uniform) SetLen ¶
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 ¶
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 (*Uniform) Size ¶
Size() returns actual byte-wise size of this uniform raw data (c.f., StdSize)
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 ¶
Activate generates the Uniform Buffer Object structure and reserves the binding point
func (*Uniforms) AddUniform ¶
AddUniform adds a Uniform variable to this collection of Uniforms of given type
func (*Uniforms) Bind ¶
Bind binds the Uniform Buffer Object structure to given program Activate must be called first
func (*Uniforms) BindingPoint ¶
BindingPoint returns the unique binding point for this set of Uniforms -- needed for connecting to Programs
func (*Uniforms) Handle ¶
Handle returns the handle for the Program -- only valid after a Compile call
func (*Uniforms) LenDefines ¶
LenDefines returns the #define NAME_LEN source code for all Uniforms, empty if no arrays
func (*Uniforms) Resize ¶
Resize resizes the buffer if needed -- call if any of the member uniforms might have been resized. Calls Activate if not already activated.
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 ¶
Handle returns the unique handle for these Vectors within the program where it is used
func (*Vectors) Name ¶
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.
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 ¶
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)