diff --git a/Examples/Emscripten/Cxx/ConeFullScreen/CMakeLists.txt b/Examples/Emscripten/Cxx/ConeFullScreen/CMakeLists.txt deleted file mode 100644 index 9b0f36feee168aeadc26f95999a5f60305be58a6..0000000000000000000000000000000000000000 --- a/Examples/Emscripten/Cxx/ConeFullScreen/CMakeLists.txt +++ /dev/null @@ -1,93 +0,0 @@ -cmake_minimum_required(VERSION 3.13) -project(ConeFullScreen) - -# ----------------------------------------------------------------------------- -# EMSCRIPTEN only -# ----------------------------------------------------------------------------- - -if (NOT EMSCRIPTEN) - message("Skipping example: This needs to run inside an Emscripten build environment") - return () -endif () - -# ----------------------------------------------------------------------------- -# Handle VTK dependency -# ----------------------------------------------------------------------------- - -find_package(VTK - COMPONENTS - FiltersSources # VTK pipeline - InteractionStyle # Mouse handling - RenderingOpenGL2 # For Rendering - RenderingUI # For SDL2 Window -) - -if (NOT VTK_FOUND) - message("Skipping example: ${VTK_NOT_FOUND_MESSAGE}") - return () -endif () - -# ----------------------------------------------------------------------------- -# WebAssembly build options -# ----------------------------------------------------------------------------- - -set(emscripten_options) -list(APPEND emscripten_options - "--bind" - "-g3" - "-O3" - "SHELL:-s EXPORT_NAME=vtkApp" - "SHELL:-s ALLOW_MEMORY_GROWTH=1" - "SHELL:-s DEMANGLE_SUPPORT=1" - "SHELL:-s EMULATE_FUNCTION_POINTER_CASTS=0" - "SHELL:-s ERROR_ON_UNDEFINED_SYMBOLS=0" - "SHELL:-s MODULARIZE=1" - "SHELL:-s USE_PTHREADS=0" - "SHELL:-s WASM=1" -) - -# ----------------------------------------------------------------------------- -# Compile example code -# ----------------------------------------------------------------------------- - -add_executable(ConeFullScreen ConeFullScreen.cxx) - -target_link_libraries(ConeFullScreen - PRIVATE - VTK::FiltersSources - VTK::InteractionStyle - VTK::RenderingOpenGL2 - VTK::RenderingUI -) - -target_compile_options(ConeFullScreen - PUBLIC - ${emscripten_options} -) - -target_link_options(ConeFullScreen - PUBLIC - ${emscripten_options} -) - -# ----------------------------------------------------------------------------- -# VTK modules initialization -# ----------------------------------------------------------------------------- - -vtk_module_autoinit( - TARGETS ConeFullScreen - MODULES ${VTK_LIBRARIES} -) - -# ----------------------------------------------------------------------------- -# Copy HTML to build directory -# ----------------------------------------------------------------------------- - -add_custom_command( - TARGET ConeFullScreen - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E copy_if_different - "${CMAKE_CURRENT_SOURCE_DIR}/index.html" - $<TARGET_FILE_DIR:ConeFullScreen> -) diff --git a/Examples/Emscripten/Cxx/ConeFullScreen/ConeFullScreen.cxx b/Examples/Emscripten/Cxx/ConeFullScreen/ConeFullScreen.cxx deleted file mode 100644 index 797f7ba69222f9c0f0d1feebca2ab96fd7d6eeb0..0000000000000000000000000000000000000000 --- a/Examples/Emscripten/Cxx/ConeFullScreen/ConeFullScreen.cxx +++ /dev/null @@ -1,82 +0,0 @@ -/*========================================================================= - Program: Visualization Toolkit - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. -=========================================================================*/ - -#include "vtkActor.h" -#include "vtkConeSource.h" -#include "vtkInteractorStyleTrackballCamera.h" -#include "vtkNew.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkRenderer.h" -#include "vtkSDL2OpenGLRenderWindow.h" -#include "vtkSDL2RenderWindowInteractor.h" - -#include <emscripten.h> -#include <emscripten/html5.h> - -//------------------------------------------------------------------------------ -// Static objects -//------------------------------------------------------------------------------ - -static vtkSDL2OpenGLRenderWindow* renderWindow = vtkSDL2OpenGLRenderWindow::New(); - -//------------------------------------------------------------------------------ - -EM_BOOL resize_window(int eventType, const EmscriptenUiEvent* e, void* userData) -{ - renderWindow->SetSize(e->windowInnerWidth, e->windowInnerHeight); - renderWindow->Render(); - return 0; -} - -//------------------------------------------------------------------------------ -// Main -//------------------------------------------------------------------------------ - -int main(int argc, char* argv[]) -{ - // Create a renderer and interactor - vtkNew<vtkRenderer> renderer; - renderWindow->SetMultiSamples(0); - renderWindow->AddRenderer(renderer); - vtkNew<vtkSDL2RenderWindowInteractor> renderWindowInteractor; - renderWindowInteractor->SetRenderWindow(renderWindow); - - vtkNew<vtkInteractorStyleTrackballCamera> style; - renderWindowInteractor->SetInteractorStyle(style); - style->SetDefaultRenderer(renderer); - - // Create pipeline - vtkNew<vtkConeSource> coneSource; - coneSource->Update(); - - vtkNew<vtkPolyDataMapper> mapper; - mapper->SetInputConnection(coneSource->GetOutputPort()); - - vtkNew<vtkActor> actor; - actor->SetMapper(mapper); - - // Add the actors to the scene - renderer->AddActor(actor); - - // Start rendering app - renderer->SetBackground(0.2, 0.3, 0.4); - renderWindow->SetSize(300, 300); - - // Attach Window Resize Callback - emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, 0, 1, resize_window); - - // Start event loop - renderWindowInteractor->Start(); - - // Exit - renderWindow->Delete(); - return 0; -} diff --git a/Examples/Emscripten/Cxx/ConeFullScreen/README.md b/Examples/Emscripten/Cxx/ConeFullScreen/README.md deleted file mode 100644 index 5c305b48fae56405c5864b55afa40a1b5127ad7b..0000000000000000000000000000000000000000 --- a/Examples/Emscripten/Cxx/ConeFullScreen/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# WebAssembly ConeFullScreen Example - -This example aims to provide a base example on how to write a VTK viewer for -WebAssembly while adding callback to monitor browser size to adjust the rendering canvas. - -## Compiling example against VTK - -We assume inside the `work/` directory to find the source of VTK under `src/` -and its build tree under `build-vtk-wasm`. - -If VTK is not built yet, please follow the guide `../README.md`. - -Let's create the build directory for our example - -``` -mkdir -p work/build-conefullscreen -``` - -Start docker inside that working directory - -``` -docker run --rm --entrypoint /bin/bash -v $PWD:/work -p 8000:8000 -it dockcross/web-wasm:20230222-162287d - -cd /work/build-conefullscreen - -cmake \ - -G Ninja \ - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \ - -DVTK_DIR=/work/build-vtk-wasm \ - /work/src/Examples/Emscripten/Cxx/ConeFullScreen - -cmake --build . -``` - -## Serve and test generated code - -``` -cd work/build-conefullscreen -python3 -m http.server 8000 -``` - -Open your browser to http://localhost:8000 diff --git a/Examples/Emscripten/Cxx/ConeFullScreen/index.html b/Examples/Emscripten/Cxx/ConeFullScreen/index.html deleted file mode 100644 index 0560ce6e9cede3038edbfc2b75ff353e4c4761b9..0000000000000000000000000000000000000000 --- a/Examples/Emscripten/Cxx/ConeFullScreen/index.html +++ /dev/null @@ -1,38 +0,0 @@ -<!doctype html> -<html> - <head> - <meta charset="utf-8"/> - </head> - <body> - <canvas id="canvas" style="position: absolute; left: 0; top: 0;"></canvas> - <script type="text/javascript" src="ConeFullScreen.js"></script> - <script type='text/javascript'> - var Module = { - canvas: (function() { - var canvas = document.getElementById('canvas'); - // As a default initial behavior, pop up an alert when webgl context is lost. To make your - // application robust, you may want to override this behavior before shipping! - // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 - canvas.addEventListener( - "webglcontextlost", - function(e) { - alert('WebGL context lost. You will need to reload the page.'); - e.preventDefault(); - }, - false - ); - return canvas; - })(), - onRuntimeInitialized: function() { - console.log('initialized'); - setTimeout(() => { - window.dispatchEvent(new Event('resize')); - }, 0); - }, - }; - - // Use the export name to instantiate the app - var app = vtkApp(Module); - </script> - </body> -</html>