diff --git a/thermion_flutter/thermion_flutter/windows/wgl_context.cpp b/thermion_flutter/thermion_flutter/windows/wgl_context.cpp index 28dedbc0..aa62544d 100644 --- a/thermion_flutter/thermion_flutter/windows/wgl_context.cpp +++ b/thermion_flutter/thermion_flutter/windows/wgl_context.cpp @@ -12,9 +12,9 @@ WGLContext::WGLContext(flutter::PluginRegistrarWindows *pluginRegistrar, flutter::TextureRegistrar *textureRegistrar) : FlutterRenderContext(pluginRegistrar, textureRegistrar) { - #if WGL_USE_BACKING_WINDOW - return; - #endif +#if WGL_USE_BACKING_WINDOW + +#else auto hwnd = pluginRegistrar->GetView()->GetNativeWindow(); @@ -98,6 +98,7 @@ WGLContext::WGLContext(flutter::PluginRegistrarWindows *pluginRegistrar, std::cout << "Failed to create OpenGL context." << std::endl; return; } + #endif } void WGLContext::ResizeRenderingSurface(uint32_t width, uint32_t height, uint32_t left, uint32_t top) { @@ -106,6 +107,33 @@ void WGLContext::ResizeRenderingSurface(uint32_t width, uint32_t height, uint32_ #endif } +void WGLContext::DestroyRenderingSurface(std::unique_ptr> result) { + #if WGL_USE_BACKING_WINDOW + _backingWindow->Destroy(); + _backingWindow = nullptr; + #else + + // if (!_active) { + // result->Success("Texture has already been detroyed, ignoring"); + // return; + // } + + // auto sh = std::make_shared< + // std::unique_ptr>>( + // std::move(result)); + + // _textureRegistrar->UnregisterTexture( + // _active->flutterTextureId, [=, sharedResult = std::move(sh)]() { + // this->_inactive = std::move(this->_active); + // auto unique = std::move(*(sharedResult.get())); + // unique->Success(flutter::EncodableValue(true)); + // std::cout << "Unregistered/destroyed texture." << std::endl; + // }); + // } + #endif +} + + void WGLContext::CreateRenderingSurface( uint32_t width, uint32_t height, std::unique_ptr> result, uint32_t left, uint32_t top) { diff --git a/thermion_flutter/thermion_flutter/windows/wgl_context.h b/thermion_flutter/thermion_flutter/windows/wgl_context.h index 0968bf41..c68e2ad3 100644 --- a/thermion_flutter/thermion_flutter/windows/wgl_context.h +++ b/thermion_flutter/thermion_flutter/windows/wgl_context.h @@ -16,6 +16,9 @@ namespace thermion_flutter { void CreateRenderingSurface( uint32_t width, uint32_t height, std::unique_ptr> result, uint32_t left, uint32_t top); + + void DestroyRenderingSurface(std::unique_ptr> result); + void ResizeRenderingSurface( uint32_t width, uint32_t height, uint32_t left, uint32_t top );