import { GLclampf4, GLsizei2 } from './tuples'; import { Bindable } from './bindable'; import { Context } from './context'; import { AbstractObject } from './object'; import { Renderbuffer } from './renderbuffer'; import { Texture2D } from './texture2d'; /** * WebGL Framebuffer base implementation providing size accessors and requiring for bind, unbind, resize, validity, * and initialization implementations. * ``` * @todo add usage example * ``` */ export declare class Framebuffer extends AbstractObject implements Bindable { /** * Default framebuffer, e.g., used for unbind. */ static readonly DEFAULT_FRAMEBUFFER: undefined; /** * Access to all attached renderbuffer objects. */ protected _buffersByAttachment: Map; /** * Access to all attached texture objects. */ protected _texturesByAttachment: Map; /** * RGBA color, depth value, or stencil value used for clearing the * associated buffer. */ protected _clearDepth: GLfloat; protected _clearStencil: GLint; protected _clearColors: Array; /** * Queue of all draw buffers that are to be cleared on `clear`. */ protected _colorClearQueue: number[]; /** @see {@link drawBuffers} */ protected _drawBuffers: number[]; protected _drawBuffersChanged: boolean; /** * Depending on the webgl version and provided bitmask, clears attachments of the framebuffer. Note that this * function is set/unset to es2Clear or es3Clear on initialization/uninitialization. * @param mask - Bitmask specifying which bits are to be cleared (and thereby which attachments). * @param bind - Allows to skip binding the framebuffer (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the framebuffer (e.g., when binding is handled outside). * @param colorClearQueue - allows to specify a specific queue of color attachments to be cleared. The webgl1 * implementation ignores this parameter. If no parameter is given, the webgl2 implementation clears all color * attachments. */ clear: ((mask: GLbitfield, bind?: boolean, unbind?: boolean, colorClearQueue?: Array) => void); /** * Returns a string describing the given status of a framebuffer object. * @param context - Context for valid GLenums. * @param status - A framebuffer's status. */ protected static statusString(context: Context, status: GLenum): string; /** * Create a framebuffer object on the GPU and attaches all given renderable objects (either renderbuffer or * texture) to the framebuffer object. * @param attachments - tuples that associate an attachment to its actual render object, either a renderbuffer or * texture, e.g., `[ gl.COLOR_ATTACHMENT0, someTexture ]`. */ protected create(attachments: Array<[GLenum, Renderbuffer | Texture2D]>): WebGLFramebuffer | undefined; /** * Delete the framebuffer object on the GPU. This should have the reverse effect of `create`. */ protected delete(): void; /** * WebGL1 implementation for clearing framebuffer attachments. * @param mask - A GLbitfield bitwise OR mask that indicates the buffers to be cleared. * @param bind - Allows to skip binding the framebuffer (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the framebuffer (e.g., when binding is handled outside). */ protected es2Clear(mask: GLbitfield, bind?: boolean, unbind?: boolean): void; /** * WebGL2 implementation for clearing framebuffer attachments. * @param mask - A GLbitfield bitwise OR mask that indicates the buffers to be cleared. * @param bind - Allows to skip binding the framebuffer (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the framebuffer (e.g., when binding is handled outside). * @param colorClearQueue - Allows to specify a specific queue of color attachments to be cleared. If no * parameter is given, the webgl2 implementation clears all color attachments. */ protected es3Clear(mask: GLbitfield, bind?: boolean, unbind?: boolean, colorClearQueue?: Array): void; /** * * @param attachment - */ protected hasAttachment(attachment: GLenum): boolean; /** * Binds the framebuffer object as framebuffer to the provided target. * @param target - Specifying the binding point (target). */ bind(target?: GLenum): void; /** * Binds the default back buffer as framebuffer to the provided target. * @param target - Specifying the binding point (target). */ unbind(target?: GLenum): void; /** * Sets the clear color used for clearing a draw buffer. In order to have transparency working, the canvas needs * to have the alpha attribute enabled. This stage also supports premultiplied alpha, which is applied * automatically when the context's `premultipliedAlpha` attribute is set. * @param color - RGBA clear color. * @param drawBuffer - The draw buffer index. If no index is provided, the color will be applied to all buffers. */ clearColor(color: GLclampf4, drawBuffer?: GLint): void; clearDepth(depth: GLfloat): void; clearStencil(stencil: GLint): void; /** * Access to attached textures, identified by a valid framebuffer attachment. * @param attachment - The attachment to request the texture object of. * @returns - A texture object if one exists for the given attachment, otherwise undefined. */ texture(attachment: GLenum): Texture2D | undefined; /** * Forwards a resize to all attachments, renderbuffers and textures. * @param width - Targeted/new width for all attachments in px. * @param height - Targeted/new height for all attachments in px. * @param bind - Allows to skip binding the specific attachment (e.g., when binding is handled outside). * @param unbind - Allows to skip unbinding the specific attachment (e.g., when binding is handled outside). */ resize(width: GLsizei, height: GLsizei, bind?: boolean, unbind?: boolean): void; /** * Readonly access to the framebuffer width in pixel. If the width of the attachments are not all identical, * the minimal width as the renderable width of this framebuffer is returned. * @returns - The minimal width of the renderable width over all attachments. */ get width(): GLsizei; /** * Readonly access to the framebuffer height in pixel. If the height of the attachments are not all identical, * the minimal height as the renderable height of this framebuffer is returned. * @returns - The minimal height of the renderable height over all attachments. */ get height(): GLsizei; /** * Convenience getter for the 2-tuple containing the texture's width and height. * @see {@link width} * @see {@link heigth} */ get size(): GLsizei2; /** * Set one or multiple draw buffers. * @param attachments - Array of attachment identifier (e.g., gl.COLOR_ATTACHMENT0). */ set drawBuffers(attachments: Array); /** * Used to remember which attachments are available as potential draw buffers. */ get drawBuffers(): Array; }