# HG changeset patch # User Sebastien Jodogne # Date 1575920747 -3600 # Node ID 358461330978df3581785bf1182b998d04f437cb # Parent e71ee3e8844859850362f167b00bb90006ef89b8 global function GetWebGLViewportsRegistry() diff -r e71ee3e88448 -r 358461330978 Framework/StoneInitialization.cpp --- a/Framework/StoneInitialization.cpp Mon Dec 09 20:25:22 2019 +0100 +++ b/Framework/StoneInitialization.cpp Mon Dec 09 20:45:47 2019 +0100 @@ -60,6 +60,11 @@ # include #endif +#if ORTHANC_ENABLE_WASM == 1 +static double viewportsTimeout_ = 1000; +static std::auto_ptr viewportsRegistry_; +#endif + #include "Toolbox/LinearAlgebra.h" #include @@ -170,6 +175,10 @@ void StoneFinalize() { +#if ORTHANC_ENABLE_WASM == 1 + viewportsRegistry_.reset(); +#endif + #if ORTHANC_ENABLE_SDL == 1 OrthancStone::SdlWindow::GlobalFinalize(); #endif @@ -188,4 +197,32 @@ Orthanc::Logging::Finalize(); } + + +#if ORTHANC_ENABLE_WASM == 1 + void SetWebGLViewportsRegistryTimeout(double timeout) + { + if (viewportsRegistry_.get()) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); + } + else + { + viewportsTimeout_ = timeout; + } + } +#endif + + +#if ORTHANC_ENABLE_WASM == 1 + WebGLViewportsRegistry& GetWebGLViewportsRegistry() + { + if (viewportsRegistry_.get() == NULL) + { + viewportsRegistry_.reset(new WebGLViewportsRegistry(viewportsTimeout_)); + } + + return *viewportsRegistry_; + } +#endif } diff -r e71ee3e88448 -r 358461330978 Framework/StoneInitialization.h --- a/Framework/StoneInitialization.h Mon Dec 09 20:25:22 2019 +0100 +++ b/Framework/StoneInitialization.h Mon Dec 09 20:45:47 2019 +0100 @@ -21,6 +21,18 @@ #pragma once +#if !defined(ORTHANC_ENABLE_WASM) +# error Macro ORTHANC_ENABLE_WASM must be defined +#endif + +#if !defined(ORTHANC_ENABLE_LOGGING_PLUGIN) +# error Macro ORTHANC_ENABLE_LOGGING_PLUGIN must be defined +#endif + +#if ORTHANC_ENABLE_WASM == 1 +# include "Viewport/WebGLViewportsRegistry.h" +#endif + #include namespace OrthancStone @@ -32,4 +44,12 @@ #endif void StoneFinalize(); + +#if ORTHANC_ENABLE_WASM == 1 + void SetWebGLViewportsRegistryTimeout(double timeout); +#endif + +#if ORTHANC_ENABLE_WASM == 1 + WebGLViewportsRegistry& GetWebGLViewportsRegistry(); +#endif }