Phaser API Documentation

  Version: 
createProgram([vertSrc], [fragSrc])

Description:

This method will create the Shader Program on the current GL context.

If a program already exists, it will be destroyed and the new one will take its place.

After the program is created the uniforms will be reset and this shader will be rebound.

This is a very expensive process and if your shader is referenced elsewhere in your game those references may then be lost, so be sure to use this carefully.

However, if you need to update say the fragment shader source, then you can pass the new source into this method and it'll rebuild the program using it. If you don't want to change the vertex shader src, pass undefined as the parameter.

Parameters:

name type arguments description
vertSrc string <optional>

The source code of the vertex shader. If not given, uses the source already defined in this Shader.

fragSrc string <optional>

The source code of the fragment shader. If not given, uses the source already defined in this Shader.

Returns:
Description:

This WebGLShader instance.

Since: 3.60.0