assetProgram method
Implementation
int assetProgram(String vertex, String fragment) {
final gl = Engine.flutterGlPlugin.gl;
final vertexShader = assetShader(gl.VERTEX_SHADER, vertex);
if (vertexShader == 0) {
if (kDebugMode) {
print('error vertex shader');
}
return 0;
}
final fragmentShader = assetShader(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)
..deleteShader(vertexShader)
..deleteShader(fragmentShader);
if (kDebugMode) {
print('create program=$programHandle');
}
return programHandle as int;
}