import { type Device, type TextureProps, type TextureViewProps, type Sampler, type SamplerProps, type CopyExternalImageOptions, type TextureReadOptions, type TextureWriteOptions, Buffer, Texture } from '@luma.gl/core'; import { GLSamplerParameters, GL, GLTextureTarget, GLTextureCubeMapTarget, GLTexelDataFormat, GLPixelType } from '@luma.gl/webgl/constants'; import { WebGLDevice } from "../webgl-device.js"; import { WEBGLFramebuffer } from "./webgl-framebuffer.js"; import { WEBGLSampler } from "./webgl-sampler.js"; import { WEBGLTextureView } from "./webgl-texture-view.js"; /** * WebGL... the texture API from hell... hopefully made simpler */ export declare class WEBGLTexture extends Texture { readonly device: WebGLDevice; readonly gl: WebGL2RenderingContext; handle: WebGLTexture; sampler: WEBGLSampler; view: WEBGLTextureView; /** * The WebGL target corresponding to the texture type * @note `target` cannot be modified by bind: * textures are special because when you first bind them to a target, * When you first bind a texture as a GL_TEXTURE_2D, you are saying that this texture is a 2D texture. * And it will always be a 2D texture; this state cannot be changed ever. * A texture that was first bound as a GL_TEXTURE_2D, must always be bound as a GL_TEXTURE_2D; * attempting to bind it as GL_TEXTURE_3D will give rise to a run-time error */ glTarget: GLTextureTarget; /** The WebGL format - essentially channel structure */ glFormat: GLTexelDataFormat; /** The WebGL data format - the type of each channel */ glType: GLPixelType; /** The WebGL constant corresponding to the WebGPU style constant in format */ glInternalFormat: GL; /** Whether the internal format is compressed */ compressed: boolean; /** Texture binding slot - TODO - move to texture view? */ _textureUnit: number; /** Cached framebuffer reused for color texture readback. */ _framebuffer: WEBGLFramebuffer | null; /** Cache key for the currently attached readback subresource `${mipLevel}:${layer}`. */ _framebufferAttachmentKey: string | null; constructor(device: Device, props: TextureProps); destroy(): void; createView(props: TextureViewProps): WEBGLTextureView; setSampler(sampler?: Sampler | SamplerProps): void; copyExternalImage(options_: CopyExternalImageOptions): { width: number; height: number; }; copyImageData(options_: any): void; /** * Reads a color texture subresource into a GPU buffer using `PIXEL_PACK_BUFFER`. * * @note Only first-pass color readback is supported. Unsupported formats and aspects throw * before any WebGL calls are issued. */ readBuffer(options?: TextureReadOptions & { byteOffset?: number; }, buffer?: Buffer): Buffer; readDataAsync(options?: TextureReadOptions): Promise; writeBuffer(buffer: Buffer, options_?: TextureWriteOptions): void; writeData(data: ArrayBuffer | SharedArrayBuffer | ArrayBufferView, options_?: TextureWriteOptions): void; /** @todo - for now we always use 1 for maximum compatibility, we can fine tune later */ private _getRowByteAlignment; /** * Wraps a given texture into a framebuffer object, that can be further used * to read data from the texture object. */ _getFramebuffer(): WEBGLFramebuffer; readDataSyncWebGL(options_?: TextureReadOptions): ArrayBuffer; /** * Iterates the requested mip/layer/slice range, reattaching the cached read framebuffer as * needed before delegating the actual `readPixels()` call to the supplied callback. */ private _readColorTextureLayers; /** * Attaches a single color subresource to the cached read framebuffer. * * @note Repeated attachments of the same `(mipLevel, layer)` tuple are skipped. */ private _attachReadSubresource; /** * @note - this is used by the DynamicTexture class to generate mipmaps on WebGL */ generateMipmapsWebGL(options?: { force?: boolean; }): void; /** * Sets sampler parameters on texture */ _setSamplerParameters(parameters: GLSamplerParameters): void; _getActiveUnit(): number; _bind(_textureUnit?: number): number; _unbind(_textureUnit?: number): number | undefined; } /** Convert a WebGPU style texture constant to a WebGL style texture constant */ export declare function getWebGLTextureTarget(dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d'): GLTextureTarget; /** * In WebGL, cube maps specify faces by overriding target instead of using the depth parameter. * @note We still bind the texture using GL.TEXTURE_CUBE_MAP, but we need to use the face-specific target when setting mip levels. * @returns glTarget unchanged, if dimension !== 'cube'. */ export declare function getWebGLCubeFaceTarget(glTarget: GLTextureTarget, dimension: '1d' | '2d' | '2d-array' | 'cube' | 'cube-array' | '3d', level: number): GLTextureTarget | GLTextureCubeMapTarget; //# sourceMappingURL=webgl-texture.d.ts.map