LogoPixi’VN
pixi-jsClasses

Class: GlProgram

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:71

A wrapper for a WebGL Program. You can create one and then pass it to a shader. This will manage the WebGL program that is compiled and uploaded to the GPU.

To get the most out of this class, you should be familiar with glsl shaders and how they work.

See

https://developer.mozilla.org/en-US/docs/Web/API/WebGLProgram

Example

// Create a new program
const program = new GlProgram({
  vertex: '...',
  fragment: '...',
});

There are a few key things that pixi shader will do for you automatically:
<br>
- If no precision is provided in the shader, it will be injected into the program source for you.
This precision will be taken form the options provided, if none is provided,
then the program will default to the defaultOptions.
<br>
- It will inject the program name into the shader source if none is provided.
<br>
 - It will set the program version to 300 es.

For optimal usage and best performance, its best to reuse programs as much as possible.
You should use the {@link GlProgram.from} helper function to create programs.
@class

Advanced

Constructors

Constructor

> new GlProgram(options): GlProgram

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:112

Creates a shiny new GlProgram. Used by WebGL renderer.

Parameters

options

GlProgramOptions

The options for the program.

Returns

GlProgram

Properties

_attributeData

> _attributeData: Record<string, ExtractedAttributeData>

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:82

Internal

attribute data extracted from the program once created this happens when the program is used for the first time


_cacheKey

> _cacheKey: string

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:107

Internal

A cache key used to identify the program instance.


_key

> readonly _key: number

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:102

Internal

the key that identifies the program via its source vertex + fragment


_uniformBlockData

> _uniformBlockData: Record<string, GlUniformBlockData>

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:92

Internal

uniform data extracted from the program once created this happens when the program is used for the first time


_uniformData

> _uniformData: Record<string, GlUniformData>

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:87

Internal

uniform data extracted from the program once created this happens when the program is used for the first time


fragment?

> readonly optional fragment?: string

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:75

the fragment glsl shader source.


transformFeedbackVaryings?

> optional transformFeedbackVaryings?: object

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:94

details on how to use this program with transform feedback

bufferMode

> bufferMode: "separate" | "interleaved"

names

> names: string[]


vertex?

> readonly optional vertex?: string

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:77

the vertex glsl shader source


defaultOptions

> static defaultOptions: Partial<GlProgramOptions>

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:73

The default options used by the program.

Methods

destroy()

> destroy(): void

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:114

destroys the program

Returns

void


from()

> static from(options): GlProgram

Defined in: node_modules/pixi.js/lib/rendering/renderers/gl/shader/GlProgram.d.ts:122

Helper function that creates a program for a given source. It will check the program cache if the program has already been created. If it has that one will be returned, if not a new one will be created and cached.

Parameters

options

GlProgramOptions

The options for the program.

Returns

GlProgram

A program using the same source