deleteTexture method
Implementation
Future<void> deleteTexture(FlutterAngleTexture texture,[bool releaseAll = true]) async {
if (Platform.isAndroid) {
return;
}
else if(Platform.isLinux){
_libEGL!.makeCurrent(_baseAppContext);
}
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) {
_rawOpenGl.glBindFramebuffer(GL_FRAMEBUFFER, texture.fboId);
if (!_isRBO) _rawOpenGl.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D, 0, 0); //unbind texutre
else _rawOpenGl.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0); //unbind colorbutter
_rawOpenGl.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0); //unbind depth buffer
_rawOpenGl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
_rawOpenGl.glClearColor(0.0, 0.0, 0.0, 0.0);
_rawOpenGl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
Pointer<Uint32> fbo = calloc();
fbo.value = texture.fboId;
_rawOpenGl.glDeleteBuffers(1, fbo);
calloc.free(fbo);
_activeFramebuffer = null;
Pointer<Uint32> depth = calloc();
depth.value = texture.depth;
_rawOpenGl.glDeleteRenderbuffers(1, depth);
calloc.free(depth);
}
if(releaseAll) await _channel.invokeMethod('deleteTexture',{"textureId": texture.textureId});
}