Skip to content

Commit

Permalink
Use EmscriptenApplication on emscripten
Browse files Browse the repository at this point in the history
Signed-off-by: Squareys <squareys@googlemail.com>
  • Loading branch information
Squareys committed May 22, 2019
1 parent 76b75bc commit c9cd997
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/arealights/AreaLightsExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
#include <Magnum/GL/Texture.h>
#include <Magnum/GL/TextureFormat.h>
#include <Magnum/GL/Version.h>
#ifdef CORRADE_TARGET_EMSCRIPTEN
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
#include <Magnum/Shaders/Flat.h>
#include <Magnum/Text/Alignment.h>
#include <Magnum/Trade/AbstractImporter.h>
Expand Down
6 changes: 4 additions & 2 deletions src/arealights/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ endif()
find_package(Magnum REQUIRED
GL
Shaders
Trade
Sdl2Application)
Trade)
find_package(MagnumExtras REQUIRED Ui)

if(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
find_package(MagnumPlugins REQUIRED
DdsImporter
StbTrueTypeFont)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
Expand Down
6 changes: 5 additions & 1 deletion src/audio/AudioExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
#include <Magnum/GL/Mesh.h>
#include <Magnum/GL/Renderer.h>
#include <Magnum/MeshTools/Compile.h>
#ifdef CORRADE_TARGET_EMSCRIPTEN
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
#include <Magnum/Primitives/Cone.h>
#include <Magnum/Primitives/Cylinder.h>
#include <Magnum/Shaders/Flat.h>
Expand Down Expand Up @@ -180,8 +184,8 @@ AudioExample::AudioExample(const Arguments& arguments):
Debug{} << "HRTF specifier:" << _context.hrtfSpecifierString();

/* Loop at 60 Hz max */
setSwapInterval(1);
#ifndef CORRADE_TARGET_EMSCRIPTEN
setSwapInterval(1);
setMinimalLoopPeriod(16);
#endif
}
Expand Down
6 changes: 4 additions & 2 deletions src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ find_package(Magnum REQUIRED
Primitives
SceneGraph
Shaders
Trade
Sdl2Application)
Trade)

if(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
find_package(MagnumPlugins REQUIRED StbVorbisAudioImporter)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
Expand Down
7 changes: 7 additions & 0 deletions src/box2d/Box2DExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
#include <Magnum/Math/ConfigurationValue.h>
#include <Magnum/Math/DualComplex.h>
#include <Magnum/MeshTools/Compile.h>
#ifdef CORRADE_TARGET_EMSCRIPTEN
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
#include <Magnum/Primitives/Square.h>
#include <Magnum/SceneGraph/Camera.h>
#include <Magnum/SceneGraph/Drawable.h>
Expand Down Expand Up @@ -166,7 +170,10 @@ Box2DExample::Box2DExample(const Arguments& arguments): Platform::Application{ar
}
}

#ifndef CORRADE_TARGET_EMSCRIPTEN
setSwapInterval(1);
#endif

#if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_ANDROID)
setMinimalLoopPeriod(16);
#endif
Expand Down
8 changes: 7 additions & 1 deletion src/box2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@ find_package(Magnum REQUIRED
MeshTools
Primitives
SceneGraph
Sdl2Application
Shaders
Trade)
find_package(Box2D REQUIRED)

if(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
find_package(MagnumPlugins REQUIRED StbVorbisAudioImporter)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)

add_executable(magnum-box2d Box2DExample.cpp)
Expand Down
6 changes: 5 additions & 1 deletion src/bullet/BulletExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
#include <Magnum/Math/Constants.h>
#include <Magnum/MeshTools/Compile.h>
#include <Magnum/MeshTools/Transform.h>
#ifdef CORRADE_TARGET_EMSCRIPTEN
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
#include <Magnum/Primitives/Cube.h>
#include <Magnum/Primitives/UVSphere.h>
#include <Magnum/SceneGraph/Camera.h>
Expand Down Expand Up @@ -215,8 +219,8 @@ BulletExample::BulletExample(const Arguments& arguments): Platform::Application(
}

/* Loop at 60 Hz max */
setSwapInterval(1);
#ifndef CORRADE_TARGET_EMSCRIPTEN
setSwapInterval(1);
setMinimalLoopPeriod(16);
#endif
_timeline.start();
Expand Down
7 changes: 6 additions & 1 deletion src/bullet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ find_package(Magnum REQUIRED
MeshTools
Primitives
SceneGraph
Sdl2Application
Shaders
Trade)
find_package(MagnumIntegration REQUIRED Bullet)

if(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)

add_executable(magnum-bullet BulletExample.cpp)
Expand Down
10 changes: 9 additions & 1 deletion src/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/../../modules/")
endif()

find_package(Magnum REQUIRED GL Sdl2Application)
find_package(Magnum REQUIRED GL)
find_package(MagnumIntegration REQUIRED ImGui)

if(CORRADE_TARGET_ANDROID)
find_package(Magnum REQUIRED AndroidApplication)
elseif(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)

# Bundle a better font
Expand Down
2 changes: 2 additions & 0 deletions src/imgui/ImGuiExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

#ifdef CORRADE_TARGET_ANDROID
#include <Magnum/Platform/AndroidApplication.h>
#elif defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
Expand Down
9 changes: 7 additions & 2 deletions src/mouseinteraction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ find_package(Magnum REQUIRED
MeshTools
Primitives
SceneGraph
Shaders
Sdl2Application)
Shaders)

if(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)

Expand Down
4 changes: 4 additions & 0 deletions src/mouseinteraction/MouseInteractionExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
#include <Magnum/GL/Renderer.h>
#include <Magnum/Math/FunctionsBatch.h>
#include <Magnum/MeshTools/Compile.h>
#ifdef CORRADE_TARGET_EMSCRIPTEN
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
#include <Magnum/Primitives/Grid.h>
#include <Magnum/SceneGraph/Camera.h>
#include <Magnum/SceneGraph/Drawable.h>
Expand Down
9 changes: 7 additions & 2 deletions src/picking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ find_package(Magnum REQUIRED
GL
MeshTools
Primitives
SceneGraph
Sdl2Application)
SceneGraph)

if(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

project(MagnumPickingExample)

Expand Down
4 changes: 4 additions & 0 deletions src/picking/PickingExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
#include <Magnum/Math/Color.h>
#include <Magnum/MeshTools/CompressIndices.h>
#include <Magnum/MeshTools/Interleave.h>
#ifdef CORRADE_TARGET_EMSCRIPTEN
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
#include <Magnum/Primitives/Cube.h>
#include <Magnum/Primitives/Plane.h>
#include <Magnum/Primitives/UVSphere.h>
Expand Down
2 changes: 2 additions & 0 deletions src/primitives/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ find_package(Magnum REQUIRED

if(CORRADE_TARGET_ANDROID)
find_package(Magnum REQUIRED AndroidApplication)
elseif(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/primitives/PrimitivesExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <Magnum/MeshTools/CompressIndices.h>
#ifdef CORRADE_TARGET_ANDROID
#include <Magnum/Platform/AndroidApplication.h>
#elif defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
Expand Down
9 changes: 7 additions & 2 deletions src/text/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ find_package(Magnum REQUIRED
GL
Shaders
Text
Trade
Sdl2Application)
Trade)

if(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()

if(MAGNUM_BUILD_STATIC)
find_package(Magnum REQUIRED TgaImporter MagnumFont)
Expand Down
4 changes: 4 additions & 0 deletions src/text/TextExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
#include <Magnum/GL/Mesh.h>
#include <Magnum/GL/Renderer.h>
#include <Magnum/Math/Complex.h>
#ifdef CORRADE_TARGET_EMSCRIPTEN
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
#include <Magnum/Shaders/DistanceFieldVector.h>
#include <Magnum/Trade/AbstractImporter.h>
#include <Magnum/Text/AbstractFont.h>
Expand Down
2 changes: 2 additions & 0 deletions src/textured-triangle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ endif()

if(CORRADE_TARGET_ANDROID)
find_package(Magnum REQUIRED AndroidApplication)
elseif(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/textured-triangle/TexturedTriangleExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <Magnum/GL/TextureFormat.h>
#ifdef CORRADE_TARGET_ANDROID
#include <Magnum/Platform/AndroidApplication.h>
#elif defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/triangle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ find_package(Magnum REQUIRED GL Shaders)

if(CORRADE_TARGET_ANDROID)
find_package(Magnum REQUIRED AndroidApplication)
elseif(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/triangle/TriangleExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <Magnum/GL/Mesh.h>
#ifdef CORRADE_TARGET_ANDROID
#include <Magnum/Platform/AndroidApplication.h>
#elif defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ find_package(Magnum REQUIRED

if(CORRADE_TARGET_ANDROID)
find_package(Magnum REQUIRED AndroidApplication)
elseif(CORRADE_TARGET_EMSCRIPTEN)
find_package(Magnum REQUIRED EmscriptenApplication)
else()
find_package(Magnum REQUIRED Sdl2Application)
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/viewer/ViewerExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include <Magnum/MeshTools/Compile.h>
#ifdef CORRADE_TARGET_ANDROID
#include <Magnum/Platform/AndroidApplication.h>
#elif defined(CORRADE_TARGET_EMSCRIPTEN)
#include <Magnum/Platform/EmscriptenApplication.h>
#else
#include <Magnum/Platform/Sdl2Application.h>
#endif
Expand Down

0 comments on commit c9cd997

Please sign in to comment.