Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emscripten application #300

Merged
merged 35 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
55960fb
Animation: use float literals everywhere.
mosra Jun 4, 2019
cf1c78f
GL: ffs, a time query and nowhere it mentions *what* is the time unit.
mosra Jun 4, 2019
b970b4d
Platform: Add initial EmscriptenApplication
Squareys Dec 13, 2018
2952a19
Platform: various minor EmscriptenApplication cleanup.
mosra May 26, 2019
9c8dfbc
Platform: hide Emscripten forward declarations from Doxygen.
mosra May 26, 2019
251e858
Platform: the EmscriptenApplication destructor doesn't need to be vir…
mosra May 26, 2019
173a87e
Platform: none of EmscriptenApplication constructors were defined.
mosra May 26, 2019
e375fac
Platform: properly define enum operators for all EmscriptenApp flags.
mosra May 26, 2019
f2fb0b3
Platform: fix build on Emscripten 1.38.17 and newer.
mosra May 26, 2019
e1e1da9
Platform: it's good to enable exts by default in EmscriptenApp.
mosra May 26, 2019
4c8ac4f
Platform: those flags are not flags, damnit.
mosra May 26, 2019
73e0199
Platform: well, these OTOH *don't* need to be flags.
mosra May 26, 2019
fc4860e
Platform: give the docs the love they deserve.
mosra May 26, 2019
fd137f3
Platform: make EmscriptenApplication work correctly w/o TARGET_GL.
mosra May 26, 2019
e64adb7
Platform: test explicitly enabled extensions in EmscriptenApplication.
mosra May 26, 2019
5ddd3a6
Platform: test also key release events in EmscriptenApplication.
mosra May 26, 2019
562cf67
Platform: test initial window size params in GLFW and SDL2 apps.
mosra May 26, 2019
b28ac46
Platform: no need to reinterpret_cast the void pointers.
mosra May 26, 2019
8254e16
Platform: rework DPI awareness and resize event in EmscriptenApp.
mosra May 26, 2019
ba1ca34
Platform: do not redraw all the time in EmscriptenApplicationTest.
mosra May 26, 2019
1aa4989
Platform: expose raw event structures in EmscriptenApplication.
mosra May 26, 2019
e7671c0
Platform: why this is here and not here.
mosra May 26, 2019
e0019f5
Platform: this is all wrong anyway and mainLoopIteration() is useless.
mosra May 26, 2019
ac0d698
Platform: actually properly destroy the WebGL context after.
mosra May 26, 2019
9ac7c7f
Platform: test EmscriptenApplication text input.
mosra May 26, 2019
41859d8
Platform: why is this protected when it's public elsewhere.
mosra May 26, 2019
de0d991
Platform: add EmscriptenApplication::setContainerCssClass().
mosra May 26, 2019
1bd78f9
Platform: move friends into privates.
mosra May 26, 2019
ed564b5
Platform: doc++
mosra May 26, 2019
aa67673
doc: mention EmscriptenApplication everywhere.
mosra May 26, 2019
62e74ea
dox: Link to building-doc from developer guide
Squareys May 29, 2019
524e8a9
package/archlinux: enable EmscriptenApplication.
mosra May 26, 2019
cc28453
Platform: Fix UTF8 text input in EmscriptenApplication
Squareys May 28, 2019
6e5f6b8
Platform: light-weight main loop for EmscriptenApplication
Squareys May 29, 2019
733d417
Platform: testing for wheel events.
mosra Jun 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ option(WITH_EGLCONTEXT "Build EglContext library" OFF)
if(CORRADE_TARGET_ANDROID)
option(WITH_ANDROIDAPPLICATION "Build AndroidApplication library" OFF)

# Emscripten-specific application libraries
elseif(CORRADE_TARGET_EMSCRIPTEN)
option(WITH_EMSCRIPTENAPPLICATION "Build EmscriptenApplication library" OFF)

# iOS-specific application libraries
elseif(CORRADE_TARGET_IOS)
option(WITH_WINDOWLESSIOSAPPLICATION "Build WindowlessIosApplication library" OFF)
Expand Down
3 changes: 3 additions & 0 deletions doc/building.dox
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ going to build any of the @ref example-index "examples", you'll need it.
@ref Platform::AndroidApplication "AndroidApplication" library. Available
only on @ref CORRADE_TARGET_ANDROID "Android". Enables also building of the
GL library.
- `WITH_EMSCRIPTENAPPLICATION` --- Build the
@ref Platform::EmscriptenApplication "EmscriptenApplication" library.
Available only on @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten".
- `WITH_GLFWAPPLICATION` --- Build the
@ref Platform::GlfwApplication "GlfwApplication" library. Depends on
[GLFW](http://glfw.org).
Expand Down
4 changes: 4 additions & 0 deletions doc/changelog.dox
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ See also:

@subsubsection changelog-latest-new-platform Platform libraries

- Added @ref Platform::EmscriptenApplication, implementing a lightweight and
more flexible alternative to @ref Platform::Sdl2Application for Emscripten.
This is now the recommended application to use for WebGL builds. See
[mosra/magnum#300](https://github.com/mosra/magnum/pull/300).
- @ref Platform::Sdl2Application and @ref Platform::GlfwApplication are now
DPI-aware on Windows as well. See their documentation,
@ref platforms-windows-hidpi and [mosra/magnum#243](https://github.com/mosra/magnum/issues/243)
Expand Down
2 changes: 2 additions & 0 deletions doc/cmake.dox
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ the components. The optional components are:

Platform namespace is split into more components:

- `AndroidApplication` --- @ref Platform::AndroidApplication "AndroidApplication"
- `EmscriptenApplication` --- @ref Platform::EmscriptenApplication "EmscriptenApplication"
- `GlfwApplication` --- @ref Platform::GlfwApplication "GlfwApplication"
- `GlxApplication` --- @ref Platform::GlxApplication "GlxApplication"
- `Sdl2Application` --- @ref Platform::Sdl2Application "Sdl2Application"
Expand Down
9 changes: 5 additions & 4 deletions doc/credits.dox
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ Are the below lists missing your name or something's wrong?
improvements to @cb{.cmake} android_create_apk() @ce
- **Ivan P.** ([\@uzername](https://github.com/uzername)) --- documentation
improvements
- **Jonathan Hale** ([\@Squareys](https://github.com/Squareys)) --- @ref Audio
library enhancements, @ref Platform::GlfwApplication implementation,
frustum and cone culling, bug reports, Windows build improvements,
documentation improvements and tons of other stuff
- **Jonathan Hale** ([\@Squareys](https://github.com/Squareys)) ---
@ref Audio library enhancements, @ref Platform::GlfwApplication and
@ref Platform::EmscriptenApplication implementation, frustum and cone
culling, bug reports, Windows build improvements, documentation
improvements and tons of other stuff
- **Joel Clay** ([\@jclay](https://github.com/jclay)) --- Vcpkg packages
- **Konstantinos Chatzilygeroudis** ([\@costashatz](https://github.com/costashatz))
--- Debian package
Expand Down
34 changes: 17 additions & 17 deletions doc/developers.dox
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ required to follow them to the point.
support)
13. Mention the library in `doc/changelog.dox` (or similar files in other
repos)
14. Build documentation:
- run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
14. @ref building-doc "Build documentation":
- run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
and verify there are no new warnings
- eyeball the namespace and directory docs, fix suspicious things, look
also in the building and cmake docs
Expand Down Expand Up @@ -307,8 +307,8 @@ in inverse.
more information.
6. Mention the new functionality in `doc/changelog.dox` (and similar files in
other repos)
7. Build documentation:
- run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
7. @ref building-doc "Build documentation":
- run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
and verify there are no new warnings
- eyeball the relevant docs and fix suspicious things
8. Build a coverage build (`package/archlinux/PKGBUILD-coverage`), or abuse
Expand All @@ -328,8 +328,8 @@ in inverse --- but usually @ref developers-deprecation "deprecate first".
3. Add a test for it to corresponding file, verify the test gets actually run
4. Mention the new functionality in `doc/changelog.dox` (and similar files in
other repos)
5. Build documentation:
- run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
5. @ref building-doc "Build documentation":
- run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
and verify there are no new warnings
- eyeball the relevant docs and fix suspicious things
6. Build a coverage build (`package/archlinux/PKGBUILD-coverage`), or abuse
Expand All @@ -354,8 +354,8 @@ in inverse --- but usually @ref developers-deprecation "deprecate first".
5. Populate it, see @ref coding-style for more information
6. Mention the new page in `doc/changelog.dox` (and similar files in other
repos)
7. Build documentation:
- run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
7. @ref building-doc "Build documentation":
- run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
and verify there are no new warnings
- eyeball the relevant docs and fix suspicious things
8. Push to `master`
Expand Down Expand Up @@ -399,8 +399,8 @@ in inverse --- but usually @ref developers-deprecation "deprecate first".
7. Upon verifying the above, start updating dependent code
8. Mention the deprecated API in the deprecation section of `doc/changelog.dox`
(and similar files in other repos)
9. Build documentation:
- run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
9. @ref building-doc "Build documentation":
- run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
and verify there are no new warnings
- eyeball the relevant docs and fix suspicious things
10. Push to a temporary branch (e.g., `next`)
Expand Down Expand Up @@ -474,8 +474,8 @@ in inverse --- but usually @ref developers-deprecation "deprecate first".
remove relevant deprecated files and update `CMakeLists.txt`
3. Mention the removed API in the compatibility section of `doc/changelog.dox`
(or similar files in other repos)
4. Build documentation:
- run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
4. @ref building-doc "Build documentation":
- run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
and verify there are no new warnings --- sometimes it happens that a
deprecated API is still being referenced
5. Push to a temporary branch (e.g., `next`)
Expand Down Expand Up @@ -603,8 +603,8 @@ unless it doesn't affect public API at all.
possibly to multiple places
9. Update relevant extension support in tables in `doc/opengl-support.dox`
10. Mention the new stuff in `doc/changelog.dox`
11. Build documentation:
- run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
11. @ref building-doc "Build documentation":
- run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
and verify there are no new warnings
- eyeball the relevant docs and fix suspicious things
12. Build and test for relevant platforms locally (as the public CI can't test
Expand Down Expand Up @@ -790,7 +790,7 @@ inverse.
1. (Optionally) remove `build/doc-public` to get rid of stale files
2. Verify there are no untracked files, modifications or branches different
than `master` checked out that could mess up the docs
3. Run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-public`,
3. Run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-public`,
look for suspicious warnings
4. Upload contents of `build/doc-public/html/` to `doc/magnum-new/` and remove
`doc/magnum-old/` if any
Expand All @@ -810,8 +810,8 @@ inverse.
5. Add the contributor to `CREDITS.md`, if not already there
6. Update `doc/changelog.dox` (and similar files in other repos), if not
already done
7. Build documentation:
- run [dox2html5.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
7. @ref building-doc "Build documentation:
- run [doxygen.py](http://mcss.mosra.cz/doxygen/) on `Doxyfile-mcss`
and verify there are no new warnings
- eyeball the relevant docs and fix suspicious things
8. Push to a temporary branch (e.g., `next`)
Expand Down
31 changes: 17 additions & 14 deletions doc/platforms-html5.dox
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ In case you don't have an OpenGL ES build set up yet, you need to copy
Magnum source to the `modules/` dir in your project so it is able to find the
WebGL libraries.

Magnum provides an Emscripten application wrapper in
@ref Platform::Sdl2Application. See its documentation for more information
about general usage. You can also use the Emscripten APIs directly or any other
way.
Magnum provides Emscripten application wrappers in @ref Platform::Sdl2Application
and @ref Platform::EmscriptenApplication. See their documentation for more
information about general usage. You can also use the Emscripten APIs directly
or any other way.

@note The @ref Platform::Sdl2Application also contains a fully configured
bootstrap project that's ready to build and deploy. Check its documentation
for details.
@note @ref Platform::EmscriptenApplication also contains a fully configured
bootstrap project that is ready to build and deploy. Check its
documentation for details.

To target the web browser, you need to provide a HTML markup for your
application. Template one is below. The markup references two files,
Expand Down Expand Up @@ -198,9 +198,8 @@ EGL and WebGL libraries.

Windowless Magnum apps (i.e. apps that use the OpenGL context without a window)
can be run in the browser as well using the @ref Platform::WindowlessEglApplication
class. See its documentation for more information
about general usage. You can also use the Emscripten APIs directly or any other
way.
class. See its documentation for more information about general usage. You can
also use the Emscripten APIs directly or any other way.

@note @ref Platform::WindowlessEglApplication also contains a fully configured
bootstrap project that's ready to build and deploy. Check its documentation
Expand Down Expand Up @@ -330,7 +329,8 @@ the @cb{.css} div#sizer @ce will center it, following the canvas width. If you
need more advanced styling, check out [m.css](http://mcss.mosra.cz).

@note It's also possible to modify the container CSS classes from the C++ side
using @ref Platform::Sdl2Application::setContainerCssClass().
using @ref Platform::EmscriptenApplication::setContainerCssClass() /
@ref Platform::Sdl2Application::setContainerCssClass().

@section platforms-html5-events Controlling event behavior

Expand All @@ -350,8 +350,11 @@ Module.doNotCaptureKeyboard = true;
</script>
@endcode

The above is implicitly set for windowless apps, because these don't have any
event loop.
The above is implicitly set for @ref Platform::WindowlessEglApplication,
because it does not have an event loop.

@cb{.js} Module.doNotCaptureKeyboard @ce is not supported by
@ref Platform::EmscriptenApplication.

Another solution is to specify the element on which it should capture keybard
using @cb{.js} Module.keyboardListeningElement @ce --- it requires the actual
Expand All @@ -367,7 +370,7 @@ like this:

After that, the canvas can be focused with a @m_class{m-label m-default} **Tab**
key. But because Emscripten eats all mouse input, the `mousedown` event won't
be propagated to focus the canvas unlesss you do that manually:
be propagated to focus the canvas unless you do that manually:

@code{.js}
Module.keyboardListeningElement = Module.canvas;
Expand Down
14 changes: 10 additions & 4 deletions modules/FindMagnum.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
# TextureTools - TextureTools library
# Trade - Trade library
# Vk - Vk library
# AndroidApplication - Android application
# EmscriptenApplication - Emscripten application
# GlfwApplication - GLFW application
# GlxApplication - GLX application
# Sdl2Application - SDL2 application
Expand Down Expand Up @@ -338,10 +340,10 @@ endif()
set(_MAGNUM_LIBRARY_COMPONENT_LIST
Audio DebugTools GL MeshTools Primitives SceneGraph Shaders Text
TextureTools Trade Vk
AndroidApplication GlfwApplication GlxApplication Sdl2Application
XEglApplication WindowlessCglApplication WindowlessEglApplication
WindowlessGlxApplication WindowlessIosApplication WindowlessWglApplication
WindowlessWindowsEglApplication
AndroidApplication EmscriptenApplication GlfwApplication GlxApplication
Sdl2Application XEglApplication WindowlessCglApplication
WindowlessEglApplication WindowlessGlxApplication WindowlessIosApplication
WindowlessWglApplication WindowlessWindowsEglApplication
CglContext EglContext GlxContext WglContext
OpenGLTester)
set(_MAGNUM_PLUGIN_COMPONENT_LIST
Expand Down Expand Up @@ -410,6 +412,10 @@ endif()

set(_MAGNUM_Trade_DEPENDENCIES )
set(_MAGNUM_AndroidApplication_DEPENDENCIES GL)
set(_MAGNUM_EmscriptenApplication_DEPENDENCIES)
if(MAGNUM_TARGET_GL)
list(APPEND _MAGNUM_EmscriptenApplication_DEPENDENCIES GL)
endif()

set(_MAGNUM_GlfwApplication_DEPENDENCIES )
if(MAGNUM_TARGET_GL)
Expand Down
1 change: 1 addition & 0 deletions package/archlinux/PKGBUILD-emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ build() {
-DCMAKE_INSTALL_PREFIX=/usr/lib/emscripten/system \
-DMAGNUM_DEPLOY_PREFIX=/srv/http/emscripten \
-DWITH_AUDIO=ON \
-DWITH_EMSCRIPTENAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_WINDOWLESSEGLAPPLICATION=ON \
-DWITH_ANYAUDIOIMPORTER=ON \
Expand Down
1 change: 1 addition & 0 deletions package/archlinux/PKGBUILD-emscripten-wasm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ build() {
-DCMAKE_INSTALL_PREFIX=/usr/lib/emscripten/system \
-DMAGNUM_DEPLOY_PREFIX=/srv/http/emscripten \
-DWITH_AUDIO=ON \
-DWITH_EMSCRIPTENAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_WINDOWLESSEGLAPPLICATION=ON \
-DWITH_ANYAUDIOIMPORTER=ON \
Expand Down
1 change: 1 addition & 0 deletions package/archlinux/PKGBUILD-emscripten-wasm-webgl2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ build() {
-DMAGNUM_DEPLOY_PREFIX=/srv/http/emscripten-webgl2 \
-DTARGET_GLES2=OFF \
-DWITH_AUDIO=ON \
-DWITH_EMSCRIPTENAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_WINDOWLESSEGLAPPLICATION=ON \
-DWITH_ANYAUDIOIMPORTER=ON \
Expand Down
1 change: 1 addition & 0 deletions package/archlinux/PKGBUILD-emscripten-webgl2
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ build() {
-DMAGNUM_DEPLOY_PREFIX=/srv/http/emscripten-webgl2 \
-DTARGET_GLES2=OFF \
-DWITH_AUDIO=ON \
-DWITH_EMSCRIPTENAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_WINDOWLESSEGLAPPLICATION=ON \
-DWITH_ANYAUDIOIMPORTER=ON \
Expand Down
1 change: 1 addition & 0 deletions package/ci/travis-emscripten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ cmake .. \
-DCMAKE_FIND_ROOT_PATH=$HOME/deps \
-DWITH_AUDIO=ON \
-DWITH_VK=OFF \
-DWITH_EMSCRIPTENAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_WINDOWLESSEGLAPPLICATION=ON \
-DWITH_ANYAUDIOIMPORTER=ON \
Expand Down
2 changes: 1 addition & 1 deletion src/Magnum/Animation/Easing.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ Combination of @ref circularIn() and @ref circularOut().
@see @ref sineInOut()
*/
inline Float circularInOut(Float t) {
if(t < 0.5f) return 0.5f*(1.0f - std::sqrt(1.0f - 4*t*t));
if(t < 0.5f) return 0.5f*(1.0f - std::sqrt(1.0f - 4.0f*t*t));
return 0.5f*(1.0f + std::sqrt(-4.0f*t*t + 8.0f*t - 3.0f));
}

Expand Down
13 changes: 7 additions & 6 deletions src/Magnum/GL/TimeQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ usage of both methods:

@snippet MagnumGL.cpp TimeQuery-usage2

Using the latter results in fewer OpenGL calls when doing more measures.
Using the latter results in fewer OpenGL calls when doing more measures. All
times are reported in nanoseconds.

@requires_gl33 Extension @gl_extension{ARB,timer_query}
@requires_es_extension Extension @gl_extension{EXT,disjoint_timer_query}
Expand All @@ -66,8 +67,8 @@ class TimeQuery: public AbstractQuery {
*/
enum class Target: GLenum {
/**
* Elapsed time. Use @ref result<UnsignedLong>() or @ref result<Long>()
* to retrieve the result.
* Elapsed time, in nanoseconds. Use @ref result<UnsignedLong>() or
* @ref result<Long>() to retrieve the result.
* @see @ref timestamp()
*/
#ifndef MAGNUM_TARGET_GLES
Expand All @@ -77,9 +78,9 @@ class TimeQuery: public AbstractQuery {
#endif

/**
* Timestamp. For use with @ref timestamp() only, use
* @ref result<UnsignedLong>() or @ref result<Long>() to retrieve
* the result.
* Timestamp, in nanoseconds. For use with @ref timestamp() only,
* use @ref result<UnsignedLong>() or @ref result<Long>() to
* retrieve the result.
*/
#ifndef MAGNUM_TARGET_GLES
Timestamp = GL_TIMESTAMP
Expand Down
Loading