@thi.ng/webgl
Version:
WebGL & GLSL abstraction layer
246 lines • 6.13 kB
TypeScript
import type { IBind, IObjectOf, IRelease } from "@thi.ng/api";
import type { IConfigure } from "./buffers.js";
export declare enum TextureFormat {
ALPHA = 6406,
DEPTH_COMPONENT = 6402,
DEPTH_COMPONENT16 = 33189,
DEPTH_COMPONENT24 = 33190,
DEPTH_COMPONENT32F = 36012,
DEPTH_STENCIL = 34041,
DEPTH24_STENCIL8 = 35056,
DEPTH32F_STENCIL8 = 36013,
LUMINANCE = 6409,
LUMINANCE_ALPHA = 6410,
R11F_G11F_B10F = 35898,
R16F = 33325,
R16I = 33331,
R16UI = 33332,
R32F = 33326,
R32I = 33333,
R32UI = 33334,
R8 = 33321,
R8_SNORM = 36756,
R8I = 33329,
R8UI = 33330,
RED = 6403,
RED_INTEGER = 36244,
RG = 33319,
RG_INTEGER = 33320,
RG16F = 33327,
RG16I = 33337,
RG16UI = 33338,
RG32F = 33328,
RG32I = 33339,
RG32UI = 33340,
RG8 = 33323,
RG8_SNORM = 36757,
RG8I = 33335,
RG8UI = 33336,
RGB = 6407,
RGB_INTEGER = 36248,
RGB10_A2 = 32857,
RGB10_A2UI = 36975,
RGB16F = 34843,
RGB16I = 36233,
RGB16UI = 36215,
RGB32F = 34837,
RGB32I = 36227,
RGB32UI = 36209,
RGB5_A1 = 32855,
RGB565 = 36194,
RGB8 = 32849,
RGB8_SNORM = 36758,
RGB8I = 36239,
RGB8UI = 36221,
RGB9_E5 = 35901,
RGBA = 6408,
RGBA_INTEGER = 36249,
RGBA16F = 34842,
RGBA16I = 36232,
RGBA16UI = 36214,
RGBA32F = 34836,
RGBA32I = 36226,
RGBA32UI = 36208,
RGBA4 = 32854,
RGBA8 = 32856,
RGBA8_SNORM = 36759,
RGBA8I = 36238,
RGBA8UI = 36220,
SRGB8 = 35905,
SRGB8_ALPHA8 = 35907
}
export declare enum TextureType {
BYTE = 5120,
UNSIGNED_BYTE = 5121,
SHORT = 5122,
UNSIGNED_SHORT = 5123,
INT = 5124,
UNSIGNED_INT = 5125,
FLOAT = 5126,
HALF_FLOAT = 5131,
UNSIGNED_SHORT_4_4_4_4 = 32819,
UNSIGNED_SHORT_5_5_5_1 = 32820,
UNSIGNED_SHORT_5_6_5 = 33635,
UNSIGNED_INT_2_10_10_10_REV = 33640,
UNSIGNED_INT_24_8 = 34042,
UNSIGNED_INT_10F_11F_11F_REV = 35899,
UNSIGNED_INT_5_9_9_9_REV = 35902,
HALF_FLOAT_OES = 36193,
FLOAT_32_UNSIGNED_INT_24_8_REV = 36269
}
export declare enum TextureTarget {
TEXTURE_2D = 3553,
TEXTURE_3D = 32879,
TEXTURE_CUBE_MAP = 34067,
TEXTURE_2D_ARRAY = 35866
}
export declare enum TextureFilter {
LINEAR = 9729,
NEAREST = 9728,
NEAREST_MIPMAP_NEAREST = 9984,
LINEAR_MIPMAP_NEAREST = 9985,
NEAREST_MIPMAP_LINEAR = 9986,
LINEAR_MIPMAP_LINEAR = 9987
}
export declare enum TextureRepeat {
REPEAT = 10497,
CLAMP = 33071,
REPEAT_MIRROR = 33648
}
export interface TextureFormatDecl {
/**
* Base format
*/
format: TextureFormat;
/**
* Acceptable types and their resulting byte size per pixel.
* Interleaved layout `[format, size, format, size...]`
*/
types: (TextureType | number)[];
/**
* Number of color components
*/
num: number;
/**
* Format is renderable
*/
render?: boolean;
/**
* Format is renderable via extension
*/
renderExt?: boolean;
/**
* Format is filterable (other than GL_NEAREST)
*/
filter?: boolean;
/**
* WebGL 2 only
*/
gl2?: boolean;
}
export declare const TEX_FORMATS: IObjectOf<TextureFormatDecl>;
export type ReadableTextureFormat = TextureFormat.ALPHA | TextureFormat.RED | TextureFormat.RG | TextureFormat.RGB | TextureFormat.RGBA | TextureFormat.RED_INTEGER | TextureFormat.RG_INTEGER | TextureFormat.RGB_INTEGER | TextureFormat.RGBA_INTEGER;
export interface TextureOpts {
/**
* If this value is null or a typedarray then size options (i.e.
* `width`, `height`, `depth`) MUST be given (the latter only if
* `target` is TEXTURE_3D).
*/
image: ArrayBufferView | TexImageSource | null;
/**
* @defaultValue TextureTarget.TEXTURE_2D
*/
target: TextureTarget;
/**
* Only needed if overriding `format`'s default type.
*/
type: TextureType;
/**
* @defaultValue TextureFilter.NEAREST
*/
filter: TextureFilter | [TextureFilter, TextureFilter?];
/**
* @defaultValue TextureRepeat.CLAMP
*/
wrap: TextureRepeat | [TextureRepeat, TextureRepeat?, TextureRepeat?];
/**
* Min/max level-of-detail values.
*
* @defaultValue none
*/
lod: [number, number?];
/**
* Min/max mipmap levels (ints)
*
* @defaultValue none
*/
minMaxLevel: [number, number];
/**
* Mipmap level to configure (e.g. if providing custom mipmaps)
*
* @defaultValue 0
*/
level: number;
/**
* @defaultValue TextureFormat.RGBA
*/
format: TextureFormat;
/**
* Texture width in pixels. Only used if `image` is null or a typed
* array.
*
* @defaultValue none
*/
width: number;
/**
* Texture height in pixels. Only used if `image` is null or a typed
* array.
*
* @defaultValue none
*/
height: number;
/**
* Texture depth in pixels. Only used if `target` is
* `TextureTarget.TEXTURE_3D`
*
* @defaultValue none
*/
depth: number;
/**
* True, if mipmaps should be generated.
*
* @defaultValue false
*/
mipmap: boolean;
/**
* True, if source data should be flipped along its vertical axis.
*
* @defaultValue none
*/
flip: boolean;
/**
* True, if the source data's color channels should be
* pre-multiplied with the alpha channel.
*
* @defaultValue none
*/
premultiply: boolean;
/**
* True, if given `image` is only defining a sub-image (i.e. partial
* update of a previously configured texture). If true, also uses
* `pos` option.
*/
sub: boolean;
/**
* Pixel position offset for `sub` image updates.
*/
pos: number[];
}
export interface ITexture extends IBind<number>, IConfigure<Partial<TextureOpts>>, IRelease {
tex: WebGLTexture;
target: TextureTarget;
format: TextureFormat;
type: TextureType;
size: number[];
}
//# sourceMappingURL=texture.d.ts.map