Skip to main content
Version: Phaser v4.0.0

WebGLShaderSetterWrapper

Stores the metadata and WebGL function references needed to set shader uniform values for every GLSL data type. The core of the class is the constants map, which is keyed by WebGL type constant (e.g. gl.FLOAT, gl.FLOAT_VEC2, gl.FLOAT_MAT4) and provides the corresponding uniform setter function, element count, byte size, and matrix flag for each type.

Because the WebGL uniform setter functions (gl.uniform1f, gl.uniform2i, etc.) are bound to the rendering context at construction time, this class exists primarily to capture those function references once and make them available throughout the lifetime of the renderer. It is created by the WebGLRenderer and used internally when uploading uniform data to GPU shader programs.

Constructor

new WebGLShaderSetterWrapper(renderer)

Parameters

nametypeoptionaldescription
rendererPhaser.Renderer.WebGL.WebGLRendererNoThe WebGLRenderer instance that owns this WebGLShaderSetterWrapper.

Scope: static

Source: src/renderer/webgl/wrappers/WebGLShaderSetterWrapper.js#L9
Since: 4.0.0

Public Members

constants

constants: Phaser.Types.Renderer.WebGL.Wrappers.ShaderSetterConstants

Description:

A lookup table keyed by WebGL type constant (hex value) that maps each GLSL data type to its uniform setter functions, component count, byte size per component, and a flag indicating whether the type is a matrix. Used when uploading uniform values to a shader program so the correct WebGL call is chosen automatically for each uniform's declared type.

Source: src/renderer/webgl/wrappers/WebGLShaderSetterWrapper.js#L36
Since: 4.0.0