import { Bindable } from './bindable'; import { AbstractObject } from './object'; /** * Wrapper around an OpenGL array or element array buffer. This buffer may be used to be attached to multiple VAOs. */ export declare class Buffer extends AbstractObject implements Bindable { /** * Default buffer, e.g., used for unbind. */ static readonly DEFAULT_BUFFER: undefined; /** @see {@link target} */ protected _target: GLenum | undefined; /** * Create a buffer object on the GPU. */ protected create(target: GLenum): WebGLBuffer | undefined; /** * Delete the buffer object on the GPU. This should have the reverse effect of `create`. */ protected delete(): void; /** * Binds the buffer object as buffer to predefined target. */ bind(): void; /** * Binds null as current buffer to predefined target; */ unbind(): void; /** * Creates the buffer object's data store and updates the objects status. * @param data - Data that will be copied into the objects data store. * @param usage - Usage pattern of the data store. * @param bind - Allows to skip binding the object (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the object (e.g., when binding is handled outside). */ data(data: ArrayBufferView | ArrayBuffer | GLsizeiptr, usage: GLenum, bind?: boolean, unbind?: boolean): void; /** * Updates a subset of a buffer object's data store. * @param dstByteOffset - Offset in bytes where the data replacement will start. * @param srcData - Data that will be copied into the data store. * @param srcOffset - Element index offset where to start reading the buffer. * @param length - Length of the data to copy into the data store. * @param bind - Allows to skip binding the object (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the object (e.g., when binding is handled outside). */ subData(dstByteOffset: GLintptr, srcData: ArrayBufferView | ArrayBuffer, srcOffset?: GLuint, length?: GLuint, bind?: boolean, unbind?: boolean): void; /** * Specifies the memory layout of the buffer for a binding point. Integer data will be cast to float according to * "normalized". * @param index - Index of the vertex attribute that is to be setup and enabled. * @param size - Number of components per vertex attribute. * @param type - Data type of each component in the array. * @param normalized - Whether integer data values should be normalized when being casted to a float. * @param stride - Offset in bytes between the beginning of consecutive vertex attributes. * @param offset - Offset in bytes of the first component in the vertex attribute array. * @param bind - Allows to skip binding the object (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the object (e.g., when binding is handled outside). * @see attribEnableInt */ 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. Only to be used for integers. * @param index - Index of the vertex attribute that is to be setup and enabled. * @param size - Number of components per vertex attribute. * @param type - Data type of each component in the array. * @param stride - Offset in bytes between the beginning of consecutive vertex attributes. * @param offset - Offset in bytes of the first component in the vertex attribute array. * @param bind - Allows to skip binding the object (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the object (e.g., when binding is handled outside). * @see attribEnable */ attribEnableInt(index: GLuint, size: GLint, type: GLenum, stride?: GLsizei, offset?: GLintptr, bind?: boolean, unbind?: boolean): void; /** * Disables a buffer binding point. * @param index - Index of the vertex attribute that is to be disabled. * @param bind - Allows to skip binding the object (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the object (e.g., when binding is handled outside). */ attribDisable(index: GLuint, bind?: boolean, unbind?: boolean): void; /** * Returns the number of bytes this object approximately allocates on the GPU. */ get bytes(): number; /** * 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. */ get target(): GLenum | undefined; }