Options
All
  • Public
  • Public/Protected
  • All
Menu

Class VertexArray

Wrapper for drawable objects by means of multiple vertex buffer that could be bound to a vertex array. If the context supports vertex array objects either natively (webgl2) or by extension, the drawable buffer are bound only once on initialization and only a single VAO bind and unbind is required for a rendering pass.

The VertexArray can be used wrapped around any VertexBuffer interface:

export class ScreenFillingTriangle extends VertexArray {
// ...
    bind(index: GLuint): void { ... }
    unbind(index: GLuint): void { ... }
    draw(): void { ... }
}

export class ScreenFillingTriangleVAO extends VertexArray<ScreenFillingTriangle> { }

With that the screen-filling triangle can be drawn as follows:

this.someTriangleVAO.draw();

Hierarchy

  • AbstractObject<any>
    • VertexArray

Implements

  • Bindable

Index

Constructors

constructor

  • Object constructor, requires a context and a valid identifier.

    Parameters

    • context: Context

      Valid context to create the object for.

    • Optional identifier: string

      Meaningful name for identification of this instance.

    Returns VertexArray

Properties

Protected _bind

_bind: () => void

The feature specific bind function. This is mapped on initialization either to native VAO bind, extension based VAO bind or directly to the drawable's bind.

Type declaration

    • (): void
    • Returns void

Protected _buffersBound

_buffersBound: boolean = false

Flag to track one-time initialization (in case vertex arrays are supported).

Protected _context

_context: Context
see

context

Protected _identifier

_identifier: string

Protected _object

_object: any
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 _unbind

_unbind: () => void

The feature specific unbind function. This is mapped on initialization either to native VAO unbind, extension based VAO unbind or directly to the drawable's unbind.

Type declaration

    • (): void
    • Returns void

Protected _valid

_valid: boolean = false
see

valid

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.

Type declaration

    • (): void
    • Returns void

Protected assertUninitialized

assertUninitialized: () => void = ...

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.

Type declaration

    • (): void
    • Returns void

Static Readonly DEFAULT_VERTEX_ARRAY

DEFAULT_VERTEX_ARRAY: undefined = ...

Default vertex array, e.g., used for unbind.

Accessors

context

  • Read-only access to the objects context, used to get context information and WebGL API access.

    Returns 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
  • Property getter for readonly access to the initialization status of an initializable instance.

    Returns boolean

object

  • get object(): T

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

bind

  • bind(): void

Protected create

  • create(bindBOs: () => void, unbindBOs: () => void): any
  • Depending on the context features, a vertex array object is created and the bind method is specified (either native, by extension, or none/direct bind).

    Parameters

    • bindBOs: () => void

      Function that should bind all VBOs and IBOs required for drawing.

        • (): void
        • Returns void

    • unbindBOs: () => void

      Function that should unbind all VBOs and IBOs used for drawing.

        • (): void
        • Returns void

    Returns any

Protected delete

  • delete(): void
  • On deletion either the VAO is deleted (when VAOs are supported natively or by extension) or nothing happens. Note that the VAO does not own any of its associated buffers (which can be shared over multiple VAO instances or used directly).

    Returns 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

invalidate

  • invalidate(): void
  • Can be used to enforce rebinding all buffers, e.g., when data has changed.

    Returns void

ref

  • ref(): void
  • Increment the reference count of this object.

    Returns void

unbind

  • unbind(): 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
  • Decrement the reference count of this object.

    Returns void

Static Protected Readonly assertInitializedFalse

Static Protected Readonly assertUninitializedFalse

Static assert_initialized

  • assert_initialized(): MethodDecorator
  • Method decorator for asserting the initialization status of an initializable to be true.

    see

    assertInitialized

    Returns MethodDecorator

Static assert_uninitialized

  • assert_uninitialized(): MethodDecorator

Static discard

  • discard(): MethodDecorator
  • Method decorator for discarding of Initializable inheritors. This decorator asserts the initialization status of the instance that is to be discarded, 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

Static initialize

  • initialize(): MethodDecorator
  • 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

  • uninitialize(): MethodDecorator
  • 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