UNPKG

4.65 kBTypeScriptView Raw
1import type { DRAW_MODES } from '@pixi/constants';
2import type { ExtensionMetadata } from '@pixi/extensions';
3import type { IRenderingContext } from '../IRenderer';
4import type { Renderer } from '../Renderer';
5import type { Program } from '../shader/Program';
6import type { Shader } from '../shader/Shader';
7import type { ISystem } from '../system/ISystem';
8import type { Geometry } from './Geometry';
9import type { GLBuffer } from './GLBuffer';
10/**
11 * System plugin to the renderer to manage geometry.
12 * @memberof PIXI
13 */
14export declare class GeometrySystem implements ISystem {
15 /** @ignore */
16 static extension: ExtensionMetadata;
17 /**
18 * `true` if we has `*_vertex_array_object` extension.
19 * @readonly
20 */
21 hasVao: boolean;
22 /**
23 * `true` if has `ANGLE_instanced_arrays` extension.
24 * @readonly
25 */
26 hasInstance: boolean;
27 /**
28 * `true` if support `gl.UNSIGNED_INT` in `gl.drawElements` or `gl.drawElementsInstanced`.
29 * @readonly
30 */
31 canUseUInt32ElementIndex: boolean;
32 protected CONTEXT_UID: number;
33 protected gl: IRenderingContext;
34 protected _activeGeometry: Geometry;
35 protected _activeVao: WebGLVertexArrayObject;
36 protected _boundBuffer: GLBuffer;
37 /** Cache for all geometries by id, used in case renderer gets destroyed or for profiling. */
38 readonly managedGeometries: {
39 [key: number]: Geometry;
40 };
41 /** Renderer that owns this {@link GeometrySystem}. */
42 private renderer;
43 /** @param renderer - The renderer this System works for. */
44 constructor(renderer: Renderer);
45 /** Sets up the renderer context and necessary buffers. */
46 protected contextChange(): void;
47 /**
48 * Binds geometry so that is can be drawn. Creating a Vao if required
49 * @param geometry - Instance of geometry to bind.
50 * @param shader - Instance of shader to use vao for.
51 */
52 bind(geometry?: Geometry, shader?: Shader): void;
53 /** Reset and unbind any active VAO and geometry. */
54 reset(): void;
55 /** Update buffers of the currently bound geometry. */
56 updateBuffers(): void;
57 /**
58 * Check compatibility between a geometry and a program
59 * @param geometry - Geometry instance.
60 * @param program - Program instance.
61 */
62 protected checkCompatibility(geometry: Geometry, program: Program): void;
63 /**
64 * Takes a geometry and program and generates a unique signature for them.
65 * @param geometry - To get signature from.
66 * @param program - To test geometry against.
67 * @returns - Unique signature of the geometry and program
68 */
69 protected getSignature(geometry: Geometry, program: Program): string;
70 /**
71 * Creates or gets Vao with the same structure as the geometry and stores it on the geometry.
72 * If vao is created, it is bound automatically. We use a shader to infer what and how to set up the
73 * attribute locations.
74 * @param geometry - Instance of geometry to to generate Vao for.
75 * @param shader - Instance of the shader.
76 * @param incRefCount - Increment refCount of all geometry buffers.
77 */
78 protected initGeometryVao(geometry: Geometry, shader: Shader, incRefCount?: boolean): WebGLVertexArrayObject;
79 /**
80 * Disposes geometry.
81 * @param geometry - Geometry with buffers. Only VAO will be disposed
82 * @param [contextLost=false] - If context was lost, we suppress deleteVertexArray
83 */
84 disposeGeometry(geometry: Geometry, contextLost?: boolean): void;
85 /**
86 * Dispose all WebGL resources of all managed geometries.
87 * @param [contextLost=false] - If context was lost, we suppress `gl.delete` calls
88 */
89 disposeAll(contextLost?: boolean): void;
90 /**
91 * Activate vertex array object.
92 * @param geometry - Geometry instance.
93 * @param program - Shader program instance.
94 */
95 protected activateVao(geometry: Geometry, program: Program): void;
96 /**
97 * Draws the currently bound geometry.
98 * @param type - The type primitive to render.
99 * @param size - The number of elements to be rendered. If not specified, all vertices after the
100 * starting vertex will be drawn.
101 * @param start - The starting vertex in the geometry to start drawing from. If not specified,
102 * drawing will start from the first vertex.
103 * @param instanceCount - The number of instances of the set of elements to execute. If not specified,
104 * all instances will be drawn.
105 */
106 draw(type: DRAW_MODES, size?: number, start?: number, instanceCount?: number): this;
107 /** Unbind/reset everything. */
108 protected unbind(): void;
109 destroy(): void;
110}