UNPKG

2.69 kBTypeScriptView Raw
1import { PRECISION } from '@pixi/constants';
2import type { GLProgram } from './GLProgram';
3export interface IAttributeData {
4 type: string;
5 size: number;
6 location: number;
7 name: string;
8}
9export interface IUniformData {
10 index: number;
11 type: string;
12 size: number;
13 isArray: boolean;
14 value: any;
15 name: string;
16}
17export interface IProgramExtraData {
18 transformFeedbackVaryings?: {
19 names: string[];
20 bufferMode: 'separate' | 'interleaved';
21 };
22}
23/**
24 * Helper class to create a shader program.
25 * @memberof PIXI
26 */
27export declare class Program {
28 /**
29 * Default specify float precision in vertex shader.
30 * @static
31 * @type {PIXI.PRECISION}
32 * @default PIXI.PRECISION.HIGH
33 */
34 static defaultVertexPrecision: PRECISION;
35 /**
36 * Default specify float precision in fragment shader.
37 * iOS is best set at highp due to https://github.com/pixijs/pixijs/issues/3742
38 * @static
39 * @type {PIXI.PRECISION}
40 * @default PIXI.PRECISION.MEDIUM
41 */
42 static defaultFragmentPrecision: PRECISION;
43 id: number;
44 /** Source code for the vertex shader. */
45 vertexSrc: string;
46 /** Source code for the fragment shader. */
47 fragmentSrc: string;
48 nameCache: any;
49 glPrograms: {
50 [key: number]: GLProgram;
51 };
52 syncUniforms: any;
53 /** Assigned when a program is first bound to the shader system. */
54 attributeData: {
55 [key: string]: IAttributeData;
56 };
57 /** Assigned when a program is first bound to the shader system. */
58 uniformData: {
59 [key: string]: IUniformData;
60 };
61 extra: IProgramExtraData;
62 /**
63 * @param vertexSrc - The source of the vertex shader.
64 * @param fragmentSrc - The source of the fragment shader.
65 * @param name - Name for shader
66 * @param extra - Extra data for shader
67 */
68 constructor(vertexSrc?: string, fragmentSrc?: string, name?: string, extra?: IProgramExtraData);
69 /**
70 * The default vertex shader source.
71 * @readonly
72 */
73 static get defaultVertexSrc(): string;
74 /**
75 * The default fragment shader source.
76 * @readonly
77 */
78 static get defaultFragmentSrc(): string;
79 /**
80 * A short hand function to create a program based of a vertex and fragment shader.
81 *
82 * This method will also check to see if there is a cached program.
83 * @param vertexSrc - The source of the vertex shader.
84 * @param fragmentSrc - The source of the fragment shader.
85 * @param name - Name for shader
86 * @returns A shiny new PixiJS shader program!
87 */
88 static from(vertexSrc?: string, fragmentSrc?: string, name?: string): Program;
89}