UNPKG

3.85 kBTypeScriptView Raw
1import {
2 Blending,
3 BlendingDstFactor,
4 BlendingEquation,
5 BlendingSrcFactor,
6 CullFace,
7 DepthModes,
8} from "../../constants.js";
9import { Material } from "../../materials/Material.js";
10import { Vector4 } from "../../math/Vector4.js";
11import { WebGLRenderTarget } from "../WebGLRenderTarget.js";
12import { WebGLExtensions } from "./WebGLExtensions.js";
13
14declare class ColorBuffer {
15 setMask(colorMask: boolean): void;
16 setLocked(lock: boolean): void;
17 setClear(r: number, g: number, b: number, a: number, premultipliedAlpha: boolean): void;
18 reset(): void;
19}
20
21declare class DepthBuffer {
22 constructor();
23
24 setReversed(value: boolean): void;
25 getReversed(): boolean;
26 setTest(depthTest: boolean): void;
27 setMask(depthMask: boolean): void;
28 setFunc(depthFunc: DepthModes): void;
29 setLocked(lock: boolean): void;
30 setClear(depth: number): void;
31 reset(): void;
32}
33
34declare class StencilBuffer {
35 constructor();
36
37 setTest(stencilTest: boolean): void;
38 setMask(stencilMask: number): void;
39 setFunc(stencilFunc: number, stencilRef: number, stencilMask: number): void;
40 setOp(stencilFail: number, stencilZFail: number, stencilZPass: number): void;
41 setLocked(lock: boolean): void;
42 setClear(stencil: number): void;
43 reset(): void;
44}
45
46declare class WebGLState {
47 constructor(gl: WebGLRenderingContext, extensions: WebGLExtensions);
48
49 buffers: {
50 color: ColorBuffer;
51 depth: DepthBuffer;
52 stencil: StencilBuffer;
53 };
54
55 enable(id: number): void;
56 disable(id: number): void;
57 bindFramebuffer(target: number, framebuffer: WebGLFramebuffer | null): void;
58 drawBuffers(renderTarget: WebGLRenderTarget | null, framebuffer: WebGLFramebuffer | null): void;
59 useProgram(program: any): boolean;
60 setBlending(
61 blending: Blending,
62 blendEquation?: BlendingEquation,
63 blendSrc?: BlendingSrcFactor,
64 blendDst?: BlendingDstFactor,
65 blendEquationAlpha?: BlendingEquation,
66 blendSrcAlpha?: BlendingSrcFactor,
67 blendDstAlpha?: BlendingDstFactor,
68 premultiplyAlpha?: boolean,
69 ): void;
70 setMaterial(material: Material, frontFaceCW: boolean, hardwareClippingPlanes: number): void;
71 setFlipSided(flipSided: boolean): void;
72 setCullFace(cullFace: CullFace): void;
73 setLineWidth(width: number): void;
74 setPolygonOffset(polygonoffset: boolean, factor?: number, units?: number): void;
75 setScissorTest(scissorTest: boolean): void;
76 activeTexture(webglSlot: number): void;
77 bindTexture(webglType: number, webglTexture: any): void;
78 unbindTexture(): void;
79 // Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/compressedTexImage2D
80 compressedTexImage2D(
81 target: number,
82 level: number,
83 internalformat: number,
84 width: number,
85 height: number,
86 border: number,
87 data: ArrayBufferView,
88 ): void;
89 // Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D
90 texImage2D(
91 target: number,
92 level: number,
93 internalformat: number,
94 width: number,
95 height: number,
96 border: number,
97 format: number,
98 type: number,
99 pixels: ArrayBufferView | null,
100 ): void;
101 texImage2D(target: number, level: number, internalformat: number, format: number, type: number, source: any): void;
102 texImage3D(
103 target: number,
104 level: number,
105 internalformat: number,
106 width: number,
107 height: number,
108 depth: number,
109 border: number,
110 format: number,
111 type: number,
112 pixels: any,
113 ): void;
114 scissor(scissor: Vector4): void;
115 viewport(viewport: Vector4): void;
116 reset(): void;
117}
118
119export { WebGLState };