diff --git a/thermion_dart/native/include/RenderTicker.hpp b/thermion_dart/native/include/RenderTicker.hpp index 0f30df1c..800bad5a 100644 --- a/thermion_dart/native/include/RenderTicker.hpp +++ b/thermion_dart/native/include/RenderTicker.hpp @@ -51,6 +51,12 @@ namespace thermion /// @param numViews void setRenderable(filament::SwapChain *swapChain, filament::View **view, uint8_t numViews); + /// @brief + /// @param swapChain + /// @param view + /// @param numViews + void removeSwapChain(filament::SwapChain *swapChain); + /// @brief /// @param animationManager void addAnimationManager(AnimationManager* animationManager); diff --git a/thermion_dart/native/include/c_api/TRenderTicker.h b/thermion_dart/native/include/c_api/TRenderTicker.h index 62183fdb..f28f6940 100644 --- a/thermion_dart/native/include/c_api/TRenderTicker.h +++ b/thermion_dart/native/include/c_api/TRenderTicker.h @@ -15,6 +15,7 @@ extern "C" EMSCRIPTEN_KEEPALIVE void RenderTicker_render(TRenderTicker *tRenderTicker, uint64_t frameTimeInNanos); EMSCRIPTEN_KEEPALIVE void RenderTicker_setRenderable(TRenderTicker *tRenderTicker, TSwapChain *swapChain, TView **views, uint8_t numViews); + EMSCRIPTEN_KEEPALIVE void RenderTicker_removeSwapChain(TRenderTicker *tRenderTicker, TSwapChain *swapChain); #ifdef __cplusplus } diff --git a/thermion_dart/native/src/c_api/TRenderTicker.cpp b/thermion_dart/native/src/c_api/TRenderTicker.cpp index 4cfa496e..b6ece511 100644 --- a/thermion_dart/native/src/c_api/TRenderTicker.cpp +++ b/thermion_dart/native/src/c_api/TRenderTicker.cpp @@ -61,5 +61,10 @@ EMSCRIPTEN_KEEPALIVE void RenderTicker_setOverlayManager(TRenderTicker *tRenderT renderTicker->addOverlayManager(overlayManager); } +EMSCRIPTEN_KEEPALIVE void RenderTicker_removeSwapChain(TRenderTicker *tRenderTicker, TSwapChain *tSwapChain) { + auto *renderTicker = reinterpret_cast(tRenderTicker); + auto *swapChain = reinterpret_cast(tSwapChain); + renderTicker->removeSwapChain(swapChain); +} } diff --git a/thermion_flutter/thermion_flutter_method_channel/lib/src/thermion_flutter_method_channel_platform.dart b/thermion_flutter/thermion_flutter_method_channel/lib/src/thermion_flutter_method_channel_platform.dart index ba8b954e..984b2bef 100644 --- a/thermion_flutter/thermion_flutter_method_channel/lib/src/thermion_flutter_method_channel_platform.dart +++ b/thermion_flutter/thermion_flutter_method_channel/lib/src/thermion_flutter_method_channel_platform.dart @@ -22,6 +22,10 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform { static SwapChain? _swapChain; + SwapChain? getActiveSwapchain() { + return _swapChain; + } + ThermionFlutterMethodChannelPlatform._(); static ThermionFlutterMethodChannelPlatform? instance; @@ -114,7 +118,7 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform { // TODO - see if we can use `renderStandaloneView` in FilamentViewer to // avoid this if (Platform.isMacOS || Platform.isIOS) { - _swapChain = await FilamentApp.instance!.createHeadlessSwapChain(1, 1); + _swapChain = await FilamentApp.instance!.createHeadlessSwapChain(1, 1, hasStencilBuffer: true); await FilamentApp.instance!.register(_swapChain!, viewer.view); await viewer.view.setRenderable(true); } @@ -215,7 +219,8 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform { TextureUsage.TEXTURE_USAGE_SAMPLEABLE, TextureUsage.TEXTURE_USAGE_STENCIL_ATTACHMENT }, - textureFormat: TextureFormat.DEPTH24_STENCIL8, // TextureFormat.DEPTH32F, + textureFormat: + TextureFormat.DEPTH24_STENCIL8, // TextureFormat.DEPTH32F, textureSamplerType: TextureSamplerType.SAMPLER_2D, );