Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Buffer

Wrapper around an OpenGL array or element array buffer. This buffer may be used to be attached to multiple VAOs.

Hierarchy

Implements

Index

Constructors

constructor

  • new Buffer(context: Context, identifier?: undefined | string): Buffer
  • Object constructor, requires a context and a valid identifier.

    Parameters

    • context: Context

      Valid context to create the object for.

    • Optional identifier: undefined | string

      Meaningful name for identification of this instance.

    Returns Buffer

Properties

Protected _context

_context: Context
see

context

Protected _identifier

_identifier: string

Protected _object

_object: WebGLBuffer | undefined
see

object

Protected _referenceCount

_referenceCount: number = 0

Number of references to this object. If at least a single reference was counted, this object can neither be initialized (and thus created) nor uninitialized (and thus deleted). The reference count is controlled via ref() and unref() functions.

Protected _target

_target: GLenum | undefined = Buffer.DEFAULT_BUFFER
see

target

Protected _valid

_valid: boolean = false
see

valid

Static DEFAULT_BUFFER

DEFAULT_BUFFER: undefined = undefined

Default buffer, e.g., used for unbind.

Accessors

bytes

  • get bytes(): number
  • Returns the number of bytes this object approximately allocates on the GPU.

    Returns number

context

identifier

  • get identifier(): string
  • Every GPU asset that allocates memory should provide a human readable identifier for GPU allocation tracking and debugging purposes. Please note that the identifier might changed on initialization due to the generation and assignment of a unique identifier.

    Returns string

    • This assets identifier used for gpu allocation tracking and debugging.

initialized

  • get initialized(): boolean

object

  • get object(): WebGLBuffer

target

  • get target(): GLenum | undefined
  • Target to which the buffer object is bound (either GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER). Readonly access to the target (as specified on initialization) the buffer will be bound to.

    Returns GLenum | undefined

valid

  • get valid(): boolean
  • Cached object status used to derive validity when initialized.

    Returns boolean

    • True if the object status is complete, false otherwise.

Methods

Protected assertInitialized

  • assertInitialized(): void
  • Asserts the objects initialization status to be true. Note that the implementation is cached and forwarded to either an empty function when initialized and to an acutal assert(false) otherwise.

    Returns void

Protected assertUninitialized

  • assertUninitialized(): undefined
  • Asserts the objects initialization status to be false. Note that the implementation is cached and forwarded to either an empty function when uninitialized and to an acutal assert(false) otherwise.

    Returns undefined

attribDisable

  • attribDisable(index: GLuint, bind?: boolean, unbind?: boolean): void
  • Disables a buffer binding point.

    Parameters

    • index: GLuint

      Index of the vertex attribute that is to be disabled.

    • Default value bind: boolean = true

      Allows to skip binding the object (e.g., when binding is handled outside).

    • Default value unbind: boolean = true

      Allows to skip unbinding the object (e.g., when binding is handled outside).

    Returns void

attribEnable

  • attribEnable(index: GLuint, size: GLint, type: GLenum, normalized?: GLboolean, stride?: GLsizei, offset?: GLintptr, bind?: boolean, unbind?: boolean): void
  • Specifies the memory layout of the buffer for a binding point.

    Parameters

    • index: GLuint

      Index of the vertex attribute that is to be setup and enabled.

    • size: GLint

      Number of components per vertex attribute.

    • type: GLenum

      Data type of each component in the array.

    • Default value normalized: GLboolean = false

      Whether integer data values should be normalized when being casted to a float.

    • Default value stride: GLsizei = 0

      Offset in bytes between the beginning of consecutive vertex attributes.

    • Default value offset: GLintptr = 0

      Offset in bytes of the first component in the vertex attribute array.

    • Default value bind: boolean = true

      Allows to skip binding the object (e.g., when binding is handled outside).

    • Default value unbind: boolean = true

      Allows to skip unbinding the object (e.g., when binding is handled outside).

    Returns void

bind

  • bind(): void
  • Binds the buffer object as buffer to predefined target.

    Returns void

Protected create

  • create(target: GLenum): WebGLBuffer | undefined

data

  • data(data: ArrayBufferView | ArrayBuffer | GLsizeiptr, usage: GLenum, bind?: boolean, unbind?: boolean): void
  • Creates the buffer object's data store and updates the objects status.

    Parameters

    • data: ArrayBufferView | ArrayBuffer | GLsizeiptr

      Data that will be copied into the objects data store.

    • usage: GLenum

      Usage pattern of the data store.

    • Default value bind: boolean = true

      Allows to skip binding the object (e.g., when binding is handled outside).

    • Default value unbind: boolean = true

      Allows to skip unbinding the object (e.g., when binding is handled outside).

    Returns void

Protected delete

  • delete(): void

initialize

  • initialize(...args: any[]): boolean
  • override

    Ensure that an object handle is created at the point of initialization. When overriding this function super.initialize() has to be invoked immediately/first. Please note that initialization of invalid object raises an assertion in order to prevent further actions without a valid WebGL object. After object creation the valid property is expected to be set accordingly.

    Parameters

    • Rest ...args: any[]

    Returns boolean

ref

  • ref(): void

subData

  • subData(dstByteOffset: GLintptr, srcData: ArrayBufferView | ArrayBuffer, srcOffset?: GLuint, length?: GLuint, bind?: boolean, unbind?: boolean): void
  • Updates a subset of a buffer object's data store.

    Parameters

    • dstByteOffset: GLintptr

      Offset in bytes where the data replacement will start.

    • srcData: ArrayBufferView | ArrayBuffer

      Data that will be copied into the data store.

    • Default value srcOffset: GLuint = 0

      Element index offset where to start reading the buffer.

    • Default value length: GLuint = 0

      Length of the data to copy into the data store.

    • Default value bind: boolean = true

      Allows to skip binding the object (e.g., when binding is handled outside).

    • Default value unbind: boolean = true

      Allows to skip unbinding the object (e.g., when binding is handled outside).

    Returns void

unbind

  • unbind(): void
  • Binds null as current buffer to predefined target;

    Returns void

uninitialize

  • uninitialize(): void
  • override

    Ensure that an object handle is deleted, invalidated, and its allocated GPU resources are set to zero. When overriding this function super.uninitialize() has to be invoked last/at the end. Note that an object cannot be uninitialized if it is referenced (reference count > 0).

    Returns void

unref

  • unref(): void

Static Protected assertInitializedFalse

Static Protected assertUninitializedFalse

Static assert_initialized

Static assert_uninitialized

Static initialize

  • Method decorator for initialization of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be initialized, invokes its initialization with arbitrary number of parameters, and sets the initialization status to the initialization success (either false or true). In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to either a static, always-failing assert or an empty/undefined function.

    Returns MethodDecorator

Static uninitialize

  • Method decorator for uninitialization of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be uninitialized, invokes its uninitialization, and falsifies the initialization status. In order to encourage the use of assertInitialized and assertUninitialized they are dynamically bound to a static, always-failing assert and an empty/undefined function respectively.

    Returns MethodDecorator