stringProgramm method

dynamic stringProgramm(
  1. String vertex,
  2. String fragment
)

Implementation

dynamic stringProgramm(String vertex, String fragment) {
  final gl = Engine.flutterGlPlugin.gl;
  final vertexShader = stringShader(gl.VERTEX_SHADER, vertex);
  if (vertexShader == 0) {
    if (kDebugMode) {
      print('error vertex shader');
    }
    return 0;
  }

  final fragmentShader = stringShader(gl.FRAGMENT_SHADER, fragment);
  if (fragmentShader == 0) {
    gl.deleteShader(vertexShader);
    if (kDebugMode) {
      print('error fragment shader');
    }
    return 0;
  }

  // Create the program object
  final programHandle = gl.createProgram();
  if (programHandle == 0) {
    if (kDebugMode) {
      print('error creating programm');
    }
    return 0;
  }

  gl
    ..attachShader(programHandle, vertexShader)
    ..attachShader(programHandle, fragmentShader)
    ..linkProgram(programHandle);
  if (kDebugMode) {
    print('create program=$programHandle');
  }
  return programHandle;
}