Browse Source

Dropped NaCl support.

pull/217/head
Vladimír Vondruš 9 years ago
parent
commit
2145ae9b96
  1. 35
      CMakeLists.txt
  2. 2
      README.md
  3. 9
      doc/best-practices.dox
  4. 54
      doc/building.dox
  5. 6
      doc/changelog.dox
  6. 2
      doc/cmake.dox
  7. 2
      doc/mainpage.dox
  8. 1
      doc/opengl-support.dox
  9. 6
      doc/platform.dox
  10. 11
      modules/FindCorrade.cmake
  11. 9
      modules/FindMagnum.cmake
  12. 5
      modules/FindOpenGLES2.cmake
  13. 65
      package/archlinux/PKGBUILD-nacl-glibc
  14. 67
      package/archlinux/PKGBUILD-nacl-newlib
  15. 50
      src/Magnum/AbstractFramebuffer.cpp
  16. 2
      src/Magnum/AbstractFramebuffer.h
  17. 43
      src/Magnum/AbstractObject.cpp
  18. 12
      src/Magnum/AbstractQuery.cpp
  19. 85
      src/Magnum/AbstractShaderProgram.cpp
  20. 49
      src/Magnum/AbstractTexture.cpp
  21. 47
      src/Magnum/Buffer.cpp
  22. 83
      src/Magnum/Buffer.h
  23. 2
      src/Magnum/CMakeLists.txt
  24. 3
      src/Magnum/Context.cpp
  25. 6
      src/Magnum/Context.h
  26. 60
      src/Magnum/DebugOutput.cpp
  27. 4
      src/Magnum/Extensions.h
  28. 8
      src/Magnum/Framebuffer.cpp
  29. 41
      src/Magnum/Implementation/driverSpecific.cpp
  30. 2
      src/Magnum/Math/Complex.h
  31. 6
      src/Magnum/Math/Functions.h
  32. 2
      src/Magnum/Math/Test/FunctionsTest.cpp
  33. 78
      src/Magnum/Mesh.cpp
  34. 8
      src/Magnum/MeshView.cpp
  35. 10
      src/Magnum/OpenGL.h
  36. 17
      src/Magnum/OpenGLTester.h
  37. 78
      src/Magnum/Platform/CMakeLists.txt
  38. 2
      src/Magnum/Platform/Context.h
  39. 276
      src/Magnum/Platform/NaClApplication.cpp
  40. 821
      src/Magnum/Platform/NaClApplication.h
  41. 43
      src/Magnum/Platform/NaClApplication.js
  42. 1
      src/Magnum/Platform/Screen.h
  43. 1
      src/Magnum/Platform/ScreenedApplication.h
  44. 125
      src/Magnum/Platform/WindowlessNaClApplication.cpp
  45. 356
      src/Magnum/Platform/WindowlessNaClApplication.h
  46. 41
      src/Magnum/Platform/magnum-info-nacl.html
  47. 6
      src/Magnum/Platform/magnum-info-nacl.nmf
  48. 29
      src/Magnum/Platform/magnum-info.cpp
  49. 14
      src/Magnum/Renderbuffer.cpp
  50. 3
      src/Magnum/Renderbuffer.h
  51. 9
      src/Magnum/Renderer.cpp
  52. 12
      src/Magnum/Shader.cpp
  53. 29
      src/Magnum/Test/BufferGLTest.cpp
  54. 2
      src/Magnum/Text/CMakeLists.txt
  55. 22
      src/Magnum/Text/Renderer.cpp
  56. 6
      src/Magnum/Text/Renderer.h
  57. 7
      src/Magnum/Text/Test/RendererGLTest.cpp
  58. 2
      src/Magnum/Text/fontconverter.cpp
  59. 2
      src/Magnum/TextureTools/CMakeLists.txt
  60. 2
      src/Magnum/TextureTools/distancefieldconverter.cpp
  61. 2
      src/Magnum/TimeQuery.h
  62. 4
      src/Magnum/Timeline.h
  63. 10
      src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt
  64. 60
      src/MagnumExternal/OpenGL/GLES2/NaCl/flextGLNaCl.h.template
  65. 8
      src/MagnumExternal/OpenGL/GLES2/README.md
  66. 1989
      src/MagnumExternal/OpenGL/GLES2/flextGLNaCl.h
  67. 2
      src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt
  68. 3
      src/MagnumExternal/OpenGL/KHR/CMakeLists.txt

35
CMakeLists.txt

@ -51,9 +51,9 @@ find_package(Corrade REQUIRED PluginManager Utility)
include(CMakeDependentOption) include(CMakeDependentOption)
# If targeting iOS, Android, NaCl, Emscripten or Windows RT, set explicit # If targeting iOS, Android, Emscripten or Windows RT, set explicit OpenGL ES
# OpenGL ES support # 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(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) option(TARGET_GLES "Build for OpenGL ES / WebGL" OFF)
else() else()
set(TARGET_GLES ON) 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) 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) 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) # Magnum Info (currently only using GLX, CGL or WGL/EGL on Windows)
if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL OR CORRADE_TARGET_WINDOWS) if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS)
option(WITH_MAGNUMINFO "Build magnum-info utility" OFF) option(WITH_MAGNUMINFO "Build magnum-info utility" OFF)
endif() 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 # EGL context and windowless EGL application, available everywhere except on
# platforms which don't support extension loading # 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) 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) option(WITH_EGLCONTEXT "Build EglContext library" OFF)
endif() 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 # Android-specific application libraries
elseif(CORRADE_TARGET_ANDROID) if(CORRADE_TARGET_ANDROID)
option(WITH_ANDROIDAPPLICATION "Build AndroidApplication library" OFF) option(WITH_ANDROIDAPPLICATION "Build AndroidApplication library" OFF)
# iOS-specific application libraries # iOS-specific application libraries
@ -144,7 +139,7 @@ elseif(CORRADE_TARGET_WINDOWS)
endif() endif()
# Platform-independent (almost) application libraries # 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") option(WITH_GLFWAPPLICATION "Build GlfwApplication library")
cmake_dependent_option(WITH_GLUTAPPLICATION "Build GlutApplication library" OFF "NOT TARGET_GLES" OFF) cmake_dependent_option(WITH_GLUTAPPLICATION "Build GlutApplication library" OFF "NOT TARGET_GLES" OFF)
option(WITH_SDL2APPLICATION "Build Sdl2Application library" OFF) option(WITH_SDL2APPLICATION "Build Sdl2Application library" OFF)
@ -175,20 +170,12 @@ if(BUILD_TESTS)
endif() endif()
# OpenGLTester library, built by default only if GL tests are enabled # 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) cmake_dependent_option(WITH_OPENGLTESTER "Build OpenGLTester library" OFF "NOT BUILD_GL_TESTS" ON)
endif() endif()
# If targeting NaCl, set explicit OpenGL ES 2.0 support. For Android and # Dynamic linking is meaningless on Emscripten and too inconvenient on Android
# Emscripten the decision between ES 2.0 / WebGL 1.0 and ES 3.0 / WebGL 2.0 if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
# 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)
set(BUILD_STATIC ON) set(BUILD_STATIC ON)
set(BUILD_PLUGINS_STATIC ON) set(BUILD_PLUGINS_STATIC ON)
endif() endif()

2
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) * **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) * **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) * **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) * **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 FEATURES

9
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 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) - [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) - [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::setStencilFunction(), @ref Renderer::setStencilMask() and
@ref Renderer::setBlendFunction() documentation for more information. @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 @section best-practices-hw Hardware-specific
@subsection best-practices-intel Intel hardware @subsection best-practices-intel Intel hardware

54
doc/building.dox

@ -208,14 +208,12 @@ platform best:
- `WITH_GLFWAPPLICATION` - @ref Platform::GlfwApplication "GlfwApplication" - `WITH_GLFWAPPLICATION` - @ref Platform::GlfwApplication "GlfwApplication"
- `WITH_GLUTAPPLICATION` - @ref Platform::GlutApplication "GlutApplication" - `WITH_GLUTAPPLICATION` - @ref Platform::GlutApplication "GlutApplication"
- `WITH_GLXAPPLICATION` - @ref Platform::GlxApplication "GlxApplication" - `WITH_GLXAPPLICATION` - @ref Platform::GlxApplication "GlxApplication"
- `WITH_NACLAPPLICATION` - @ref Platform::NaClApplication "NaClApplication"
- `WITH_SDL2APPLICATION` - @ref Platform::Sdl2Application "Sdl2Application" - `WITH_SDL2APPLICATION` - @ref Platform::Sdl2Application "Sdl2Application"
- `WITH_XEGLAPPLICATION` - @ref Platform::XEglApplication "XEglApplication" - `WITH_XEGLAPPLICATION` - @ref Platform::XEglApplication "XEglApplication"
- `WITH_WINDOWLESSCGLAPPLICATION` - @ref Platform::WindowlessCglApplication "WindowlessCglApplication" - `WITH_WINDOWLESSCGLAPPLICATION` - @ref Platform::WindowlessCglApplication "WindowlessCglApplication"
- `WITH_WINDOWLESSEGLAPPLICATION` - @ref Platform::WindowlessEglApplication "WindowlessEglApplication" - `WITH_WINDOWLESSEGLAPPLICATION` - @ref Platform::WindowlessEglApplication "WindowlessEglApplication"
- `WITH_WINDOWLESSGLXAPPLICATION` - @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication" - `WITH_WINDOWLESSGLXAPPLICATION` - @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication"
- `WITH_WINDOWLESSIOSAPPLICATION` - @ref Platform::WindowlessIosApplication "WindowlessIosApplication" - `WITH_WINDOWLESSIOSAPPLICATION` - @ref Platform::WindowlessIosApplication "WindowlessIosApplication"
- `WITH_WINDOWLESSNACLAPPLICATION` - @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
- `WITH_WINDOWLESSWGLAPPLICATION` - @ref Platform::WindowlessWglApplication "WindowlessWglApplication" - `WITH_WINDOWLESSWGLAPPLICATION` - @ref Platform::WindowlessWglApplication "WindowlessWglApplication"
- `WITH_WINDOWLESSWINDOWSEGLAPPLICATION` - @ref Platform::WindowlessWindowsEglApplication "WindowlessWindowsEglApplication" - `WITH_WINDOWLESSWINDOWSEGLAPPLICATION` - @ref Platform::WindowlessWindowsEglApplication "WindowlessWindowsEglApplication"
@ -308,8 +306,8 @@ e.g.:
Platforms which have windowless GL context creation implemented (currently all Platforms which have windowless GL context creation implemented (currently all
platforms except @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten", platforms except @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten",
@ref CORRADE_TARGET_NACL "NaCl", @ref CORRADE_TARGET_WINDOWS_RT "Windows RT" @ref CORRADE_TARGET_WINDOWS_RT "Windows RT" and
and @ref CORRADE_TARGET_ANDROID "Android") can build also tests for OpenGL @ref CORRADE_TARGET_ANDROID "Android") can build also tests for OpenGL
functionality. You can enable them with `BUILD_GL_TESTS`. All GL tests are 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 suffixed with `GLTest` so they can be also selectively included/excluded when
running CTest, e.g.: 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 Then you can install the package using `cmake --build . --target install` to
make it available for depending projects. 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 @subsection building-cross-emscripten Crosscompiling for Emscripten
You will need [Emscripten](https://github.com/kripken/emscripten/wiki/Tutorial) You will need [Emscripten](https://github.com/kripken/emscripten/wiki/Tutorial)

6
doc/changelog.dox

@ -33,6 +33,7 @@ namespace Magnum {
## De­pen­den­cy changes ## 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) - Dropped support for the old MinGW32 (only MinGW-w64 is supported now)
- Bumped minimal CMake version to 2.8.12 - Bumped minimal CMake version to 2.8.12
- Removed support for macOS 10.8 and older - Removed support for macOS 10.8 and older
@ -223,8 +224,7 @@ namespace Magnum {
classes that manage OpenGL context to make threaded context creation classes that manage OpenGL context to make threaded context creation
possible possible
- First-class support for scroll events in - First-class support for scroll events in
@ref Platform::Sdl2Application::MouseScrollEvent and @ref Platform::Sdl2Application::MouseScrollEvent
@ref Platform::NaClApplication::MouseScrollEvent
- Added @ref Platform::Sdl2Application::MouseEvent::clickCount() - Added @ref Platform::Sdl2Application::MouseEvent::clickCount()
- Added @ref Platform::Sdl2Application::multiGestureEvent() - Added @ref Platform::Sdl2Application::multiGestureEvent()
- Exposing key repeat in - Exposing key repeat in
@ -414,7 +414,7 @@ namespace Magnum {
- Fixed WebGL context creation on Internet Explorer, it claims to have - Fixed WebGL context creation on Internet Explorer, it claims to have
version 0.94 version 0.94
- Fixed random browser-specific issues by avoiding the use of XHTML in - 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 - @ref Trade::ObjImporter "ObjImporter" plugin now opens the files as binary
to avoid line ending issues to avoid line ending issues
- Various compatibility updates to the @ref Shaders library - Various compatibility updates to the @ref Shaders library

2
doc/cmake.dox

@ -102,14 +102,12 @@ Platform namespace is split into more components:
- `GlfwApplication` -- @ref Platform::GlfwApplication "GlfwApplication" - `GlfwApplication` -- @ref Platform::GlfwApplication "GlfwApplication"
- `GlutApplication` -- @ref Platform::GlutApplication "GlutApplication" - `GlutApplication` -- @ref Platform::GlutApplication "GlutApplication"
- `GlxApplication` -- @ref Platform::GlxApplication "GlxApplication" - `GlxApplication` -- @ref Platform::GlxApplication "GlxApplication"
- `NaClApplication` -- @ref Platform::NaClApplication "NaClApplication"
- `Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application" - `Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application"
- `XEglApplication` -- @ref Platform::XEglApplication "XEglApplication" - `XEglApplication` -- @ref Platform::XEglApplication "XEglApplication"
- `WindowlessCglApplication` -- @ref Platform::WindowlessCglApplication "WindowlessCglApplication" - `WindowlessCglApplication` -- @ref Platform::WindowlessCglApplication "WindowlessCglApplication"
- `WindowlessEglApplication` -- @ref Platform::WindowlessEglApplication "WindowlessEglApplication" - `WindowlessEglApplication` -- @ref Platform::WindowlessEglApplication "WindowlessEglApplication"
- `WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication" - `WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication"
- `WindowlessIosApplication` -- @ref Platform::WindowlessIosApplication "WindowlessIosApplication" - `WindowlessIosApplication` -- @ref Platform::WindowlessIosApplication "WindowlessIosApplication"
- `WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
- `WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication" - `WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication"
- `WindowlessWindowsEglApplication` -- @ref Platform::WindowlessWindowsEglApplication "WindowlessWindowsEglApplication" - `WindowlessWindowsEglApplication` -- @ref Platform::WindowlessWindowsEglApplication "WindowlessWindowsEglApplication"

2
doc/mainpage.dox

@ -82,8 +82,6 @@ Platforms:
- **OS X**, **iOS** (through SDL2 or GLFW toolkit) - **OS X**, **iOS** (through SDL2 or GLFW toolkit)
- **Android** 2.3 (API Level 9) and higher - **Android** 2.3 (API Level 9) and higher
- **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit) - **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)) - **HTML5/JavaScript** (through [Emscripten](https://github.com/kripken/emscripten/wiki))
@section mainpage-features Features @section mainpage-features Features

1
doc/opengl-support.dox

@ -351,7 +351,6 @@ Extension | Status
@extension{APPLE,texture_format_BGRA8888} | done @extension{APPLE,texture_format_BGRA8888} | done
@extension{ARM,shader_framebuffer_fetch} | missing renderer setup and limit query @extension{ARM,shader_framebuffer_fetch} | missing renderer setup and limit query
@extension{ARM,shader_framebuffer_fetch_depth_stencil} | done (shading language only) @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_filter_anisotropic} | done
@extension{EXT,texture_format_BGRA8888} | done @extension{EXT,texture_format_BGRA8888} | done
@extension{EXT,read_format_bgra} | done @extension{EXT,read_format_bgra} | done

6
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: These platform-specific libraries are available:
- `CglContext` -- CGL context (Mac OS X) - `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) - `GlxContext` -- GLX context (X11-based Unix)
- `WglContext` -- WGL context (Windows) - `WglContext` -- WGL context (Windows)
Systems not listed here (such as Emscripten or NaCl) don't need any `Context` Systems not listed here (such as Emscripten) don't need any `Context` library,
library, because dynamic function pointer loading is not available on these. because dynamic function pointer loading is not available on these.
For example, when you create the OpenGL context using GLX, you need to find For example, when you create the OpenGL context using GLX, you need to find
`GlxContext` component, and link to `Magnum::GlxContext` target. Similarly to `GlxContext` component, and link to `Magnum::GlxContext` target. Similarly to

11
modules/FindCorrade.cmake

@ -80,12 +80,6 @@
# CORRADE_TARGET_IOS_SIMULATOR - Defined if compiled for iOS Simulator # CORRADE_TARGET_IOS_SIMULATOR - Defined if compiled for iOS Simulator
# CORRADE_TARGET_WINDOWS - Defined if compiled for Windows # CORRADE_TARGET_WINDOWS - Defined if compiled for Windows
# CORRADE_TARGET_WINDOWS_RT - Defined if compiled for Windows RT # 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_EMSCRIPTEN - Defined if compiled for Emscripten
# CORRADE_TARGET_ANDROID - Defined if compiled for Android # CORRADE_TARGET_ANDROID - Defined if compiled for Android
# CORRADE_TESTSUITE_TARGET_XCTEST - Defined if TestSuite is targetting Xcode # CORRADE_TESTSUITE_TARGET_XCTEST - Defined if TestSuite is targetting Xcode
@ -294,9 +288,6 @@ set(_corradeFlags
TARGET_IOS_SIMULATOR TARGET_IOS_SIMULATOR
TARGET_WINDOWS TARGET_WINDOWS
TARGET_WINDOWS_RT TARGET_WINDOWS_RT
TARGET_NACL
TARGET_NACL_NEWLIB
TARGET_NACL_GLIBC
TARGET_EMSCRIPTEN TARGET_EMSCRIPTEN
TARGET_ANDROID TARGET_ANDROID
TESTSUITE_TARGET_XCTEST TESTSUITE_TARGET_XCTEST
@ -415,7 +406,7 @@ foreach(_component ${Corrade_FIND_COMPONENTS})
# PluginManager library # PluginManager library
if(_component STREQUAL PluginManager) if(_component STREQUAL PluginManager)
# At least static build needs this # 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 set_property(TARGET Corrade::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}) INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
endif() endif()

9
modules/FindMagnum.cmake

@ -53,14 +53,12 @@
# GlfwApplication - GLFW application # GlfwApplication - GLFW application
# GlutApplication - GLUT application # GlutApplication - GLUT application
# GlxApplication - GLX application # GlxApplication - GLX application
# NaClApplication - NaCl application
# Sdl2Application - SDL2 application # Sdl2Application - SDL2 application
# XEglApplication - X/EGL application # XEglApplication - X/EGL application
# WindowlessCglApplication - Windowless CGL application # WindowlessCglApplication - Windowless CGL application
# WindowlessEglApplication - Windowless EGL application # WindowlessEglApplication - Windowless EGL application
# WindowlessGlxApplication - Windowless GLX application # WindowlessGlxApplication - Windowless GLX application
# WindowlessIosApplication - Windowless iOS application # WindowlessIosApplication - Windowless iOS application
# WindowlessNaClApplication - Windowless NaCl application
# WindowlessWglApplication - Windowless WGL application # WindowlessWglApplication - Windowless WGL application
# WindowlessWindowsEglApplication - Windowless Windows/EGL application # WindowlessWindowsEglApplication - Windowless Windows/EGL application
# CglContext - CGL context # CglContext - CGL context
@ -389,7 +387,7 @@ endif()
# Component distinction (listing them explicitly to avoid mistakes with finding # Component distinction (listing them explicitly to avoid mistakes with finding
# components from other repositories) # 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_PLUGIN_COMPONENTS "^(MagnumFont|MagnumFontConverter|ObjImporter|TgaImageConverter|TgaImporter|WavAudioImporter)$")
set(_MAGNUM_EXECUTABLE_COMPONENTS "^(distancefieldconverter|fontconverter|imageconverter|info|al-info)$") 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 set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES SDL2::SDL2) 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 # (Windowless) GLX application dependencies
elseif(_component STREQUAL GlxApplication OR _component STREQUAL WindowlessGlxApplication) elseif(_component STREQUAL GlxApplication OR _component STREQUAL WindowlessGlxApplication)
find_package(X11) find_package(X11)

5
modules/FindOpenGLES2.cmake

@ -48,10 +48,7 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN)
libGLESv2 libGLESv2
# iOS # iOS
OpenGLES OpenGLES)
# NaCl
ppapi_gles2)
set(OPENGLES2_LIBRARY_NEEDED OPENGLES2_LIBRARY) set(OPENGLES2_LIBRARY_NEEDED OPENGLES2_LIBRARY)
endif() endif()

65
package/archlinux/PKGBUILD-nacl-glibc

@ -1,65 +0,0 @@
# Author: mosra <mosra@centrum.cz>
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
}

67
package/archlinux/PKGBUILD-nacl-newlib

@ -1,67 +0,0 @@
# Author: mosra <mosra@centrum.cz>
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
}

50
src/Magnum/AbstractFramebuffer.cpp

@ -233,35 +233,15 @@ void AbstractFramebuffer::blitImplementationDSA(AbstractFramebuffer& source, Abs
#elif !defined(MAGNUM_TARGET_WEBGL) #elif !defined(MAGNUM_TARGET_WEBGL)
void AbstractFramebuffer::blitImplementationANGLE(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) { 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); source.bindInternal(FramebufferTarget::Read);
destination.bindInternal(FramebufferTarget::Draw); 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)); glBlitFramebufferANGLE(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
#else
static_cast<void>(source);
static_cast<void>(destination);
static_cast<void>(sourceRectangle);
static_cast<void>(destinationRectangle);
static_cast<void>(mask);
static_cast<void>(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) { 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); source.bindInternal(FramebufferTarget::Read);
destination.bindInternal(FramebufferTarget::Draw); 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)); glBlitFramebufferNV(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
#else
static_cast<void>(source);
static_cast<void>(destination);
static_cast<void>(sourceRectangle);
static_cast<void>(destinationRectangle);
static_cast<void>(mask);
static_cast<void>(filter);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -441,7 +421,7 @@ void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum* co
void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments) { void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glInvalidateFramebuffer(GLenum(bindInternal()), count, attachments); glInvalidateFramebuffer(GLenum(bindInternal()), count, attachments);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #elif !defined(CORRADE_TARGET_EMSCRIPTEN)
glDiscardFramebufferEXT(GLenum(bindInternal()), count, attachments); glDiscardFramebufferEXT(GLenum(bindInternal()), count, attachments);
#else #else
static_cast<void>(count); static_cast<void>(count);
@ -513,27 +493,13 @@ void AbstractFramebuffer::drawBuffersImplementationDSAEXT(GLsizei count, const G
#else #else
void AbstractFramebuffer::drawBuffersImplementationEXT(GLsizei count, const GLenum* buffers) { void AbstractFramebuffer::drawBuffersImplementationEXT(GLsizei count, const GLenum* buffers) {
bindInternal(FramebufferTarget::Draw); bindInternal(FramebufferTarget::Draw);
#ifndef CORRADE_TARGET_NACL
glDrawBuffersEXT(count, buffers); glDrawBuffersEXT(count, buffers);
#else
static_cast<void>(count);
static_cast<void>(buffers);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractFramebuffer::drawBuffersImplementationNV(GLsizei count, const GLenum* buffers) { void AbstractFramebuffer::drawBuffersImplementationNV(GLsizei count, const GLenum* buffers) {
bindInternal(FramebufferTarget::Draw); bindInternal(FramebufferTarget::Draw);
#ifndef CORRADE_TARGET_NACL
glDrawBuffersNV(count, buffers); glDrawBuffersNV(count, buffers);
#else
static_cast<void>(count);
static_cast<void>(buffers);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
#endif #endif
@ -561,11 +527,8 @@ void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glReadBuffer(buffer); glReadBuffer(buffer);
#elif !defined(CORRADE_TARGET_NACL)
glReadBufferNV(buffer);
#else #else
static_cast<void>(buffer); glReadBufferNV(buffer);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
#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) { void AbstractFramebuffer::readImplementationRobustness(const Range2Di& rectangle, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glReadnPixelsARB(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), dataSize, data); 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 #else
static_cast<void>(rectangle); glReadnPixelsEXT(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), dataSize, data);
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(dataSize);
static_cast<void>(data);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
#endif #endif

2
src/Magnum/AbstractFramebuffer.h

@ -237,8 +237,6 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @requires_gles30 Extension @extension{ANGLE,framebuffer_blit} or * @requires_gles30 Extension @extension{ANGLE,framebuffer_blit} or
* @extension{NV,framebuffer_blit} in OpenGL ES 2.0. * @extension{NV,framebuffer_blit} in OpenGL ES 2.0.
* @requires_webgl20 Framebuffer blit is not available in WebGL 1.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); static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);

43
src/Magnum/AbstractObject.cpp

@ -39,7 +39,6 @@
namespace Magnum { namespace Magnum {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
#ifndef CORRADE_TARGET_NACL
namespace { namespace {
inline GLenum extTypeFromKhrIdentifier(GLenum khrIdentifier) { inline GLenum extTypeFromKhrIdentifier(GLenum khrIdentifier) {
switch(khrIdentifier) { switch(khrIdentifier) {
@ -89,13 +88,10 @@ namespace {
/** /**
* @todo Shouldn't ES2's KHR_debug have `GL_TRANSFORM_FEEDBACK_KHR` * @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) * instead of `GL_TRANSFORM_FEEDBACK`? (it's a new enum in 2.0)
* NaCl extension header doesn't have it at all. Also the * Also the original @extension{EXT,debug_label} mentions it
* original @extension{EXT,debug_label} mentions it only * only for ES3 (i.e. no mention of @extension{EXT,transform_feedback})
* for ES3 (i.e. no mention of @extension{EXT,transform_feedback})
*/ */
#ifndef CORRADE_TARGET_NACL
case GL_TRANSFORM_FEEDBACK: case GL_TRANSFORM_FEEDBACK:
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case GL_SAMPLER: case GL_SAMPLER:
#else #else
@ -110,7 +106,6 @@ namespace {
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
} }
} }
#endif
Int AbstractObject::maxLabelLength() { Int AbstractObject::maxLabelLength() {
if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>()) if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>())
@ -134,26 +129,14 @@ void AbstractObject::labelImplementationNoOp(GLenum, GLuint, Containers::ArrayVi
void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const Containers::ArrayView<const char> label) { void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const Containers::ArrayView<const char> label) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glObjectLabel(identifier, name, label.size(), label); glObjectLabel(identifier, name, label.size(), label);
#elif !defined(CORRADE_TARGET_NACL)
glObjectLabelKHR(identifier, name, label.size(), label);
#else #else
static_cast<void>(identifier); glObjectLabelKHR(identifier, name, label.size(), label);
static_cast<void>(name);
static_cast<void>(label);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const Containers::ArrayView<const char> label) { void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const Containers::ArrayView<const char> label) {
#ifndef CORRADE_TARGET_NACL
const GLenum type = extTypeFromKhrIdentifier(identifier); const GLenum type = extTypeFromKhrIdentifier(identifier);
glLabelObjectEXT(type, name, label.size(), label); glLabelObjectEXT(type, name, label.size(), label);
#else
static_cast<void>(identifier);
static_cast<void>(name);
static_cast<void>(label);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
std::string AbstractObject::getLabelImplementationNoOp(GLenum, GLuint) { return {}; } std::string AbstractObject::getLabelImplementationNoOp(GLenum, GLuint) { return {}; }
@ -164,12 +147,8 @@ std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, c
GLsizei size = 0; GLsizei size = 0;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glGetObjectLabel(identifier, name, maxLabelLength(), &size, nullptr); glGetObjectLabel(identifier, name, maxLabelLength(), &size, nullptr);
#elif !defined(CORRADE_TARGET_NACL)
glGetObjectLabelKHR(identifier, name, maxLabelLength(), &size, nullptr);
#else #else
static_cast<void>(identifier); glGetObjectLabelKHR(identifier, name, maxLabelLength(), &size, nullptr);
static_cast<void>(name);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
/* Make place also for the null terminator */ /* Make place also for the null terminator */
@ -177,10 +156,8 @@ std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, c
label.resize(size+1); label.resize(size+1);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glGetObjectLabel(identifier, name, size+1, nullptr, &label[0]); glGetObjectLabel(identifier, name, size+1, nullptr, &label[0]);
#elif !defined(CORRADE_TARGET_NACL)
glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]);
#endif #endif
/* Pop null terminator and return the string */ /* Pop null terminator and return the string */
@ -192,23 +169,13 @@ std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, c
GLsizei size = 0; GLsizei size = 0;
/* Get label size (w/o null terminator) */ /* Get label size (w/o null terminator) */
#ifndef CORRADE_TARGET_NACL
const GLenum type = extTypeFromKhrIdentifier(identifier); const GLenum type = extTypeFromKhrIdentifier(identifier);
glGetObjectLabelEXT(type, name, 0, &size, nullptr); glGetObjectLabelEXT(type, name, 0, &size, nullptr);
#else
static_cast<void>(identifier);
static_cast<void>(name);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
/* Make place also for the null terminator */ /* Make place also for the null terminator */
std::string label; std::string label;
label.resize(size+1); label.resize(size+1);
#ifndef CORRADE_TARGET_NACL
glGetObjectLabelEXT(type, name, size+1, nullptr, &label[0]); glGetObjectLabelEXT(type, name, size+1, nullptr, &label[0]);
#else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
/* Pop null terminator and return the string */ /* Pop null terminator and return the string */
label.resize(size); label.resize(size);

12
src/Magnum/AbstractQuery.cpp

@ -123,10 +123,8 @@ template<> Int AbstractQuery::result<Int>() {
Int result; Int result;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glGetQueryObjectiv(_id, GL_QUERY_RESULT, &result); glGetQueryObjectiv(_id, GL_QUERY_RESULT, &result);
#elif !defined(CORRADE_TARGET_NACL)
glGetQueryObjectivEXT(_id, GL_QUERY_RESULT_EXT, &result);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glGetQueryObjectivEXT(_id, GL_QUERY_RESULT_EXT, &result);
#endif #endif
return result; return result;
} }
@ -135,10 +133,8 @@ template<> UnsignedLong AbstractQuery::result<UnsignedLong>() {
UnsignedLong result; UnsignedLong result;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glGetQueryObjectui64v(_id, GL_QUERY_RESULT, &result); glGetQueryObjectui64v(_id, GL_QUERY_RESULT, &result);
#elif !defined(CORRADE_TARGET_NACL)
glGetQueryObjectui64vEXT(_id, GL_QUERY_RESULT_EXT, &result);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glGetQueryObjectui64vEXT(_id, GL_QUERY_RESULT_EXT, &result);
#endif #endif
return result; return result;
} }
@ -147,10 +143,8 @@ template<> Long AbstractQuery::result<Long>() {
Long result; Long result;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glGetQueryObjecti64v(_id, GL_QUERY_RESULT, &result); glGetQueryObjecti64v(_id, GL_QUERY_RESULT, &result);
#elif !defined(CORRADE_TARGET_NACL)
glGetQueryObjecti64vEXT(_id, GL_QUERY_RESULT_EXT, &result);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glGetQueryObjecti64vEXT(_id, GL_QUERY_RESULT_EXT, &result);
#endif #endif
return result; return result;
} }

85
src/Magnum/AbstractShaderProgram.cpp

@ -38,7 +38,7 @@
#include "Implementation/ShaderProgramState.h" #include "Implementation/ShaderProgramState.h"
#include "Implementation/State.h" #include "Implementation/State.h"
#if defined(CORRADE_TARGET_NACL_NEWLIB) || defined(CORRADE_TARGET_ANDROID) #ifdef CORRADE_TARGET_ANDROID
#include <sstream> #include <sstream>
#endif #endif
@ -420,7 +420,7 @@ bool AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<Ab
message.resize(std::max(logLength, 1)-1); message.resize(std::max(logLength, 1)-1);
/** @todo Remove when this is fixed everywhere (also the include above) */ /** @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; std::ostringstream converter;
converter << i; converter << i;
#endif #endif
@ -430,7 +430,7 @@ bool AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<Ab
Error out{Debug::Flag::NoNewlineAtTheEnd}; Error out{Debug::Flag::NoNewlineAtTheEnd};
out << "AbstractShaderProgram::link(): linking"; out << "AbstractShaderProgram::link(): linking";
if(shaders.size() != 1) { if(shaders.size() != 1) {
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) #ifndef CORRADE_TARGET_ANDROID
out << "of shader" << std::to_string(i); out << "of shader" << std::to_string(i);
#else #else
out << "of shader" << converter.str(); out << "of shader" << converter.str();
@ -443,7 +443,7 @@ bool AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<Ab
Warning out{Debug::Flag::NoNewlineAtTheEnd}; Warning out{Debug::Flag::NoNewlineAtTheEnd};
out << "AbstractShaderProgram::link(): linking"; out << "AbstractShaderProgram::link(): linking";
if(shaders.size() != 1) { if(shaders.size() != 1) {
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) #ifndef CORRADE_TARGET_ANDROID
out << "of shader" << std::to_string(i); out << "of shader" << std::to_string(i);
#else #else
out << "of shader" << converter.str(); out << "of shader" << converter.str();
@ -493,14 +493,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const GLfloat* const values) { void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const GLfloat* const values) {
#ifndef CORRADE_TARGET_NACL
glProgramUniform1fvEXT(_id, location, count, values); glProgramUniform1fvEXT(_id, location, count, values);
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -521,14 +514,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) { 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()); glProgramUniform2fvEXT(_id, location, count, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -549,14 +535,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) { 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()); glProgramUniform3fvEXT(_id, location, count, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -577,14 +556,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) { 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()); glProgramUniform4fvEXT(_id, location, count, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -605,14 +577,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const GLint* const values) { void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const GLint* const values) {
#ifndef CORRADE_TARGET_NACL
glProgramUniform1ivEXT(_id, location, count, values); glProgramUniform1ivEXT(_id, location, count, values);
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -633,14 +598,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) { 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()); glProgramUniform2ivEXT(_id, location, count, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -661,14 +619,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) { 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()); glProgramUniform3ivEXT(_id, location, count, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -689,14 +640,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) { 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()); glProgramUniform4ivEXT(_id, location, count, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -865,14 +809,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) { 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()); glProgramUniformMatrix2fvEXT(_id, location, count, GL_FALSE, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -893,14 +830,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) { 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()); glProgramUniformMatrix3fvEXT(_id, location, count, GL_FALSE, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -921,14 +851,7 @@ void AbstractShaderProgram::uniformImplementationSSO(const GLint location, const
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) { 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()); glProgramUniformMatrix4fvEXT(_id, location, count, GL_FALSE, values[0].data());
#else
static_cast<void>(location);
static_cast<void>(count);
static_cast<void>(values);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif

49
src/Magnum/AbstractTexture.cpp

@ -1280,13 +1280,8 @@ void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat
bindInternal(); bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glTexStorage2D(_target, levels, GLenum(internalFormat), size.x(), size.y()); glTexStorage2D(_target, levels, GLenum(internalFormat), size.x(), size.y());
#elif !defined(CORRADE_TARGET_NACL)
glTexStorage2DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y());
#else #else
static_cast<void>(levels); glTexStorage2DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y());
static_cast<void>(internalFormat);
static_cast<void>(size);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
#endif #endif
@ -1351,13 +1346,8 @@ void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat
bindInternal(); bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glTexStorage3D(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); 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 #else
static_cast<void>(levels); glTexStorage3DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
static_cast<void>(internalFormat);
static_cast<void>(size);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
#endif #endif
@ -1569,22 +1559,12 @@ void AbstractTexture::compressedSubImageImplementationDSAEXT(GLint level, const
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #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&) { void AbstractTexture::imageImplementationDefault(GLint level, TextureFormat internalFormat, const Vector3i& size, PixelFormat format, PixelType type, const GLvoid* data, const PixelStorage&) {
bindInternal(); bindInternal();
#ifndef CORRADE_TARGET_NACL
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glTexImage3D glTexImage3D
#else #else
glTexImage3DOES glTexImage3DOES
#endif #endif
(_target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data); (_target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
#else
static_cast<void>(level);
static_cast<void>(internalFormat);
static_cast<void>(size);
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(data);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
@ -1616,16 +1596,8 @@ void AbstractTexture::subImage3DImplementationDefault(GLint level, const Vector3
bindInternal(); bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); 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 #else
static_cast<void>(level); glTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
static_cast<void>(offset);
static_cast<void>(size);
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(data);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
@ -1660,15 +1632,8 @@ void AbstractTexture::compressedSubImageImplementationDefault(const GLint level,
bindInternal(); bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glCompressedTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data); 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 #else
static_cast<void>(level); glCompressedTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), dataSize, data);
static_cast<void>(offset);
static_cast<void>(size);
static_cast<void>(format);
static_cast<void>(data);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
#endif #endif
@ -2179,12 +2144,8 @@ void AbstractTexture::DataHelper<3>::setCompressedImage(AbstractTexture& texture
texture.bindInternal(); texture.bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #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()); 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 #else
static_cast<void>(level); 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());
static_cast<void>(image);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
#endif #endif

47
src/Magnum/Buffer.cpp

@ -186,11 +186,7 @@ void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const
} }
#endif #endif
Buffer::Buffer(const TargetHint targetHint): _targetHint{targetHint}, _flags{ObjectFlag::DeleteOnDestruction} Buffer::Buffer(const TargetHint targetHint): _targetHint{targetHint}, _flags{ObjectFlag::DeleteOnDestruction} {
#ifdef CORRADE_TARGET_NACL
, _mappedBuffer{nullptr}
#endif
{
(this->*Context::current().state().buffer->createImplementation)(); (this->*Context::current().state().buffer->createImplementation)();
CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding);
} }
@ -290,10 +286,8 @@ auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint {
if(currentVAO != 0) { if(currentVAO != 0) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glBindVertexArray(currentVAO = 0); glBindVertexArray(currentVAO = 0);
#elif !defined(CORRADE_TARGET_NACL)
glBindVertexArrayOES(currentVAO = 0);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glBindVertexArrayOES(currentVAO = 0);
#endif #endif
} }
} }
@ -372,13 +366,6 @@ char* Buffer::map(const MapAccess access) {
return static_cast<char*>((this->*Context::current().state().buffer->mapImplementation)(access)); return static_cast<char*>((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<char> Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) { Containers::ArrayView<char> Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) {
return {static_cast<char*>((this->*Context::current().state().buffer->mapRangeImplementation)(offset, length, flags)), std::size_t(length)}; return {static_cast<char*>((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)(); } 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 #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -570,11 +549,8 @@ void Buffer::invalidateSubImplementationARB(GLintptr offset, GLsizeiptr length)
void* Buffer::mapImplementationDefault(MapAccess access) { void* Buffer::mapImplementationDefault(MapAccess access) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
return glMapBuffer(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access)); return glMapBuffer(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access));
#elif !defined(CORRADE_TARGET_NACL)
return glMapBufferOES(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access));
#else #else
static_cast<void>(access); return glMapBufferOES(GLenum(bindSomewhereInternal(_targetHint)), GLenum(access));
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
@ -592,13 +568,8 @@ void* Buffer::mapImplementationDSAEXT(MapAccess access) {
void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) { void* Buffer::mapRangeImplementationDefault(GLintptr offset, GLsizeiptr length, MapFlags access) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return glMapBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access)); return glMapBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access));
#elif !defined(CORRADE_TARGET_NACL)
return glMapBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access));
#else #else
static_cast<void>(offset); return glMapBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length, GLenum(access));
static_cast<void>(length);
static_cast<void>(access);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
@ -616,12 +587,8 @@ void* Buffer::mapRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr length, M
void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) { void Buffer::flushMappedRangeImplementationDefault(GLintptr offset, GLsizeiptr length) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glFlushMappedBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length); glFlushMappedBufferRange(GLenum(bindSomewhereInternal(_targetHint)), offset, length);
#elif !defined(CORRADE_TARGET_NACL)
glFlushMappedBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length);
#else #else
static_cast<void>(offset); glFlushMappedBufferRangeEXT(GLenum(bindSomewhereInternal(_targetHint)), offset, length);
static_cast<void>(length);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
@ -639,10 +606,8 @@ void Buffer::flushMappedRangeImplementationDSAEXT(GLintptr offset, GLsizeiptr le
bool Buffer::unmapImplementationDefault() { bool Buffer::unmapImplementationDefault() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
return glUnmapBuffer(GLenum(bindSomewhereInternal(_targetHint))); return glUnmapBuffer(GLenum(bindSomewhereInternal(_targetHint)));
#elif !defined(CORRADE_TARGET_NACL)
return glUnmapBufferOES(GLenum(bindSomewhereInternal(_targetHint)));
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ return glUnmapBufferOES(GLenum(bindSomewhereInternal(_targetHint)));
#endif #endif
} }

83
src/Magnum/Buffer.h

@ -188,22 +188,21 @@ for(std::size_t i: {7, 27, 56, 128}) {
CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap()); CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
@endcode @endcode
## WebGL and NaCl restrictions ## WebGL restrictions
Buffers in @ref MAGNUM_TARGET_WEBGL "WebGL" and @ref CORRADE_TARGET_NACL "NaCl" Buffers in @ref MAGNUM_TARGET_WEBGL "WebGL" need to be bound only to one unique
need to be bound only to one unique target, i.e., @ref Buffer bound to target, i.e., @ref Buffer bound to @ref Buffer::Target::Array cannot be later
@ref Buffer::Target::Array cannot be later rebound to rebound to @ref Buffer::Target::ElementArray. However, Magnum by default uses
@ref Buffer::Target::ElementArray. However, Magnum by default uses any any sufficient target when binding the buffer internally (e.g. for setting
sufficient target when binding the buffer internally (e.g. for setting data). data). To avoid GL errors, set target hint to desired target, either in
To avoid GL errors, set target hint to desired target, either in constructor or constructor or using @ref Buffer::setTargetHint():
using @ref Buffer::setTargetHint():
@code @code
Buffer vertices{Buffer::Target::Array}; Buffer vertices{Buffer::Target::Array};
Buffer indices{Buffer::Target::ElementArray}; Buffer indices{Buffer::Target::ElementArray};
@endcode @endcode
To ease up the development, @ref Mesh checks proper target hint when adding 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 ## Performance optimizations
@ -1238,33 +1237,6 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
} }
#endif #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<class T> T* mapSub(GLintptr offset, GLsizeiptr length, MapAccess access) {
return static_cast<T*>(mapSub(offset, length, access));
}
#endif
/** /**
* @brief Map buffer to client memory * @brief Map buffer to client memory
* @param offset Byte offset into the buffer * @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. * @requires_gles Buffer mapping is not available in WebGL.
*/ */
bool unmap(); 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 #endif
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
@ -1480,9 +1437,6 @@ class MAGNUM_EXPORT Buffer: public AbstractObject {
GLuint _id; GLuint _id;
TargetHint _targetHint; TargetHint _targetHint;
#ifdef CORRADE_TARGET_NACL
void* _mappedBuffer;
#endif
ObjectFlags _flags; ObjectFlags _flags;
}; };
@ -1498,31 +1452,16 @@ MAGNUM_EXPORT Debug& operator<<(Debug& debug, Buffer::TargetHint value);
MAGNUM_EXPORT Debug& operator<<(Debug& debug, Buffer::Target value); MAGNUM_EXPORT Debug& operator<<(Debug& debug, Buffer::Target value);
#endif #endif
inline Buffer::Buffer(NoCreateT) noexcept: _id{0}, _targetHint{TargetHint::Array}, _flags{ObjectFlag::DeleteOnDestruction} inline Buffer::Buffer(NoCreateT) noexcept: _id{0}, _targetHint{TargetHint::Array}, _flags{ObjectFlag::DeleteOnDestruction} {}
#ifdef CORRADE_TARGET_NACL
, _mappedBuffer{nullptr}
#endif
{}
inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint}, inline Buffer::Buffer(Buffer&& other) noexcept: _id{other._id}, _targetHint{other._targetHint}, _flags{other._flags} {
#ifdef CORRADE_TARGET_NACL
_mappedBuffer{other._mappedBuffer},
#endif
_flags{other._flags}
{
other._id = 0; other._id = 0;
#ifdef CORRADE_TARGET_NACL
other._mappedBuffer = nullptr;
#endif
} }
inline Buffer& Buffer::operator=(Buffer&& other) noexcept { inline Buffer& Buffer::operator=(Buffer&& other) noexcept {
using std::swap; using std::swap;
swap(_id, other._id); swap(_id, other._id);
swap(_targetHint, other._targetHint); swap(_targetHint, other._targetHint);
#ifdef CORRADE_TARGET_NACL
swap(_mappedBuffer, other._mappedBuffer);
#endif
swap(_flags, other._flags); swap(_flags, other._flags);
return *this; return *this;
} }

2
src/Magnum/CMakeLists.txt

@ -221,7 +221,7 @@ if(NOT (TARGET_WEBGL AND TARGET_GLES2))
endif() endif()
# Link in GL function pointer variables on platforms that support it # 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 $<TARGET_OBJECTS:MagnumFlextGLObjects>) list(APPEND Magnum_SRCS $<TARGET_OBJECTS:MagnumFlextGLObjects>)
endif() endif()

3
src/Magnum/Context.cpp

@ -261,9 +261,6 @@ const std::vector<Extension>& Extension::extensions(Version version) {
_extension(GL,APPLE,texture_format_BGRA8888), _extension(GL,APPLE,texture_format_BGRA8888),
_extension(GL,ARM,shader_framebuffer_fetch), _extension(GL,ARM,shader_framebuffer_fetch),
_extension(GL,ARM,shader_framebuffer_fetch_depth_stencil), _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_filter_anisotropic),
_extension(GL,EXT,texture_format_BGRA8888), _extension(GL,EXT,texture_format_BGRA8888),
_extension(GL,EXT,read_format_bgra), _extension(GL,EXT,read_format_bgra),

6
src/Magnum/Context.h

@ -233,9 +233,9 @@ class MAGNUM_EXPORT Context {
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
/** /**
* OpenGL ES implementation by ANGLE (translated to D3D), used by * OpenGL ES implementation by ANGLE (translated to D3D), used by
* browsers on Windows for Native Client and WebGL. As the WebGL * browsers on Windows for WebGL. As the WebGL specification
* specification explicitly disallows exposing driver information * explicitly disallows exposing driver information to the
* to the application, this check cannot be done reliably. * application, this check cannot be done reliably.
*/ */
Angle = 1 << 1, Angle = 1 << 1,

60
src/Magnum/DebugOutput.cpp

@ -34,7 +34,7 @@
#include "Magnum/Implementation/State.h" #include "Magnum/Implementation/State.h"
#include "Magnum/Implementation/DebugState.h" #include "Magnum/Implementation/DebugState.h"
#if defined(CORRADE_TARGET_NACL_NEWLIB) || defined(CORRADE_TARGET_ANDROID) #ifdef CORRADE_TARGET_ANDROID
#include <sstream> #include <sstream>
#endif #endif
@ -42,7 +42,6 @@ namespace Magnum {
namespace { namespace {
#ifndef CORRADE_TARGET_NACL
void void
#ifdef CORRADE_TARGET_WINDOWS #ifdef CORRADE_TARGET_WINDOWS
APIENTRY APIENTRY
@ -50,7 +49,6 @@ APIENTRY
callbackWrapper(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { 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); 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*) { 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; 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) */ /** @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; std::ostringstream converter;
converter << id; converter << id;
#endif #endif
output << '(' + output << '(' +
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) #ifndef CORRADE_TARGET_ANDROID
std::to_string(id) + std::to_string(id) +
#else #else
converter.str() + 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<UnsignedInt>, bool) {} void DebugOutput::controlImplementationNoOp(GLenum, GLenum, GLenum, std::initializer_list<UnsignedInt>, bool) {}
void DebugOutput::controlImplementationKhr(const GLenum source, const GLenum type, const GLenum severity, const std::initializer_list<UnsignedInt> ids, const bool enabled) { void DebugOutput::controlImplementationKhr(const GLenum source, const GLenum type, const GLenum severity, const std::initializer_list<UnsignedInt> ids, const bool enabled) {
#ifndef CORRADE_TARGET_NACL
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glDebugMessageControl glDebugMessageControl
#else #else
glDebugMessageControlKHR glDebugMessageControlKHR
#endif #endif
(source, type, severity, ids.size(), ids.begin(), enabled); (source, type, severity, ids.size(), ids.begin(), enabled);
#else
static_cast<void>(source);
static_cast<void>(type);
static_cast<void>(severity);
static_cast<void>(ids);
static_cast<void>(enabled);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
void DebugOutput::callbackImplementationNoOp(Callback, const void*) {} void DebugOutput::callbackImplementationNoOp(Callback, const void*) {}
@ -197,30 +186,21 @@ void DebugOutput::callbackImplementationKhr(const Callback callback, const void*
/* Adding callback */ /* Adding callback */
if(!original && callback) { if(!original && callback) {
#ifndef CORRADE_TARGET_NACL
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glDebugMessageCallback glDebugMessageCallback
#else #else
glDebugMessageCallbackKHR glDebugMessageCallbackKHR
#endif #endif
(callbackWrapper, userParam); (callbackWrapper, userParam);
#else
static_cast<void>(userParam);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
/* Deleting callback */ /* Deleting callback */
} else if(original && !callback) { } else if(original && !callback) {
#ifndef CORRADE_TARGET_NACL
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glDebugMessageCallback glDebugMessageCallback
#else #else
glDebugMessageCallbackKHR glDebugMessageCallbackKHR
#endif #endif
(nullptr, nullptr); (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<const char>) {} void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, DebugOutput::Severity, const Containers::ArrayView<const char>) {}
void DebugMessage::insertImplementationKhr(const Source source, const Type type, const UnsignedInt id, const DebugOutput::Severity severity, const Containers::ArrayView<const char> string) { void DebugMessage::insertImplementationKhr(const Source source, const Type type, const UnsignedInt id, const DebugOutput::Severity severity, const Containers::ArrayView<const char> string) {
#ifndef CORRADE_TARGET_NACL
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glDebugMessageInsert glDebugMessageInsert
#else #else
glDebugMessageInsertKHR glDebugMessageInsertKHR
#endif #endif
(GLenum(source), GLenum(type), id, GLenum(severity), string.size(), string.data()); (GLenum(source), GLenum(type), id, GLenum(severity), string.size(), string.data());
#else
static_cast<void>(source);
static_cast<void>(type);
static_cast<void>(id);
static_cast<void>(severity);
static_cast<void>(string);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, DebugOutput::Severity, const Containers::ArrayView<const char> string) { void DebugMessage::insertImplementationExt(Source, Type, UnsignedInt, DebugOutput::Severity, const Containers::ArrayView<const char> string) {
#ifndef CORRADE_TARGET_NACL
glInsertEventMarkerEXT(string.size(), string.data()); glInsertEventMarkerEXT(string.size(), string.data());
#else
static_cast<void>(string);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -392,28 +358,16 @@ void DebugGroup::pop() {
void DebugGroup::pushImplementationNoOp(Source, UnsignedInt, Containers::ArrayView<const char>) {} void DebugGroup::pushImplementationNoOp(Source, UnsignedInt, Containers::ArrayView<const char>) {}
void DebugGroup::pushImplementationKhr(const Source source, const UnsignedInt id, const Containers::ArrayView<const char> message) { void DebugGroup::pushImplementationKhr(const Source source, const UnsignedInt id, const Containers::ArrayView<const char> message) {
#ifndef CORRADE_TARGET_NACL
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glPushDebugGroup glPushDebugGroup
#else #else
glPushDebugGroupKHR glPushDebugGroupKHR
#endif #endif
(GLenum(source), id, message.size(), message.data()); (GLenum(source), id, message.size(), message.data());
#else
static_cast<void>(source);
static_cast<void>(id);
static_cast<void>(message);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
void DebugGroup::pushImplementationExt(Source, UnsignedInt, const Containers::ArrayView<const char> message) { void DebugGroup::pushImplementationExt(Source, UnsignedInt, const Containers::ArrayView<const char> message) {
#ifndef CORRADE_TARGET_NACL
glPushGroupMarkerEXT(message.size(), message.data()); glPushGroupMarkerEXT(message.size(), message.data());
#else
static_cast<void>(message);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
void DebugGroup::popImplementationNoOp() {} void DebugGroup::popImplementationNoOp() {}
@ -421,19 +375,13 @@ void DebugGroup::popImplementationNoOp() {}
void DebugGroup::popImplementationKhr() { void DebugGroup::popImplementationKhr() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glPopDebugGroup(); glPopDebugGroup();
#elif !defined(CORRADE_TARGET_NACL)
glPopDebugGroupKHR();
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glPopDebugGroupKHR();
#endif #endif
} }
void DebugGroup::popImplementationExt() { void DebugGroup::popImplementationExt() {
#ifndef CORRADE_TARGET_NACL
glPopGroupMarkerEXT(); glPopGroupMarkerEXT();
#else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT

4
src/Magnum/Extensions.h

@ -302,10 +302,6 @@ namespace GL {
#endif #endif
_extension(GL,ARM,shader_framebuffer_fetch, GLES200, None) // #165 _extension(GL,ARM,shader_framebuffer_fetch, GLES200, None) // #165
_extension(GL,ARM,shader_framebuffer_fetch_depth_stencil, GLES200, None) // #166 _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 { } namespace EXT {
_extension(GL,EXT,texture_filter_anisotropic, GLES200, None) // #41 _extension(GL,EXT,texture_filter_anisotropic, GLES200, None) // #41
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2

8
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) { void Framebuffer::textureLayerImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glFramebufferTextureLayer(GLenum(bindInternal()), GLenum(attachment), textureId, mipLevel, layer); 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 #else
static_cast<void>(attachment); glFramebufferTexture3DOES(GLenum(bindInternal()), GLenum(attachment), GL_TEXTURE_3D_OES, textureId, mipLevel, layer);
static_cast<void>(textureId);
static_cast<void>(mipLevel);
static_cast<void>(layer);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif #endif
} }
#endif #endif

41
src/Magnum/Implementation/driverSpecific.cpp

@ -85,13 +85,6 @@ namespace {
"nv-zero-context-profile-mask", "nv-zero-context-profile-mask",
#endif #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 #ifndef MAGNUM_TARGET_GLES
/* SVGA3D (VMware host GL driver) glDrawArrays() draws nothing when the /* SVGA3D (VMware host GL driver) glDrawArrays() draws nothing when the
vertex buffer memory is initialized using glNamedBufferData() from vertex buffer memory is initialized using glNamedBufferData() from
@ -236,40 +229,6 @@ void Context::setupDriverWorkarounds() {
} }
#endif #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 #ifndef MAGNUM_TARGET_GLES
if((detectedDriver() & DetectedDriver::Svga3D) && if((detectedDriver() & DetectedDriver::Svga3D) &&
isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>() && isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>() &&

2
src/Magnum/Math/Complex.h

@ -391,7 +391,7 @@ template<class T> class Complex {
*/ */
T length() const { T length() const {
/** @todo Remove when newlib has this fixed */ /** @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); return std::hypot(_real, _imaginary);
#else #else
return std::sqrt(dot()); return std::sqrt(dot());

6
src/Magnum/Math/Functions.h

@ -455,7 +455,7 @@ template<class T> inline T round(const T& a);
#else #else
template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type round(T a) { template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T>::type round(T a) {
/** @todo Remove when newlib has this fixed */ /** @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); return std::round(a);
#else #else
return (a > T(0)) ? std::floor(a + T(0.5)) : std::ceil(a - T(0.5)); return (a > T(0)) ? std::floor(a + T(0.5)) : std::ceil(a - T(0.5));
@ -464,7 +464,7 @@ template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T
template<std::size_t size, class T> Vector<size, T> round(const Vector<size, T>& a) { template<std::size_t size, class T> Vector<size, T> round(const Vector<size, T>& a) {
Vector<size, T> out{NoInit}; Vector<size, T> out{NoInit};
for(std::size_t i = 0; i != size; ++i) { 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]); out[i] = std::round(a[i]);
#else #else
out[i] = round(a[i]); out[i] = round(a[i]);
@ -605,7 +605,7 @@ template<class T> inline typename std::enable_if<std::is_arithmetic<T>::value, T
/* On Emscripten it works with -O2 but not with -O1 (function not defined). /* 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 I guess that's only because -O2 optimizes it out, so disabling it there
also */ 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); return std::fma(a, b, c);
#else #else
return a*b + c; return a*b + c;

2
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(2.3f), 2.0f);
CORRADE_COMPARE(Math::round(Vector3(2.3f, 0.7f, 1.5f)), Vector3(2.0f, 1.0f, 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 */ test that the behavior is the same on both implementations */
CORRADE_COMPARE(Math::round(-2.0f), -2.0f); CORRADE_COMPARE(Math::round(-2.0f), -2.0f);
CORRADE_COMPARE(Math::round(-1.5f), -2.0f); CORRADE_COMPARE(Math::round(-1.5f), -2.0f);

78
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) { 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, CORRADE_ASSERT(buffer.targetHint() == Buffer::TargetHint::ElementArray,
"Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::ElementArray << "but got" << buffer.targetHint(), *this); "Mesh::setIndexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::ElementArray << "but got" << buffer.targetHint(), *this);
#endif #endif
@ -425,10 +425,8 @@ void Mesh::bindVAO() {
_flags |= ObjectFlag::Created; _flags |= ObjectFlag::Created;
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glBindVertexArray(current = _id); glBindVertexArray(current = _id);
#elif !defined(CORRADE_TARGET_NACL)
glBindVertexArrayOES(current = _id);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glBindVertexArrayOES(current = _id);
#endif #endif
} }
} }
@ -441,10 +439,8 @@ void Mesh::createImplementationDefault() {
void Mesh::createImplementationVAO() { void Mesh::createImplementationVAO() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glGenVertexArrays(1, &_id); glGenVertexArrays(1, &_id);
#elif !defined(CORRADE_TARGET_NACL)
glGenVertexArraysOES(1, &_id);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glGenVertexArraysOES(1, &_id);
#endif #endif
CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding);
} }
@ -461,10 +457,8 @@ void Mesh::destroyImplementationDefault() {}
void Mesh::destroyImplementationVAO() { void Mesh::destroyImplementationVAO() {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glDeleteVertexArrays(1, &_id); glDeleteVertexArrays(1, &_id);
#elif !defined(CORRADE_TARGET_NACL)
glDeleteVertexArraysOES(1, &_id);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glDeleteVertexArraysOES(1, &_id);
#endif #endif
} }
@ -478,7 +472,7 @@ void Mesh::attributePointerInternal(AttributeLayout& attribute) {
} }
void Mesh::attributePointerImplementationDefault(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, 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(), ); "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::Array << "but got" << attribute.buffer.targetHint(), );
#endif #endif
@ -487,7 +481,7 @@ void Mesh::attributePointerImplementationDefault(AttributeLayout& attribute) {
} }
void Mesh::attributePointerImplementationVAO(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, 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(), ); "Mesh::addVertexBuffer(): the buffer has unexpected target hint, expected" << Buffer::TargetHint::Array << "but got" << attribute.buffer.targetHint(), );
#endif #endif
@ -555,32 +549,14 @@ void Mesh::vertexAttribDivisorImplementationDSAEXT(const GLuint index, const GLu
} }
#elif defined(MAGNUM_TARGET_GLES2) #elif defined(MAGNUM_TARGET_GLES2)
void Mesh::vertexAttribDivisorImplementationANGLE(const GLuint index, const GLuint divisor) { void Mesh::vertexAttribDivisorImplementationANGLE(const GLuint index, const GLuint divisor) {
#ifndef CORRADE_TARGET_NACL
glVertexAttribDivisorANGLE(index, divisor); glVertexAttribDivisorANGLE(index, divisor);
#else
static_cast<void>(index);
static_cast<void>(divisor);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void Mesh::vertexAttribDivisorImplementationEXT(const GLuint index, const GLuint divisor) { void Mesh::vertexAttribDivisorImplementationEXT(const GLuint index, const GLuint divisor) {
#ifndef CORRADE_TARGET_NACL
glVertexAttribDivisorEXT(index, divisor); glVertexAttribDivisorEXT(index, divisor);
#else
static_cast<void>(index);
static_cast<void>(divisor);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
void Mesh::vertexAttribDivisorImplementationNV(const GLuint index, const GLuint divisor) { void Mesh::vertexAttribDivisorImplementationNV(const GLuint index, const GLuint divisor) {
#ifndef CORRADE_TARGET_NACL
glVertexAttribDivisorNV(index, divisor); glVertexAttribDivisorNV(index, divisor);
#else
static_cast<void>(index);
static_cast<void>(divisor);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
#endif #endif
@ -619,72 +595,30 @@ void Mesh::unbindImplementationVAO() {}
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
void Mesh::drawArraysInstancedImplementationANGLE(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) { void Mesh::drawArraysInstancedImplementationANGLE(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) {
#ifndef CORRADE_TARGET_NACL
glDrawArraysInstancedANGLE(GLenum(_primitive), baseVertex, count, instanceCount); glDrawArraysInstancedANGLE(GLenum(_primitive), baseVertex, count, instanceCount);
#else
static_cast<void>(baseVertex);
static_cast<void>(count);
static_cast<void>(instanceCount);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void Mesh::drawArraysInstancedImplementationEXT(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) { void Mesh::drawArraysInstancedImplementationEXT(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) {
#ifndef CORRADE_TARGET_NACL
glDrawArraysInstancedEXT(GLenum(_primitive), baseVertex, count, instanceCount); glDrawArraysInstancedEXT(GLenum(_primitive), baseVertex, count, instanceCount);
#else
static_cast<void>(baseVertex);
static_cast<void>(count);
static_cast<void>(instanceCount);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
void Mesh::drawArraysInstancedImplementationNV(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) { void Mesh::drawArraysInstancedImplementationNV(const GLint baseVertex, const GLsizei count, const GLsizei instanceCount) {
#ifndef CORRADE_TARGET_NACL
glDrawArraysInstancedNV(GLenum(_primitive), baseVertex, count, instanceCount); glDrawArraysInstancedNV(GLenum(_primitive), baseVertex, count, instanceCount);
#else
static_cast<void>(baseVertex);
static_cast<void>(count);
static_cast<void>(instanceCount);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
void Mesh::drawElementsInstancedImplementationANGLE(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) { void Mesh::drawElementsInstancedImplementationANGLE(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) {
#ifndef CORRADE_TARGET_NACL
glDrawElementsInstancedANGLE(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset), instanceCount); glDrawElementsInstancedANGLE(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset), instanceCount);
#else
static_cast<void>(count);
static_cast<void>(indexOffset);
static_cast<void>(instanceCount);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void Mesh::drawElementsInstancedImplementationEXT(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) { void Mesh::drawElementsInstancedImplementationEXT(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) {
#ifndef CORRADE_TARGET_NACL
glDrawElementsInstancedEXT(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset), instanceCount); glDrawElementsInstancedEXT(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset), instanceCount);
#else
static_cast<void>(count);
static_cast<void>(indexOffset);
static_cast<void>(instanceCount);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
void Mesh::drawElementsInstancedImplementationNV(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) { void Mesh::drawElementsInstancedImplementationNV(const GLsizei count, const GLintptr indexOffset, const GLsizei instanceCount) {
#ifndef CORRADE_TARGET_NACL
glDrawElementsInstancedNV(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset), instanceCount); glDrawElementsInstancedNV(GLenum(_primitive), count, GLenum(_indexType), reinterpret_cast<GLvoid*>(indexOffset), instanceCount);
#else
static_cast<void>(count);
static_cast<void>(indexOffset);
static_cast<void>(instanceCount);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
#endif #endif

8
src/Magnum/MeshView.cpp

@ -96,10 +96,8 @@ void MeshView::multiDrawImplementationDefault(std::initializer_list<std::referen
if(!original._indexBuffer) { if(!original._indexBuffer) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glMultiDrawArrays(GLenum(original._primitive), baseVertex, count, meshes.size()); glMultiDrawArrays(GLenum(original._primitive), baseVertex, count, meshes.size());
#elif !defined(CORRADE_TARGET_NACL)
glMultiDrawArraysEXT(GLenum(original._primitive), baseVertex, count, meshes.size());
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glMultiDrawArraysEXT(GLenum(original._primitive), baseVertex, count, meshes.size());
#endif #endif
/* Indexed meshes */ /* Indexed meshes */
@ -115,10 +113,8 @@ void MeshView::multiDrawImplementationDefault(std::initializer_list<std::referen
{ {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glMultiDrawElements(GLenum(original._primitive), count, GLenum(original._indexType), indices, meshes.size()); glMultiDrawElements(GLenum(original._primitive), count, GLenum(original._indexType), indices, meshes.size());
#elif !defined(CORRADE_TARGET_NACL)
glMultiDrawElementsEXT(GLenum(original._primitive), count, GLenum(original._indexType), indices, meshes.size());
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ glMultiDrawElementsEXT(GLenum(original._primitive), count, GLenum(original._indexType), indices, meshes.size());
#endif #endif
} }
} }

10
src/Magnum/OpenGL.h

@ -37,16 +37,6 @@
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
#include "MagnumExternal/OpenGL/GL/flextGL.h" #include "MagnumExternal/OpenGL/GL/flextGL.h"
/* Special case for NaCl */
#elif defined(CORRADE_TARGET_NACL)
/* No extension loading */
#include "MagnumExternal/OpenGL/GLES2/flextGLNaCl.h"
/* Needed for NaCl-specific extensions */
#define GL_GLEXT_PROTOTYPES
#define GLES2_GET_FUN(name) GLES2##name
#include <GLES2/gl2ext.h>
/* Special case for Emscripten (no extension loading) */ /* Special case for Emscripten (no extension loading) */
#elif defined(CORRADE_TARGET_EMSCRIPTEN) #elif defined(CORRADE_TARGET_EMSCRIPTEN)
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2

17
src/Magnum/OpenGLTester.h

@ -67,15 +67,14 @@ the base features.
This class is available only on platforms with corresponding This class is available only on platforms with corresponding
`Platform::Windowless*Application` implementation. That currently means all `Platform::Windowless*Application` implementation. That currently means all
platforms except @ref CORRADE_TARGET_ANDROID "Android", platforms except @ref CORRADE_TARGET_ANDROID "Android" and
@ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" and @ref CORRADE_TARGET_NACL "NaCl". @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". It is built into a separate static
It is built into a separate static library and only if `WITH_OPENGLTESTER` is library and only if `WITH_OPENGLTESTER` is enabled when building Magnum. To use
enabled when building Magnum. To use it, you need to request `OpenGLTester` it, you need to request `OpenGLTester` component of `Magnum` package in CMake,
component of `Magnum` package in CMake, derive your test class from this class derive your test class from this class instead of @ref Corrade::TestSuite::Tester
instead of @ref Corrade::TestSuite::Tester and either link to and either link to `Magnum::OpenGLTester` target or add it to `LIBRARIES`
`Magnum::OpenGLTester` target or add it to `LIBRARIES` section of the section of the @ref corrade-cmake-add-test "corrade_add_test()" macro. See
@ref corrade-cmake-add-test "corrade_add_test()" macro. See @ref building and @ref building and @ref cmake for more information.
@ref cmake for more information.
## OpenGL context creation ## OpenGL context creation

78
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)) elseif(CORRADE_TARGET_UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES))
set(NEED_GLXCONTEXT 1) set(NEED_GLXCONTEXT 1)
set(MagnumSomeContext_OBJECTS $<TARGET_OBJECTS:MagnumGlxContextObjects>) set(MagnumSomeContext_OBJECTS $<TARGET_OBJECTS:MagnumGlxContextObjects>)
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(NEED_EGLCONTEXT 1)
set(MagnumSomeContext_OBJECTS $<TARGET_OBJECTS:MagnumEglContextObjects>) set(MagnumSomeContext_OBJECTS $<TARGET_OBJECTS:MagnumEglContextObjects>)
endif() endif()
@ -200,74 +200,6 @@ if(WITH_SDL2APPLICATION)
add_library(Magnum::Sdl2Application ALIAS MagnumSdl2Application) add_library(Magnum::Sdl2Application ALIAS MagnumSdl2Application)
endif() 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 # JavaScript and CSS stuff for Emscripten
if(WITH_SDL2APPLICATION AND CORRADE_TARGET_EMSCRIPTEN) if(WITH_SDL2APPLICATION AND CORRADE_TARGET_EMSCRIPTEN)
set(MagnumSdl2Application_FILES set(MagnumSdl2Application_FILES
@ -793,8 +725,6 @@ if(WITH_MAGNUMINFO)
target_link_libraries(magnum-info MagnumWindowlessIosApplication) target_link_libraries(magnum-info MagnumWindowlessIosApplication)
elseif(CORRADE_TARGET_APPLE) elseif(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-info MagnumWindowlessCglApplication) target_link_libraries(magnum-info MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_NACL)
target_link_libraries(magnum-info MagnumWindowlessNaClApplication)
elseif(CORRADE_TARGET_UNIX) elseif(CORRADE_TARGET_UNIX)
if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES)
target_link_libraries(magnum-info MagnumWindowlessEglApplication) target_link_libraries(magnum-info MagnumWindowlessEglApplication)
@ -813,11 +743,7 @@ if(WITH_MAGNUMINFO)
set_target_properties(magnum-info PROPERTIES FOLDER "Magnum/Platform") set_target_properties(magnum-info PROPERTIES FOLDER "Magnum/Platform")
install(TARGETS magnum-info DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}) install(TARGETS magnum-info DESTINATION ${MAGNUM_BINARY_INSTALL_DIR})
if(CORRADE_TARGET_NACL) if(CORRADE_TARGET_IOS)
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)
set_target_properties(magnum-info PROPERTIES set_target_properties(magnum-info PROPERTIES
MACOSX_BUNDLE ON MACOSX_BUNDLE ON
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in

2
src/Magnum/Platform/Context.h

@ -78,7 +78,7 @@ class Context: public Magnum::Context {
* complete the setup. * complete the setup.
*/ */
explicit Context(NoCreateT, Int argc, const char** argv): 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} {} Magnum::Context{NoCreate, argc, argv, flextGLInit} {}
#else #else
Magnum::Context{NoCreate, argc, argv, nullptr} {} Magnum::Context{NoCreate, argc, argv, nullptr} {}

276
src/Magnum/Platform/NaClApplication.cpp

@ -1,276 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
Vladimír Vondruš <mosra@centrum.cz>
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 <ppapi/cpp/graphics_3d.h>
#include <ppapi/cpp/fullscreen.h>
#include <ppapi/cpp/completion_callback.h>
#include <Corrade/Utility/NaClStreamBuffer.h>
#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::Key>(keyEvent.GetKeyCode()), static_cast<InputEvent::Modifier>(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::Button>(mouseEvent.GetButton()), {mouseEvent.GetPosition().x(), mouseEvent.GetPosition().y()}, static_cast<InputEvent::Modifier>(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<InputEvent::Modifier>(wheelEvent.GetModifiers())};
mouseScrollEvent(e);
#ifdef MAGNUM_BUILD_DEPRECATED
if(!Math::TypeTraits<Float>::equals(wheelEvent.GetDelta().y(), 0.0f)) {
MouseEvent e2(wheelEvent.GetDelta().y() > 0 ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, {}, static_cast<InputEvent::Modifier>(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<InputEvent::Modifier>(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<NaClApplication*>(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<NaClApplication*>(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<NaClApplication>;
template class BasicScreenedApplication<NaClApplication>;
}}

821
src/Magnum/Platform/NaClApplication.h

@ -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š <mosra@centrum.cz>
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 <memory>
#include <string>
#include <Corrade/Containers/EnumSet.h>
/* Needs to be first */
#include "Magnum/OpenGL.h"
#include <ppapi/cpp/input_event.h>
#include <ppapi/cpp/instance.h>
#include <ppapi/cpp/module.h>
#include <ppapi/cpp/mouse_lock.h>
#include <ppapi/cpp/graphics_3d_client.h>
#include <ppapi/gles2/gl2ext_ppapi.h>
#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 `&lt;application&gt;` to
name of your executable.
@code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Magnum NaCl Application</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="WebApplication.css" />
</head>
<body>
<h1>Magnum NaCl Application</h1>
<div id="listener">
<embed id="module" type="application/x-nacl" src="<application>.nmf"></embed>
<div id="status">Initialization...</div>
<div id="statusDescription"></div>
<script src="NaClApplication.js"></script>
</div>
</body>
</html>
@endcode
You can modify all the files to your liking, but the HTML file must contain at
least the `&lt;embed&gt;` enclosed in listener `&lt;div&gt;`. The JavaScript
file contains event listeners which print loading status on the page. The
status displayed in the remaining two `&lt;div&gt;`s, if they are available.
The CSS file contains rudimentary style to avoid eye bleeding.
The `&lt;embed&gt;` 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 `&lt;application&gt;` to name of your executable):
@code
{
"program": {
"x86-32": {"url": "<application>-x86-32.nexe"},
"x86-64": {"url": "<application>-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<Flag> 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<pp::Graphics3D> _graphics;
std::unique_ptr<pp::Fullscreen> _fullscreen;
Vector2i _viewportSize;
Flags _flags;
std::unique_ptr<ConsoleDebugOutput> _debugOutput;
std::unique_ptr<Platform::Context> _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<class T> 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<Modifier> 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<Button> Buttons;
/** @brief Copying is not allowed */
InputEvent(const InputEvent&) = delete;
/** @brief Moving is not allowed */
InputEvent(InputEvent&&) = delete;
/** @brief Copying is not allowed */
InputEvent& operator=(const InputEvent&) = delete;
/** @brief Moving is not allowed */
InputEvent& operator=(InputEvent&&) = delete;
/** @brief Modifiers */
constexpr Modifiers modifiers() const { return _modifiers; }
/** @brief Mouse buttons */
constexpr Buttons buttons() const { return Button(static_cast<std::uint32_t>(_modifiers)); }
/**
* @brief Set event as accepted
*
* If the event is ignored (i.e., not set as accepted), it is
* propagated elsewhere (e.g. to the browser). By default is each
* event ignored.
*/
void setAccepted(bool accepted = true) { _accepted = accepted; }
/** @brief Whether the event is accepted */
constexpr bool isAccepted() const { return _accepted; }
#ifndef DOXYGEN_GENERATING_OUTPUT
protected:
constexpr InputEvent(Modifiers modifiers): _accepted(false), _modifiers(modifiers) {}
~InputEvent() = default;
#endif
private:
bool _accepted;
const Modifiers _modifiers;
};
/**
@brief Key event
See also @ref InputEvent for more information.
@see @ref keyPressEvent(), @ref keyReleaseEvent()
*/
class NaClApplication::KeyEvent: public NaClApplication::InputEvent {
friend NaClApplication;
public:
/**
* @brief Key
*
* @see @ref key()
* @todo Slash, percent, equal to be compatible with *XApplication
*/
enum class Key: std::uint32_t {
Enter = 0x0D, /**< Enter */
Esc = 0x1B, /**< Escape */
Up = 0x26, /**< Up arrow */
Down = 0x28, /**< Down arrow */
Left = 0x25, /**< Left arrow */
Right = 0x27, /**< Right arrow */
F1 = 0x70, /**< F1 */
F2 = 0x71, /**< F2 */
F3 = 0x72, /**< F3 */
F4 = 0x73, /**< F4 */
F5 = 0x74, /**< F5 */
F6 = 0x75, /**< F6 */
F7 = 0x76, /**< F7 */
F8 = 0x77, /**< F8 */
F9 = 0x78, /**< F9 */
F10 = 0x79, /**< F10 */
F11 = 0x7A, /**< F11 */
F12 = 0x7B, /**< F12 */
Home = 0x24, /**< Home */
End = 0x23, /**< End */
PageUp = 0x21, /**< Page up */
PageDown = 0x22, /**< Page down */
Space = 0x20, /**< Space */
Comma = 0xBC, /**< Comma */
Period = 0xBE, /**< Period */
Minus = 0xBD, /**< Minus */
Plus = 0xBB, /**< Plus */
Zero = '0', /**< Zero */
One = '1', /**< One */
Two = '2', /**< Two */
Three = '3', /**< Three */
Four = '4', /**< Four */
Five = '5', /**< Five */
Six = '6', /**< Six */
Seven = '7', /**< Seven */
Eight = '8', /**< Eight */
Nine = '9', /**< Nine */
A = 'A', /**< Letter A */
B = 'B', /**< Letter B */
C = 'C', /**< Letter C */
D = 'D', /**< Letter D */
E = 'E', /**< Letter E */
F = 'F', /**< Letter F */
G = 'G', /**< Letter G */
H = 'H', /**< Letter H */
I = 'I', /**< Letter I */
J = 'J', /**< Letter J */
K = 'K', /**< Letter K */
L = 'L', /**< Letter L */
M = 'M', /**< Letter M */
N = 'N', /**< Letter N */
O = 'O', /**< Letter O */
P = 'P', /**< Letter P */
Q = 'Q', /**< Letter Q */
R = 'R', /**< Letter R */
S = 'S', /**< Letter S */
T = 'T', /**< Letter T */
U = 'U', /**< Letter U */
V = 'V', /**< Letter V */
W = 'W', /**< Letter W */
X = 'X', /**< Letter X */
Y = 'Y', /**< Letter Y */
Z = 'Z' /**< Letter Z */
};
/** @brief Key */
constexpr Key key() const { return _key; }
private:
constexpr KeyEvent(Key key, Modifiers modifiers): InputEvent(modifiers), _key(key) {}
const Key _key;
};
/**
@brief Mouse event
See also @ref InputEvent for more information.
@see @ref MouseMoveEvent, @ref MouseScrollEvent, @ref mousePressEvent(),
@ref mouseReleaseEvent()
*/
class NaClApplication::MouseEvent: public NaClApplication::InputEvent {
friend NaClApplication;
public:
/**
* @brief Button
*
* @see @ref button()
*/
enum class Button: unsigned int {
Left = PP_INPUTEVENT_MOUSEBUTTON_LEFT, /**< Left button */
Middle = PP_INPUTEVENT_MOUSEBUTTON_MIDDLE, /**< Middle button */
Right = PP_INPUTEVENT_MOUSEBUTTON_RIGHT, /**< Right button */
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* Wheel up
* @deprecated Use @ref MouseScrollEvent and @ref mouseScrollEvent() instead.
*/
WheelUp CORRADE_DEPRECATED_ENUM("use mouseScrollEvent() and MouseScrollEvent instead") = 0xFFFF01,
/**
* Wheel down
* @deprecated Use @ref MouseScrollEvent and @ref mouseScrollEvent() instead.
*/
WheelDown CORRADE_DEPRECATED_ENUM("use mouseScrollEvent() and MouseScrollEvent instead") = 0xFFFF02
#endif
};
/** @brief Button */
constexpr Button button() const { return _button; }
/**
* @brief Position
*
* @attention Note that due to the way the @ref Button::WheelUp and
* @ref Button::WheelDown events are handled by Native Client, the
* position information is not available, i.e. it is set to zero.
*/
constexpr Vector2i position() const { return _position; }
private:
constexpr MouseEvent(Button button, const Vector2i& position, Modifiers modifiers): InputEvent(modifiers), _button(button), _position(position) {}
const Button _button;
const Vector2i _position;
};
/**
@brief Mouse move event
See also @ref InputEvent for more information.
@see @ref MouseEvent, @ref MouseScrollEvent, @ref mouseMoveEvent()
*/
class NaClApplication::MouseMoveEvent: public NaClApplication::InputEvent {
friend NaClApplication;
public:
/** @brief Position */
constexpr Vector2i position() const { return _position; }
/**
* @brief Relative position
*
* Position relative to previous event.
*/
constexpr Vector2i relativePosition() const { return _relativePosition; }
private:
constexpr MouseMoveEvent(const Vector2i& position, const Vector2i& relativePosition, Modifiers modifiers): InputEvent(modifiers), _position(position), _relativePosition(relativePosition) {}
const Vector2i _position, _relativePosition;
};
/**
@brief Mouse scroll event
See also @ref InputEvent for more information.
@see @ref MouseEvent, @ref MouseMoveEvent, @ref mouseScrollEvent()
*/
class NaClApplication::MouseScrollEvent: public NaClApplication::InputEvent {
friend NaClApplication;
public:
/** @brief Scroll offset */
constexpr Vector2 offset() const { return _offset; }
private:
constexpr MouseScrollEvent(const Vector2& offset, Modifiers modifiers): InputEvent{modifiers}, _offset{offset} {}
const Vector2 _offset;
};
CORRADE_ENUMSET_OPERATORS(NaClApplication::Flags)
namespace Implementation {
template<class Application> class NaClModule: public pp::Module {
public:
~NaClModule() { glTerminatePPAPI(); }
bool Init() override {
return glInitializePPAPI(get_browser_interface());
}
pp::Instance* CreateInstance(PP_Instance instance) {
return new Application(instance);
}
};
}
/** @hideinitializer
@brief Entry point for NaCl application
@param className Class name
See @ref Magnum::Platform::NaClApplication "Platform::NaClApplication" for
usage information. This macro abstracts out platform-specific entry point code
(the classic `main()` function cannot be used in NaCl). See
@ref portability-applications for more information. When no other application
header is included this macro is also aliased to `MAGNUM_APPLICATION_MAIN()`.
*/
/* look at that insane placement of __attribute__. WTF. */
#define MAGNUM_NACLAPPLICATION_MAIN(className) \
namespace pp { \
Module __attribute__ ((visibility ("default"))) * CreateModule(); \
Module __attribute__ ((visibility ("default"))) * CreateModule() { \
return new Magnum::Platform::Implementation::NaClModule<className>(); \
} \
}
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_APPLICATION_MAIN
typedef NaClApplication Application;
typedef BasicScreen<NaClApplication> Screen;
typedef BasicScreenedApplication<NaClApplication> ScreenedApplication;
#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_NACLAPPLICATION_MAIN(className)
#else
#undef MAGNUM_APPLICATION_MAIN
#endif
#endif
CORRADE_ENUMSET_OPERATORS(NaClApplication::InputEvent::Modifiers)
CORRADE_ENUMSET_OPERATORS(NaClApplication::InputEvent::Buttons)
}}
#endif

43
src/Magnum/Platform/NaClApplication.js

@ -1,43 +0,0 @@
function setStatus(message) {
var status = document.getElementById('status');
if(status) status.innerHTML = message;
}
function setStatusDescription(message) {
var statusDescription = document.getElementById('statusDescription');
if(statusDescription) statusDescription.innerHTML = message;
}
var listener = document.getElementById('listener');
listener.addEventListener('loadstart', function() {
setStatus('Loading...');
}, true);
listener.addEventListener('progress', function(event) {
setStatus('Downloading...');
/* Show progress */
if(event.lengthComputable && event.total > 0)
setStatusDescription(Math.round(event.loaded*100/event.total) + '% of '
+ Math.round(event.total/1024) + ' kB');
/* Unknown total size */
else setStatusDescription(Math.round(event.loaded/1024) + ' kB');
}, true);
listener.addEventListener('error', function() {
setStatus('Loading failed');
setStatusDescription(document.getElementById('module').lastError + '<br />Check JavaScript console for more information.');
}, true);
listener.addEventListener('abort', function() {
setStatus('Loading aborted');
setStatusDescription('');
}, true);
listener.addEventListener('load', function() {
setStatus('');
setStatusDescription('');
}, true);

1
src/Magnum/Platform/Screen.h

@ -62,7 +62,6 @@ The following specialization are explicitly compiled into each particular
- @ref GlutApplication "BasicScreen<GlutApplication>" - @ref GlutApplication "BasicScreen<GlutApplication>"
- @ref GlxApplication "BasicScreen<GlxApplication>" - @ref GlxApplication "BasicScreen<GlxApplication>"
- @ref NaClApplication "BasicScreen<NaClApplication>"
- @ref Sdl2Application "BasicScreen<Sdl2Application>" - @ref Sdl2Application "BasicScreen<Sdl2Application>"
- @ref XEglApplication "BasicScreen<XEglApplication>" - @ref XEglApplication "BasicScreen<XEglApplication>"
*/ */

1
src/Magnum/Platform/ScreenedApplication.h

@ -90,7 +90,6 @@ The following specialization are explicitly compiled into each particular
- @ref GlutApplication "BasicScreenedApplication<GlutApplication>" - @ref GlutApplication "BasicScreenedApplication<GlutApplication>"
- @ref GlxApplication "BasicScreenedApplication<GlxApplication>" - @ref GlxApplication "BasicScreenedApplication<GlxApplication>"
- @ref NaClApplication "BasicScreenedApplication<NaClApplication>"
- @ref Sdl2Application "BasicScreenedApplication<Sdl2Application>" - @ref Sdl2Application "BasicScreenedApplication<Sdl2Application>"
- @ref XEglApplication "BasicScreenedApplication<XEglApplication>" - @ref XEglApplication "BasicScreenedApplication<XEglApplication>"
*/ */

125
src/Magnum/Platform/WindowlessNaClApplication.cpp

@ -1,125 +0,0 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
Vladimír Vondruš <mosra@centrum.cz>
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 "WindowlessNaClApplication.h"
#include <ppapi/cpp/graphics_3d.h>
#include <ppapi/cpp/completion_callback.h>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/NaClStreamBuffer.h>
#include "Magnum/Platform/Context.h"
namespace Magnum { namespace Platform {
WindowlessNaClContext::WindowlessNaClContext(pp::Instance& instance, const Configuration&, Context*) {
const std::int32_t attributes[] = {
PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 24,
PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 8,
PP_GRAPHICS3DATTRIB_WIDTH, 1,
PP_GRAPHICS3DATTRIB_HEIGHT, 1,
PP_GRAPHICS3DATTRIB_NONE
};
std::unique_ptr<pp::Graphics3D> context{new pp::Graphics3D{*instance, attributes}};
if(context->is_null())
Error() << "Platform::WindowlessNaClContext: cannot create context";
if(!BindGraphics(*context))
Error() << "Platform::WindowlessNaClContext: cannot bind graphics";
/* All went well, save the context */
_context = std::move(context);
}
WindowlessNaClContext::WindowlessNaClContext(WindowlessNaClContext&&) = default;
WindowlessNaClContext::~WindowlessNaClContext() = default;
WindowlessNaClContext& WindowlessNaClContext::operator=(WindowlessNaClContext&&) = default;
bool WindowlessNaClContext::makeCurrent() {
if(!_context) return false;
glSetCurrentContextPPAPI(_context->pp_resource());
return true;
}
struct WindowlessNaClApplication::ConsoleDebugOutput {
explicit ConsoleDebugOutput(pp::Instance* instance);
Utility::NaClConsoleStreamBuffer debugBuffer, warningBuffer, errorBuffer;
std::ostream debugOutput, warningOutput, errorOutput;
};
WindowlessNaClApplication::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::WindowlessNaClApplication: redirecting Debug, Warning and Error output to JavaScript console";
Debug::setOutput(&debugOutput);
Warning::setOutput(&warningOutput);
Error::setOutput(&errorOutput);
}
#ifndef DOXYGEN_GENERATING_OUTPUT
WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments): WindowlessNaClApplication{arguments, Configuration{}} {}
#endif
WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments, const Configuration& configuration):
WindowlessNaClApplication{arguments, NoCreate} {
createContext(configuration);
}
WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments, NoCreateT): Instance(arguments), Graphics3DClient(this), _glContext{NoCreate}, _debugOutput{new ConsoleDebugOutput{this}} {}
void WindowlessNaClApplication::createContext() { createContext({}); }
void WindowlessNaClApplication::createContext(const Configuration& configuration) {
if(!tryCreateContext(configuration)) std::exit(1);
}
bool WindowlessNaClApplication::tryCreateContext(const Configuration& configuration) {
CORRADE_ASSERT(_context->version() == Version::None, "Platform::WindowlessNaClApplication::tryCreateContext(): context already created", false);
WindowlessNaClContext glContext{*this, configuration, _context.get()};
if(!glContext.isCreated() || !glContext.makeCurrent() || !_context->tryCreate())
return false;
_glContext = std::move(glContext);
return true;
}
WindowlessNaClApplication::~WindowlessNaClApplication() = default;
bool WindowlessNaClApplication::Init(uint32_t , const char* , const char*) {
return exec() == 0;
}
void WindowlessNaClApplication::Graphics3DContextLost() {
CORRADE_ASSERT(false, "NaClApplication: context unexpectedly lost", );
}
}}

356
src/Magnum/Platform/WindowlessNaClApplication.h

@ -1,356 +0,0 @@
#ifndef Magnum_Platform_WindowlessNaClApplication_h
#define Magnum_Platform_WindowlessNaClApplication_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
Vladimír Vondruš <mosra@centrum.cz>
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::WindowlessNaClApplication, @ref Magnum::Platform::WindowlessNaClContext, macro @ref MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN()
*/
#include <memory>
#include <string>
#include <Corrade/Containers/EnumSet.h>
/* Needs to be first */
#include "Magnum/OpenGL.h"
#include <ppapi/cpp/instance.h>
#include <ppapi/cpp/module.h>
#include <ppapi/cpp/graphics_3d_client.h>
#include <ppapi/gles2/gl2ext_ppapi.h>
#include "Magnum/Magnum.h"
#include "Magnum/Tags.h"
#include "Magnum/Platform/Platform.h"
namespace pp {
class Graphics3D;
class Fullscreen;
}
namespace Magnum { namespace Platform {
/**
@brief Windowless NaCl context
GL context running in [Google Chrome Native Client](https://developers.google.com/native-client/),
used in @ref WindowlessNaClApplication. Does not have any default framebuffer.
It is built if `WITH_WINDOWLESSNACLAPPLICATION` is enabled in CMake.
Meant to be used when there is a need to manage (multiple) GL contexts
manually. See @ref platform-windowless-contexts for more information. If no
other application header is included, this class is also aliased to
`Platform::WindowlessGLContext`.
*/
class WindowlessNaClContext {
public:
class Configuration;
/**
* @brief Constructor
* @param instance Pepper instance handle
* @param configuration Context configuration
* @param context Optional Magnum context instance constructed
* using @ref NoCreate to manage driver workarounds
*
* Once the context is created, make it current using @ref makeCurrent()
* and create @ref Platform::Context instance to be able to use Magnum.
* @see @ref isCreated()
*/
explicit WindowlessNaClContext(pp::Instance& instance, const Configuration& configuration, Context* context = nullptr);
/**
* @brief Construct without creating the context
*
* Move a instance with created context over to make it usable.
*/
explicit WindowlessNaClContext(NoCreateT) {}
/** @brief Copying is not allowed */
WindowlessNaClContext(const WindowlessNaClContext&) = delete;
/** @brief Move constructor */
WindowlessNaClContext(WindowlessNaClContext&&);
/** @brief Copying is not allowed */
WindowlessNaClContext& operator=(const WindowlessNaClContext&) = delete;
/** @brief Move assignment */
WindowlessNaClContext& operator=(WindowlessNaClContext&&);
/**
* @brief Destructor
*
* Destroys the context, if any.
*/
~WindowlessNaClContext();
/** @brief Whether the context is created */
bool isCreated() const { return _context; }
/**
* @brief Make the context current
*
* Prints error message and returns `false` on failure, otherwise
* returns `true`.
*/
bool makeCurrent();
private:
std::unique_ptr<pp::Graphics3D> _context;
};
/**
@brief Configuration
@see @ref WindowlessNaClContext(),
@ref WindowlessNaClApplication::WindowlessNaClApplication(),
@ref WindowlessNaClApplication::createContext(),
@ref WindowlessNaClApplication::tryCreateContext()
*/
class WindowlessNaClContext::Configuration {
public:
constexpr /*implicit*/ Configuration() {}
};
/** @nosubgrouping
@brief Windowless NaCl application
Application for offscreen rendering using @ref WindowlessNaClContext. This
application library is available only in @ref CORRADE_TARGET_NACL "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_WINDOWLESSNACLAPPLICATION` is enabled in CMake.
## Bootstrap application
The usage is very similar to @ref NaClApplication, for which fully contained
base application along with CMake setup is available, see its documentation for
more information.
## General Usage
In CMake you need to request `WindowlessNaClApplication` component, add
`${MAGNUM_WINDOWLESSNACLAPPLICATION_INCLUDE_DIRS}` to include path and link to
`${MAGNUM_WINDOWLESSNACLAPPLICATION_LIBRARIES}`. If no other windowless
application is requested, you can also use generic
`${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}` and
`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. See
@ref building and @ref cmake for more information.
Place your code into @ref exec(). The subclass must be then registered to NaCl
API using @ref MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN() macro. See @ref platform
for more information.
@code
class MyApplication: public Platform::WindowlessNaClApplication {
// implement required methods...
};
MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN(MyApplication)
@endcode
If no other application header is included, this class is also aliased to
`Platform::WindowlessApplication` and the macro is aliased to
`MAGNUM_WINDOWLESSAPPLICATION_MAIN()` to simplify porting.
### HTML markup and NMF file
You need to provide HTML markup containing `&lt;embed&gt;` pointing to `*.nmf`
file describing the application. See @ref NaClApplication for more information.
You may want to hide the `&lt;embed&gt;` (for example using CSS
`visibility: hidden;`), as it probably won't display anything to default
framebuffer.
## 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 WindowlessNaClApplication: public pp::Instance, public pp::Graphics3DClient {
public:
/** @brief Application arguments */
typedef PP_Instance Arguments;
/**
* @brief Configuration
*
* @see @ref WindowlessNaClApplication(), @ref createContext(),
* @ref tryCreateContext()
*/
typedef WindowlessNaClContext::Configuration Configuration;
/**
* @brief Default constructor
* @param arguments Application arguments
* @param configuration Configuration
*
* Creates application with default or user-specified configuration.
* See @ref Configuration for more information. The program exits if
* the context cannot be created, see @ref tryCreateContext() for an
* alternative.
* @see @ref WindowlessNaClContext
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
explicit WindowlessNaClApplication(const Arguments& arguments, const Configuration& configuration = Configuration());
#else
/* To avoid "invalid use of incomplete type" */
explicit WindowlessNaClApplication(const Arguments& arguments, const Configuration& configuration);
explicit WindowlessNaClApplication(const Arguments& arguments);
#endif
/**
* @brief Constructor
* @param arguments Application arguments
*
* Unlike above, the context is not created and must be created later
* with @ref createContext() or @ref tryCreateContext().
*/
explicit WindowlessNaClApplication(const Arguments& arguments, NoCreateT);
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief WindowlessNaClApplication(const Arguments&, NoCreateT)
* @deprecated Use @ref WindowlessNaClApplication(const Arguments&, NoCreateT) instead.
*/
CORRADE_DEPRECATED("use WindowlessNaClApplication(const Arguments&, NoCreateT) instead") explicit WindowlessNaClApplication(const Arguments& arguments, std::nullptr_t): WindowlessNaClApplication{arguments, NoCreate} {}
#endif
/** @brief Copying is not allowed */
WindowlessNaClApplication(const WindowlessNaClApplication&) = delete;
/** @brief Moving is not allowed */
WindowlessNaClApplication(WindowlessNaClApplication&&) = delete;
/** @brief Copying is not allowed */
WindowlessNaClApplication& operator=(const WindowlessNaClApplication&) = delete;
/** @brief Moving is not allowed */
WindowlessNaClApplication& operator=(WindowlessNaClApplication&&) = delete;
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/**
* @brief Execute application
* @return Value for returning from `main()`
*
* This function is not meant to be called from user code, see
* @ref MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN() for usage information.
*/
virtual int exec() = 0;
protected:
/* Nobody will need to have (and delete) WindowlessNaClApplication*,
thus this is faster than public pure virtual destructor */
~WindowlessNaClApplication();
/**
* @brief Create context with given configuration
*
* Must be called if and only if the context wasn't created by the
* constructor itself. Error message is printed and the program exits
* if the context cannot be created, see @ref tryCreateContext() for an
* alternative.
* @see @ref WindowlessNaClContext
*/
#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
/**
* @brief Try to create context with given configuration
*
* Unlike @ref createContext() returns `false` if the context cannot be
* created, `true` otherwise.
*/
bool tryCreateContext(const Configuration& configuration);
private:
struct ConsoleDebugOutput;
void Graphics3DContextLost() override;
bool Init(std::uint32_t, const char*, const char*) override;
WindowlessNaClContext _glContext;
std::unique_ptr<Platform::Context> _context;
std::unique_ptr<ConsoleDebugOutput> _debugOutput;
};
namespace Implementation {
template<class Application> class WindowlessNaClModule: public pp::Module {
public:
~WindowlessNaClModule() { glTerminatePPAPI(); }
bool Init() override {
return glInitializePPAPI(get_browser_interface());
}
pp::Instance* CreateInstance(PP_Instance instance) {
return new Application(instance);
}
};
}
/** @hideinitializer
@brief Entry point for windowless NaCl application
@param className Class name
See @ref Magnum::Platform::WindowlessNaClApplication "Platform::WindowlessNaClApplication"
for usage information. This macro abstracts out platform-specific entry point
code (the classic `main()` function cannot be used in NaCl). See
@ref portability-applications for more information. When no other windowless
application header is included this macro is also aliased to
`MAGNUM_WINDOWLESSAPPLICATION_MAIN()`.
*/
/* look at that insane placement of __attribute__. WTF. */
#define MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN(className) \
namespace pp { \
Module __attribute__ ((visibility ("default"))) * CreateModule(); \
Module __attribute__ ((visibility ("default"))) * CreateModule() { \
return new Magnum::Platform::Implementation::WindowlessNaClModule<className>(); \
} \
}
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_WINDOWLESSAPPLICATION_MAIN
typedef WindowlessNaClApplication WindowlessApplication;
typedef WindowlessNaClContext WindowlessGLContext;
#define MAGNUM_WINDOWLESSAPPLICATION_MAIN(className) MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN(className)
#else
#undef MAGNUM_WINDOWLESSAPPLICATION_MAIN
#endif
#endif
}}
#endif

41
src/Magnum/Platform/magnum-info-nacl.html

@ -1,41 +0,0 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Magnum Info</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="WebApplication.css" />
<style type="text/css">
#module {
position: absolute;
visibility: hidden; /* The module doesn't display anything */
}
#info {
width: 640px;
height: 480px;
overflow: auto;
font-family: monospace;
white-space: pre-wrap;
}
</style>
</head>
<body>
<h1>Magnum Info</h1>
<div id="listener">
<embed id="module" type="application/x-nacl" src="magnum-info.nmf"></embed>
<div id="status">Initialization...</div>
<div id="statusDescription"></div>
<div id="info"></div>
<script src="NaClApplication.js"></script>
<script type="text/javascript">
function messageReceived(message) {
var info = document.getElementById('info');
info.innerHTML += message.data;
}
var listener = document.getElementById('listener');
listener.addEventListener('message', messageReceived, true);
</script>
</div>
</body>
</html>

6
src/Magnum/Platform/magnum-info-nacl.nmf

@ -1,6 +0,0 @@
{
"program": {
"x86-32": {"url": "magnum-info-x86-32.nexe"},
"x86-64": {"url": "magnum-info-x86-64.nexe"}
}
}

29
src/Magnum/Platform/magnum-info.cpp

@ -25,9 +25,6 @@
#include <Corrade/Utility/Arguments.h> #include <Corrade/Utility/Arguments.h>
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
#ifdef CORRADE_TARGET_NACL
#include <Corrade/Utility/NaClStreamBuffer.h>
#endif
#include "Magnum/AbstractShaderProgram.h" #include "Magnum/AbstractShaderProgram.h"
#include "Magnum/Buffer.h" #include "Magnum/Buffer.h"
@ -59,8 +56,6 @@
#ifdef MAGNUM_TARGET_HEADLESS #ifdef MAGNUM_TARGET_HEADLESS
#include "Magnum/Platform/WindowlessEglApplication.h" #include "Magnum/Platform/WindowlessEglApplication.h"
#elif defined(CORRADE_TARGET_NACL)
#include "Magnum/Platform/WindowlessNaClApplication.h"
#elif defined(CORRADE_TARGET_IOS) #elif defined(CORRADE_TARGET_IOS)
#include "Magnum/Platform/WindowlessIosApplication.h" #include "Magnum/Platform/WindowlessIosApplication.h"
#elif defined(CORRADE_TARGET_APPLE) #elif defined(CORRADE_TARGET_APPLE)
@ -154,27 +149,16 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat
.addSkippedPrefix("magnum", "engine-specific options") .addSkippedPrefix("magnum", "engine-specific options")
.setHelp("Displays information about Magnum engine and OpenGL capabilities."); .setHelp("Displays information about Magnum engine and OpenGL capabilities.");
/**
* @todo Make this work in NaCl, somehow the arguments aren't passed to
* constructor but to Init() or whatnot
*/
#ifdef CORRADE_TARGET_IOS #ifdef CORRADE_TARGET_IOS
{ {
static_cast<void>(arguments); static_cast<void>(arguments);
const char* iosArguments[] = { "", "--limits" }; const char* iosArguments[] = { "", "--limits" };
args.parse(2, iosArguments); args.parse(2, iosArguments);
} }
#elif !defined(CORRADE_TARGET_NACL) #else
args.parse(arguments.argc, arguments.argv); args.parse(arguments.argc, arguments.argv);
#endif #endif
/* Pass debug output as messages to JavaScript */
#ifdef CORRADE_TARGET_NACL
Utility::NaClMessageStreamBuffer buffer(this);
std::ostream out(&buffer);
Debug::setOutput(&out);
#endif
Debug() << ""; Debug() << "";
Debug() << " +---------------------------------------------------------+"; Debug() << " +---------------------------------------------------------+";
Debug() << " | Information about Magnum engine and OpenGL capabilities |"; Debug() << " | Information about Magnum engine and OpenGL capabilities |";
@ -183,8 +167,6 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat
#ifdef MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN #ifdef MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN
Debug() << "Used application: Platform::WindowlessEglApplication"; Debug() << "Used application: Platform::WindowlessEglApplication";
#elif defined(MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN)
Debug() << "Used application: Platform::WindowlessNaClApplication";
#elif defined(MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN) #elif defined(MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN)
Debug() << "Used application: Platform::WindowlessIosApplication"; Debug() << "Used application: Platform::WindowlessIosApplication";
#elif defined(MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN) #elif defined(MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN)
@ -223,15 +205,6 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat
#ifdef CORRADE_TARGET_WINDOWS_RT #ifdef CORRADE_TARGET_WINDOWS_RT
Debug() << " CORRADE_TARGET_WINDOWS_RT"; Debug() << " CORRADE_TARGET_WINDOWS_RT";
#endif #endif
#ifdef CORRADE_TARGET_NACL
Debug() << " CORRADE_TARGET_NACL";
#endif
#ifdef CORRADE_TARGET_NACL_NEWLIB
Debug() << " CORRADE_TARGET_NACL_NEWLIB";
#endif
#ifdef CORRADE_TARGET_NACL_GLIBC
Debug() << " CORRADE_TARGET_NACL_GLIBC";
#endif
#ifdef CORRADE_TARGET_EMSCRIPTEN #ifdef CORRADE_TARGET_EMSCRIPTEN
Debug() << " CORRADE_TARGET_EMSCRIPTEN"; Debug() << " CORRADE_TARGET_EMSCRIPTEN";
#endif #endif

14
src/Magnum/Renderbuffer.cpp

@ -162,27 +162,13 @@ void Renderbuffer::storageMultisampleImplementationDefault(const GLsizei samples
} }
#elif !defined(MAGNUM_TARGET_WEBGL) #elif !defined(MAGNUM_TARGET_WEBGL)
void Renderbuffer::storageMultisampleImplementationANGLE(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { void Renderbuffer::storageMultisampleImplementationANGLE(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) {
#ifndef CORRADE_TARGET_NACL
bind(); bind();
glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, samples, GLenum(internalFormat), size.x(), size.y()); glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, samples, GLenum(internalFormat), size.x(), size.y());
#else
static_cast<void>(samples);
static_cast<void>(internalFormat);
static_cast<void>(size);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
void Renderbuffer::storageMultisampleImplementationNV(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) { void Renderbuffer::storageMultisampleImplementationNV(const GLsizei samples, const RenderbufferFormat internalFormat, const Vector2i& size) {
#ifndef CORRADE_TARGET_NACL
bind(); bind();
glRenderbufferStorageMultisampleNV(GL_RENDERBUFFER, samples, GLenum(internalFormat), size.x(), size.y()); glRenderbufferStorageMultisampleNV(GL_RENDERBUFFER, samples, GLenum(internalFormat), size.x(), size.y());
#else
static_cast<void>(samples);
static_cast<void>(internalFormat);
static_cast<void>(size);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif

3
src/Magnum/Renderbuffer.h

@ -237,8 +237,7 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject {
* or @extension{NV,framebuffer_multisample} in OpenGL ES 2.0. * or @extension{NV,framebuffer_multisample} in OpenGL ES 2.0.
* @requires_webgl20 Multisample framebuffers are not available in * @requires_webgl20 Multisample framebuffers are not available in
* WebGL 1.0. * WebGL 1.0.
* @todo How about @extension{APPLE,framebuffer_multisample}? * @todo How about @extension{APPLE,framebuffer_multisample}, @fn_gl_extension{RenderbufferStorageMultisample,EXT,multisampled_render_to_texture}?
* @todo NaCl has @fn_gl_extension{RenderbufferStorageMultisample,EXT,multisampled_render_to_texture}
*/ */
void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size); void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size);
#endif #endif

9
src/Magnum/Renderer.cpp

@ -85,17 +85,12 @@ void Renderer::setProvokingVertex(const ProvokingVertex mode) {
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
void Renderer::setPolygonMode(const PolygonMode mode) { void Renderer::setPolygonMode(const PolygonMode mode) {
#ifndef CORRADE_TARGET_NACL
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glPolygonMode glPolygonMode
#else #else
glPolygonModeNV glPolygonModeNV
#endif #endif
(GL_FRONT_AND_BACK, GLenum(mode)); (GL_FRONT_AND_BACK, GLenum(mode));
#else
static_cast<void>(mode);
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
#endif
} }
#endif #endif
@ -230,10 +225,8 @@ Renderer::GraphicsResetStatus Renderer::graphicsResetStatusImplementationDefault
Renderer::GraphicsResetStatus Renderer::graphicsResetStatusImplementationRobustness() { Renderer::GraphicsResetStatus Renderer::graphicsResetStatusImplementationRobustness() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
return GraphicsResetStatus(glGetGraphicsResetStatusARB()); return GraphicsResetStatus(glGetGraphicsResetStatusARB());
#elif !defined(CORRADE_TARGET_NACL)
return GraphicsResetStatus(glGetGraphicsResetStatusEXT());
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ return GraphicsResetStatus(glGetGraphicsResetStatusEXT());
#endif #endif
} }
#endif #endif

12
src/Magnum/Shader.cpp

@ -39,7 +39,7 @@
#include "Implementation/State.h" #include "Implementation/State.h"
#include "Implementation/ShaderState.h" #include "Implementation/ShaderState.h"
#if defined(CORRADE_TARGET_NACL_NEWLIB) || defined(CORRADE_TARGET_ANDROID) #ifdef CORRADE_TARGET_ANDROID
#include <sstream> #include <sstream>
#endif #endif
@ -779,7 +779,7 @@ std::vector<std::string> Shader::sources() const { return _sources; }
Shader& Shader::addSource(std::string source) { Shader& Shader::addSource(std::string source) {
if(!source.empty()) { if(!source.empty()) {
/** @todo Remove when newlib has this fixed (also the include above) */ /** @todo Remove when newlib has this fixed (also the include above) */
#if defined(CORRADE_TARGET_NACL_NEWLIB) || defined(CORRADE_TARGET_ANDROID) #ifdef CORRADE_TARGET_ANDROID
std::ostringstream converter; std::ostringstream converter;
converter << (_sources.size()+1)/2; converter << (_sources.size()+1)/2;
#endif #endif
@ -796,7 +796,7 @@ Shader& Shader::addSource(std::string source) {
least some user-provided source, an empty string is added here least some user-provided source, an empty string is added here
instead. */ instead. */
if(!_sources.empty()) _sources.push_back("#line 1 " + if(!_sources.empty()) _sources.push_back("#line 1 " +
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) #ifndef CORRADE_TARGET_ANDROID
std::to_string((_sources.size()+1)/2) + std::to_string((_sources.size()+1)/2) +
#else #else
converter.str() + converter.str() +
@ -860,7 +860,7 @@ bool Shader::compile(std::initializer_list<std::reference_wrapper<Shader>> shade
message.resize(std::max(logLength, 1)-1); message.resize(std::max(logLength, 1)-1);
/** @todo Remove when this is fixed everywhere (also the include above) */ /** @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; std::ostringstream converter;
converter << i; converter << i;
#endif #endif
@ -870,7 +870,7 @@ bool Shader::compile(std::initializer_list<std::reference_wrapper<Shader>> shade
Error out{Debug::Flag::NoNewlineAtTheEnd}; Error out{Debug::Flag::NoNewlineAtTheEnd};
out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader"; out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader";
if(shaders.size() != 1) { if(shaders.size() != 1) {
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) #ifndef CORRADE_TARGET_ANDROID
out << std::to_string(i); out << std::to_string(i);
#else #else
out << converter.str(); out << converter.str();
@ -883,7 +883,7 @@ bool Shader::compile(std::initializer_list<std::reference_wrapper<Shader>> shade
Warning out{Debug::Flag::NoNewlineAtTheEnd}; Warning out{Debug::Flag::NoNewlineAtTheEnd};
out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader"; out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader";
if(shaders.size() != 1) { if(shaders.size() != 1) {
#if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) #ifndef CORRADE_TARGET_ANDROID
out << std::to_string(i); out << std::to_string(i);
#else #else
out << converter.str(); out << converter.str();

29
src/Magnum/Test/BufferGLTest.cpp

@ -52,9 +52,6 @@ struct BufferGLTest: OpenGLTester {
void data(); void data();
void map(); void map();
#ifdef CORRADE_TARGET_NACL
void mapSub();
#endif
void mapRange(); void mapRange();
void mapRangeExplicitFlush(); void mapRangeExplicitFlush();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -78,9 +75,6 @@ BufferGLTest::BufferGLTest() {
&BufferGLTest::data, &BufferGLTest::data,
&BufferGLTest::map, &BufferGLTest::map,
#ifdef CORRADE_TARGET_NACL
&BufferGLTest::mapSub,
#endif
&BufferGLTest::mapRange, &BufferGLTest::mapRange,
&BufferGLTest::mapRangeExplicitFlush, &BufferGLTest::mapRangeExplicitFlush,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -304,29 +298,6 @@ void BufferGLTest::map() {
#endif #endif
} }
#ifdef CORRADE_TARGET_NACL
void BufferGLTest::mapSub() {
if(!Context::current().isExtensionSupported<Extensions::GL::CHROMIUM::map_sub>())
CORRADE_SKIP(Extensions::GL::CHROMIUM::map_sub::string() + std::string(" is not supported"));
Buffer buffer;
constexpr char data[] = {2, 7, 5, 13, 25};
buffer.setData(data, BufferUsage::StaticDraw);
char* contents = buffer.mapSub<char>(1, 4, Buffer::MapAccess::WriteOnly);
MAGNUM_VERIFY_NO_ERROR();
CORRADE_VERIFY(contents);
contents[3] = 107;
buffer.unmapSub();
MAGNUM_VERIFY_NO_ERROR();
/** @todo How to verify the contents in ES? */
}
#endif
void BufferGLTest::mapRange() { void BufferGLTest::mapRange() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::map_buffer_range>()) if(!Context::current().isExtensionSupported<Extensions::GL::ARB::map_buffer_range>())

2
src/Magnum/Text/CMakeLists.txt

@ -71,8 +71,6 @@ if(WITH_FONTCONVERTER)
target_link_libraries(magnum-fontconverter MagnumWindowlessIosApplication) target_link_libraries(magnum-fontconverter MagnumWindowlessIosApplication)
elseif(CORRADE_TARGET_APPLE) elseif(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-fontconverter MagnumWindowlessCglApplication) target_link_libraries(magnum-fontconverter MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_NACL)
target_link_libraries(magnum-fontconverter MagnumWindowlessNaClApplication)
elseif(CORRADE_TARGET_UNIX) elseif(CORRADE_TARGET_UNIX)
if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES)
target_link_libraries(magnum-fontconverter MagnumWindowlessEglApplication) target_link_libraries(magnum-fontconverter MagnumWindowlessEglApplication)

22
src/Magnum/Text/Renderer.cpp

@ -265,16 +265,6 @@ AbstractRenderer::BufferUnmapImplementation AbstractRenderer::bufferUnmapImpleme
void* AbstractRenderer::bufferMapImplementationFull(Buffer& buffer, GLsizeiptr) { void* AbstractRenderer::bufferMapImplementationFull(Buffer& buffer, GLsizeiptr) {
return buffer.map(Buffer::MapAccess::WriteOnly); return buffer.map(Buffer::MapAccess::WriteOnly);
} }
#ifdef CORRADE_TARGET_NACL
void* AbstractRenderer::bufferMapImplementationSub(Buffer& buffer, GLsizeiptr length) {
return buffer.mapSub(0, length, Buffer::MapAccess::WriteOnly);
}
void AbstractRenderer::bufferUnmapImplementationSub(Buffer& buffer) {
buffer.unmapSub();
}
#endif
#endif #endif
#if !defined(MAGNUM_TARGET_GLES2) || defined(CORRADE_TARGET_EMSCRIPTEN) #if !defined(MAGNUM_TARGET_GLES2) || defined(CORRADE_TARGET_EMSCRIPTEN)
@ -310,19 +300,9 @@ AbstractRenderer::AbstractRenderer(AbstractFont& font, const GlyphCache& cache,
#elif defined(MAGNUM_TARGET_GLES2) && !defined(CORRADE_TARGET_EMSCRIPTEN) #elif defined(MAGNUM_TARGET_GLES2) && !defined(CORRADE_TARGET_EMSCRIPTEN)
if(Context::current().isExtensionSupported<Extensions::GL::EXT::map_buffer_range>()) { if(Context::current().isExtensionSupported<Extensions::GL::EXT::map_buffer_range>()) {
bufferMapImplementation = &AbstractRenderer::bufferMapImplementationRange; bufferMapImplementation = &AbstractRenderer::bufferMapImplementationRange;
} } else {
#ifdef CORRADE_TARGET_NACL
else if(Context::current().isExtensionSupported<Extensions::GL::CHROMIUM::map_sub>()) {
bufferMapImplementation = &AbstractRenderer::bufferMapImplementationSub;
bufferUnmapImplementation = &AbstractRenderer::bufferUnmapImplementationSub;
}
#endif
else {
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::mapbuffer); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::mapbuffer);
Warning() << "Text::Renderer:" << Extensions::GL::EXT::map_buffer_range::string() Warning() << "Text::Renderer:" << Extensions::GL::EXT::map_buffer_range::string()
#ifdef CORRADE_TARGET_NACL
<< "or" << Extensions::GL::CHROMIUM::map_sub::string()
#endif
<< "is not supported, using inefficient" << Extensions::GL::OES::mapbuffer::string() << "is not supported, using inefficient" << Extensions::GL::OES::mapbuffer::string()
<< "instead"; << "instead";
} }

6
src/Magnum/Text/Renderer.h

@ -140,9 +140,6 @@ class MAGNUM_TEXT_EXPORT AbstractRenderer {
#if defined(MAGNUM_TARGET_GLES2) && !defined(CORRADE_TARGET_EMSCRIPTEN) #if defined(MAGNUM_TARGET_GLES2) && !defined(CORRADE_TARGET_EMSCRIPTEN)
typedef void*(*BufferMapImplementation)(Buffer&, GLsizeiptr); typedef void*(*BufferMapImplementation)(Buffer&, GLsizeiptr);
static MAGNUM_TEXT_LOCAL void* bufferMapImplementationFull(Buffer& buffer, GLsizeiptr length); static MAGNUM_TEXT_LOCAL void* bufferMapImplementationFull(Buffer& buffer, GLsizeiptr length);
#ifdef CORRADE_TARGET_NACL
static MAGNUM_TEXT_LOCAL void* bufferMapImplementationSub(Buffer& buffer, GLsizeiptr length);
#endif
static MAGNUM_TEXT_LOCAL void* bufferMapImplementationRange(Buffer& buffer, GLsizeiptr length); static MAGNUM_TEXT_LOCAL void* bufferMapImplementationRange(Buffer& buffer, GLsizeiptr length);
static BufferMapImplementation bufferMapImplementation; static BufferMapImplementation bufferMapImplementation;
#else #else
@ -157,9 +154,6 @@ class MAGNUM_TEXT_EXPORT AbstractRenderer {
#if defined(MAGNUM_TARGET_GLES2) && !defined(CORRADE_TARGET_EMSCRIPTEN) #if defined(MAGNUM_TARGET_GLES2) && !defined(CORRADE_TARGET_EMSCRIPTEN)
typedef void(*BufferUnmapImplementation)(Buffer&); typedef void(*BufferUnmapImplementation)(Buffer&);
static MAGNUM_TEXT_LOCAL void bufferUnmapImplementationDefault(Buffer& buffer); static MAGNUM_TEXT_LOCAL void bufferUnmapImplementationDefault(Buffer& buffer);
#ifdef CORRADE_TARGET_NACL
static MAGNUM_TEXT_LOCAL void bufferUnmapImplementationSub(Buffer& buffer);
#endif
static MAGNUM_TEXT_LOCAL BufferUnmapImplementation bufferUnmapImplementation; static MAGNUM_TEXT_LOCAL BufferUnmapImplementation bufferUnmapImplementation;
#else #else
#ifndef CORRADE_TARGET_EMSCRIPTEN #ifndef CORRADE_TARGET_EMSCRIPTEN

7
src/Magnum/Text/Test/RendererGLTest.cpp

@ -269,13 +269,8 @@ void RendererGLTest::mutableText() {
CORRADE_SKIP(Extensions::GL::ARB::map_buffer_range::string() + std::string(" is not supported")); CORRADE_SKIP(Extensions::GL::ARB::map_buffer_range::string() + std::string(" is not supported"));
#elif defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_EMSCRIPTEN) #elif defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_EMSCRIPTEN)
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::map_buffer_range>() && if(!Context::current().isExtensionSupported<Extensions::GL::EXT::map_buffer_range>() &&
!Context::current().isExtensionSupported<Extensions::GL::OES::mapbuffer>() !Context::current().isExtensionSupported<Extensions::GL::OES::mapbuffer>())
#ifdef CORRADE_TARGET_NACL
&& !Context::current().isExtensionSupported<Extensions::GL::CHROMIUM::map_sub>()
#endif
) {
CORRADE_SKIP("No required extension is supported"); CORRADE_SKIP("No required extension is supported");
}
#endif #endif
TestFont font; TestFont font;

2
src/Magnum/Text/fontconverter.cpp

@ -34,8 +34,6 @@
#ifdef MAGNUM_TARGET_HEADLESS #ifdef MAGNUM_TARGET_HEADLESS
#include "Magnum/Platform/WindowlessEglApplication.h" #include "Magnum/Platform/WindowlessEglApplication.h"
#elif defined(CORRADE_TARGET_NACL)
#include "Magnum/Platform/WindowlessNaClApplication.h"
#elif defined(CORRADE_TARGET_IOS) #elif defined(CORRADE_TARGET_IOS)
#include "Magnum/Platform/WindowlessIosApplication.h" #include "Magnum/Platform/WindowlessIosApplication.h"
#elif defined(CORRADE_TARGET_APPLE) #elif defined(CORRADE_TARGET_APPLE)

2
src/Magnum/TextureTools/CMakeLists.txt

@ -68,8 +68,6 @@ if(WITH_DISTANCEFIELDCONVERTER)
target_link_libraries(magnum-distancefieldconverter MagnumWindowlessIosApplication) target_link_libraries(magnum-distancefieldconverter MagnumWindowlessIosApplication)
elseif(CORRADE_TARGET_APPLE) elseif(CORRADE_TARGET_APPLE)
target_link_libraries(magnum-distancefieldconverter MagnumWindowlessCglApplication) target_link_libraries(magnum-distancefieldconverter MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_NACL)
target_link_libraries(magnum-distancefieldconverter MagnumWindowlessNaClApplication)
elseif(CORRADE_TARGET_UNIX) elseif(CORRADE_TARGET_UNIX)
if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES) if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES)
target_link_libraries(magnum-distancefieldconverter MagnumWindowlessEglApplication) target_link_libraries(magnum-distancefieldconverter MagnumWindowlessEglApplication)

2
src/Magnum/TextureTools/distancefieldconverter.cpp

@ -40,8 +40,6 @@
#ifdef MAGNUM_TARGET_HEADLESS #ifdef MAGNUM_TARGET_HEADLESS
#include "Magnum/Platform/WindowlessEglApplication.h" #include "Magnum/Platform/WindowlessEglApplication.h"
#elif defined(CORRADE_TARGET_NACL)
#include "Magnum/Platform/WindowlessNaClApplication.h"
#elif defined(CORRADE_TARGET_IOS) #elif defined(CORRADE_TARGET_IOS)
#include "Magnum/Platform/WindowlessIosApplication.h" #include "Magnum/Platform/WindowlessIosApplication.h"
#elif defined(CORRADE_TARGET_APPLE) #elif defined(CORRADE_TARGET_APPLE)

2
src/Magnum/TimeQuery.h

@ -174,7 +174,7 @@ class TimeQuery: public AbstractQuery {
void timestamp() { void timestamp() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
glQueryCounter(id(), GL_TIMESTAMP); glQueryCounter(id(), GL_TIMESTAMP);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #elif !defined(CORRADE_TARGET_EMSCRIPTEN)
glQueryCounterEXT(id(), GL_TIMESTAMP_EXT); glQueryCounterEXT(id(), GL_TIMESTAMP_EXT);
#else #else
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */

4
src/Magnum/Timeline.h

@ -63,8 +63,8 @@ buffer swap. You can use @ref previousFrameDuration() to compute animation
speed. To limit application framerate you can use speed. To limit application framerate you can use
@ref Platform::Sdl2Application::setSwapInterval() "Platform::*Application::setSwapInterval()" or @ref Platform::Sdl2Application::setSwapInterval() "Platform::*Application::setSwapInterval()" or
@ref Platform::Sdl2Application::setMinimalLoopPeriod() "Platform::*Application::setMinimalLoopPeriod()". @ref Platform::Sdl2Application::setMinimalLoopPeriod() "Platform::*Application::setMinimalLoopPeriod()".
Note that on @ref CORRADE_TARGET_NACL "NaCl" and @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" Note that on @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" the framerate is
the framerate is governed by browser and you can't do anything about it. governed by browser and you can't do anything about it.
Example usage: Example usage:
@code @code

10
src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt vendored

@ -29,10 +29,8 @@ if(CORRADE_TARGET_WINDOWS AND MAGNUM_TARGET_DESKTOP_GLES)
set(MagnumOpenGL_HEADERS flextGLWindowsDesktop.h) set(MagnumOpenGL_HEADERS flextGLWindowsDesktop.h)
set(MagnumOpenGL_SRCS flextGLWindowsDesktop.cpp) set(MagnumOpenGL_SRCS flextGLWindowsDesktop.cpp)
# NaCl and Emscripten are special, provide only some extensions for them (and # Emscripten is special, provide only some extensions for it (and no extension
# no extension loading) # loading)
elseif(CORRADE_TARGET_NACL)
set(MagnumOpenGL_HEADERS flextGLNaCl.h)
elseif(CORRADE_TARGET_EMSCRIPTEN) elseif(CORRADE_TARGET_EMSCRIPTEN)
set(MagnumOpenGL_HEADERS flextGLEmscripten.h) set(MagnumOpenGL_HEADERS flextGLEmscripten.h)
@ -42,8 +40,8 @@ else()
set(MagnumOpenGL_SRCS flextGL.cpp) set(MagnumOpenGL_SRCS flextGL.cpp)
endif() endif()
# NaCl and Emscripten don't have the ability to load function pointers manually # Emscripten doesn't have the ability to load function pointers manually
if(NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_EMSCRIPTEN) if(NOT CORRADE_TARGET_EMSCRIPTEN)
# flextGLPlatform*.cpp is compiled as part of Magnum*Context libraries in Platform # flextGLPlatform*.cpp is compiled as part of Magnum*Context libraries in Platform
add_library(MagnumFlextGLObjects OBJECT ${MagnumOpenGL_SRCS}) add_library(MagnumFlextGLObjects OBJECT ${MagnumOpenGL_SRCS})
target_include_directories(MagnumFlextGLObjects PUBLIC $<TARGET_PROPERTY:Magnum,INTERFACE_INCLUDE_DIRECTORIES>) target_include_directories(MagnumFlextGLObjects PUBLIC $<TARGET_PROPERTY:Magnum,INTERFACE_INCLUDE_DIRECTORIES>)

60
src/MagnumExternal/OpenGL/GLES2/NaCl/flextGLNaCl.h.template vendored

@ -1,60 +0,0 @@
@require(passthru, functions, enums, options, version, extensions)
#ifndef _flextgl_h_
#define _flextgl_h_
/* Defensive include guards */
#if defined(__gl2_h_)
#error Attempt to include auto-generated header after including gl2.h
#endif
#if defined(__gl2platform_h_)
#error Attempt to include auto-generated header after including gl2platform.h
#endif
#define __gl2_h_
#define __gl2platform_h_
#ifdef __cplusplus
extern "C" {
#endif
void flextGLInit();
/* Function declaration macros */
#define FLEXTGL_EXPORT __attribute__ ((visibility ("default")))
#define APIENTRY
#ifndef GL_APICALL
#define GL_APICALL KHRONOS_APICALL
#endif
#ifndef GL_APIENTRY
#define GL_APIENTRY KHRONOS_APIENTRY
#endif
/* Data types */
@passthru
/* Enums */
@enums
/* Function prototypes */
@for cat,funcs in functions:
/* GL_@cat */
#ifndef GL_@cat
#define GL_@cat 1
@for f in funcs:
GL_APICALL @f.returntype GL_APIENTRY GLES2@f.name\
(@f.param_type_list_string());
#define gl@f.name GLES2@f.name
@end
#endif
@end
#ifdef __cplusplus
}
#endif
#endif

8
src/MagnumExternal/OpenGL/GLES2/README.md vendored

@ -20,14 +20,12 @@ iOS, on the other hand, doesn't have any extension loader mechanism and all
supported entrypoints are exported from the library, so we set the function supported entrypoints are exported from the library, so we set the function
pointers to those exported symbols in case the system GL header defines them. pointers to those exported symbols in case the system GL header defines them.
NaCl and Emscripten don't have the ability to manually load extension pointers, Emscripten doesn't have the ability to manually load extension pointers, thus
thus they have only header files: it has only header files:
.../flextGLgen.py -D . -t NaCl/ extensions.txt
.../flextGLgen.py -D . -t Emscripten/ Emscripten/extensions.txt .../flextGLgen.py -D . -t Emscripten/ Emscripten/extensions.txt
This will generate stripped-down `flextGLNaCl.h` and `flextGLEmscripten.h` This will generate stripped-down `flextGLEmscripten.h` files.
files.
As usual, be sure to check the diff for suspicious changes and As usual, be sure to check the diff for suspicious changes and
whitespace-at-EOL (although there shouldn't be any). whitespace-at-EOL (although there shouldn't be any).

1989
src/MagnumExternal/OpenGL/GLES2/flextGLNaCl.h vendored

File diff suppressed because it is too large Load Diff

2
src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt vendored

@ -41,7 +41,7 @@ else()
endif() endif()
# Emscripten doesn't have the ability to load function pointers manually # Emscripten doesn't have the ability to load function pointers manually
if(NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_EMSCRIPTEN) if(NOT CORRADE_TARGET_EMSCRIPTEN)
# flextGLPlatform*.cpp is compiled as part of Magnum*Context libraries in Platform # flextGLPlatform*.cpp is compiled as part of Magnum*Context libraries in Platform
add_library(MagnumFlextGLObjects OBJECT ${MagnumOpenGL_SRCS}) add_library(MagnumFlextGLObjects OBJECT ${MagnumOpenGL_SRCS})
target_include_directories(MagnumFlextGLObjects PUBLIC $<TARGET_PROPERTY:Magnum,INTERFACE_INCLUDE_DIRECTORIES>) target_include_directories(MagnumFlextGLObjects PUBLIC $<TARGET_PROPERTY:Magnum,INTERFACE_INCLUDE_DIRECTORIES>)

3
src/MagnumExternal/OpenGL/KHR/CMakeLists.txt vendored

@ -23,7 +23,4 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
# NaCl has its own gl2.h, this one causes linker issues
if(NOT CORRADE_TARGET_NACL)
install(FILES khrplatform.h DESTINATION ${MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR}/OpenGL/KHR) install(FILES khrplatform.h DESTINATION ${MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR}/OpenGL/KHR)
endif()

Loading…
Cancel
Save