visualization-tools

Home > @visualization-tools/core > IGlAttribute

IGlAttribute interface

Wrapper for dirty checked GL attributes with VAO and shared mutable buffer support. ChangeIds must be generated program wide to avoid collisions IncrementingIdentifierFactory (rc-js-util) is a suitable implementation.

Signature:

export interface IGlAttribute<TArray extends TTypedArray> 

Properties

Property Type Description
componentsPerVertex number The size of the attribute
name string The name of the attribute, must match the shader name exactly.

Methods

Method Description
bindArray(componentRenderer, usage) Binds the current buffer to ARRAY_BUFFER.
bindArrayInstanced(componentRenderer, divisor, usage) Like bind but with instancing enabled for this attribute.
bindTransform(componentRenderer, index) Binds the current buffer to TRANSFORM_FEEDBACK_BUFFER.
getBuffer()  
getSharableState() The internal state of the attribute that can be shared, namely the buffer that the attribute points to.
initialize(componentRenderer) Called once on creation or context restored.
link(sharedState) Links this attribute to shared state, such that a change to one attribute results in a change to all attributes.
onContextLost() Called once on context loss.
reset(componentRenderer) Reset the state of this attribute. If OES_vertex_array_object is enabled or the context is webgl2 this is a no-op. Called after update as part of the update strategy. Does not affect buffer state.
setBuffer(buffer)  
setData(data, changeId) Copy new data into the buffer.
setOffset(byteOffset) Set the byte offset into the buffer.
setSize(context, byteSize, usage, changeId) Resizes the buffer ready as a copy target. Clears the current data / dirty state.
setStride(byteStride) Set the number of bytes to the start of the next attribute.
setSubBufferData(componentRenderer, byteOffset, data, changeId, modificationId) Overwrite data in the buffer. The argument modificationId is provided to allow multiple writes per draw, if the modificationId is larger than the previous call’s modificationId then the modification is allowed. This resets whenever changeId changes.
swapBuffer(attribute) Transfer this attribute’s buffer to the argument and vice versa.