stringShader method

dynamic stringShader(
  1. int type,
  2. String source
)

Implementation

dynamic stringShader(int type, String source) {
  currentProgram = -1;
  final gl = Engine.flutterGlPlugin.gl;
  final shader = gl.createShader(type);
  if (shader == 0) {
    if (kDebugMode) {
      print('Error: failed to create shader.');
    }
    return 0;
  }

  if (kDebugMode) {
    print('Loaded Shader');
  }

  gl.shaderSource(shader, source);

  // Compile the shader
  gl.compileShader(shader);
  var res = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  if (res == 0 || res == false) {
    if (kDebugMode) {
      print("Error compiling shader: ${gl.getShaderInfoLog(shader)}");
    }
  }

  return shader;
}