import { Context } from './context'; import { Initializable } from './initializable'; /** * A generic WebGL object trait that has a size, a status, an identifier, and is initializable. A context and an object * handle are provided for internal use and can be read from outside. Furthermore, an object supports optional reference * counting. If used, an object cannot be initialized when already referenced, and cannot be delete as long as at least * a single reference is active. */ export declare abstract class AbstractObject extends Initializable { /** @see {@link context} */ protected _context: Context; /** @see {@link identifier} */ protected _identifier: string; /** @see {@link object} */ protected _object: T | undefined; /** @see {@link valid} */ protected _valid: boolean; /** * 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 _referenceCount: number; /** * Object constructor, requires a context and a valid identifier. * @param context - Valid context to create the object for. * @param identifier - Meaningful name for identification of this instance. */ constructor(context: Context, identifier?: string); /** * Object creation which is invoked on initialization. * @returns - The created WebGL object handle. */ protected abstract create(...args: Array): T | undefined; /** * Object deletion which is invoked on uninitialization. */ protected abstract delete(): void; /** * @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. */ initialize(...args: Array): boolean; /** * @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). */ uninitialize(): void; /** * Read-only access to the objects context, used to get context information and WebGL API access. */ get context(): Context; /** * 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 - This assets identifier used for gpu allocation tracking and debugging. */ get identifier(): string; /** * Read-only access to the WebGL object handle. */ get object(): T; /** * Cached object status used to derive validity when initialized. * @returns - True if the object status is complete, false otherwise. */ get valid(): boolean; /** * Increment the reference count of this object. */ ref(): void; /** * Decrement the reference count of this object. */ unref(): void; }