import { GLsizei3 } from './tuples'; import { Bindable } from './bindable'; import { TexImage3DData } from './gl2facade'; import { AbstractObject } from './object'; /** * Wrapper for an WebGL 2D texture providing size accessors and requiring for bind, unbind, resize, validity, and * initialization implementations. The texture object is created on initialization and deleted on uninitialization. * After being initialized, the texture can be resized, reformated, and data can set directly or via load: * ``` * const texture = new Texture3D(context, 'Texture'); * texture.initialize(1, 1, 1, gl.RGB8, gl.RGB, gl.UNSIGNED_BYTE); * texture.load('/img/webgl-operate-logo.png', true) * ``` */ export declare class Texture3D extends AbstractObject implements Bindable { /** * Default texture, e.g., used for unbind. */ static readonly DEFAULT_TEXTURE: undefined; /** @see {@link width} */ protected _width: GLsizei; /** @see {@link height} */ protected _height: GLsizei; /** @see {@link depth} */ protected _depth: GLsizei; /** @see {@link internalFormat} */ protected _internalFormat: GLenum; /** @see {@link format} */ protected _format: GLenum; /** @see {@link type} */ protected _type: GLenum; /** * Create a texture object on the GPU. * @param width - Initial width of the texture in px. * @param height - Initial height of the texture in px. * @param depth - Initial depth of the texture in px. * @param internalFormat - Internal format of the texture object. * @param format - Format of the texture data even though no data is passed. * @param type - Data type of the texel data. */ protected create(width: GLsizei, height: GLsizei, depth: GLsizei, internalFormat: GLenum, format: GLenum, type: GLenum): WebGLTexture | undefined; /** * Delete the texture object on the GPU. This should have the reverse effect of `create`. */ protected delete(): void; protected reallocate(): void; /** * Bind the texture object to a texture unit. */ bind(unit?: GLenum): void; /** * Unbind the texture object from a texture unit. */ unbind(unit?: GLenum): void; /** * Asynchronous load of an image comprising a column/row of slices via URL or data URI. Please note that due to the lack * of sub-data access on images, the slices are loaded using a auxiliary canvas and context (temporarily). The sub * images (slices) are drawn using the canvas and the image data is then captured. * @param uri - Uniform resource locator string referencing image slices that should be loaded (data URI supported). * @param slices - Number of slices (resulting in the 3D texture's depth) vertically aligned within the image. * @param crossOrigin - Enable cross origin data loading. * @param useHorizontalSlicing - Optional: Whether or not to use horizontal (rows) instead of vertical (columns) slice alignment. * @returns - Promise for handling image load status. */ load(uri: string, slices: GLsizei, crossOrigin?: boolean, useHorizontalSlicing?: boolean): Promise; /** * Asynchronous load of multiple images, each containing a column/row of slices, via URL or data URI. * This can be used, e. g., for a dynamically sized array of 3D textures. * Note that all the images must have the exact same dimensions. * Each image is loaded and drawn into a large, multi-row/-column image. This image is then used as a base64 encoded * PNG for subsequent usage in the regular @see {load} function. * @param uris - Uniform resource locator strings referencing a set of equally-sized images that should be loaded (data URI supported). * @param slices - Number of slices (resulting in the 3D texture's depth) vertically aligned within each image. * @param crossOrigin - Enable cross origin data loading. * @param useHorizontalSlicing - Optional: Whether or not to use horizontal (rows) instead of vertical (columns) slice alignment. * @returns - Promise for handling image load status. */ loadFromSingleImages(uris: string[], slices: GLsizei, crossOrigin?: boolean, useHorizontalSlicing?: boolean): Promise; /** * Pass image data to the texture object. * @param data - Texel data that will be copied into the objects data store. * @param bind - Allows to skip binding the texture (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the texture (e.g., when binding is handled outside). */ data(data: TexImage3DData, bind?: boolean, unbind?: boolean): void; /** * Sets the texture object's magnification and minification filter. * @param mag - Value for the TEXTURE_MAG_FILTER parameter. * @param min - Value for the TEXTURE_MIN_FILTER parameter. * @param bind - Allows to skip binding the texture (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the texture (e.g., when binding is handled outside). */ filter(mag: GLenum, min: GLenum, bind?: boolean, unbind?: boolean): void; /** * Sets the texture object's wrapping function for s and t coordinates. * @param wrap_s - Value for the TEXTURE_WRAP_S parameter, defaulted to CLAMP_TO_EDGE. * @param wrap_t - Value for the TEXTURE_WRAP_T parameter, defaulted to CLAMP_TO_EDGE. * @param wrap_r - Value for the TEXTURE_WRAP_R parameter, defaulted to CLAMP_TO_EDGE. * @param bind - Allows to skip binding the texture (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the texture (e.g., when binding is handled outside). */ wrap(wrap_s: GLenum, wrap_t: GLenum, wrap_r: GLenum, bind?: boolean, unbind?: boolean): void; /** * This can be used to reformat the texture image without creating a new texture object. Please note that this * resets the texture's image data to undefined. @see {@link data} for setting new image data. * @param internalFormat - Internal format of the texture object. * @param format - Format of the texture data even though no data is passed. * @param type - Data type of the texel data. * @param bind - Allows to skip binding the texture (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the texture (e.g., when binding is handled outside). */ reformat(internalFormat: GLenum, format?: GLenum, type?: GLenum, bind?: boolean, unbind?: boolean): void; /** * This should be used to implement efficient resize the texture. * @param width - Targeted/new width of the texture in px. * @param height - Targeted/new height of the texture in px. * @param depth - Targeted/new depth of the texture in px. * @param bind - Allows to skip binding the texture (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the texture (e.g., when binding is handled outside). */ resize(width: GLsizei, height: GLsizei, depth: GLsizei, bind?: boolean, unbind?: boolean): void; /** * Returns the number of bytes this object approximately allocates on the GPU. The size will be zero when no * image data was passed to the texture object. */ get bytes(): GLsizei; /** * Cached internal format of the texture for efficient resize. This can only be changed by re-initialization. */ get internalFormat(): GLenum; /** * Cached format of the data provided to the texture object for efficient resize. This is set on initialization and * might change on data transfers. */ get format(): GLenum; /** * Cached type of the data provided to the texture used for efficient resize. This is set on initialization and * might change on data transfers. */ get type(): GLenum; /** * The width of the texture object in px. */ get width(): GLsizei; /** * The height of the texture object in px. */ get height(): GLsizei; /** * The depth of the texture object in px. */ get depth(): GLsizei; /** * Convenience getter for the 3-tuple containing width and height. * @see {@link width} * @see {@link heigth} * @see {@link depth} */ get size(): GLsizei3; }