You’re reading the docs for Phaser v4.0.0. The latest is Phaser v4.1.0.

WebGLGlobalWrapper

Phaser.Renderer.WebGL.Wrappers.WebGLGlobalWrapper

Wrapper for the WebGL global state, including blend mode, texture bindings, scissor test, stencil test, depth test, and other GL context settings. It tracks the current state and applies changes efficiently to avoid redundant WebGL calls.

Constructor

new WebGLGlobalWrapper(renderer)

Parameters

nametypeoptionaldescription
rendererPhaser.Renderer.WebGL.WebGLRendererNoThe WebGLRenderer to create the WebGLGlobalWrapper for.

Scope: static

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L10
Since: 4.0.0

Public Members

renderer

renderer: Phaser.Renderer.WebGL.WebGLRenderer

Description:

The WebGLRenderer this WebGLGlobalWrapper is associated with.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L30
Since: 4.0.0


state

state: Phaser.Types.Renderer.WebGL.WebGLGlobalParameters

Description:

The current WebGL global state parameters tracked by this wrapper.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L39
Since: 4.0.0


Public Methods

update

instanceupdate([state], [force], [vaoLast])

Description:

Sets the global WebGL state. Parameters are updated on the WebGLRenderingContext only if they are defined in the input state, and different from the current state.

When force is true, and state is defined, parameters on state are always set, regardless of the current state.

When force is true, and state is undefined, the current state is used to reset all the parameters.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersYesThe state to set. If undefined, the current state is used when force is true.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.
vaoLastbooleanYesfalseIf true, the VAO will be set last. Otherwise, it will be set first. This is useful when performing state changes that will affect a VAO, such as bindings.elementArrayBuffer.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L49
Since: 4.0.0


updateBindings

instanceupdateBindings(state, [force])

Description:

Updates the bindings state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L132
Since: 4.0.0


updateBindingsActiveTexture

instanceupdateBindingsActiveTexture(state, [force])

Description:

Updates the active texture unit state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L170
Since: 4.0.0


updateBindingsArrayBuffer

instanceupdateBindingsArrayBuffer(state, [force])

Description:

Updates the array buffer (ARRAY_BUFFER) binding state. This binds the vertex buffer object used to supply vertex attribute data to the GPU.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L195
Since: 4.0.0


updateBindingsElementArrayBuffer

instanceupdateBindingsElementArrayBuffer(state, [force])

Description:

Updates the index array buffer state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L229
Since: 4.0.0


updateBindingsFramebuffer

instanceupdateBindingsFramebuffer(state, [force])

Description:

Updates the framebuffer state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L262
Since: 4.0.0


updateBindingsProgram

instanceupdateBindingsProgram(state, [force])

Description:

Updates the currently bound WebGL shader program by calling gl.useProgram.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L288
Since: 4.0.0


updateBindingsRenderbuffer

instanceupdateBindingsRenderbuffer(state, [force])

Description:

Updates the renderbuffer state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L313
Since: 4.0.0


updateBlend

instanceupdateBlend(state, [force])

Description:

Updates the blend state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L339
Since: 4.0.0


updateBlendColor

instanceupdateBlendColor(state, [force])

Description:

Updates the blend color.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L368
Since: 4.0.0


updateBlendEnabled

instanceupdateBlendEnabled(state, [force])

Description:

Updates the blend enabled state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L399
Since: 4.0.0


updateBlendEquation

instanceupdateBlendEquation(state, [force])

Description:

Updates the blend equation state.

Equations are always treated as separate.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L431
Since: 4.0.0


updateBlendFunc

instanceupdateBlendFunc(state, [force])

Description:

Updates the blend function state.

Functions are always treated as separate.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L458
Since: 4.0.0


updateColorClearValue

instanceupdateColorClearValue(state, [force])

Description:

Updates the RGBA color value used to fill the color buffer when gl.clear is called with the color buffer bit.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L488
Since: 4.0.0


updateColorWritemask

instanceupdateColorWritemask(state, [force])

Description:

Updates the color write mask, which controls which RGBA color components are written to the color buffer during rendering.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L521
Since: 4.0.0


updateCullFace

instanceupdateCullFace(state, [force])

Description:

Updates the cull face state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L553
Since: 4.0.0


updateDepthTest

instanceupdateDepthTest(state, [force])

Description:

Updates the depth test state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L585
Since: 4.0.0


updateScissor

instanceupdateScissor(state, [force])

Description:

Updates the scissor state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L617
Since: 4.0.0


updateScissorBox

instanceupdateScissorBox(state, [force])

Description:

Updates the scissor box state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L670
Since: 4.0.0


updateScissorEnabled

instanceupdateScissorEnabled(state, [force])

Description:

Updates the scissor enabled state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L638
Since: 4.0.0


updateStencil

instanceupdateStencil(state, [force])

Description:

Updates the stencil state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L706
Since: 4.0.0


updateStencilClear

instanceupdateStencilClear(state, [force])

Description:

Updates the value used to clear the stencil buffer when gl.clear is called with the stencil buffer bit.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L735
Since: 4.0.0


updateStencilEnabled

instanceupdateStencilEnabled(state, [force])

Description:

Updates the stencil enabled state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L760
Since: 4.0.0


updateStencilFunc

instanceupdateStencilFunc(state, [force])

Description:

Updates the stencil function state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L792
Since: 4.0.0


updateStencilOp

instanceupdateStencilOp(state, [force])

Description:

Updates the stencil operation state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L819
Since: 4.0.0


updateTexturing

instanceupdateTexturing(state, [force])

Description:

Updates the texturing state, which takes effect when creating a texture. This includes flipY and premultiplyAlpha.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L846
Since: 4.0.0


updateTexturingFlipY

instanceupdateTexturingFlipY(state, [force])

Description:

Updates the UNPACK_FLIP_Y_WEBGL pixel store parameter, which controls whether texture image data is flipped vertically when uploaded to the GPU.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L868
Since: 4.0.0


updateTexturingPremultiplyAlpha

instanceupdateTexturingPremultiplyAlpha(state, [force])

Description:

Updates the UNPACK_PREMULTIPLY_ALPHA_WEBGL pixel store parameter, which controls whether the alpha channel is pre-multiplied into the RGB components when texture image data is uploaded to the GPU.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L894
Since: 4.0.0


updateVAO

instanceupdateVAO(state, [force])

Description:

Updates the vertex array object state.

Note that the VAO is automatically affected by bindings of elementArrayBuffer and any attribute settings, as written in WebGL. When binding the VAO, ensure that other bindings come before or after, as you intend. When using update, the VAO is set first by default.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L921
Since: 4.0.0


updateViewport

instanceupdateViewport(state, [force])

Description:

Updates the viewport state.

Parameters:

nametypeoptionaldefaultdescription
statePhaser.Types.Renderer.WebGL.WebGLGlobalParametersNoThe state to set.
forcebooleanYesfalseIf true, the state will be set regardless of the current state.

Source: src/renderer/webgl/wrappers/WebGLGlobalWrapper.js#L960
Since: 4.0.0