deleteTexture method
Implementation
Future<void> deleteTexture(FlutterAngleTexture texture,[bool releaseAll = true]) async {
if (Platform.isAndroid) return;
if(_useSurface && texture.surfaceId != nullptr){
_libEGL!.eglMakeCurrent(_display, texture.surfaceId!, texture.surfaceId!, _baseAppContext);
_libEGL!.eglDestroySurface(_display, texture.surfaceId!);
texture.surfaceId = nullptr;
}
angleConsole.warning('There is no active FlutterGL Texture to delete');
if (_activeFramebuffer == texture.fboId && releaseAll) {
gl.glBindFramebuffer(GL_FRAMEBUFFER, texture.fboId);
if (!_isRBO){
gl.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, 0, 0);
}
else{
gl.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
}
gl.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl.glClearColor(0.0, 0.0, 0.0, 0.0);
gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
Pointer<Uint32> fbo = calloc();
fbo.value = texture.fboId;
gl.glDeleteBuffersPointer(1, fbo);
calloc.free(fbo);
_activeFramebuffer = null;
Pointer<Uint32> depth = calloc();
depth.value = texture.depth;
gl.glDeleteRenderbuffersPointer(1, depth);
calloc.free(depth);
}
if(releaseAll){
await _channel.invokeMethod('deleteTexture',{"textureId": texture.textureId});
}
}