changeset 665:419e5662d7a5

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 15 May 2019 12:28:58 +0200
parents 9631a10ed3af
children daf43666bbc2 e9339f2b5de7
files Resources/CMake/OrthancStoneConfiguration.cmake Samples/WebAssembly/BasicScene.cpp
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Wed May 15 11:52:35 2019 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Wed May 15 12:28:58 2019 +0200
@@ -146,13 +146,19 @@
 
 
 if (ENABLE_OPENGL)
-  include(FindOpenGL)
-  if (NOT OPENGL_FOUND)
-    message(FATAL_ERROR "Cannot find OpenGL on your system")
+  if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
+    # If including "FindOpenGL.cmake" using Emscripten (targetting
+    # WebAssembly), the "OPENGL_LIBRARIES" value incorrectly includes
+    # the "nul" library, which leads to warning message in Emscripten:
+    # 'shared:WARNING: emcc: cannot find library "nul"'.
+    include(FindOpenGL)
+    if (NOT OPENGL_FOUND)
+      message(FATAL_ERROR "Cannot find OpenGL on your system")
+    endif()
+
+    link_libraries(${OPENGL_LIBRARIES})
   endif()
 
-  link_libraries(${OPENGL_LIBRARIES})
-
   add_definitions(
     -DGL_GLEXT_PROTOTYPES=1
     -DORTHANC_ENABLE_OPENGL=1
--- a/Samples/WebAssembly/BasicScene.cpp	Wed May 15 11:52:35 2019 +0200
+++ b/Samples/WebAssembly/BasicScene.cpp	Wed May 15 12:28:58 2019 +0200
@@ -153,8 +153,10 @@
     void SetupEvents(const std::string& canvas);
 
   public:
-    WebAssemblyViewport(const std::string& canvas) :
+    WebAssemblyViewport(MessageBroker& broker,
+                        const std::string& canvas) :
       context_(canvas),
+      scene_(broker),
       compositor_(context_, scene_)
     {
       compositor_.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, 
@@ -361,6 +363,7 @@
 std::auto_ptr<OrthancStone::WebAssemblyViewport>  viewport1_;
 std::auto_ptr<OrthancStone::WebAssemblyViewport>  viewport2_;
 std::auto_ptr<OrthancStone::WebAssemblyViewport>  viewport3_;
+OrthancStone::MessageBroker  broker_;
 
 
 EM_BOOL OnWindowResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData)
@@ -396,15 +399,15 @@
   EMSCRIPTEN_KEEPALIVE
   void Initialize()
   {
-    viewport1_.reset(new OrthancStone::WebAssemblyViewport("mycanvas1"));
+    viewport1_.reset(new OrthancStone::WebAssemblyViewport(broker_, "mycanvas1"));
     PrepareScene(viewport1_->GetScene());
     viewport1_->UpdateSize();
 
-    viewport2_.reset(new OrthancStone::WebAssemblyViewport("mycanvas2"));
+    viewport2_.reset(new OrthancStone::WebAssemblyViewport(broker_, "mycanvas2"));
     PrepareScene(viewport2_->GetScene());
     viewport2_->UpdateSize();
 
-    viewport3_.reset(new OrthancStone::WebAssemblyViewport("mycanvas3"));
+    viewport3_.reset(new OrthancStone::WebAssemblyViewport(broker_, "mycanvas3"));
     PrepareScene(viewport3_->GetScene());
     viewport3_->UpdateSize();