createShader static method

int createShader(
  1. OpenGLContextES gl,
  2. int type,
  3. String source
)

Creates shader.

  • gl the OpenGlES context.
  • type the shader type.
    • gl.VERTEX_SHADER
    • gl.FRAGMENT_SHADER
  • source the shader source

Implementation

static int createShader(OpenGLContextES gl, int type, String source) {
  int shader = gl.createShader(type);
  gl.shaderSource(shader, source);
  gl.compileShader(shader);
  var success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  if (success == 0 || success == false) {
    print("Error compiling shader: " + gl.getShaderInfoLog(shader));
    throw 'Failed to create the shader';
  }
  return shader;
}