From 2145ae9b969f058e39bcaa008c7e5f6bab57189e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 19 Aug 2017 19:07:49 +0200 Subject: [PATCH] Dropped NaCl support. --- CMakeLists.txt | 35 +- README.md | 2 - doc/best-practices.dox | 9 +- doc/building.dox | 54 +- doc/changelog.dox | 6 +- doc/cmake.dox | 2 - doc/mainpage.dox | 2 - doc/opengl-support.dox | 1 - doc/platform.dox | 6 +- modules/FindCorrade.cmake | 11 +- modules/FindMagnum.cmake | 9 +- modules/FindOpenGLES2.cmake | 5 +- package/archlinux/PKGBUILD-nacl-glibc | 65 - package/archlinux/PKGBUILD-nacl-newlib | 67 - src/Magnum/AbstractFramebuffer.cpp | 50 +- src/Magnum/AbstractFramebuffer.h | 2 - src/Magnum/AbstractObject.cpp | 43 +- src/Magnum/AbstractQuery.cpp | 12 +- src/Magnum/AbstractShaderProgram.cpp | 85 +- src/Magnum/AbstractTexture.cpp | 49 +- src/Magnum/Buffer.cpp | 47 +- src/Magnum/Buffer.h | 83 +- src/Magnum/CMakeLists.txt | 2 +- src/Magnum/Context.cpp | 3 - src/Magnum/Context.h | 6 +- src/Magnum/DebugOutput.cpp | 60 +- src/Magnum/Extensions.h | 4 - src/Magnum/Framebuffer.cpp | 8 +- src/Magnum/Implementation/driverSpecific.cpp | 41 - src/Magnum/Math/Complex.h | 2 +- src/Magnum/Math/Functions.h | 6 +- src/Magnum/Math/Test/FunctionsTest.cpp | 2 +- src/Magnum/Mesh.cpp | 78 +- src/Magnum/MeshView.cpp | 8 +- src/Magnum/OpenGL.h | 10 - src/Magnum/OpenGLTester.h | 17 +- src/Magnum/Platform/CMakeLists.txt | 78 +- src/Magnum/Platform/Context.h | 2 +- src/Magnum/Platform/NaClApplication.cpp | 276 --- src/Magnum/Platform/NaClApplication.h | 821 ------- src/Magnum/Platform/NaClApplication.js | 43 - src/Magnum/Platform/Screen.h | 1 - src/Magnum/Platform/ScreenedApplication.h | 1 - .../Platform/WindowlessNaClApplication.cpp | 125 -- .../Platform/WindowlessNaClApplication.h | 356 --- src/Magnum/Platform/magnum-info-nacl.html | 41 - src/Magnum/Platform/magnum-info-nacl.nmf | 6 - src/Magnum/Platform/magnum-info.cpp | 29 +- src/Magnum/Renderbuffer.cpp | 14 - src/Magnum/Renderbuffer.h | 3 +- src/Magnum/Renderer.cpp | 9 +- src/Magnum/Shader.cpp | 12 +- src/Magnum/Test/BufferGLTest.cpp | 29 - src/Magnum/Text/CMakeLists.txt | 2 - src/Magnum/Text/Renderer.cpp | 22 +- src/Magnum/Text/Renderer.h | 6 - src/Magnum/Text/Test/RendererGLTest.cpp | 7 +- src/Magnum/Text/fontconverter.cpp | 2 - src/Magnum/TextureTools/CMakeLists.txt | 2 - .../TextureTools/distancefieldconverter.cpp | 2 - src/Magnum/TimeQuery.h | 2 +- src/Magnum/Timeline.h | 4 +- .../OpenGL/GLES2/CMakeLists.txt | 10 +- .../OpenGL/GLES2/NaCl/flextGLNaCl.h.template | 60 - src/MagnumExternal/OpenGL/GLES2/README.md | 8 +- src/MagnumExternal/OpenGL/GLES2/flextGLNaCl.h | 1989 ----------------- .../OpenGL/GLES3/CMakeLists.txt | 2 +- src/MagnumExternal/OpenGL/KHR/CMakeLists.txt | 5 +- 68 files changed, 116 insertions(+), 4745 deletions(-) delete mode 100644 package/archlinux/PKGBUILD-nacl-glibc delete mode 100644 package/archlinux/PKGBUILD-nacl-newlib delete mode 100644 src/Magnum/Platform/NaClApplication.cpp delete mode 100644 src/Magnum/Platform/NaClApplication.h delete mode 100644 src/Magnum/Platform/NaClApplication.js delete mode 100644 src/Magnum/Platform/WindowlessNaClApplication.cpp delete mode 100644 src/Magnum/Platform/WindowlessNaClApplication.h delete mode 100644 src/Magnum/Platform/magnum-info-nacl.html delete mode 100644 src/Magnum/Platform/magnum-info-nacl.nmf delete mode 100644 src/MagnumExternal/OpenGL/GLES2/NaCl/flextGLNaCl.h.template delete mode 100644 src/MagnumExternal/OpenGL/GLES2/flextGLNaCl.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e96f2dacd..846da4064 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,9 +51,9 @@ find_package(Corrade REQUIRED PluginManager Utility) include(CMakeDependentOption) -# If targeting iOS, Android, NaCl, Emscripten or Windows RT, set explicit -# OpenGL ES support -if(NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_WINDOWS_RT) +# If targeting iOS, Android, Emscripten or Windows RT, set explicit OpenGL ES +# support +if(NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_WINDOWS_RT) option(TARGET_GLES "Build for OpenGL ES / WebGL" OFF) else() set(TARGET_GLES ON) @@ -63,8 +63,8 @@ cmake_dependent_option(TARGET_GLES2 "Build for OpenGL ES 2 / WebGL 1.0" ON "TARG cmake_dependent_option(TARGET_DESKTOP_GLES "Build for OpenGL ES on desktop" OFF "TARGET_GLES" OFF) option(TARGET_HEADLESS "Build command-line utilities for use on a headless machines" OFF) -# Magnum Info (currently only using GLX, CGL, WGL/EGL on Windows or on NaCl) -if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL OR CORRADE_TARGET_WINDOWS) +# Magnum Info (currently only using GLX, CGL or WGL/EGL on Windows) +if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS) option(WITH_MAGNUMINFO "Build magnum-info utility" OFF) endif() @@ -101,18 +101,13 @@ cmake_dependent_option(WITH_AL_INFO "Build magnum-al-info utility" OFF "WITH_AUD # EGL context and windowless EGL application, available everywhere except on # platforms which don't support extension loading -if(NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_NACL) +if(NOT CORRADE_TARGET_EMSCRIPTEN) cmake_dependent_option(WITH_WINDOWLESSEGLAPPLICATION "Build WindowlessEglApplication library" OFF "NOT TARGET_GLES OR TARGET_DESKTOP_GLES OR NOT WITH_MAGNUMINFO" ON) option(WITH_EGLCONTEXT "Build EglContext library" OFF) endif() -# NaCl-specific application libraries -if(CORRADE_TARGET_NACL) - option(WITH_NACLAPPLICATION "Build NaClApplication library" OFF) - cmake_dependent_option(WITH_WINDOWLESSNACLAPPLICATION "Build WindowlessNaClApplication library" OFF "NOT WITH_MAGNUMINFO" ON) - # Android-specific application libraries -elseif(CORRADE_TARGET_ANDROID) +if(CORRADE_TARGET_ANDROID) option(WITH_ANDROIDAPPLICATION "Build AndroidApplication library" OFF) # iOS-specific application libraries @@ -144,7 +139,7 @@ elseif(CORRADE_TARGET_WINDOWS) endif() # Platform-independent (almost) application libraries -if(NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_ANDROID) +if(NOT CORRADE_TARGET_ANDROID) option(WITH_GLFWAPPLICATION "Build GlfwApplication library") cmake_dependent_option(WITH_GLUTAPPLICATION "Build GlutApplication library" OFF "NOT TARGET_GLES" OFF) option(WITH_SDL2APPLICATION "Build Sdl2Application library" OFF) @@ -175,20 +170,12 @@ if(BUILD_TESTS) endif() # OpenGLTester library, built by default only if GL tests are enabled -if(NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN) +if(NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN) cmake_dependent_option(WITH_OPENGLTESTER "Build OpenGLTester library" OFF "NOT BUILD_GL_TESTS" ON) endif() -# If targeting NaCl, set explicit OpenGL ES 2.0 support. For Android and -# Emscripten the decision between ES 2.0 / WebGL 1.0 and ES 3.0 / WebGL 2.0 -# must be done by the user. -if(CORRADE_TARGET_NACL) - set(TARGET_GLES2 ON) -endif() - -# NaCl newlib toolchain supports only static linking, dynamic linking is -# meaningless on Emscripten and too inconvenient on Android -if(CORRADE_TARGET_NACL_NEWLIB OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) +# Dynamic linking is meaningless on Emscripten and too inconvenient on Android +if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) set(BUILD_STATIC ON) set(BUILD_PLUGINS_STATIC ON) endif() diff --git a/README.md b/README.md index 124271dd8..9ba554542 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,6 @@ Platforms: * **iOS** (through SDL2 toolkit) [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum) * **Android** 2.3 (API Level 9) and higher [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum) * **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit) [![Build Status](https://ci.appveyor.com/api/projects/status/5b477m034cfaskse/branch/master?svg=true)](https://ci.appveyor.com/project/mosra/magnum/branch/master) -* **Google Chrome** (through [Native Client](https://developers.google.com/native-client/), - both `newlib` and `glibc` toolchains are supported) * **HTML5/JavaScript** (through [Emscripten](https://github.com/kripken/emscripten/wiki)) [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum) FEATURES diff --git a/doc/best-practices.dox b/doc/best-practices.dox index 552d0dc66..f4431e2e9 100644 --- a/doc/best-practices.dox +++ b/doc/best-practices.dox @@ -71,7 +71,7 @@ information. - [Best Practices for Working with Texture Data](http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/TechniquesForWorkingWithTextureData/TechniquesForWorkingWithTextureData.html) - [Best Practices for Shaders](http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/BestPracticesforShaders/BestPracticesforShaders.html#//apple_ref/doc/uid/TP40008793-CH7-SW3) -@subsection best-practices-angle ANGLE (WebGL, NaCl) +@subsection best-practices-angle ANGLE (WebGL) - [WebGL Insights -- ANGLE](https://books.google.cz/books?id=6crECQAAQBAJ&lpg=PP1&pg=PA3&redir_esc=y#v=onepage&q&f=true) @@ -85,13 +85,6 @@ buffer attachments. See @ref Buffer, @ref Framebuffer, @ref Renderer::setStencilFunction(), @ref Renderer::setStencilMask() and @ref Renderer::setBlendFunction() documentation for more information. -@subsection best-practices-nacl Google Chrome Native Client - -- [Best practices for 3D graphics](https://developers.google.com/native-client/beta/devguide/coding/3D-graphics#best-practices) - -Similarly to WebGL, buffers in NaCl implementation need to be bound only to one -unique target. See @ref Buffer class documentation for more information. - @section best-practices-hw Hardware-specific @subsection best-practices-intel Intel hardware diff --git a/doc/building.dox b/doc/building.dox index c13e09067..10f2c9054 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -208,14 +208,12 @@ platform best: - `WITH_GLFWAPPLICATION` - @ref Platform::GlfwApplication "GlfwApplication" - `WITH_GLUTAPPLICATION` - @ref Platform::GlutApplication "GlutApplication" - `WITH_GLXAPPLICATION` - @ref Platform::GlxApplication "GlxApplication" -- `WITH_NACLAPPLICATION` - @ref Platform::NaClApplication "NaClApplication" - `WITH_SDL2APPLICATION` - @ref Platform::Sdl2Application "Sdl2Application" - `WITH_XEGLAPPLICATION` - @ref Platform::XEglApplication "XEglApplication" - `WITH_WINDOWLESSCGLAPPLICATION` - @ref Platform::WindowlessCglApplication "WindowlessCglApplication" - `WITH_WINDOWLESSEGLAPPLICATION` - @ref Platform::WindowlessEglApplication "WindowlessEglApplication" - `WITH_WINDOWLESSGLXAPPLICATION` - @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication" - `WITH_WINDOWLESSIOSAPPLICATION` - @ref Platform::WindowlessIosApplication "WindowlessIosApplication" -- `WITH_WINDOWLESSNACLAPPLICATION` - @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication" - `WITH_WINDOWLESSWGLAPPLICATION` - @ref Platform::WindowlessWglApplication "WindowlessWglApplication" - `WITH_WINDOWLESSWINDOWSEGLAPPLICATION` - @ref Platform::WindowlessWindowsEglApplication "WindowlessWindowsEglApplication" @@ -308,8 +306,8 @@ e.g.: Platforms which have windowless GL context creation implemented (currently all platforms except @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten", -@ref CORRADE_TARGET_NACL "NaCl", @ref CORRADE_TARGET_WINDOWS_RT "Windows RT" -and @ref CORRADE_TARGET_ANDROID "Android") can build also tests for OpenGL +@ref CORRADE_TARGET_WINDOWS_RT "Windows RT" and +@ref CORRADE_TARGET_ANDROID "Android") can build also tests for OpenGL functionality. You can enable them with `BUILD_GL_TESTS`. All GL tests are suffixed with `GLTest` so they can be also selectively included/excluded when running CTest, e.g.: @@ -485,54 +483,6 @@ hierarchy and specify path where Corrade is installed in `CMAKE_PREFIX_PATH`. Then you can install the package using `cmake --build . --target install` to make it available for depending projects. -@subsection building-cross-nacl Crosscompiling for Google Chrome Native Client - -You will need [Native Client SDK](https://developers.google.com/native-client/beta/sdk/download). -Tested version is `pepper_22`. - -You can choose from either `glibc` or `newlib` toolchain. `Newlib` supports -only static linking, thus `BUILD_STATIC` is always enabled. Don't forget to -adapt `NACL_PREFIX` variable in `generic/NaCl-*-x86-32.cmake` and -`generic/NaCl-*-x86-64.cmake` to path where your SDK is installed. Default is -`/usr/nacl`. You may need to adapt also `NACL_TOOLCHAIN_PATH` so CMake is able -to find the compiler. NaCl currently supports only OpenGL ES 2, thus -`TARGET_GLES` and `TARGET_GLES2` is always enabled. - -Then create build directories for x86-32 and x86-64 and run cmake and build -command in them. Be sure to adapt `CMAKE_INSTALL_PREFIX` to the same value as -in `NACL_PREFIX` in toolchain file and specify path where Corrade is installed -in `CMAKE_PREFIX_PATH`. - - mkdir build-nacl-x86-32 && cd build-nacl-x86-32 - cmake .. \ - -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-32.cmake" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH=/usr/nacl \ - -DCMAKE_INSTALL_PREFIX=/usr/nacl \ - -DWITH_NACLAPPLICATION=ON \ - -DLIB_SUFFIX=/32 - cmake --build . - - mkdir build-nacl-x86-64 && cd build-nacl-x86-64 - cmake .. \ - -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-64.cmake" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_PREFIX_PATH=/usr/nacl \ - -DCMAKE_INSTALL_PREFIX=/usr/nacl \ - -DWITH_NACLAPPLICATION=ON - cmake --build . - -Then you can install both versions using `cmake --build . --target install` to -make them available for depending projects. The headers are shared by both -versions. - -For ArchLinux there are also prepared package files in `package/archlinux`, -named `PKGBUILD-nacl-glibc` and `PKGBUILD-nacl-newlib`, see -@ref building-packages-arch "above" for more information. - -See @ref Platform::NaClApplication documentation for more information about -building your projects for Google Chrome Native Client. - @subsection building-cross-emscripten Crosscompiling for Emscripten You will need [Emscripten](https://github.com/kripken/emscripten/wiki/Tutorial) diff --git a/doc/changelog.dox b/doc/changelog.dox index 48f20734b..38aba57cb 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -33,6 +33,7 @@ namespace Magnum { ## De­pen­den­cy changes +- Completely removed NaCl support (see https://blog.chromium.org/2017/05/goodbye-pnacl-hello-webassembly.html) - Dropped support for the old MinGW32 (only MinGW-w64 is supported now) - Bumped minimal CMake version to 2.8.12 - Removed support for macOS 10.8 and older @@ -223,8 +224,7 @@ namespace Magnum { classes that manage OpenGL context to make threaded context creation possible - First-class support for scroll events in - @ref Platform::Sdl2Application::MouseScrollEvent and - @ref Platform::NaClApplication::MouseScrollEvent + @ref Platform::Sdl2Application::MouseScrollEvent - Added @ref Platform::Sdl2Application::MouseEvent::clickCount() - Added @ref Platform::Sdl2Application::multiGestureEvent() - Exposing key repeat in @@ -414,7 +414,7 @@ namespace Magnum { - Fixed WebGL context creation on Internet Explorer, it claims to have version 0.94 - Fixed random browser-specific issues by avoiding the use of XHTML in - Emscripten and NaCl builds + Emscripten builds - @ref Trade::ObjImporter "ObjImporter" plugin now opens the files as binary to avoid line ending issues - Various compatibility updates to the @ref Shaders library diff --git a/doc/cmake.dox b/doc/cmake.dox index a798bc573..bd9c0a090 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -102,14 +102,12 @@ Platform namespace is split into more components: - `GlfwApplication` -- @ref Platform::GlfwApplication "GlfwApplication" - `GlutApplication` -- @ref Platform::GlutApplication "GlutApplication" - `GlxApplication` -- @ref Platform::GlxApplication "GlxApplication" -- `NaClApplication` -- @ref Platform::NaClApplication "NaClApplication" - `Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application" - `XEglApplication` -- @ref Platform::XEglApplication "XEglApplication" - `WindowlessCglApplication` -- @ref Platform::WindowlessCglApplication "WindowlessCglApplication" - `WindowlessEglApplication` -- @ref Platform::WindowlessEglApplication "WindowlessEglApplication" - `WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication" - `WindowlessIosApplication` -- @ref Platform::WindowlessIosApplication "WindowlessIosApplication" -- `WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication" - `WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication" - `WindowlessWindowsEglApplication` -- @ref Platform::WindowlessWindowsEglApplication "WindowlessWindowsEglApplication" diff --git a/doc/mainpage.dox b/doc/mainpage.dox index 937b6bc64..fe7024523 100644 --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -82,8 +82,6 @@ Platforms: - **OS X**, **iOS** (through SDL2 or GLFW toolkit) - **Android** 2.3 (API Level 9) and higher - **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit) -- **Google Chrome** (through [Native Client](https://developers.google.com/native-client/), - both `newlib` and `glibc` toolchains are supported) - **HTML5/JavaScript** (through [Emscripten](https://github.com/kripken/emscripten/wiki)) @section mainpage-features Features diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index f0389c686..8aa4708f7 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -351,7 +351,6 @@ Extension | Status @extension{APPLE,texture_format_BGRA8888} | done @extension{ARM,shader_framebuffer_fetch} | missing renderer setup and limit query @extension{ARM,shader_framebuffer_fetch_depth_stencil} | done (shading language only) -@extension{CHROMIUM,map_sub} (NaCl only) | only buffer mapping @extension{EXT,texture_filter_anisotropic} | done @extension{EXT,texture_format_BGRA8888} | done @extension{EXT,read_format_bgra} | done diff --git a/doc/platform.dox b/doc/platform.dox index 0948af7c0..1f74b7073 100644 --- a/doc/platform.dox +++ b/doc/platform.dox @@ -296,12 +296,12 @@ find particular `*Context` library, add its include dir and then link to it. These platform-specific libraries are available: - `CglContext` -- CGL context (Mac OS X) -- `EglContext` -- EGL context (everywhere except Emscripten and NaCl) +- `EglContext` -- EGL context (everywhere except Emscripten) - `GlxContext` -- GLX context (X11-based Unix) - `WglContext` -- WGL context (Windows) -Systems not listed here (such as Emscripten or NaCl) don't need any `Context` -library, because dynamic function pointer loading is not available on these. +Systems not listed here (such as Emscripten) don't need any `Context` library, +because dynamic function pointer loading is not available on these. For example, when you create the OpenGL context using GLX, you need to find `GlxContext` component, and link to `Magnum::GlxContext` target. Similarly to diff --git a/modules/FindCorrade.cmake b/modules/FindCorrade.cmake index b885a2ef4..ef1040ab7 100644 --- a/modules/FindCorrade.cmake +++ b/modules/FindCorrade.cmake @@ -80,12 +80,6 @@ # CORRADE_TARGET_IOS_SIMULATOR - Defined if compiled for iOS Simulator # CORRADE_TARGET_WINDOWS - Defined if compiled for Windows # CORRADE_TARGET_WINDOWS_RT - Defined if compiled for Windows RT -# CORRADE_TARGET_NACL - Defined if compiled for Google Chrome Native -# Client -# CORRADE_TARGET_NACL_NEWLIB - Defined if compiled for Google Chrome Native -# Client with `newlib` toolchain -# CORRADE_TARGET_NACL_GLIBC - Defined if compiled for Google Chrome Native -# Client with `glibc` toolchain # CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten # CORRADE_TARGET_ANDROID - Defined if compiled for Android # CORRADE_TESTSUITE_TARGET_XCTEST - Defined if TestSuite is targetting Xcode @@ -294,9 +288,6 @@ set(_corradeFlags TARGET_IOS_SIMULATOR TARGET_WINDOWS TARGET_WINDOWS_RT - TARGET_NACL - TARGET_NACL_NEWLIB - TARGET_NACL_GLIBC TARGET_EMSCRIPTEN TARGET_ANDROID TESTSUITE_TARGET_XCTEST @@ -415,7 +406,7 @@ foreach(_component ${Corrade_FIND_COMPONENTS}) # PluginManager library if(_component STREQUAL PluginManager) # At least static build needs this - if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL_GLIBC) + if(CORRADE_TARGET_UNIX) set_property(TARGET Corrade::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}) endif() diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index e6bbce242..ef58d203c 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -53,14 +53,12 @@ # GlfwApplication - GLFW application # GlutApplication - GLUT application # GlxApplication - GLX application -# NaClApplication - NaCl application # Sdl2Application - SDL2 application # XEglApplication - X/EGL application # WindowlessCglApplication - Windowless CGL application # WindowlessEglApplication - Windowless EGL application # WindowlessGlxApplication - Windowless GLX application # WindowlessIosApplication - Windowless iOS application -# WindowlessNaClApplication - Windowless NaCl application # WindowlessWglApplication - Windowless WGL application # WindowlessWindowsEglApplication - Windowless Windows/EGL application # CglContext - CGL context @@ -389,7 +387,7 @@ endif() # Component distinction (listing them explicitly to avoid mistakes with finding # components from other repositories) -set(_MAGNUM_LIBRARY_COMPONENTS "^(Audio|DebugTools|MeshTools|Primitives|SceneGraph|Shaders|Shapes|Text|TextureTools|AndroidApplication|GlfwApplication|GlutApplication|GlxApplication|NaClApplication|Sdl2Application|XEglApplication|WindowlessCglApplication|WindowlessEglApplication|WindowlessGlxApplication|WindowlessIosApplication|WindowlessNaClApplication|WindowlessWglApplication|WindowlessWindowsEglApplication|CglContext|EglContext|GlxContext|WglContext|OpenGLTester)$") +set(_MAGNUM_LIBRARY_COMPONENTS "^(Audio|DebugTools|MeshTools|Primitives|SceneGraph|Shaders|Shapes|Text|TextureTools|AndroidApplication|GlfwApplication|GlutApplication|GlxApplication|Sdl2Application|XEglApplication|WindowlessCglApplication|WindowlessEglApplication|WindowlessGlxApplication|WindowlessIosApplication|WindowlessWglApplication|WindowlessWindowsEglApplication|CglContext|EglContext|GlxContext|WglContext|OpenGLTester)$") set(_MAGNUM_PLUGIN_COMPONENTS "^(MagnumFont|MagnumFontConverter|ObjImporter|TgaImageConverter|TgaImporter|WavAudioImporter)$") set(_MAGNUM_EXECUTABLE_COMPONENTS "^(distancefieldconverter|fontconverter|imageconverter|info|al-info)$") @@ -537,11 +535,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) set_property(TARGET Magnum::${_component} APPEND PROPERTY INTERFACE_LINK_LIBRARIES SDL2::SDL2) - # (Windowless) NaCl application dependencies - elseif(_component STREQUAL NaClApplication OR _component STREQUAL WindowlessNaClApplication) - set_property(TARGET Magnum::${_component} APPEND PROPERTY - INTERFACE_LINK_LIBRARIES ppapi_cpp ppapi) - # (Windowless) GLX application dependencies elseif(_component STREQUAL GlxApplication OR _component STREQUAL WindowlessGlxApplication) find_package(X11) diff --git a/modules/FindOpenGLES2.cmake b/modules/FindOpenGLES2.cmake index 947297e18..65e9ffbe7 100644 --- a/modules/FindOpenGLES2.cmake +++ b/modules/FindOpenGLES2.cmake @@ -48,10 +48,7 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN) libGLESv2 # iOS - OpenGLES - - # NaCl - ppapi_gles2) + OpenGLES) set(OPENGLES2_LIBRARY_NEEDED OPENGLES2_LIBRARY) endif() diff --git a/package/archlinux/PKGBUILD-nacl-glibc b/package/archlinux/PKGBUILD-nacl-glibc deleted file mode 100644 index 79f180961..000000000 --- a/package/archlinux/PKGBUILD-nacl-glibc +++ /dev/null @@ -1,65 +0,0 @@ -# Author: mosra -pkgname=nacl-magnum -pkgver=dev.glibc -pkgrel=1 -pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (NaCl glibc version)" -arch=('any') -url="http://magnum.graphics" -license=('MIT') -depends=('nacl-corrade') -makedepends=('nacl-sdk' 'cmake' 'corrade' 'ninja') -options=('!strip' '!buildflags') - -_rootdir=$startdir/../../ - -build() { - # Build 32bit - mkdir -p "$_rootdir/build-nacl-glibc-x86-32" - cd "$_rootdir/build-nacl-glibc-x86-32" - - cmake .. \ - -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-glibc-x86-32.cmake" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr/nacl \ - -DWITH_MAGNUMINFO=OFF \ - -DWITH_NACLAPPLICATION=ON \ - -DWITH_MAGNUMFONT=ON \ - -DWITH_MAGNUMFONTCONVERTER=ON \ - -DWITH_OBJIMPORTER=ON \ - -DWITH_TGAIMAGECONVERTER=ON \ - -DWITH_TGAIMPORTER=ON \ - -DWITH_WAVAUDIOIMPORTER=ON \ - -DLIB_SUFFIX=/32 \ - -G Ninja - ninja - - # Build 64bit - mkdir -p "$_rootdir/build-nacl-glibc-x86-64" - cd "$_rootdir/build-nacl-glibc-x86-64" - - cmake .. \ - -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-glibc-x86-64.cmake" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr/nacl \ - -DWITH_MAGNUMINFO=OFF \ - -DWITH_NACLAPPLICATION=ON \ - -DWITH_MAGNUMFONT=ON \ - -DWITH_MAGNUMFONTCONVERTER=ON \ - -DWITH_OBJIMPORTER=ON \ - -DWITH_TGAIMAGECONVERTER=ON \ - -DWITH_TGAIMPORTER=ON \ - -DWITH_WAVAUDIOIMPORTER=ON \ - -G Ninja - ninja -} - -package() { - # Install 32bit - cd "$_rootdir/build-nacl-glibc-x86-32" - DESTDIR="$pkgdir/" ninja install/strip - - # Install 64bit (the headers will be overwritten, but they are (and should - # be) the same for both versions - cd "$_rootdir/build-nacl-glibc-x86-64" - DESTDIR="$pkgdir/" ninja install/strip -} diff --git a/package/archlinux/PKGBUILD-nacl-newlib b/package/archlinux/PKGBUILD-nacl-newlib deleted file mode 100644 index c00257960..000000000 --- a/package/archlinux/PKGBUILD-nacl-newlib +++ /dev/null @@ -1,67 +0,0 @@ -# Author: mosra -pkgname=nacl-magnum -pkgver=dev.newlib -pkgrel=1 -pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (NaCl newlib version)" -arch=('any') -url="http://magnum.graphics" -license=('MIT') -depends=('nacl-corrade') -makedepends=('nacl-sdk' 'cmake' 'corrade' 'ninja') -options=('!strip' '!buildflags') - -_rootdir=$startdir/../../ - -build() { - # Build 32bit - mkdir -p "$_rootdir/build-nacl-newlib-x86-32" - cd "$_rootdir/build-nacl-newlib-x86-32" - - cmake .. \ - -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-newlib-x86-32.cmake" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr/nacl \ - -DWITH_MAGNUMINFO=ON \ - -DWITH_NACLAPPLICATION=ON \ - -DWITH_WINDOWLESSNACLAPPLICATION=ON \ - -DWITH_MAGNUMFONT=ON \ - -DWITH_MAGNUMFONTCONVERTER=ON \ - -DWITH_OBJIMPORTER=ON \ - -DWITH_TGAIMAGECONVERTER=ON \ - -DWITH_TGAIMPORTER=ON \ - -DWITH_WAVAUDIOIMPORTER=ON \ - -DLIB_SUFFIX=/32 \ - -G Ninja - ninja - - # Build 64bit - mkdir -p "$_rootdir/build-nacl-newlib-x86-64" - cd "$_rootdir/build-nacl-newlib-x86-64" - - cmake .. \ - -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-newlib-x86-64.cmake" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr/nacl \ - -DWITH_MAGNUMINFO=ON \ - -DWITH_NACLAPPLICATION=ON \ - -DWITH_WINDOWLESSNACLAPPLICATION=ON \ - -DWITH_MAGNUMFONT=ON \ - -DWITH_MAGNUMFONTCONVERTER=ON \ - -DWITH_OBJIMPORTER=ON \ - -DWITH_TGAIMAGECONVERTER=ON \ - -DWITH_TGAIMPORTER=ON \ - -DWITH_WAVAUDIOIMPORTER=ON \ - -G Ninja - ninja -} - -package() { - # Install 32bit - cd "$_rootdir/build-nacl-newlib-x86-32" - DESTDIR="$pkgdir/" ninja install/strip - - # Install 64bit (the headers will be overwritten, but they are (and should - # be) the same for both versions - cd "$_rootdir/build-nacl-newlib-x86-64" - DESTDIR="$pkgdir/" ninja install/strip -} diff --git a/src/Magnum/AbstractFramebuffer.cpp b/src/Magnum/AbstractFramebuffer.cpp index 6fd4e5656..234599d04 100644 --- a/src/Magnum/AbstractFramebuffer.cpp +++ b/src/Magnum/AbstractFramebuffer.cpp @@ -233,35 +233,15 @@ void AbstractFramebuffer::blitImplementationDSA(AbstractFramebuffer& source, Abs #elif !defined(MAGNUM_TARGET_WEBGL) void AbstractFramebuffer::blitImplementationANGLE(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) { - #ifndef CORRADE_TARGET_NACL source.bindInternal(FramebufferTarget::Read); destination.bindInternal(FramebufferTarget::Draw); glBlitFramebufferANGLE(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter)); - #else - static_cast(source); - static_cast(destination); - static_cast(sourceRectangle); - static_cast(destinationRectangle); - static_cast(mask); - static_cast(filter); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } void AbstractFramebuffer::blitImplementationNV(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) { - #ifndef CORRADE_TARGET_NACL source.bindInternal(FramebufferTarget::Read); destination.bindInternal(FramebufferTarget::Draw); glBlitFramebufferNV(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter)); - #else - static_cast(source); - static_cast(destination); - static_cast(sourceRectangle); - static_cast(destinationRectangle); - static_cast(mask); - static_cast(filter); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -441,7 +421,7 @@ void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum* co void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments) { #ifndef MAGNUM_TARGET_GLES2 glInvalidateFramebuffer(GLenum(bindInternal()), count, attachments); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) + #elif !defined(CORRADE_TARGET_EMSCRIPTEN) glDiscardFramebufferEXT(GLenum(bindInternal()), count, attachments); #else static_cast(count); @@ -513,27 +493,13 @@ void AbstractFramebuffer::drawBuffersImplementationDSAEXT(GLsizei count, const G #else void AbstractFramebuffer::drawBuffersImplementationEXT(GLsizei count, const GLenum* buffers) { bindInternal(FramebufferTarget::Draw); - - #ifndef CORRADE_TARGET_NACL glDrawBuffersEXT(count, buffers); - #else - static_cast(count); - static_cast(buffers); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #ifndef MAGNUM_TARGET_WEBGL void AbstractFramebuffer::drawBuffersImplementationNV(GLsizei count, const GLenum* buffers) { bindInternal(FramebufferTarget::Draw); - - #ifndef CORRADE_TARGET_NACL glDrawBuffersNV(count, buffers); - #else - static_cast(count); - static_cast(buffers); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif #endif @@ -561,11 +527,8 @@ void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) { #ifndef MAGNUM_TARGET_GLES2 glReadBuffer(buffer); - #elif !defined(CORRADE_TARGET_NACL) - glReadBufferNV(buffer); #else - static_cast(buffer); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glReadBufferNV(buffer); #endif } #endif @@ -589,15 +552,8 @@ void AbstractFramebuffer::readImplementationDefault(const Range2Di& rectangle, c void AbstractFramebuffer::readImplementationRobustness(const Range2Di& rectangle, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { #ifndef MAGNUM_TARGET_GLES glReadnPixelsARB(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), dataSize, data); - #elif !defined(CORRADE_TARGET_NACL) - glReadnPixelsEXT(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), dataSize, data); #else - static_cast(rectangle); - static_cast(format); - static_cast(type); - static_cast(dataSize); - static_cast(data); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glReadnPixelsEXT(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), dataSize, data); #endif } #endif diff --git a/src/Magnum/AbstractFramebuffer.h b/src/Magnum/AbstractFramebuffer.h index 6e5085ad2..917a500cd 100644 --- a/src/Magnum/AbstractFramebuffer.h +++ b/src/Magnum/AbstractFramebuffer.h @@ -237,8 +237,6 @@ class MAGNUM_EXPORT AbstractFramebuffer { * @requires_gles30 Extension @extension{ANGLE,framebuffer_blit} or * @extension{NV,framebuffer_blit} in OpenGL ES 2.0. * @requires_webgl20 Framebuffer blit is not available in WebGL 1.0. - * @todo NaCl exports `BlitFramebufferEXT` (although no such extension - * exists for ES) */ static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter); diff --git a/src/Magnum/AbstractObject.cpp b/src/Magnum/AbstractObject.cpp index 94fdba020..edfaa1e02 100644 --- a/src/Magnum/AbstractObject.cpp +++ b/src/Magnum/AbstractObject.cpp @@ -39,7 +39,6 @@ namespace Magnum { #ifndef MAGNUM_TARGET_WEBGL -#ifndef CORRADE_TARGET_NACL namespace { inline GLenum extTypeFromKhrIdentifier(GLenum khrIdentifier) { switch(khrIdentifier) { @@ -89,13 +88,10 @@ namespace { /** * @todo Shouldn't ES2's KHR_debug have `GL_TRANSFORM_FEEDBACK_KHR` * instead of `GL_TRANSFORM_FEEDBACK`? (it's a new enum in 2.0) - * NaCl extension header doesn't have it at all. Also the - * original @extension{EXT,debug_label} mentions it only - * for ES3 (i.e. no mention of @extension{EXT,transform_feedback}) + * Also the original @extension{EXT,debug_label} mentions it + * only for ES3 (i.e. no mention of @extension{EXT,transform_feedback}) */ - #ifndef CORRADE_TARGET_NACL case GL_TRANSFORM_FEEDBACK: - #endif #ifndef MAGNUM_TARGET_GLES case GL_SAMPLER: #else @@ -110,7 +106,6 @@ namespace { CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } } -#endif Int AbstractObject::maxLabelLength() { if(!Context::current().isExtensionSupported()) @@ -134,26 +129,14 @@ void AbstractObject::labelImplementationNoOp(GLenum, GLuint, Containers::ArrayVi void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const Containers::ArrayView label) { #ifndef MAGNUM_TARGET_GLES glObjectLabel(identifier, name, label.size(), label); - #elif !defined(CORRADE_TARGET_NACL) - glObjectLabelKHR(identifier, name, label.size(), label); #else - static_cast(identifier); - static_cast(name); - static_cast(label); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glObjectLabelKHR(identifier, name, label.size(), label); #endif } void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const Containers::ArrayView label) { - #ifndef CORRADE_TARGET_NACL const GLenum type = extTypeFromKhrIdentifier(identifier); glLabelObjectEXT(type, name, label.size(), label); - #else - static_cast(identifier); - static_cast(name); - static_cast(label); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } std::string AbstractObject::getLabelImplementationNoOp(GLenum, GLuint) { return {}; } @@ -164,12 +147,8 @@ std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, c GLsizei size = 0; #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(identifier, name, maxLabelLength(), &size, nullptr); - #elif !defined(CORRADE_TARGET_NACL) - glGetObjectLabelKHR(identifier, name, maxLabelLength(), &size, nullptr); #else - static_cast(identifier); - static_cast(name); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glGetObjectLabelKHR(identifier, name, maxLabelLength(), &size, nullptr); #endif /* Make place also for the null terminator */ @@ -177,10 +156,8 @@ std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, c label.resize(size+1); #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(identifier, name, size+1, nullptr, &label[0]); - #elif !defined(CORRADE_TARGET_NACL) - glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]); #endif /* Pop null terminator and return the string */ @@ -192,23 +169,13 @@ std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, c GLsizei size = 0; /* Get label size (w/o null terminator) */ - #ifndef CORRADE_TARGET_NACL const GLenum type = extTypeFromKhrIdentifier(identifier); glGetObjectLabelEXT(type, name, 0, &size, nullptr); - #else - static_cast(identifier); - static_cast(name); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif /* Make place also for the null terminator */ std::string label; label.resize(size+1); - #ifndef CORRADE_TARGET_NACL glGetObjectLabelEXT(type, name, size+1, nullptr, &label[0]); - #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif /* Pop null terminator and return the string */ label.resize(size); diff --git a/src/Magnum/AbstractQuery.cpp b/src/Magnum/AbstractQuery.cpp index 8cdcd5198..d4582dae9 100644 --- a/src/Magnum/AbstractQuery.cpp +++ b/src/Magnum/AbstractQuery.cpp @@ -123,10 +123,8 @@ template<> Int AbstractQuery::result() { Int result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjectiv(_id, GL_QUERY_RESULT, &result); - #elif !defined(CORRADE_TARGET_NACL) - glGetQueryObjectivEXT(_id, GL_QUERY_RESULT_EXT, &result); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glGetQueryObjectivEXT(_id, GL_QUERY_RESULT_EXT, &result); #endif return result; } @@ -135,10 +133,8 @@ template<> UnsignedLong AbstractQuery::result() { UnsignedLong result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjectui64v(_id, GL_QUERY_RESULT, &result); - #elif !defined(CORRADE_TARGET_NACL) - glGetQueryObjectui64vEXT(_id, GL_QUERY_RESULT_EXT, &result); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glGetQueryObjectui64vEXT(_id, GL_QUERY_RESULT_EXT, &result); #endif return result; } @@ -147,10 +143,8 @@ template<> Long AbstractQuery::result() { Long result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjecti64v(_id, GL_QUERY_RESULT, &result); - #elif !defined(CORRADE_TARGET_NACL) - glGetQueryObjecti64vEXT(_id, GL_QUERY_RESULT_EXT, &result); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glGetQueryObjecti64vEXT(_id, GL_QUERY_RESULT_EXT, &result); #endif return result; } diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index 488d4e24f..fb5bfe52d 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -38,7 +38,7 @@ #include "Implementation/ShaderProgramState.h" #include "Implementation/State.h" -#if defined(CORRADE_TARGET_NACL_NEWLIB) || defined(CORRADE_TARGET_ANDROID) +#ifdef CORRADE_TARGET_ANDROID #include #endif @@ -420,7 +420,7 @@ bool AbstractShaderProgram::link(std::initializer_list(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -521,14 +514,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniform2fvEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -549,14 +535,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniform3fvEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -577,14 +556,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniform4fvEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -605,14 +577,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const GLint* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniform1ivEXT(_id, location, count, values); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -633,14 +598,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniform2ivEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -661,14 +619,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniform3ivEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -689,14 +640,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniform4ivEXT(_id, location, count, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -865,14 +809,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniformMatrix2fvEXT(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -893,14 +830,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniformMatrix3fvEXT(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif @@ -921,14 +851,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const #ifndef MAGNUM_TARGET_WEBGL void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) { - #ifndef CORRADE_TARGET_NACL glProgramUniformMatrix4fvEXT(_id, location, count, GL_FALSE, values[0].data()); - #else - static_cast(location); - static_cast(count); - static_cast(values); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 44f4c4f23..198baf574 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -1280,13 +1280,8 @@ void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glTexStorage2D(_target, levels, GLenum(internalFormat), size.x(), size.y()); - #elif !defined(CORRADE_TARGET_NACL) - glTexStorage2DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y()); #else - static_cast(levels); - static_cast(internalFormat); - static_cast(size); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glTexStorage2DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y()); #endif } #endif @@ -1351,13 +1346,8 @@ void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glTexStorage3D(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); - #elif !defined(CORRADE_TARGET_NACL) - glTexStorage3DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); #else - static_cast(levels); - static_cast(internalFormat); - static_cast(size); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glTexStorage3DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); #endif } #endif @@ -1569,22 +1559,12 @@ void AbstractTexture::compressedSubImageImplementationDSAEXT(GLint level, const #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::imageImplementationDefault(GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) { bindInternal(); - #ifndef CORRADE_TARGET_NACL #ifndef MAGNUM_TARGET_GLES2 glTexImage3D #else glTexImage3DOES #endif (_target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data); - #else - static_cast(level); - static_cast(internalFormat); - static_cast(size); - static_cast(format); - static_cast(type); - static_cast(data); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #ifndef MAGNUM_TARGET_WEBGL @@ -1616,16 +1596,8 @@ void AbstractTexture::subImage3DImplementationDefault(GLint level, const Vector3 bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); - #elif !defined(CORRADE_TARGET_NACL) - glTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); #else - static_cast(level); - static_cast(offset); - static_cast(size); - static_cast(format); - static_cast(type); - static_cast(data); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); #endif } @@ -1660,15 +1632,8 @@ void AbstractTexture::compressedSubImageImplementationDefault(const GLint level, bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glCompressedTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); - #elif !defined(CORRADE_TARGET_NACL) - glCompressedTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); #else - static_cast(level); - static_cast(offset); - static_cast(size); - static_cast(format); - static_cast(data); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glCompressedTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); #endif } #endif @@ -2179,12 +2144,8 @@ void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture texture.bindInternal(); #ifndef MAGNUM_TARGET_GLES2 glCompressedTexImage3D(texture._target, level, GLenum(image.format()), image.size().x(), image.size().y(), image.size().z(), 0, Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data()); - #elif !defined(CORRADE_TARGET_NACL) - glCompressedTexImage3DOES(texture._target, level, GLenum(image.format()), image.size().x(), image.size().y(), image.size().z(), 0, Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data()); #else - static_cast(level); - static_cast(image); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glCompressedTexImage3DOES(texture._target, level, GLenum(image.format()), image.size().x(), image.size().y(), image.size().z(), 0, Implementation::occupiedCompressedImageDataSize(image, image.data().size()), image.data()); #endif } #endif diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 3579c6c95..601f859de 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -186,11 +186,7 @@ void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const } #endif -Buffer::Buffer(const TargetHint targetHint): _targetHint{targetHint}, _flags{ObjectFlag::DeleteOnDestruction} - #ifdef CORRADE_TARGET_NACL - , _mappedBuffer{nullptr} - #endif -{ +Buffer::Buffer(const TargetHint targetHint): _targetHint{targetHint}, _flags{ObjectFlag::DeleteOnDestruction} { (this->*Context::current().state().buffer->createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -290,10 +286,8 @@ auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint { if(currentVAO != 0) { #ifndef MAGNUM_TARGET_GLES2 glBindVertexArray(currentVAO = 0); - #elif !defined(CORRADE_TARGET_NACL) - glBindVertexArrayOES(currentVAO = 0); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glBindVertexArrayOES(currentVAO = 0); #endif } } @@ -372,13 +366,6 @@ char* Buffer::map(const MapAccess access) { return static_cast((this->*Context::current().state().buffer->mapImplementation)(access)); } -#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_NACL) -void* Buffer::mapSub(const GLintptr offset, const GLsizeiptr length, const MapAccess access) { - CORRADE_ASSERT(!_mappedBuffer, "Buffer::mapSub(): the buffer is already mapped", nullptr); - return _mappedBuffer = glMapBufferSubDataCHROMIUM(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); -} -#endif - Containers::ArrayView Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) { return {static_cast((this->*Context::current().state().buffer->mapRangeImplementation)(offset, length, flags)), std::size_t(length)}; } @@ -389,14 +376,6 @@ Buffer& Buffer::flushMappedRange(const GLintptr offset, const GLsizeiptr length) } bool Buffer::unmap() { return (this->*Context::current().state().buffer->unmapImplementation)(); } - -#if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_NACL) -void Buffer::unmapSub() { - CORRADE_ASSERT(_mappedBuffer, "Buffer::unmapSub(): the buffer is not mapped", ); - glUnmapBufferSubDataCHROMIUM(_mappedBuffer); - _mappedBuffer = nullptr; -} -#endif #endif #ifndef MAGNUM_TARGET_GLES @@ -570,11 +549,8 @@ void Buffer::invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length) void* Buffer::mapImplementationDefault(MapAccess access) { #ifndef MAGNUM_TARGET_GLES return glMapBuffer(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); - #elif !defined(CORRADE_TARGET_NACL) - return glMapBufferOES(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); #else - static_cast(access); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + return glMapBufferOES(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); #endif } @@ -592,13 +568,8 @@ void* Buffer::mapImplementationDSAEXT(MapAccess access) { void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) { #ifndef MAGNUM_TARGET_GLES2 return glMapBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); - #elif !defined(CORRADE_TARGET_NACL) - return glMapBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); #else - static_cast(offset); - static_cast(length); - static_cast(access); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + return glMapBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); #endif } @@ -616,12 +587,8 @@ void* Buffer::mapRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr length, M void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) { #ifndef MAGNUM_TARGET_GLES2 glFlushMappedBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length); - #elif !defined(CORRADE_TARGET_NACL) - glFlushMappedBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length); #else - static_cast(offset); - static_cast(length); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glFlushMappedBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length); #endif } @@ -639,10 +606,8 @@ void Buffer::flushMappedRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr le bool Buffer::unmapImplementationDefault() { #ifndef MAGNUM_TARGET_GLES2 return glUnmapBuffer(GLenum(bindSomewhereInternal(_targetHint))); - #elif !defined(CORRADE_TARGET_NACL) - return glUnmapBufferOES(GLenum(bindSomewhereInternal(_targetHint))); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + return glUnmapBufferOES(GLenum(bindSomewhereInternal(_targetHint))); #endif } diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 2f7cc473a..0ec16082f 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -188,22 +188,21 @@ for(std::size_t i: {7, 27, 56, 128}) { CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap()); @endcode -## WebGL and NaCl restrictions - -Buffers in @ref MAGNUM_TARGET_WEBGL "WebGL" and @ref CORRADE_TARGET_NACL "NaCl" -need to be bound only to one unique target, i.e., @ref Buffer bound to -@ref Buffer::Target::Array cannot be later rebound to -@ref Buffer::Target::ElementArray. However, Magnum by default uses any -sufficient target when binding the buffer internally (e.g. for setting data). -To avoid GL errors, set target hint to desired target, either in constructor or -using @ref Buffer::setTargetHint(): +## WebGL restrictions + +Buffers in @ref MAGNUM_TARGET_WEBGL "WebGL" need to be bound only to one unique +target, i.e., @ref Buffer bound to @ref Buffer::Target::Array cannot be later +rebound to @ref Buffer::Target::ElementArray. However, Magnum by default uses +any sufficient target when binding the buffer internally (e.g. for setting +data). To avoid GL errors, set target hint to desired target, either in +constructor or using @ref Buffer::setTargetHint(): @code Buffer vertices{Buffer::Target::Array}; Buffer indices{Buffer::Target::ElementArray}; @endcode To ease up the development, @ref Mesh checks proper target hint when adding -vertex and index buffers in both WebGL and NaCl. +vertex and index buffers in WebGL. ## Performance optimizations @@ -1238,33 +1237,6 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { } #endif - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_NACL) - /** - * @brief Map portion of buffer to client memory - * @param offset Offset into the buffer - * @param length Length of the mapped memory - * @param access Access - * @return Pointer to buffer data - * - * The buffer is bound to hinted target before the operation (if not - * already). - * @see @ref unmapSub(), @ref setTargetHint(), - * @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub} - * @requires_gles20 Available only in NaCl build. Use - * @ref map(GLintptr, GLsizeiptr, MapFlags) elsewhere. - * @requires_es_extension Extension @extension{CHROMIUM,map_sub} - * @requires_gles Buffer mapping is not available in WebGL. - * @deprecated_gl Prefer to use @ref map(GLintptr, GLsizeiptr, MapFlags) - * instead, as it has more complete set of features. - */ - void* mapSub(GLintptr offset, GLsizeiptr length, MapAccess access); - - /** @overload */ - template T* mapSub(GLintptr offset, GLsizeiptr length, MapAccess access) { - return static_cast(mapSub(offset, length, access)); - } - #endif - /** * @brief Map buffer to client memory * @param offset Byte offset into the buffer @@ -1352,21 +1324,6 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @requires_gles Buffer mapping is not available in WebGL. */ bool unmap(); - - #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_NACL) - /** - * @brief Unmap portion of buffer - * - * Unmaps portion of buffer previously mapped with @ref mapSub(), - * invalidating the pointer returned by the function. - * @see @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub} - * @requires_gles20 Available only in NaCl build. Use - * @ref map(GLintptr, GLsizeiptr, MapFlags) elsewhere. - * @requires_es_extension Extension @extension{CHROMIUM,map_sub} - * @requires_gles Buffer mapping is not available in WebGL. - */ - void unmapSub(); - #endif #endif #ifdef DOXYGEN_GENERATING_OUTPUT @@ -1480,9 +1437,6 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { GLuint _id; TargetHint _targetHint; - #ifdef CORRADE_TARGET_NACL - void* _mappedBuffer; - #endif ObjectFlags _flags; }; @@ -1498,31 +1452,16 @@ MAGNUM_EXPORT Debug& operator<<(Debug& debug, Buffer::TargetHint value); MAGNUM_EXPORT Debug& operator<<(Debug& debug, Buffer::Target value); #endif -inline Buffer::Buffer(NoCreateT) noexcept: _id{0}, _targetHint{TargetHint::Array}, _flags{ObjectFlag::DeleteOnDestruction} - #ifdef CORRADE_TARGET_NACL - , _mappedBuffer{nullptr} - #endif -{} +inline Buffer::Buffer(NoCreateT) noexcept: _id{0}, _targetHint{TargetHint::Array}, _flags{ObjectFlag::DeleteOnDestruction} {} -inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint}, - #ifdef CORRADE_TARGET_NACL - _mappedBuffer{other._mappedBuffer}, - #endif - _flags{other._flags} -{ +inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint}, _flags{other._flags} { other._id = 0; - #ifdef CORRADE_TARGET_NACL - other._mappedBuffer = nullptr; - #endif } inline Buffer& Buffer::operator=(Buffer&& other) noexcept { using std::swap; swap(_id, other._id); swap(_targetHint, other._targetHint); - #ifdef CORRADE_TARGET_NACL - swap(_mappedBuffer, other._mappedBuffer); - #endif swap(_flags, other._flags); return *this; } diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index 8898909dd..9587fc9ff 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -221,7 +221,7 @@ if(NOT (TARGET_WEBGL AND TARGET_GLES2)) endif() # Link in GL function pointer variables on platforms that support it -if(NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_NACL) +if(NOT CORRADE_TARGET_EMSCRIPTEN) list(APPEND Magnum_SRCS $) endif() diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 2ff663cd1..e79c37428 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -261,9 +261,6 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,APPLE,texture_format_BGRA8888), _extension(GL,ARM,shader_framebuffer_fetch), _extension(GL,ARM,shader_framebuffer_fetch_depth_stencil), - #ifdef CORRADE_TARGET_NACL - _extension(GL,CHROMIUM,map_sub), - #endif _extension(GL,EXT,texture_filter_anisotropic), _extension(GL,EXT,texture_format_BGRA8888), _extension(GL,EXT,read_format_bgra), diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index 5f607fbea..ad5822a41 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -233,9 +233,9 @@ class MAGNUM_EXPORT Context { #ifdef MAGNUM_TARGET_GLES /** * OpenGL ES implementation by ANGLE (translated to D3D), used by - * browsers on Windows for Native Client and WebGL. As the WebGL - * specification explicitly disallows exposing driver information - * to the application, this check cannot be done reliably. + * browsers on Windows for WebGL. As the WebGL specification + * explicitly disallows exposing driver information to the + * application, this check cannot be done reliably. */ Angle = 1 << 1, diff --git a/src/Magnum/DebugOutput.cpp b/src/Magnum/DebugOutput.cpp index 0c6b7f1cf..cccf8ec43 100644 --- a/src/Magnum/DebugOutput.cpp +++ b/src/Magnum/DebugOutput.cpp @@ -34,7 +34,7 @@ #include "Magnum/Implementation/State.h" #include "Magnum/Implementation/DebugState.h" -#if defined(CORRADE_TARGET_NACL_NEWLIB) || defined(CORRADE_TARGET_ANDROID) +#ifdef CORRADE_TARGET_ANDROID #include #endif @@ -42,7 +42,6 @@ namespace Magnum { namespace { -#ifndef CORRADE_TARGET_NACL void #ifdef CORRADE_TARGET_WINDOWS APIENTRY @@ -50,7 +49,6 @@ APIENTRY callbackWrapper(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { Context::current().state().debug->messageCallback(DebugOutput::Source(source), DebugOutput::Type(type), id, DebugOutput::Severity(severity), std::string{message, std::size_t(length)}, userParam); } -#endif void defaultCallback(const DebugOutput::Source source, const DebugOutput::Type type, const UnsignedInt id, const DebugOutput::Severity severity, const std::string& string, const void*) { Debug output; @@ -106,13 +104,13 @@ void defaultCallback(const DebugOutput::Source source, const DebugOutput::Type t } /** @todo Remove when this is fixed everywhere (also the include above) */ - #if defined(CORRADE_TARGET_NACL_NEWLIB) || defined(CORRADE_TARGET_ANDROID) + #ifdef CORRADE_TARGET_ANDROID std::ostringstream converter; converter << id; #endif output << '(' + - #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) + #ifndef CORRADE_TARGET_ANDROID std::to_string(id) + #else converter.str() + @@ -171,21 +169,12 @@ void DebugOutput::setEnabledInternal(const GLenum source, const GLenum type, con void DebugOutput::controlImplementationNoOp(GLenum, GLenum, GLenum, std::initializer_list, bool) {} void DebugOutput::controlImplementationKhr(const GLenum source, const GLenum type, const GLenum severity, const std::initializer_list ids, const bool enabled) { - #ifndef CORRADE_TARGET_NACL #ifndef MAGNUM_TARGET_GLES glDebugMessageControl #else glDebugMessageControlKHR #endif (source, type, severity, ids.size(), ids.begin(), enabled); - #else - static_cast(source); - static_cast(type); - static_cast(severity); - static_cast(ids); - static_cast(enabled); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } void DebugOutput::callbackImplementationNoOp(Callback, const void*) {} @@ -197,30 +186,21 @@ void DebugOutput::callbackImplementationKhr(const Callback callback, const void* /* Adding callback */ if(!original && callback) { - #ifndef CORRADE_TARGET_NACL #ifndef MAGNUM_TARGET_GLES glDebugMessageCallback #else glDebugMessageCallbackKHR #endif (callbackWrapper, userParam); - #else - static_cast(userParam); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif /* Deleting callback */ } else if(original && !callback) { - #ifndef CORRADE_TARGET_NACL #ifndef MAGNUM_TARGET_GLES glDebugMessageCallback #else glDebugMessageCallbackKHR #endif (nullptr, nullptr); - #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } } @@ -283,30 +263,16 @@ void DebugMessage::insertInternal(const Source source, const Type type, const Un void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, DebugOutput::Severity, const Containers::ArrayView) {} void DebugMessage::insertImplementationKhr(const Source source, const Type type, const UnsignedInt id, const DebugOutput::Severity severity, const Containers::ArrayView string) { - #ifndef CORRADE_TARGET_NACL #ifndef MAGNUM_TARGET_GLES glDebugMessageInsert #else glDebugMessageInsertKHR #endif (GLenum(source), GLenum(type), id, GLenum(severity), string.size(), string.data()); - #else - static_cast(source); - static_cast(type); - static_cast(id); - static_cast(severity); - static_cast(string); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, DebugOutput::Severity, const Containers::ArrayView string) { - #ifndef CORRADE_TARGET_NACL glInsertEventMarkerEXT(string.size(), string.data()); - #else - static_cast(string); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #ifndef MAGNUM_TARGET_GLES @@ -392,28 +358,16 @@ void DebugGroup::pop() { void DebugGroup::pushImplementationNoOp(Source, UnsignedInt, Containers::ArrayView) {} void DebugGroup::pushImplementationKhr(const Source source, const UnsignedInt id, const Containers::ArrayView message) { - #ifndef CORRADE_TARGET_NACL #ifndef MAGNUM_TARGET_GLES glPushDebugGroup #else glPushDebugGroupKHR #endif (GLenum(source), id, message.size(), message.data()); - #else - static_cast(source); - static_cast(id); - static_cast(message); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } void DebugGroup::pushImplementationExt(Source, UnsignedInt, const Containers::ArrayView message) { - #ifndef CORRADE_TARGET_NACL glPushGroupMarkerEXT(message.size(), message.data()); - #else - static_cast(message); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } void DebugGroup::popImplementationNoOp() {} @@ -421,19 +375,13 @@ void DebugGroup::popImplementationNoOp() {} void DebugGroup::popImplementationKhr() { #ifndef MAGNUM_TARGET_GLES glPopDebugGroup(); - #elif !defined(CORRADE_TARGET_NACL) - glPopDebugGroupKHR(); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glPopDebugGroupKHR(); #endif } void DebugGroup::popImplementationExt() { - #ifndef CORRADE_TARGET_NACL glPopGroupMarkerEXT(); - #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #ifndef DOXYGEN_GENERATING_OUTPUT diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index ed97c220c..f10750697 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -302,10 +302,6 @@ namespace GL { #endif _extension(GL,ARM,shader_framebuffer_fetch, GLES200, None) // #165 _extension(GL,ARM,shader_framebuffer_fetch_depth_stencil, GLES200, None) // #166 - } namespace CHROMIUM { - #ifdef CORRADE_TARGET_NACL - _extension(GL,CHROMIUM,map_sub, GLES200, None) - #endif } namespace EXT { _extension(GL,EXT,texture_filter_anisotropic, GLES200, None) // #41 #ifdef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index 6d2742456..dc9bd98b9 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -382,14 +382,8 @@ void Framebuffer::textureImplementationDSAEXT(const BufferAttachment attachment, void Framebuffer::textureLayerImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) { #ifndef MAGNUM_TARGET_GLES2 glFramebufferTextureLayer(GLenum(bindInternal()), GLenum(attachment), textureId, mipLevel, layer); - #elif !defined(CORRADE_TARGET_NACL) - glFramebufferTexture3DOES(GLenum(bindInternal()), GLenum(attachment), GL_TEXTURE_3D_OES, textureId, mipLevel, layer); #else - static_cast(attachment); - static_cast(textureId); - static_cast(mipLevel); - static_cast(layer); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glFramebufferTexture3DOES(GLenum(bindInternal()), GLenum(attachment), GL_TEXTURE_3D_OES, textureId, mipLevel, layer); #endif } #endif diff --git a/src/Magnum/Implementation/driverSpecific.cpp b/src/Magnum/Implementation/driverSpecific.cpp index 53d8d4428..ed2e32a62 100644 --- a/src/Magnum/Implementation/driverSpecific.cpp +++ b/src/Magnum/Implementation/driverSpecific.cpp @@ -85,13 +85,6 @@ namespace { "nv-zero-context-profile-mask", #endif - #ifdef CORRADE_TARGET_NACL - /* NaCl advertises some additional extensions but the GLESv2 library - does not have any entrypoints for them and there is no GetProcAddress - equivalent, thus marking them as unsupported. */ - "nacl-missing-extension-entrypoints", - #endif - #ifndef MAGNUM_TARGET_GLES /* SVGA3D (VMware host GL driver) glDrawArrays() draws nothing when the vertex buffer memory is initialized using glNamedBufferData() from @@ -236,40 +229,6 @@ void Context::setupDriverWorkarounds() { } #endif - #ifdef CORRADE_TARGET_NACL - if(!isDriverWorkaroundDisabled("nacl-missing-extension-entrypoints")) { - _setRequiredVersion(GL::EXT::multi_draw_arrays, None); - _setRequiredVersion(GL::EXT::debug_label, None); - _setRequiredVersion(GL::EXT::debug_marker, None); - _setRequiredVersion(GL::EXT::disjoint_timer_query, None); - _setRequiredVersion(GL::EXT::separate_shader_objects, None); - _setRequiredVersion(GL::EXT::multisampled_render_to_texture, None); - _setRequiredVersion(GL::EXT::robustness, None); - _setRequiredVersion(GL::KHR::debug, None); - _setRequiredVersion(GL::NV::read_buffer_front, None); - _setRequiredVersion(GL::OES::mapbuffer, None); - _setRequiredVersion(GL::ANGLE::framebuffer_blit, None); - _setRequiredVersion(GL::ANGLE::framebuffer_multisample, None); - _setRequiredVersion(GL::ANGLE::instanced_arrays, None); - _setRequiredVersion(GL::APPLE::framebuffer_multisample, None); - _setRequiredVersion(GL::EXT::discard_framebuffer, None); - _setRequiredVersion(GL::EXT::blend_minmax, None); - _setRequiredVersion(GL::EXT::texture_storage, None); - _setRequiredVersion(GL::EXT::map_buffer_range, None); - _setRequiredVersion(GL::EXT::instanced_arrays, None); - _setRequiredVersion(GL::EXT::draw_instanced, None); - _setRequiredVersion(GL::NV::draw_buffers, None); - _setRequiredVersion(GL::NV::fbo_color_attachments, None); // ?? - _setRequiredVersion(GL::NV::read_buffer, None); - _setRequiredVersion(GL::NV::draw_instanced, None); - _setRequiredVersion(GL::NV::framebuffer_blit, None); - _setRequiredVersion(GL::NV::framebuffer_multisample, None); - _setRequiredVersion(GL::NV::instanced_arrays, None); - _setRequiredVersion(GL::OES::texture_3D, None); - _setRequiredVersion(GL::OES::vertex_array_object, None); - } - #endif - #ifndef MAGNUM_TARGET_GLES if((detectedDriver() & DetectedDriver::Svga3D) && isExtensionSupported() && diff --git a/src/Magnum/Math/Complex.h b/src/Magnum/Math/Complex.h index 5866c2c00..2f312ae7f 100644 --- a/src/Magnum/Math/Complex.h +++ b/src/Magnum/Math/Complex.h @@ -391,7 +391,7 @@ template class Complex { */ T length() const { /** @todo Remove when newlib has this fixed */ - #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) + #ifndef CORRADE_TARGET_ANDROID return std::hypot(_real, _imaginary); #else return std::sqrt(dot()); diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index 735ee21e5..def95b4cc 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -455,7 +455,7 @@ template inline T round(const T& a); #else template inline typename std::enable_if::value, T>::type round(T a) { /** @todo Remove when newlib has this fixed */ - #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) + #ifndef CORRADE_TARGET_ANDROID return std::round(a); #else return (a > T(0)) ? std::floor(a + T(0.5)) : std::ceil(a - T(0.5)); @@ -464,7 +464,7 @@ template inline typename std::enable_if::value, T template Vector round(const Vector& a) { Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) { - #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) + #ifndef CORRADE_TARGET_ANDROID out[i] = std::round(a[i]); #else out[i] = round(a[i]); @@ -605,7 +605,7 @@ template inline typename std::enable_if::value, T /* On Emscripten it works with -O2 but not with -O1 (function not defined). I guess that's only because -O2 optimizes it out, so disabling it there also */ - #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) && !defined(CORRADE_TARGET_EMSCRIPTEN) + #if !defined(CORRADE_TARGET_ANDROID) && !defined(CORRADE_TARGET_EMSCRIPTEN) return std::fma(a, b, c); #else return a*b + c; diff --git a/src/Magnum/Math/Test/FunctionsTest.cpp b/src/Magnum/Math/Test/FunctionsTest.cpp index 3dae7ad8a..f7453f580 100644 --- a/src/Magnum/Math/Test/FunctionsTest.cpp +++ b/src/Magnum/Math/Test/FunctionsTest.cpp @@ -241,7 +241,7 @@ void FunctionsTest::round() { CORRADE_COMPARE(Math::round(2.3f), 2.0f); CORRADE_COMPARE(Math::round(Vector3(2.3f, 0.7f, 1.5f)), Vector3(2.0f, 1.0f, 2.0f)); - /* We are working around missing std::round() in NaCl newlib, thus we must + /* We are working around missing std::round() in Android, thus we must test that the behavior is the same on both implementations */ CORRADE_COMPARE(Math::round(-2.0f), -2.0f); CORRADE_COMPARE(Math::round(-1.5f), -2.0f); diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index 95031cbbf..59df823d2 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -241,7 +241,7 @@ Mesh& Mesh::addVertexBufferInstanced(Buffer& buffer, const UnsignedInt divisor, } Mesh& Mesh::setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, UnsignedInt start, UnsignedInt end) { - #if defined(CORRADE_TARGET_NACL) || defined(MAGNUM_TARGET_WEBGL) + #ifdef MAGNUM_TARGET_WEBGL CORRADE_ASSERT(buffer.targetHint() == Buffer::TargetHint::ElementArray, "Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::ElementArray << "but got" << buffer.targetHint(), *this); #endif @@ -425,10 +425,8 @@ void Mesh::bindVAO() { _flags |= ObjectFlag::Created; #ifndef MAGNUM_TARGET_GLES2 glBindVertexArray(current = _id); - #elif !defined(CORRADE_TARGET_NACL) - glBindVertexArrayOES(current = _id); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glBindVertexArrayOES(current = _id); #endif } } @@ -441,10 +439,8 @@ void Mesh::createImplementationDefault() { void Mesh::createImplementationVAO() { #ifndef MAGNUM_TARGET_GLES2 glGenVertexArrays(1, &_id); - #elif !defined(CORRADE_TARGET_NACL) - glGenVertexArraysOES(1, &_id); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glGenVertexArraysOES(1, &_id); #endif CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -461,10 +457,8 @@ void Mesh::destroyImplementationDefault() {} void Mesh::destroyImplementationVAO() { #ifndef MAGNUM_TARGET_GLES2 glDeleteVertexArrays(1, &_id); - #elif !defined(CORRADE_TARGET_NACL) - glDeleteVertexArraysOES(1, &_id); #else - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ + glDeleteVertexArraysOES(1, &_id); #endif } @@ -478,7 +472,7 @@ void Mesh::attributePointerInternal(AttributeLayout& attribute) { } void Mesh::attributePointerImplementationDefault(AttributeLayout& attribute) { - #if defined(CORRADE_TARGET_NACL) || defined(MAGNUM_TARGET_WEBGL) + #ifdef MAGNUM_TARGET_WEBGL CORRADE_ASSERT(attribute.buffer.targetHint() == Buffer::TargetHint::Array, "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::Array << "but got" << attribute.buffer.targetHint(), ); #endif @@ -487,7 +481,7 @@ void Mesh::attributePointerImplementationDefault(AttributeLayout& attribute) { } void Mesh::attributePointerImplementationVAO(AttributeLayout& attribute) { - #if defined(CORRADE_TARGET_NACL) || defined(MAGNUM_TARGET_WEBGL) + #ifdef MAGNUM_TARGET_WEBGL CORRADE_ASSERT(attribute.buffer.targetHint() == Buffer::TargetHint::Array, "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::Array << "but got" << attribute.buffer.targetHint(), ); #endif @@ -555,32 +549,14 @@ void Mesh::vertexAttribDivisorImplementationDSAEXT(const GLuint index, const GLu } #elif defined(MAGNUM_TARGET_GLES2) void Mesh::vertexAttribDivisorImplementationANGLE(const GLuint index, const GLuint divisor) { - #ifndef CORRADE_TARGET_NACL glVertexAttribDivisorANGLE(index, divisor); - #else - static_cast(index); - static_cast(divisor); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #ifndef MAGNUM_TARGET_WEBGL void Mesh::vertexAttribDivisorImplementationEXT(const GLuint index, const GLuint divisor) { - #ifndef CORRADE_TARGET_NACL glVertexAttribDivisorEXT(index, divisor); - #else - static_cast(index); - static_cast(divisor); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } void Mesh::vertexAttribDivisorImplementationNV(const GLuint index, const GLuint divisor) { - #ifndef CORRADE_TARGET_NACL glVertexAttribDivisorNV(index, divisor); - #else - static_cast(index); - static_cast(divisor); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif #endif @@ -619,72 +595,30 @@ void Mesh::unbindImplementationVAO() {} #ifdef MAGNUM_TARGET_GLES2 void Mesh::drawArraysInstancedImplementationANGLE(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) { - #ifndef CORRADE_TARGET_NACL glDrawArraysInstancedANGLE(GLenum(_primitive), baseVertex, count, instanceCount); - #else - static_cast(baseVertex); - static_cast(count); - static_cast(instanceCount); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #ifndef MAGNUM_TARGET_WEBGL void Mesh::drawArraysInstancedImplementationEXT(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) { - #ifndef CORRADE_TARGET_NACL glDrawArraysInstancedEXT(GLenum(_primitive), baseVertex, count, instanceCount); - #else - static_cast(baseVertex); - static_cast(count); - static_cast(instanceCount); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } void Mesh::drawArraysInstancedImplementationNV(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) { - #ifndef CORRADE_TARGET_NACL glDrawArraysInstancedNV(GLenum(_primitive), baseVertex, count, instanceCount); - #else - static_cast(baseVertex); - static_cast(count); - static_cast(instanceCount); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif void Mesh::drawElementsInstancedImplementationANGLE(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) { - #ifndef CORRADE_TARGET_NACL glDrawElementsInstancedANGLE(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexOffset), instanceCount); - #else - static_cast(count); - static_cast(indexOffset); - static_cast(instanceCount); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #ifndef MAGNUM_TARGET_WEBGL void Mesh::drawElementsInstancedImplementationEXT(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) { - #ifndef CORRADE_TARGET_NACL glDrawElementsInstancedEXT(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexOffset), instanceCount); - #else - static_cast(count); - static_cast(indexOffset); - static_cast(instanceCount); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } void Mesh::drawElementsInstancedImplementationNV(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) { - #ifndef CORRADE_TARGET_NACL glDrawElementsInstancedNV(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast(indexOffset), instanceCount); - #else - static_cast(count); - static_cast(indexOffset); - static_cast(instanceCount); - CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ - #endif } #endif #endif diff --git a/src/Magnum/MeshView.cpp b/src/Magnum/MeshView.cpp index 567f58ec7..bdeea5225 100644 --- a/src/Magnum/MeshView.cpp +++ b/src/Magnum/MeshView.cpp @@ -96,10 +96,8 @@ void MeshView::multiDrawImplementationDefault(std::initializer_list - /* Special case for Emscripten (no extension loading) */ #elif defined(CORRADE_TARGET_EMSCRIPTEN) #ifdef MAGNUM_TARGET_GLES2 diff --git a/src/Magnum/OpenGLTester.h b/src/Magnum/OpenGLTester.h index 62a774a04..40440fb3a 100644 --- a/src/Magnum/OpenGLTester.h +++ b/src/Magnum/OpenGLTester.h @@ -67,15 +67,14 @@ the base features. This class is available only on platforms with corresponding `Platform::Windowless*Application` implementation. That currently means all -platforms except @ref CORRADE_TARGET_ANDROID "Android", -@ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" and @ref CORRADE_TARGET_NACL "NaCl". -It is built into a separate static library and only if `WITH_OPENGLTESTER` is -enabled when building Magnum. To use it, you need to request `OpenGLTester` -component of `Magnum` package in CMake, derive your test class from this class -instead of @ref Corrade::TestSuite::Tester and either link to -`Magnum::OpenGLTester` target or add it to `LIBRARIES` section of the -@ref corrade-cmake-add-test "corrade_add_test()" macro. See @ref building and -@ref cmake for more information. +platforms except @ref CORRADE_TARGET_ANDROID "Android" and +@ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". It is built into a separate static +library and only if `WITH_OPENGLTESTER` is enabled when building Magnum. To use +it, you need to request `OpenGLTester` component of `Magnum` package in CMake, +derive your test class from this class instead of @ref Corrade::TestSuite::Tester +and either link to `Magnum::OpenGLTester` target or add it to `LIBRARIES` +section of the @ref corrade-cmake-add-test "corrade_add_test()" macro. See +@ref building and @ref cmake for more information. ## OpenGL context creation diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 69d24b1b7..ea655264d 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -47,7 +47,7 @@ if(WITH_GLFWAPPLICATION OR WITH_GLUTAPPLICATION OR WITH_SDL2APPLICATION) elseif(CORRADE_TARGET_UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) set(NEED_GLXCONTEXT 1) set(MagnumSomeContext_OBJECTS $) - elseif(MAGNUM_TARGET_GLES AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_NACL) + elseif(MAGNUM_TARGET_GLES AND NOT CORRADE_TARGET_EMSCRIPTEN) set(NEED_EGLCONTEXT 1) set(MagnumSomeContext_OBJECTS $) endif() @@ -200,74 +200,6 @@ if(WITH_SDL2APPLICATION) add_library(Magnum::Sdl2Application ALIAS MagnumSdl2Application) endif() -# NaCl application -if(WITH_NACLAPPLICATION) - if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL NaCl) - message(FATAL_ERROR "NaClApplication is available only when targeting Google Chrome Native Client. Set WITH_NACLAPPLICATION to OFF to skip building it.") - endif() - - set(MagnumNaClApplication_SRCS NaClApplication.cpp) - set(MagnumNaClApplication_HEADERS NaClApplication.h) - - add_library(MagnumNaClApplication STATIC - ${MagnumNaClApplication_SRCS} - ${MagnumNaClApplication_HEADERS}) - set_target_properties(MagnumNaClApplication PROPERTIES - DEBUG_POSTFIX "-d" - FOLDER "Magnum/Platform") - # Assuming that PIC is not needed because the Application lib is always - # linked to the executable and not to any intermediate shared lib - target_link_libraries(MagnumNaClApplication Magnum ppapi_cpp ppapi) - - install(FILES ${MagnumNaClApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) - install(TARGETS MagnumNaClApplication - RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} - LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} - ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - - # Magnum NaClApplication target alias for superprojects - add_library(Magnum::NaClApplication ALIAS MagnumNaClApplication) -endif() - -# Windowless NaCl application -if(WITH_WINDOWLESSNACLAPPLICATION) - if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL NaCl) - message(FATAL_ERROR "WindowlessNaClApplication is available only when targeting Google Chrome Native Client. Set WITH_WINDOWLESSNACLAPPLICATION to OFF to skip building it.") - endif() - - set(MagnumWindowlessNaClApplication_SRCS WindowlessNaClApplication.cpp) - set(MagnumWindowlessNaClApplication_HEADERS WindowlessNaClApplication.h) - - add_library(MagnumWindowlessNaClApplication STATIC - ${MagnumWindowlessNaClApplication_SRCS} - ${MagnumWindowlessNaClApplication_HEADERS}) - set_target_properties(MagnumWindowlessNaClApplication PROPERTIES - DEBUG_POSTFIX "-d" - FOLDER "Magnum/Platform") - if(BUILD_STATIC_PIC) - set_target_properties(MagnumWindowlessNaClApplication PROPERTIES POSITION_INDEPENDENT_CODE ON) - endif() - target_link_libraries(MagnumWindowlessNaClApplication Magnum ppapi_cpp ppapi) - - install(FILES ${MagnumWindowlessNaClApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) - install(TARGETS MagnumWindowlessNaClApplication - RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} - LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} - ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - - # Magnum WindowlessNaClApplication target alias for superprojects - add_library(Magnum::WindowlessNaClApplication ALIAS MagnumWindowlessNaClApplication) -endif() - -# JavaScript and CSS stuff for NaCl -if(WITH_NACLAPPLICATION OR WITH_WINDOWLESSNACLAPPLICATION) - set(MagnumNaClApplication_FILES - NaClApplication.js - WebApplication.css) - list(APPEND MagnumPlatform_FILES ${MagnumNaClApplication_FILES}) - install(FILES ${MagnumNaClApplication_FILES} DESTINATION ${MAGNUM_DATA_INSTALL_DIR}) -endif() - # JavaScript and CSS stuff for Emscripten if(WITH_SDL2APPLICATION AND CORRADE_TARGET_EMSCRIPTEN) set(MagnumSdl2Application_FILES @@ -793,8 +725,6 @@ if(WITH_MAGNUMINFO) target_link_libraries(magnum-info MagnumWindowlessIosApplication) elseif(CORRADE_TARGET_APPLE) target_link_libraries(magnum-info MagnumWindowlessCglApplication) - elseif(CORRADE_TARGET_NACL) - target_link_libraries(magnum-info MagnumWindowlessNaClApplication) elseif(CORRADE_TARGET_UNIX) if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) target_link_libraries(magnum-info MagnumWindowlessEglApplication) @@ -813,11 +743,7 @@ if(WITH_MAGNUMINFO) set_target_properties(magnum-info PROPERTIES FOLDER "Magnum/Platform") install(TARGETS magnum-info DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}) - if(CORRADE_TARGET_NACL) - install(FILES magnum-info-nacl.html DESTINATION ${MAGNUM_DATA_INSTALL_DIR} RENAME magnum-info.html) - install(FILES magnum-info-nacl.nmf DESTINATION ${MAGNUM_DATA_INSTALL_DIR} RENAME magnum-info.nmf) - list(APPEND MagnumPlatform_FILES magnum-info-nacl.html magnum-info-nacl.nmf) - elseif(CORRADE_TARGET_IOS) + if(CORRADE_TARGET_IOS) set_target_properties(magnum-info PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in diff --git a/src/Magnum/Platform/Context.h b/src/Magnum/Platform/Context.h index bc7340c5a..cdf70b113 100644 --- a/src/Magnum/Platform/Context.h +++ b/src/Magnum/Platform/Context.h @@ -78,7 +78,7 @@ class Context: public Magnum::Context { * complete the setup. */ explicit Context(NoCreateT, Int argc, const char** argv): - #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) + #ifndef CORRADE_TARGET_EMSCRIPTEN Magnum::Context{NoCreate, argc, argv, flextGLInit} {} #else Magnum::Context{NoCreate, argc, argv, nullptr} {} diff --git a/src/Magnum/Platform/NaClApplication.cpp b/src/Magnum/Platform/NaClApplication.cpp deleted file mode 100644 index 4c2807e92..000000000 --- a/src/Magnum/Platform/NaClApplication.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 - Vladimír Vondruš - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. -*/ - -#include "NaClApplication.h" - -#include -#include -#include -#include - -#include "Magnum/Platform/Context.h" -#include "Magnum/Platform/ScreenedApplication.hpp" - -namespace Magnum { namespace Platform { - -static_assert(NaClApplication::MouseEvent::Button::WheelUp != NaClApplication::MouseEvent::Button::Left && - NaClApplication::MouseEvent::Button::WheelUp != NaClApplication::MouseEvent::Button::Middle && - NaClApplication::MouseEvent::Button::WheelUp != NaClApplication::MouseEvent::Button::Right && - NaClApplication::MouseEvent::Button::WheelDown != NaClApplication::MouseEvent::Button::Left && - NaClApplication::MouseEvent::Button::WheelDown != NaClApplication::MouseEvent::Button::Middle && - NaClApplication::MouseEvent::Button::WheelDown != NaClApplication::MouseEvent::Button::Right, ""); - -struct NaClApplication::ConsoleDebugOutput { - explicit ConsoleDebugOutput(pp::Instance* instance); - - Utility::NaClConsoleStreamBuffer debugBuffer, warningBuffer, errorBuffer; - std::ostream debugOutput, warningOutput, errorOutput; -}; - -NaClApplication::ConsoleDebugOutput::ConsoleDebugOutput(pp::Instance* instance): debugBuffer(instance, Utility::NaClConsoleStreamBuffer::LogLevel::Log), warningBuffer(instance, Utility::NaClConsoleStreamBuffer::LogLevel::Warning), errorBuffer(instance, Utility::NaClConsoleStreamBuffer::LogLevel::Error), debugOutput(&debugBuffer), warningOutput(&warningBuffer), errorOutput(&errorBuffer) { - /* Inform about this change on standard output */ - Debug() << "Platform::NaClApplication: redirecting Debug, Warning and Error output to JavaScript console"; - - Debug::setOutput(&debugOutput); - Warning::setOutput(&warningOutput); - Error::setOutput(&errorOutput); -} - -#ifndef DOXYGEN_GENERATING_OUTPUT -NaClApplication::NaClApplication(const Arguments& arguments): NaClApplication{arguments, Configuration{}} {} -#endif - -NaClApplication::NaClApplication(const Arguments& arguments, const Configuration& configuration): NaClApplication{arguments, NoCreate} { - createContext(configuration); -} - -NaClApplication::NaClApplication(const Arguments& arguments, NoCreateT): Instance(arguments), Graphics3DClient(this), MouseLock(this) { - _debugOutput.reset(new ConsoleDebugOutput{this}); -} - -void NaClApplication::createContext() { createContext({}); } - -void NaClApplication::createContext(const Configuration& configuration) { - if(!tryCreateContext(configuration)) std::exit(1); -} - -bool NaClApplication::tryCreateContext(const Configuration& configuration) { - CORRADE_ASSERT(!_context, "Platform::NaClApplication::tryCreateContext(): context already created", false); - - _viewportSize = configuration.size(); - - const std::int32_t attributes[] = { - PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, - PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24, - PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8, - PP_GRAPHICS3DATTRIB_SAMPLES, configuration.sampleCount(), - PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, configuration.sampleCount() > 1 ? 1 : 0, - PP_GRAPHICS3DATTRIB_WIDTH, configuration.size().x(), - PP_GRAPHICS3DATTRIB_HEIGHT, configuration.size().y(), - PP_GRAPHICS3DATTRIB_NONE - }; - - _graphics.reset(new pp::Graphics3D(this, attributes)); - if(_graphics->is_null()) { - Error() << "Platform::NaClApplication::tryCreateContext(): cannot create context"; - _graphics.reset(); - return false; - } - if(!BindGraphics(*_graphics)) { - Error() << "Platform::NaClApplication::tryCreateContext(): cannot bind graphics"; - _graphics.reset(); - return false; - } - - _fullscreen.reset(new pp::Fullscreen(this)); - - glSetCurrentContextPPAPI(_graphics->pp_resource()); - - /* Enable input handling for mouse and keyboard */ - RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE|PP_INPUTEVENT_CLASS_WHEEL); - RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); - - /* Return true if the initialization succeeds */ - return !!(_context = Platform::Context::tryCreate()); -} - -NaClApplication::~NaClApplication() = default; - -bool NaClApplication::isFullscreen() { - return _fullscreen->IsFullscreen(); -} - -bool NaClApplication::setFullscreen(bool enabled) { - /* Given fullscreen mode already set or switching to it is in progress, done */ - if(isFullscreen() == enabled || ((_flags & Flag::FullscreenSwitchInProgress) && (_flags & Flag::WillBeFullscreen) == enabled)) - return true; - - /* Switch to opposite fullscreen mode is in progress, can't revert it back */ - if((_flags & Flag::FullscreenSwitchInProgress) && (_flags & Flag::WillBeFullscreen) != enabled) - return false; - - /* Set fullscreen */ - if(!_fullscreen->SetFullscreen(enabled)) - return false; - - /* Set flags */ - _flags |= Flag::FullscreenSwitchInProgress; - enabled ? _flags |= Flag::WillBeFullscreen : _flags &= ~Flag::WillBeFullscreen; - return true; -} - -void NaClApplication::DidChangeView(const pp::View& view) { - /* Fullscreen switch in progress */ - if(_flags & Flag::FullscreenSwitchInProgress) { - /* Done, remove the progress flag */ - if(isFullscreen() == bool(_flags & Flag::WillBeFullscreen)) { - _flags &= ~Flag::FullscreenSwitchInProgress; - _flags |= Flag::Redraw; - } - - /* Don't process anything during the switch */ - else return; - } - - Vector2i size(view.GetRect().width(), view.GetRect().height()); - - /* Canvas resized */ - if(_viewportSize != size) { - _graphics->ResizeBuffers(size.x(), size.y()); - viewportEvent(_viewportSize = size); - } - - drawEvent(); -} - -bool NaClApplication::HandleInputEvent(const pp::InputEvent& event) { - /* Don't handle anything during switch from/to fullscreen */ - if(_flags & Flag::FullscreenSwitchInProgress) return false; - - Flags tmpFlags = _flags; - - switch(event.GetType()) { - case PP_INPUTEVENT_TYPE_KEYDOWN: - case PP_INPUTEVENT_TYPE_KEYUP: { - pp::KeyboardInputEvent keyEvent(event); - KeyEvent e(static_cast(keyEvent.GetKeyCode()), static_cast(keyEvent.GetModifiers())); - event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN ? keyPressEvent(e) : keyReleaseEvent(e); - if(!e.isAccepted()) return false; - break; - } - - case PP_INPUTEVENT_TYPE_MOUSEDOWN: - case PP_INPUTEVENT_TYPE_MOUSEUP: { - pp::MouseInputEvent mouseEvent(event); - MouseEvent e(static_cast(mouseEvent.GetButton()), {mouseEvent.GetPosition().x(), mouseEvent.GetPosition().y()}, static_cast(mouseEvent.GetModifiers())); - event.GetType() == PP_INPUTEVENT_TYPE_MOUSEDOWN ? mousePressEvent(e) : mouseReleaseEvent(e); - if(!e.isAccepted()) return false; - break; - } - - case PP_INPUTEVENT_TYPE_WHEEL: { - pp::WheelInputEvent wheelEvent(event); - MouseScrollEvent e{{wheelEvent.GetDelta().x(), wheelEvent.GetDelta().y()}, static_cast(wheelEvent.GetModifiers())}; - mouseScrollEvent(e); - #ifdef MAGNUM_BUILD_DEPRECATED - if(!Math::TypeTraits::equals(wheelEvent.GetDelta().y(), 0.0f)) { - MouseEvent e2(wheelEvent.GetDelta().y() > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {}, static_cast(wheelEvent.GetModifiers())); - mousePressEvent(e2); - if(!e.isAccepted() && !e2.isAccepted()) return false; - } else if(!e.isAccepted()) return false; - #else - if(!e.isAccepted()) return false; - #endif - break; - } - - case PP_INPUTEVENT_TYPE_MOUSEMOVE: { - pp::MouseInputEvent mouseEvent(event); - MouseMoveEvent e({mouseEvent.GetPosition().x(), mouseEvent.GetPosition().y()}, {mouseEvent.GetMovement().x(), mouseEvent.GetMovement().y()}, static_cast(mouseEvent.GetModifiers())); - mouseMoveEvent(e); - if(!e.isAccepted()) return false; - break; - } - - default: return false; - } - - /* Assume everything is properly sequential here */ - CORRADE_INTERNAL_ASSERT((tmpFlags & Flag::SwapInProgress) == (_flags & Flag::SwapInProgress)); - - /* Redraw, if it won't be handled after swap automatically */ - if((_flags & Flag::Redraw) && !(_flags & Flag::SwapInProgress)) { - _flags &= ~Flag::Redraw; - drawEvent(); - } - - return true; -} - -void NaClApplication::swapBuffers() { - /* Swap already in progress, do nothing */ - if(_flags & Flag::SwapInProgress) return; - - /* Swap buffers and call swapCallback() when done */ - _flags |= Flag::SwapInProgress; - _graphics->SwapBuffers(pp::CompletionCallback(&swapCallback, this)); -} - -void NaClApplication::swapCallback(void* applicationInstance, std::int32_t) { - NaClApplication* instance = static_cast(applicationInstance); - instance->_flags &= ~Flag::SwapInProgress; - - /* Redraw, if requested */ - if(instance->_flags & Flag::Redraw) { - instance->_flags &= ~Flag::Redraw; - instance->drawEvent(); - } -} - -void NaClApplication::setMouseLocked(bool enabled) { - /* Already done, nothing to do */ - if(enabled == isMouseLocked()) return; - - if(enabled) LockMouse(pp::CompletionCallback(&mouseLockCallback, this)); - else UnlockMouse(); -} - -void NaClApplication::mouseLockCallback(void* applicationInstance, std::int32_t) { - NaClApplication* instance = static_cast(applicationInstance); - instance->_flags |= Flag::MouseLocked; -} - -void NaClApplication::viewportEvent(const Vector2i&) {} -void NaClApplication::keyPressEvent(KeyEvent&) {} -void NaClApplication::keyReleaseEvent(KeyEvent&) {} -void NaClApplication::mousePressEvent(MouseEvent&) {} -void NaClApplication::mouseReleaseEvent(MouseEvent&) {} -void NaClApplication::mouseMoveEvent(MouseMoveEvent&) {} -void NaClApplication::mouseScrollEvent(MouseScrollEvent&) {} - -template class BasicScreen; -template class BasicScreenedApplication; - -}} diff --git a/src/Magnum/Platform/NaClApplication.h b/src/Magnum/Platform/NaClApplication.h deleted file mode 100644 index 02e874ef7..000000000 --- a/src/Magnum/Platform/NaClApplication.h +++ /dev/null @@ -1,821 +0,0 @@ -#ifndef Magnum_Platform_NaClApplication_h -#define Magnum_Platform_NaClApplication_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 - Vladimír Vondruš - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. -*/ - -/** @file - * @brief Class @ref Magnum::Platform::NaClApplication, macro @ref MAGNUM_NACLAPPLICATION_MAIN() - */ - -#include -#include -#include - -/* Needs to be first */ -#include "Magnum/OpenGL.h" - -#include -#include -#include -#include -#include -#include - -#include "Magnum/Magnum.h" -#include "Magnum/Tags.h" -#include "Magnum/Math/Vector2.h" -#include "Magnum/Platform/Platform.h" - -namespace pp { - class Graphics3D; - class Fullscreen; -} - -#ifndef CORRADE_TARGET_NACL -#error this header is available only on Google Chrome Native Client build -#endif - -namespace Magnum { namespace Platform { - -/** @nosubgrouping -@brief NaCl application - -Application running in [Google Chrome Native Client](https://developers.google.com/native-client/). -Supports keyboard and mouse handling. - -This application library is available only in -@ref CORRADE_TARGET_NACL "Google Chrome Native Client", see respective sections -in @ref building-corrade-cross-nacl "Corrade's" and @ref building-cross-nacl "Magnum's" -building documentation. It is built if `WITH_NACLAPPLICATION` is enabled in -CMake. - -## Bootstrap application - -Fully contained base application using @ref Sdl2Application for desktop build -and @ref NaClApplication for Native Client build along with full HTML markup -and CMake setup is available in `base-nacl` branch of -[Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) repository, -download it as [tar.gz](https://github.com/mosra/magnum-bootstrap/archive/base-nacl.tar.gz) -or [zip](https://github.com/mosra/magnum-bootstrap/archive/base-nacl.zip) file. -After extracting the downloaded archive, you can do the desktop build in the -same way as with @ref Sdl2Application. For the Native Client build you also -need to put the contents of toolchains repository from https://github.com/mosra/toolchains -in `toolchains/` subdirectory. Don't forget to adapt `NACL_PREFIX` variable in -`toolchains/generic/NaCl-newlib-x86-32.cmake` and -`toolchains/generic/NaCl-newlib-x86-64.cmake` to path where your SDK is -installed. Default is `/usr/nacl`. You may need to adapt also -`NACL_TOOLCHAIN_PATH` so CMake is able to find the compiler. - -Then create build directories for x86-32 and x86-64 and run `cmake` and -build/install commands in them. The toolchains need access to the platform -file, so be sure to properly set **absolute** path to `toolchains/modules/` -directory containing `Platform/NaCl.cmake`. Set `CMAKE_INSTALL_PREFIX` to -location of your webserver to have the files installed in proper location (e.g. -`/srv/http/nacl`). - - mkdir build-nacl-x86-32 && cd build-nacl-x86-32 - cmake .. \ - -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-32.cmake" \ - -DCMAKE_INSTALL_PREFIX=/srv/http/nacl - cmake --build . - cmake --build . --target install - - mkdir build-nacl-x86-64 && cd build-nacl-x86-64 - cmake .. \ - -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-64.cmake" \ - -DCMAKE_INSTALL_PREFIX=/srv/http/nacl - cmake --build . - cmake --build . --target install - -See @ref cmake for more information. - -You can then open `MyApplication` through your webserver in Chrome (e.g. -`http://localhost/nacl/MyApplication.html`). - -## General usage - -For CMake you need to copy `FindOpenGLES2.cmake` from `modules/` directory in -Magnum source to `modules/` dir in your project (so it is able to find OpenGL -ES). Request `NaClApplication` component of `Magnum` package and link to -`Magnum::NaClApplication` target. If no other application is requested, you can -also use generic `Magnum::Application` alias to simplify porting. Again, see -@ref building and @ref cmake for more information. - -In C++ code you need to implement at least @ref drawEvent() to be able to draw -on the screen. The subclass must be then registered to NaCl API using -@ref MAGNUM_NACLAPPLICATION_MAIN() macro. See @ref platform for more -information. -@code -class MyApplication: public Platform::NaClApplication { - // implement required methods... -}; -MAGNUM_NACLAPPLICATION_MAIN(MyApplication) -@endcode - -If no other application header is included, this class is also aliased to -`Platform::Application` and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` -to simplify porting. - -### HTML markup and NMF file - -You need to provide HTML markup for your application. Template one is below or -in the bootstrap application, you can modify it to your liking. The markup -references two files, `NaClApplication.js` and `WebApplication.css`, both are -in `Platform/` directory in the source tree and are also installed into -`share/magnum/` inside your NaCl toolchain. Change `<application>` to -name of your executable. -@code - - - - Magnum NaCl Application - - - - -

Magnum NaCl Application

-
- -
Initialization...
-
- -
- - -@endcode - -You can modify all the files to your liking, but the HTML file must contain at -least the `<embed>` enclosed in listener `<div>`. The JavaScript -file contains event listeners which print loading status on the page. The -status displayed in the remaining two `<div>`s, if they are available. -The CSS file contains rudimentary style to avoid eye bleeding. - -The `<embed>` file references NMF file which you need to provide too. If -you target @ref CORRADE_TARGET_NACL_NEWLIB "newlib", the file is pretty simple, -for example (change `<application>` to name of your executable): -@code -{ - "program": { - "x86-32": {"url": "-x86-32.nexe"}, - "x86-64": {"url": "-x86-64.nexe"} - } -} -@endcode - -If you target @ref CORRADE_TARGET_NACL_GLIBC "glibc", you need to specify also -all additional dependencies. See [Native Client](https://developers.google.com/native-client/) -documentation for more information. - -## Redirecting output to Chrome's JavaScript console - -The application by default redirects @ref Corrade::Utility::Debug "Debug", -@ref Corrade::Utility::Warning "Warning" and @ref Corrade::Utility::Error "Error" -output to JavaScript console. See also @ref Corrade::Utility::NaClConsoleStreamBuffer -for more information. -*/ -class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public pp::MouseLock { - public: - /** @brief Application arguments */ - typedef PP_Instance Arguments; - - class Configuration; - class InputEvent; - class KeyEvent; - class MouseEvent; - class MouseMoveEvent; - class MouseScrollEvent; - - /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, const Configuration&) */ - #ifdef DOXYGEN_GENERATING_OUTPUT - explicit NaClApplication(const Arguments& arguments, const Configuration& configuration = Configuration()); - #else - /* To avoid "invalid use of incomplete type" */ - explicit NaClApplication(const Arguments& arguments, const Configuration& configuration); - explicit NaClApplication(const Arguments& arguments); - #endif - - /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, NoCreateT) */ - explicit NaClApplication(const Arguments& arguments, NoCreateT); - - #ifdef MAGNUM_BUILD_DEPRECATED - /** - * @copybrief NaClApplication(const Arguments&, NoCreateT) - * @deprecated Use @ref NaClApplication(const Arguments&, NoCreateT) instead. - */ - CORRADE_DEPRECATED("use NaClApplication(const Arguments&, NoCreateT) instead") explicit NaClApplication(const Arguments& arguments, std::nullptr_t): NaClApplication{arguments, NoCreate} {} - #endif - - /** @brief Copying is not allowed */ - NaClApplication(const NaClApplication&) = delete; - - /** @brief Moving is not allowed */ - NaClApplication(NaClApplication&&) = delete; - - /** @brief Copying is not allowed */ - NaClApplication& operator=(const NaClApplication&) = delete; - - /** @brief Moving is not allowed */ - NaClApplication& operator=(NaClApplication&&) = delete; - - protected: - /* Nobody will need to have (and delete) NaClApplication*, thus this is - faster than public pure virtual destructor */ - ~NaClApplication(); - - /** @copydoc Sdl2Application::createContext() */ - #ifdef DOXYGEN_GENERATING_OUTPUT - void createContext(const Configuration& configuration = Configuration()); - #else - /* To avoid "invalid use of incomplete type" */ - void createContext(const Configuration& configuration); - void createContext(); - #endif - - /** @copydoc Sdl2Application::tryCreateContext() */ - bool tryCreateContext(const Configuration& configuration); - - /** @{ @name Screen handling */ - - public: - /** @brief Whether the application runs fullscreen */ - bool isFullscreen(); - - /** - * @brief Set fullscreen - * @return `False` if switch to opposite mode is in progress or if the - * switch is not possible, `true` otherwise. - * - * The switch is done asynchronously, during the switch no event - * processing is done. - */ - bool setFullscreen(bool enabled); - - protected: - /** - * @brief Swap buffers - * - * Paints currently rendered framebuffer on screen. - */ - void swapBuffers(); - - /** @copydoc Sdl2Application::redraw() */ - void redraw() { _flags |= Flag::Redraw; } - - #ifdef DOXYGEN_GENERATING_OUTPUT - protected: - #else - private: - #endif - /** @copydoc Sdl2Application::viewportEvent() */ - virtual void viewportEvent(const Vector2i& size); - - /** @copydoc Sdl2Application::drawEvent() */ - virtual void drawEvent() = 0; - - /*@}*/ - - /** @{ @name Keyboard handling */ - - /** - * @brief Key press event - * - * Called when an key is pressed. Default implementation does nothing. - * If you accept the event, call @ref InputEvent::setAccepted() "setAccepted()" - * on it, otherwise the event will be propagated to the browser. - */ - virtual void keyPressEvent(KeyEvent& event); - - /** - * @brief Key release event - * - * Called when an key is released. Default implementation does nothing. - * If you accept the event, call @ref InputEvent::setAccepted() "setAccepted()" - * on it, otherwise the event will be propagated to the browser. - */ - virtual void keyReleaseEvent(KeyEvent& event); - - /*@}*/ - - /** @{ @name Mouse handling */ - - public: - /** @brief Whether mouse is locked */ - bool isMouseLocked() const { return _flags & Flag::MouseLocked; } - - /** - * @brief Enable or disable mouse locking - * - * When mouse is locked, the cursor is hidden and only - * @ref MouseMoveEvent::relativePosition() is changing, absolute - * position stays the same. - */ - void setMouseLocked(bool enabled); - - #ifdef DOXYGEN_GENERATING_OUTPUT - protected: - #else - private: - #endif - /** - * @brief Mouse press event - * - * Called when mouse button is pressed. Default implementation does - * nothing. If you accept the event, call @ref InputEvent::setAccepted() "setAccepted()" - * on it, otherwise the event will be propagated to the browser. - */ - virtual void mousePressEvent(MouseEvent& event); - - /** - * @brief Mouse release event - * - * Called when mouse button is released. Default implementation does - * nothing. If you accept the event, call @ref InputEvent::setAccepted() "setAccepted()" - * on it, otherwise the event will be propagated to the browser. - */ - virtual void mouseReleaseEvent(MouseEvent& event); - - /** - * @brief Mouse move event - * - * Called when mouse is moved. Default implementation does nothing. If - * you accept the event, call @ref InputEvent::setAccepted() "setAccepted()" - * on it, otherwise the event will be propagated to the browser. - */ - virtual void mouseMoveEvent(MouseMoveEvent& event); - - /** - * @brief Mouse scroll event - * - * Called when a scrolling device is used (mouse wheel or scrolling - * area on a touchpad). Default implementation does nothing. If you - * accept the event, call @ref InputEvent::setAccepted() "setAccepted()" - * on it, otherwise the event will be propagated to the browser. - */ - virtual void mouseScrollEvent(MouseScrollEvent& event); - - /*@}*/ - - private: - struct ConsoleDebugOutput; - - enum class Flag: UnsignedByte { - SwapInProgress = 1 << 0, - Redraw = 1 << 1, - FullscreenSwitchInProgress = 1 << 2, - WillBeFullscreen = 1 << 3, - MouseLocked = 1 << 4 - }; - typedef Containers::EnumSet Flags; - - void Graphics3DContextLost() override { - CORRADE_ASSERT(false, "NaClApplication: context unexpectedly lost", ); - } - - void MouseLockLost() override { - _flags &= ~Flag::MouseLocked; - } - - void DidChangeView(const pp::View& view) override; - - bool HandleInputEvent(const pp::InputEvent& event) override; - - static void swapCallback(void* applicationInstance, std::int32_t); - static void mouseLockCallback(void* applicationInstance, std::int32_t); - - std::unique_ptr _graphics; - std::unique_ptr _fullscreen; - Vector2i _viewportSize; - Flags _flags; - - std::unique_ptr _debugOutput; - std::unique_ptr _context; - - CORRADE_ENUMSET_FRIEND_OPERATORS(Flags) -}; - -/** -@brief Configuration - -Double-buffered RGBA canvas with depth and stencil buffers. -@see @ref NaClApplication(), @ref createContext(), @ref tryCreateContext() -*/ -class NaClApplication::Configuration { - public: - constexpr /*implicit*/ Configuration(): _size(640, 480), _sampleCount(0) {} - - /** - * @brief Set window title - * @return Reference to self (for method chaining) - * - * @note This function does nothing and is included only for - * compatibility with other toolkits. You need to set the title - * separately in application's HTML markup. - */ - template Configuration& setTitle(const T&) { return *this; } - - /** @brief Window size */ - Vector2i size() const { return _size; } - - /** - * @brief Set window size - * @return Reference to self (for method chaining) - * - * Default is `{640, 480}`. - */ - Configuration& setSize(const Vector2i& size) { - _size = size; - return *this; - } - - /** - * @brief Set context version - * - * @note This function does nothing and is included only for - * compatibility with other toolkits. @ref Version::GLES200 is - * always used. - */ - Configuration& setVersion(Version) { return *this; } - - /** @brief Sample count */ - Int sampleCount() const { return _sampleCount; } - - /** - * @brief Set sample count - * @return Reference to self (for method chaining) - * - * Default is `0`, thus no multisampling. See also - * @ref Renderer::Feature::Multisampling. - */ - Configuration& setSampleCount(Int count) { - _sampleCount = count; - return *this; - } - - private: - Vector2i _size; - Int _sampleCount; -}; - -/** -@brief Base for input events - -If you accept the event, call @ref setAccepted(), otherwise the event will be -propagated to the browser. -@see @ref KeyEvent, @ref MouseEvent, @ref MouseMoveEvent, @ref keyPressEvent(), - @ref keyReleaseEvent(), @ref mousePressEvent(), @ref mouseReleaseEvent(), - @ref mouseMoveEvent() -*/ -class NaClApplication::InputEvent { - public: - /** - * @brief Modifier - * - * @see @ref Modifiers, @ref modifiers() - * @todo AltGr + PP_INPUTEVENT_MODIFIER_ISKEYPAD, PP_INPUTEVENT_MODIFIER_ISAUTOREPEAT - */ - enum class Modifier: std::uint32_t { - Shift = PP_INPUTEVENT_MODIFIER_SHIFTKEY, /**< Shift */ - Ctrl = PP_INPUTEVENT_MODIFIER_CONTROLKEY, /**< Ctrl */ - Alt = PP_INPUTEVENT_MODIFIER_ALTKEY, /**< Alt */ - Meta = PP_INPUTEVENT_MODIFIER_METAKEY, /**< Meta */ - CapsLock = PP_INPUTEVENT_MODIFIER_CAPSLOCKKEY, /**< Caps lock */ - NumLock = PP_INPUTEVENT_MODIFIER_NUMLOCKKEY /**< Num lock */ - }; - - /** - * @brief Set of modifiers - * - * @see @ref modifiers() - */ - typedef Containers::EnumSet Modifiers; - - /** - * @brief Mouse button - * - * @see @ref Buttons, @ref buttons() - */ - enum class Button: std::uint32_t { - Left = PP_INPUTEVENT_MODIFIER_LEFTBUTTONDOWN, /**< Left button */ - Middle = PP_INPUTEVENT_MODIFIER_MIDDLEBUTTONDOWN, /**< Middle button */ - Right = PP_INPUTEVENT_MODIFIER_RIGHTBUTTONDOWN /**< Right button */ - }; - - /** - * @brief Set of mouse buttons - * - * @see @ref buttons() - */ - typedef Containers::EnumSet