diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4909b4f95..4aa84607b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,6 +63,11 @@ else()
option(WITH_SDL2APPLICATION "Build Sdl2Application library" OFF)
endif()
+option(BUILD_DEPRECATED "Include deprecated API in the build" ON)
+if(BUILD_DEPRECATED)
+ set(MAGNUM_BUILD_DEPRECATED 1)
+endif()
+
option(BUILD_STATIC "Build static libraries (default are shared)" OFF)
cmake_dependent_option(BUILD_STATIC_PIC "Build static libraries with position-independent code" OFF "BUILD_STATIC" OFF)
option(BUILD_TESTS "Build unit tests." OFF)
@@ -83,11 +88,12 @@ endif()
if(CORRADE_TARGET_NACL OR CORRADE_TARGET_EMSCRIPTEN)
set(TARGET_GLES 1)
set(TARGET_GLES2 1)
+endif()
- # Newlib toolchain supports only static linking
- if(CORRADE_TARGET_NACL_NEWLIB)
- set(BUILD_STATIC ON)
- endif()
+# NaCl newlib toolchain supports only static linking, dynamic linking is
+# meaningless on Emscripten
+if(CORRADE_TARGET_NACL_NEWLIB OR CORRADE_TARGET_EMSCRIPTEN)
+ set(BUILD_STATIC ON)
endif()
if(BUILD_STATIC)
diff --git a/Doxyfile b/Doxyfile
index 90af7401d..ee684d052 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -210,6 +210,7 @@ ALIASES = \
"fn_gl_extension{3}=gl\1\2()" \
"fn_gles_extension{3}=gl\1\2()" \
"def_gl{1}=`GL_\1`" \
+ "deprecated_gl=@xrefitem deprecated-gl \"Deprecated OpenGL API\" \"Deprecated OpenGL API list\"" \
"requires_gl30=@xrefitem requires-gl30 \"Requires OpenGL 3.0\" \"Functionality requiring OpenGL 3.0\"" \
"requires_gl31=@xrefitem requires-gl31 \"Requires OpenGL 3.1\" \"Functionality requiring OpenGL 3.1\"" \
"requires_gl32=@xrefitem requires-gl32 \"Requires OpenGL 3.2\" \"Functionality requiring OpenGL 3.2\"" \
@@ -1644,7 +1645,7 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
-PREDEFINED = DOXYGEN_GENERATING_OUTPUT
+PREDEFINED = DOXYGEN_GENERATING_OUTPUT MAGNUM_BUILD_DEPRECATED
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
diff --git a/PKGBUILD b/PKGBUILD
index 893f31af4..c04bc16ee 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -7,7 +7,7 @@ arch=('i686' 'x86_64')
url="https://github.com/mosra/magnum"
license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2')
-makedepends=('cmake')
+makedepends=('cmake' 'ninja')
options=(!strip)
provides=('magnum-git')
@@ -30,8 +30,9 @@ build() {
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
- -DBUILD_TESTS=TRUE
- make
+ -DBUILD_TESTS=TRUE \
+ -G Ninja
+ ninja
}
check() {
@@ -41,5 +42,5 @@ check() {
package() {
cd "$startdir/build"
- make DESTDIR="$pkgdir/" install
+ DESTDIR="$pkgdir/" ninja install
}
diff --git a/PKGBUILD-emscripten b/PKGBUILD-emscripten
new file mode 100644
index 000000000..f80ca8080
--- /dev/null
+++ b/PKGBUILD-emscripten
@@ -0,0 +1,37 @@
+# Author: mosra
+pkgname=emscripten-magnum
+pkgver=dev
+pkgrel=1
+pkgdesc="C++11 and OpenGL 2D/3D graphics engine (Emscripten)"
+arch=('any')
+url="http://mosra.cz/blog/magnum.php"
+license=('MIT')
+depends=('emscripten-corrade')
+makedepends=('cmake')
+options=(!strip !buildflags)
+
+build() {
+ if [ ! -d "$startdir/build-emscripten" ] ; then
+ mkdir "$startdir/build-emscripten"
+ cd "$startdir/build-emscripten"
+
+ cmake .. \
+ -DCMAKE_MODULE_PATH="$startdir/toolchains/modules" \
+ -DCMAKE_TOOLCHAIN_FILE="$startdir/toolchains/generic/Emscripten.cmake" \
+ -DWITH_AUDIO=OFF
+ fi
+
+ cd "$startdir/build-emscripten"
+
+ cmake .. \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=/usr/emscripten/system \
+ -DWITH_AUDIO=OFF \
+ -DWITH_SDL2APPLICATION=ON
+ make
+}
+
+package() {
+ cd "$startdir/build-emscripten"
+ make DESTDIR="$pkgdir/" install
+}
diff --git a/README.md b/README.md
index 18fc6b706..b927853e1 100644
--- a/README.md
+++ b/README.md
@@ -39,14 +39,22 @@ DESIGN GOALS
SUPPORTED PLATFORMS
===================
+Graphics APIs:
+
* **OpenGL** 2.1 through 4.4, core profile functionality and modern
extensions
* **OpenGL ES** 2.0, 3.0 and extensions to match desktop OpenGL functionality
+* **WebGL** 1.0 and extensions to match desktop OpenGL functionality
+
+Platforms:
+
* **Linux** and embedded Linux (natively using GLX/EGL and Xlib or through
GLUT or SDL2 toolkit)
* **Windows** (through GLUT or SDL2 toolkit)
+* **OS X** (through SDL2 toolkit, thanks to [Miguel Martin](https://github.com/miguelishawt))
* **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))
FEATURES
========
diff --git a/doc/building.dox b/doc/building.dox
index f3e414ecd..10db305a4 100644
--- a/doc/building.dox
+++ b/doc/building.dox
@@ -23,15 +23,10 @@
*/
namespace Magnum {
+
/** @page building Downloading and building
@brief Guide how to download and build %Magnum on different platforms.
-%Magnum can be downloaded from GitHub and built either
-@ref building-compilation "manually" or using already prepared packaging files,
-currently only @ref building-arch "ArchLinux PKGBUILDs". Guide how to
-crosscompile for @ref building-win "Windows" and
-@ref building-nacl "Google Chrome Native Client" is also available.
-
@tableofcontents
Minimal set of tools and libraries required for building is:
@@ -44,6 +39,8 @@ Minimal set of tools and libraries required for building is:
- **Corrade** - Plugin management and utility library. See
@ref building-corrade "Corrade download and installation guide" for more
information.
+- **OpenAL** - By default needed by Audio library, but you can disable building
+ of it by setting `WITH_AUDIO` to `OFF` (see below).
@section building-download Downloading the sources
@@ -53,16 +50,12 @@ compressed archive or use the command line:
git clone git://github.com/mosra/magnum.git
-If you need toolchains for crosscompiling, run also the following commands, or,
-if you build from source archive, download snapshot of toolchains repository
-from https://github.com/mosra/toolchains and put them in `toolchains/`
-subdirectory.
-
- git submodule init
- git submodule update
-
@section building-compilation Compilation, installation
+Relevant information about CMake usage was described in
+@ref building-corrade "Corrade download and installation guide", this guide is
+assuming you have at least basic knowledge of CMake.
+
@subsection building-linux Via command-line (on Linux/Unix)
On Unix-based OSs, the library (for example with support for GLUT applications)
@@ -75,12 +68,7 @@ can be built and installed using these four commands:
make
make install
-The library provides a lot of CMake options (described in sections later). They
-can be passed to CMake either as `-Dname=value` parameters on command-line
-(like above) or set conveniently using `cmake-gui`:
-
- cd build
- cmake-gui .
+See @ref building-features "below" for additional configuration options.
@subsection building-windows Using QtCreator and CMake GUI (on Windows)
@@ -96,14 +84,11 @@ and you won't need to explicitly specify path to each one.
Then just open project's root `CMakeLists.txt` file within QtCreator. It then
asks you where to create build directory, allows you to specify initial CMake
-parameters and then you can just press Configure and everything should be ready
-to be built. You might need to set some CMake parameters before configuring,
-they can be set with `-Dname=value`. See below for more information.
+parameters and then you can just press *Configure* and everything is be ready
+to be built.
-After the initial import you might want to reconfigure some CMake variables
-(more information below). Start CMake GUI, point it to the recently created
-build dir, modify the variables and press Generate. QtCreator will detect the
-changes and reparse the project accordingly.
+After the initial import you might want to reconfigure some CMake variables,
+see @ref building-features "below" for more information.
For most convenient usage it's best to set `CMAKE_INSTALL_PREFIX` to directory
where MinGW is installed (e.g. `C:/MinGW/`) and add `C:/MinGW/bin` and
@@ -112,7 +97,7 @@ within QtCreator by adding new `make install` build rule.
@subsubsection building-windows-troubleshooting Windows troubleshooting
-If CMake isn't able to find dependencies (e.g. Corrade is not found) and you
+If CMake isn't able to find dependencies (e.g. %Corrade is not found) and you
have installed them to MinGW directory, point to `CMAKE_FIND_ROOT_PATH` to
MinGW installation prefix, e.g. specify `-DCMAKE_FIND_ROOT_PATH=C:/MinGW/`
CMake parameter.
@@ -132,6 +117,12 @@ Clang), pass `-DCMAKE_CXX_COMPILER=clang++` to CMake.
the module with your code instead of depending on it being in system location.
You can install it by enabling `WITH_FIND_MODULE`.
+The library is constantly evolving and thus some APIs are deprecated and then
+later removed in favor of better ones. To preserve backwards compatibility,
+%Magnum is by default built with all deprecated APIs. However, to make your
+code more robust and future-proof, it's recommended to build the library with
+`BUILD_DEPRECATED` disabled.
+
By default the engine is built for desktop OpenGL. Using `TARGET_*` CMake
parameters you can target other platforms. Note that some features are
available for desktop OpenGL only, see @ref requires-gl.
@@ -151,7 +142,7 @@ By default the engine is built with everything except application libraries
(see below). Using `WITH_*` CMake parameters you can specify which parts will
be built and which not:
- - `WITH_AUDIO` - Audio library. Requires **OpenAL** library.
+ - `WITH_AUDIO` - Audio library.
- `WITH_DEBUGTOOLS` - DebugTools library. Enables also building of MeshTools,
Primitives, SceneGraph, Shaders and Shapes libraries.
- `WITH_MESHTOOLS` - MeshTools library. Enabled automatically if `WITH_DEBUGTOOLS`
@@ -177,44 +168,52 @@ None of the @ref Platform "application libraries" is built by default (and you
need at least one). Choose the one which suits your requirements and your
platform best:
-- `WITH_GLUTAPPLICATION` - @ref Platform::GlutApplication "GlutApplication",
- available only if targeting desktop OpenGL. Requires **GLUT** library.
-- `WITH_GLXAPPLICATION` - @ref Platform::GlxApplication "GlxApplication".
- Requires **X11** and **GLX** libraries.
-- `WITH_NACLAPPLICATION` - @ref Platform::NaClApplication "NaClApplication",
- available only if targeting Google Chrome Native Client (see below).
-- `WITH_SDL2APPLICATION` - @ref Platform::Sdl2Application "Sdl2Application".
- Requires **SDL2** library.
-- `WITH_XEGLAPPLICATION` - @ref Platform::XEglApplication "XEglApplication",
- available only if targeting OpenGL ES (see above). Requires **X11** and **EGL**
- libraries.
-- `WITH_WINDOWLESSGLXAPPLICATION` - @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication".
- Requires **X11** and **GLX** libraries.
+- `WITH_GLUTAPPLICATION` - @ref Platform::GlutApplication "GlutApplication"
+- `WITH_GLXAPPLICATION` - @ref Platform::GlxApplication "GlxApplication"
+- `WITH_NACLAPPLICATION` - @ref Platform::NaClApplication "NaClApplication"
+- `WITH_SDL2APPLICATION` - @ref Platform::Sdl2Application "Sdl2Application"
+- `WITH_XEGLAPPLICATION` - @ref Platform::XEglApplication "XEglApplication"
+- `WITH_WINDOWLESSGLXAPPLICATION` - @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication"
+- `WITH_WINDOWLESSNACLAPPLICATION` - @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
+
+Note that [each namespace](namespaces.html) and all @ref Platform libraries
+contain more detailed information about dependencies, availability on
+particular platform and also guide how to enable given library in build and use
+it with CMake.
@subsection building-tests Building and running unit tests
If you want to build also unit tests (which are not built by default), enable
-`BUILD_TEST` in CMake. Unit tests use Corrade's @ref Corrade::TestSuite
+`BUILD_TESTS` in CMake. Unit tests use Corrade's @ref Corrade::TestSuite
"TestSuite" framework and can be run either manually (the binaries are located
in `Test/` subdirectories of build directory) or using
ctest --output-on-failure
in build directory. On Windows the tests require the library to be installed
-with DLLs accessible through `PATH`. See above for more information.
+with DLLs accessible through `PATH`. See
+@ref building-windows "above Windows documentation" for more information.
+
+Platforms which have windowless context creation implemented (currently only
+desktop Linux) can build also tests for OpenGL functionality. You can enable
+them with `BUILD_GL_TESTS`.
@subsection building-doc Building documentation
The documentation (which you are currently reading) is written in **Doxygen**
(version 1.8 with Markdown support is used, but older versions should do good
-job too) and additionally uses **Graphviz** for class diagrams and **TeX**
-for math formulas. The documentation can be build by running
+job too) and additionally uses **TeX** for math formulas. The documentation can
+be build by running
doxygen
in root directory (i.e. where `Doxyfile` is). Resulting HTML documentation
will be in `build/doc/` directory. You might need to create `build/` directory
-if it doesn't exist yet.
+if it doesn't exist yet. If %Corrade with generated documentation is placed in
+`corrade` directory next to `magnum`, the documentation will be crosslinked
+with %Corrade's one. If related projects (`magnum-plugins`, `magnum-integration`
+and `magnum-examples`, see below) are places along these, their documentation
+will be also included in generated output.
@section building-related Related projects
@@ -225,7 +224,9 @@ formats are maintained in @ref building-plugins "Plugins repository",
Integration with various external math and physics libraries is provided by
@ref building-integration "Integration library".
-@section building-arch Building ArchLinux packages
+@section building-packages Prepared packages
+
+@subsection building-packages-arch ArchLinux packages
In `package/archlinux` directory is currently one PKGBUILD for Git development
build. The package is also in AUR under the same name.
@@ -242,7 +243,22 @@ If you want to build with another compiler (e.g. Clang), run makepkg this way:
Development PKGBUILDs can detect when Clang is used and remove unsupported CXX
flags.
-@section building-win Crosscompiling for Windows using MinGW
+@section building-crosscompiling Crosscompiling
+
+For crosscompiling you need to have *both* target and native version of
+%Corrade installed, because %Corrade needs to run `corrade-rc` utility on the
+host system as part of the build process. If native version of `corrade-rc` is
+not found on the system, crosscompilation will fail.
+
+You also need to have the toolchains submodule updated. Either run the
+following commands, or, if you build from source archive, download snapshot of
+toolchains repository from https://github.com/mosra/toolchains and put the
+contents in `toolchains/` subdirectory.
+
+ git submodule init
+ git submodule update
+
+@subsection building-cross-win Crosscompiling for Windows using MinGW
@note This guide is tailored mainly for crosscompiling from ArchLinux. For
this system there is also prepared `mingw32-magnum` development package in
@@ -255,10 +271,9 @@ You will need MinGW32 versions of the compiler and all dependent libraries
- `mingw32-runtime`
- `mingw32-corrade`
-Make sure you have `toolchains` submodule updated, as
-@ref building-download "explained above". Then create build directory and run
-cmake and make. You may need to modify the `basic-mingw32.cmake` file and
-`CMAKE_INSTALL_PREFIX` to suit your distribution filesystem hierarchy.
+Then create build directory and run cmake and make. You may need to modify the
+`basic-mingw32.cmake` file and `CMAKE_INSTALL_PREFIX` to suit your distribution
+filesystem hierarchy.
mkdir build-win
cd build-win
@@ -270,20 +285,18 @@ cmake and make. You may need to modify the `basic-mingw32.cmake` file and
Then you can install the package using `make install` to make it available for
depending projects.
-@section building-nacl Compiling for Google Chrome Native Client
+@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`.
-Make sure you have `toolchains` submodule updated, as
-@ref building-download "explained above". 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.
+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 make in
them. The toolchains need access to its platform file, so be sure to properly
@@ -318,5 +331,38 @@ for depending projects. The headers are shared by both versions.
For ArchLinux there are also prepared package files in root, named
`PKGBUILD-nacl-glibc` and `PKGBUILD-nacl-newlib`.
+@subsection building-cross-emscripten Crosscompiling for Emscripten
+
+You will need [Emscripten](https://github.com/kripken/emscripten/wiki/Tutorial)
+installed and configured.
+
+Don't forget to adapt `EMSCRIPTEN_PREFIX` variable in `generic/Emscripten.cmake`
+to path where Emscripten is installed. Default is `/usr/emscripten`. Emscripten
+supports dynamic only to simplify porting and they are generally slower, thus
+`BUILD_STATIC` is implicitly enabled.
+
+Then create build directory and run cmake and make in it. The toolchain needs
+access to its platform file, so be sure to properly set **absolute** path to
+`modules/` directory containing `Platform/Emscripten.cmake`. Default is
+`/usr/emscripten`. Also set `CMAKE_INSTALL_PREFIX` to value which is contained
+in `CMAKE_FIND_ROOT_PATH` in toolchain file.
+
+ mkdir -p build-emscripten
+ cd build-emscripten
+ cmake .. \
+ -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \
+ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten.cmake" \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=/usr/emscripten/system \
+ -DWITH_SDL2APPLICATION=ON
+ make
+
+Then you can install the library using `make install` to make it available for
+depending projects.
+
+If you have Node.js installed, you can also build and run unit tests using
+`ctest`. See `BUILD_TESTS` above.
+
*/
+
}
diff --git a/doc/cmake.dox b/doc/cmake.dox
index 6493356b5..fbea44ae0 100644
--- a/doc/cmake.dox
+++ b/doc/cmake.dox
@@ -51,7 +51,7 @@ components. The base library depends on %Corrade and OpenGL libraries (or
OpenGL ES libraries). Additional dependencies are specified by the components.
The optional components are:
-- `%Audio` -- Audio library (depends on OpenAL library)
+- `%Audio` -- Audio library
- `%DebugTools` -- DebugTools library (depends on `%MeshTools`,
`%Primitives`, `%SceneGraph`, `%Shaders` and `%Shapes` components)
- `%MeshTools` -- MeshTools library
@@ -65,17 +65,17 @@ The optional components are:
Platform namespace is split into more components:
- `%GlutApplication` -- @ref Platform::GlutApplication "GlutApplication"
- (depends on GLUT library)
-- `%GlxApplication` -- @ref Platform::GlxApplication "GlxApplication" (depends
- on GLX and X11 libraries)
+- `%GlxApplication` -- @ref Platform::GlxApplication "GlxApplication"
- `%NaClApplication` -- @ref Platform::NaClApplication "NaClApplication"
- (only if targeting Google Chrome Native Client)
- `%Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application"
- (depends on SDL2 library)
- `%XEglApplication` -- @ref Platform::XEglApplication "XEglApplication"
- (depends on EGL and X11 libraries)
+- `%WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
- `%WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication"
- (depends on GLX and X11 libraries)
+
+Note that [each namespace](namespaces.html) and all @ref Platform libraries
+contain more detailed information about dependencies, availability on
+particular platform and also guide how to enable given library in build and use
+it with CMake.
Example usage with specifying additional components is:
@@ -96,6 +96,8 @@ convenience aliases `MAGNUM_APPLICATION_LIBRARIES` /
Features of found %Magnum library are exposed in these CMake variables, they
are also available as preprocessor variables if including Magnum.h:
+- `MAGNUM_BUILD_DEPRECATED` -- Defined if compiled with deprecated APIs
+ included
- `MAGNUM_BUILD_STATIC` -- Defined if built as static libraries. Default are
shared libraries.
- `MAGNUM_TARGET_GLES` -- Defined if compiled for OpenGL ES
diff --git a/doc/debug-tools.dox b/doc/debug-tools.dox
index 95f4ded6d..2ffe8df0f 100644
--- a/doc/debug-tools.dox
+++ b/doc/debug-tools.dox
@@ -24,15 +24,17 @@
namespace Magnum {
/** @page debug-tools Debugging helpers
-
@brief Convenience classes to help you during development.
-@tableofcontents
+- Previous page: @ref shapes
-DebugTools library provides various helper classes to help you with
+@ref DebugTools library provides various helper classes to help you with
prototyping and debugging applications without the need to write too much
common code. They probably have no usage in production code, but can be useful
-in development.
+in development. See documentation of @ref DebugTools namespace for more
+information about building and usage with CMake.
+
+@tableofcontents
@section debug-tools-renderers Debug renderers
@@ -75,5 +77,6 @@ new DebugTools::ObjectRenderer2D(*object, "my", debugDrawables);
See DebugTools::ObjectRenderer and DebugTools::ShapeRenderer for more
information.
+- Previous page: @ref shapes
*/
}
diff --git a/doc/features.dox b/doc/features.dox
index a2e0e22db..bd0ba5ff9 100644
--- a/doc/features.dox
+++ b/doc/features.dox
@@ -24,7 +24,7 @@
namespace Magnum {
/** @page features Feature overview
-@brief Fundamental principles and design goals
+@brief Fundamental principles and design goals.
- @subpage platform -- @copybrief platform
- @subpage types -- @copybrief types
diff --git a/doc/mainpage.dox b/doc/mainpage.dox
index d24de7caf..4cea30e2d 100644
--- a/doc/mainpage.dox
+++ b/doc/mainpage.dox
@@ -64,14 +64,22 @@ recent C++11 features and to abstract away platform-specific issues.
@section mainpage-platforms Supported platforms
+Graphics APIs:
+
- **OpenGL** 2.1 through 4.4, core profile functionality and modern
extensions
- **OpenGL ES** 2.0, 3.0 and extensions to match desktop OpenGL functionality
+- **WebGL** 1.0 and extensions to match desktop OpenGL functionality
+
+Platforms:
+
- **Linux** and embedded Linux (natively using GLX/EGL and Xlib or through
GLUT or SDL2 toolkit)
- **Windows** (through GLUT or SDL2 toolkit)
+- **OS X** (through SDL2 toolkit, thanks to [Miguel Martin](https://github.com/miguelishawt))
- **Google Chrome** (through [Native Client](https://developers.google.com/native-client/),
both `newlib` and `glibc` toolchains are supported)
+- **HTML5/JavaScript** (through [Emscripten](https://github.com/kripken/emscripten/wiki))
@section mainpage-features Features
diff --git a/doc/matrix-vector.dox b/doc/matrix-vector.dox
index c5703196a..e3b112bbc 100644
--- a/doc/matrix-vector.dox
+++ b/doc/matrix-vector.dox
@@ -24,15 +24,18 @@
namespace Magnum {
/** @page matrix-vector Operations with matrices and vectors
-
@brief Introduction to essential classes of the graphics pipeline.
-@tableofcontents
+- Previous page: @ref types
+- Next page: @ref transformations
Matrices and vectors are the most important part of graphics programming and
-one of goals of %Magnum is to make their usage as intuitive as possible. This
-page will overview their usage and introduce some tricks to make your life
-easier.
+one of goals of %Magnum is to make their usage as intuitive as possible. They
+are contained in @ref Math namespace and common variants also have aliases in
+root @ref Magnum namespace. See documentation of these namespaces for more
+information about usage with CMake.
+
+@tableofcontents
@section matrix-vector-hierarchy Matrix and vector classes
@@ -101,8 +104,8 @@ auto diag2 = Matrix3::fromDiagonal({3.0f, 2.0f, 1.0f});
It is possible to create matrices from other matrices and vectors with the same
row count; vectors from vector and scalar:
@code
-Math::RectangularMatrix<2, 3, Int> a;
-Math::Vector<3, Int> b, c;
+Math::Matrix2x3 a;
+Math::Vector3 b, c;
Math::Matrix3 mat(a, b);
Math::Vector<8, Int> vec(1, b, 2, c);
@endcode
@@ -115,7 +118,7 @@ on the array itself:
@code
Int[] mat = { 2, 4, 6,
1, 3, 5 };
-RectangularMatrix<2, 3, Int>::from(mat) *= 2; // mat == { 4, 8, 12, 2, 6, 10 }
+Math::Matrix2x3::from(mat) *= 2; // mat == { 4, 8, 12, 2, 6, 10 }
@endcode
Note that unlike constructors, this function has no way to check whether the
array is long enough to contain all elements, so use with caution.
@@ -169,7 +172,7 @@ Math::Vector<6, Int> w10xyz = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original); /
@section matrix-vector-operations Operations with matrices and vectors
Vectors can be added, subtracted, negated and multiplied or divided with
-scalars, as is common in mathematics, Magnum also adds the ability to divide
+scalars, as is common in mathematics, %Magnum also adds the ability to divide
scalar with vector:
@code
Vector3 a(1.0f, 2.0f, 3.0f);
@@ -232,10 +235,10 @@ OpenGL matrices are column-major, thus it is reasonable to have matrices in
%Magnum also column major (and vectors as columns). This has naturally some
implications and it may differ from what is common in mathematics:
-- Order of template arguments in specification of RectangularMatrix is also
- column-major:
+- Order of template arguments in specification of @ref Math::RectangularMatrix
+ is also column-major:
@code
-Math::RectangularMatrix<2, 3, Int> mat; // two columns, three rows
+Math::RectangularMatrix<2, 5, Int> mat; // two columns, five rows
@endcode
- Order of components in matrix constructors is also column-major, further
emphasized by requirement that you have to pass directly column vectors:
@@ -256,5 +259,10 @@ mat[2][0] = 5; // first element of third column
alternatives which operate on columns. It's then up to user decision to
operate with transposed matrices or use the slower non-transposed
alternative of the algorithm.
+
+
+
+- Previous page: @ref types
+- Next page: @ref transformations
*/
-}}
+}
diff --git a/doc/namespaces.dox b/doc/namespaces.dox
index 229abad25..043c7676e 100644
--- a/doc/namespaces.dox
+++ b/doc/namespaces.dox
@@ -33,8 +33,9 @@
Contains classes for interacting with OpenGL.
-This library is built by default and found by default in CMake. See
-@ref building and @ref cmake for more information.
+This library is built by default. To use it, you need to add `${MAGNUM_INCLUDE_DIRS}`
+to include path and link to `${MAGNUM_LIBRARIES}`. See @ref building and
+@ref cmake for more information.
*/
/** @dir Platform
@@ -43,12 +44,15 @@ This library is built by default and found by default in CMake. See
/** @namespace Magnum::Platform
@brief Platform-specific application and context creation
-Base classes for creating applications with various toolkits. See @ref platform
-for introduction.
+Base classes for creating applications with various toolkits.
-Parts of this namespace are built when `WITH_*APPLICATION` is enabled and found
-as `*Application` component in CMake. See @ref building and @ref cmake for more
-information.
+Parts of this namespace are built if `WITH_*APPLICATION` is enabled in CMake,
+with each library having specific toolkit dependencies and platform
+requirements. To use particular application library, you need to request given
+`*Application` component in CMake, add `${MAGNUM_*APPLICATION_INCLUDE_DIRS}` to
+include path and link to `${MAGNUM_*APPLICATION_LIBRARIES}`. See particular
+`*Application` class documentation, @ref building, @ref cmake and @ref platform
+for more information.
*/
/** @dir Math
@@ -57,11 +61,11 @@ information.
/** @namespace Magnum::Math
@brief %Math library
-Template classes for matrix and vector calculations. See @ref matrix-vector
-and @ref transformations for introduction.
+Template classes for matrix and vector calculations.
-This library is built by default and found by default in CMake. See
-@ref building and @ref cmake for more information.
+This library is built by default. To use it, you need to add `${MAGNUM_INCLUDE_DIRS}`
+to include path and link to `${MAGNUM_LIBRARIES}`. See @ref building,
+@ref cmake, @ref matrix-vector and @ref transformations for more information.
*/
/** @dir Math/Algorithms
@@ -72,8 +76,9 @@ This library is built by default and found by default in CMake. See
Various matrix and vector algorithms.
-This library is built by default and found by default in CMake. See
-@ref building and @ref cmake for more information.
+This library is built by default. To use it, you need to add `${MAGNUM_INCLUDE_DIRS}`
+to include path and link to `${MAGNUM_LIBRARIES}`. See @ref building and
+@ref cmake for more information.
*/
/** @dir Math/Geometry
@@ -84,8 +89,9 @@ This library is built by default and found by default in CMake. See
Functions for computing intersections, distances, areas and volumes.
-This library is built by default and found by default in CMake. See
-@ref building and @ref cmake for more information.
+This library is built by default. To use it, you need to add `${MAGNUM_INCLUDE_DIRS}`
+to include path and link to `${MAGNUM_LIBRARIES}`. See @ref building and
+@ref cmake for more information.
*/
/** @dir Audio
@@ -96,10 +102,13 @@ This library is built by default and found by default in CMake. See
Audio import, playback and integration with @ref SceneGraph.
-This library is built when `WITH_AUDIO` is enabled and found as `%Audio`
-component in CMake. See @ref building and @ref cmake for more information.
-Additional plugins are part of plugin repository, see @ref building-plugins and
-@ref cmake-plugins for more information.
+This library depends on **OpenAL** library. It is built if `WITH_AUDIO` is
+enabled in CMake. To use this library, you need to request `%Audio` component
+in CMake, add `${MAGNUM_AUDIO_INCLUDE_DIRS}` to include path and link to
+`${MAGNUM_AUDIO_LIBRARIES}`. See @ref building and @ref cmake for more
+information. Additional plugins are part of plugin repository, see particular
+`*Importer` class documentation, @ref building-plugins and @ref cmake-plugins
+for more information.
*/
/** @dir DebugTools
@@ -108,12 +117,12 @@ Additional plugins are part of plugin repository, see @ref building-plugins and
/** @namespace Magnum::DebugTools
@brief %Debug tools
-Debugging helpers, renderers and profilers. See @ref debug-tools for
-introduction.
+Debugging helpers, renderers and profilers.
-This library is built when `WITH_DEBUGTOOLS` is enabled and found as
-`%DebugTools` component in CMake. See @ref building and @ref cmake for more
-information.
+This library is built if `WITH_DEBUGTOOLS` is enabled in CMake. To use this
+library, you need to request `%DebugTools` component in CMake and link to
+`${MAGNUM_DEBUGTOOLS_LIBRARIES}`. See @ref building, @ref cmake and
+@ref debug-tools for more information.
*/
/** @dir MeshTools
@@ -124,8 +133,9 @@ information.
Tools for generating, optimizing and cleaning meshes.
-This library is built when `WITH_MESHTOOLS` is enabled and found as
-`%MeshTools` component in CMake. See @ref building and @ref cmake for more
+This library is built if `WITH_MESHTOOLS` is enabled in CMake. To use this
+library, you need to request `%MeshTools` component in CMake and link to
+`${MAGNUM_MESHTOOLS_LIBRARIES}`. See @ref building and @ref cmake for more
information.
*/
@@ -137,8 +147,9 @@ information.
Basic primitives for testing purposes.
-This library is built when `WITH_PRIMITIVES` is enabled and found as
-`%Primitives` component in CMake. See @ref building and @ref cmake for more
+This library is built if `WITH_PRIMITIVES` is enabled in CMake. To use this
+library, you need to request `%Primitives` component in CMake and link to
+`${MAGNUM_PRIMITIVES_LIBRARIES}`. See @ref building and @ref cmake for more
information.
*/
@@ -149,24 +160,26 @@ information.
@namespace Magnum::SceneGraph
@brief %Scene graph library
-Managing object hierarchy, transformations and interactions. See
-@ref scenegraph for introduction.
+Managing object hierarchy, transformations and interactions.
-This library is built when `WITH_SCENEGRAPH` is enabled and found as
-`%SceneGraph` component in CMake. See @ref building and @ref cmake for more
-information.
+This library is built if `WITH_SCENEGRAPH` is enabled in CMake. To use this
+library, you need to request `%SceneGraph` component in CMake and link to
+`${MAGNUM_SCENEGRAPH_LIBRARIES}`. See @ref building, @ref cmake and
+@ref scenegraph for more information.
*/
/** @dir Shaders
* @brief Namespace Magnum::Shaders
*/
/** @namespace Magnum::Shaders
-@brief Sample shaders
+@brief Builtin shaders
-Collection of shaders for testing purposes.
+Collection of shaders for easy prototyping and basic usage.
-This library is built when `WITH_SHADERS` is enabled and found as `%Shaders`
-component in CMake. See @ref building and @ref cmake for more information.
+This library is built if `WITH_SHADERS` is enabled in CMake. To use this
+library, you need to request `%Shaders` component in CMake and link to
+`${MAGNUM_MESHTOOLS_SHADERS}`. See @ref building and @ref cmake for more
+information.
*/
/** @dir Shapes
@@ -175,10 +188,12 @@ component in CMake. See @ref building and @ref cmake for more information.
/** @namespace Magnum::Shapes
@brief %Shape library
-Collision detection system. See @ref shapes for introduction.
+Collision detection system.
-This library is built when `WITH_SHAPES` is enabled and found as `%Shapes`
-component in CMake. See @ref building and @ref cmake for more information.
+This library is built if `WITH_SHAPES` is enabled in CMake. To use this
+library, you need to request `%Shapes` component in CMake and link to
+`${MAGNUM_SHAPES_LIBRARIES}`. See @ref building, @ref cmake and @ref shapes for
+more information.
*/
/** @dir Text
@@ -189,10 +204,12 @@ component in CMake. See @ref building and @ref cmake for more information.
Font texture creation and text layouting.
-This library is built when `WITH_TEXT` is enabled and found as `%Text`
-component in CMake. See @ref building and @ref cmake for more information.
-Additional plugins are part of plugin repository, see @ref building-plugins and
-@ref cmake-plugins for more information.
+This library is built if `WITH_TEXT` is enabled in CMake. To use this library,
+you need to request `%Text` component in CMake and link to `${MAGNUM_TEXT_LIBRARIES}`.
+See @ref building and @ref cmake for more information. Additional plugins are
+part of plugin repository, see particular `*Font` and `*FontConverter` class
+documentation, @ref building-plugins and @ref cmake-plugins for more
+information.
*/
/** @dir TextureTools
@@ -203,8 +220,9 @@ Additional plugins are part of plugin repository, see @ref building-plugins and
Tools for generating, compressing and optimizing textures.
-This library is built when `WITH_TEXTURETOOLS` is enabled and found as
-`%TextureTools` component in CMake. See @ref building and @ref cmake for more
+This library is built if `WITH_TEXTURETOOLS` is enabled in CMake. To use this
+library, you need to request `%TextureTools` component in CMake and link to
+`${MAGNUM_TEXTURETOOLS_LIBRARIES}`. See @ref building and @ref cmake for more
information.
*/
@@ -217,8 +235,10 @@ information.
Contains plugin interfaces for importing data of various formats and classes
for direct access to the data.
-This library is built by default and found by default in CMake. See
-@ref building and @ref cmake for more information. Additional plugins are part
-of plugin repository, see @ref building-plugins and @ref cmake-plugins for more
+This library is built by default. To use it, you need to add `${MAGNUM_INCLUDE_DIRS}`
+to include path and link to `${MAGNUM_LIBRARIES}`. See @ref building and
+@ref cmake for more information. Additional plugins are part of plugin
+repository, see particular `*Importer` and `*ImageConverter` class
+documentation, @ref building-plugins and @ref cmake-plugins for more
information.
*/
diff --git a/doc/platform.dox b/doc/platform.dox
index ffecf7b8d..18293bca0 100644
--- a/doc/platform.dox
+++ b/doc/platform.dox
@@ -24,39 +24,55 @@
namespace Magnum { namespace Platform {
/** @page platform Platform support
+@brief Integration into windowing toolkits and creation of windowless contexts.
-@brief Integration into windowing toolkits and creation of windowless contexts
+- Next page: @ref types
-@tableofcontents
+@ref Platform namespace contains classes integrating %Magnum engine into
+various toolkits, both windowed and windowless. Each class has slightly
+different dependencies and platform requirements, see documentation of
+@ref Platform namespace and particular `*Application` classes for more
+information about building and usage with CMake.
-Platform namespace provides classes integrating %Magnum engine into various
-toolkits, both windowed and windowless. All the classes have common API to
-achieve static polymorphism, so basically you can use different toolkits on
-different platforms and the only thing you need to change is the class name,
-everything else is the same.
+@tableofcontents
-Basic usage is to subclass the chosen `*Application` class and implement
-required methods.
+All the classes have common API to achieve static polymorphism, so basically
+you can use different toolkits on different platforms and the only thing you
+need to change is the class name, everything else is the same. Basic usage is
+to subclass the chosen `*Application` class and implement required methods.
@section platform-windowed Windowed applications
Windowed applications provide a window and keyboard and mouse handling. The
-most basic toolkit (and toolkit available on most platforms) is GLUT, which is
-is implemented in GlutApplication. As said above, the usage is similar for all
-toolkits, you must provide two-argument constructor and implement at least
-@ref GlutApplication::viewportEvent() "viewportEvent()" and
-@ref GlutApplication::drawEvent() "drawEvent()".
+most basic toolkit (and toolkit packaged for most systems) is GLUT, which is
+implemented in @ref Platform::GlutApplication. As said above, the usage is
+similar for all toolkits, you must provide one-argument constructor and
+implement at least @ref GlutApplication::viewportEvent() "viewportEvent()" and
+@ref GlutApplication::drawEvent() "drawEvent()". The class can be then used
+directly in `main()`, but for convenience and portability it's better to use
+@ref MAGNUM_GLUTAPPLICATION_MAIN() macro.
+
+To simplify the porting, the library provides `Platform::Application` typedef
+and `MAGNUM_APPLICATION_MAIN()` macro (but only if only one application header
+is included, to avoid ambiguity). Changing the code to use different toolkit is
+then matter of replacing only the #`include` statement.
Barebone application implementation which will just clear the window to dark
-blue color:
+blue color is shown in the following code listing.
+
+@note Fully contained base application along with CMake setup is available in
+ `base` branch of [Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap)
+ repository.
+
@code
+#include
#include
#include
#include
using namespace Magnum;
-class MyApplication: public Platform::GlutApplication {
+class MyApplication: public Platform::Application {
public:
MyApplication(const Arguments& arguments);
@@ -64,7 +80,7 @@ class MyApplication: public Platform::GlutApplication {
void drawEvent() override;
};
-MyApplication::MyApplication(const Arguments& arguments): Platform::GlutApplication(arguments) {
+MyApplication::MyApplication(const Arguments& arguments): Platform::Application(arguments) {
// Set clear color to dark blue
Renderer::setClearColor({0.0f, 0.0f, 0.4f});
}
@@ -83,7 +99,7 @@ void MyApplication::drawEvent() {
}
// main() function implementation
-MAGNUM_GLUTAPPLICATION_MAIN(MyApplication)
+MAGNUM_APPLICATION_MAIN(MyApplication)
@endcode
@section platform-windowless Windowless applications
@@ -91,25 +107,42 @@ MAGNUM_GLUTAPPLICATION_MAIN(MyApplication)
Windowless applications provide just a context for ofscreen rendering or
performing tasks on GPU. There is not yet any platform-independent toolkit
which could handle this in portable way, thus you have to use platform-specific
-ones. As example we use WindowlessGlxApplication, you need to implement just
-@ref WindowlessGlxApplication::exec() "exec()" function.
+ones. As example we use @ref Platform::WindowlessGlxApplication, you need to
+implement just @ref WindowlessGlxApplication::exec() "exec()" function. The
+class can be then used directly in `main()`, but again, for convenience and
+portability it's better to use @ref MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN()
+macro.
+
+Similarly as with windowed applications, to simplify the porting, the library
+provides `Platform::WindowlessApplication` typedef and `MAGNUM_WINDOWLESSAPPLICATION_MAIN()`
+macro, but only if only one windowless application header is included. Changing
+the code to use different toolkit is then matter of replacing only the
+#`include` statement. Aliases for windowless applications are
+separated from aliases for windowed applications, because projects commonly
+contain both graphics application and command-line tools (for data preparation
+etc.).
Barebone application which will just print out current OpenGL version and
-renderer string and exits:
+renderer string and exits is in the following code listing.
+
+@note Fully contained windowless application along with CMake setup is
+ available in `windowless` branch of [Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap)
+ repository.
+
@code
#include
#include
using namespace Magnum;
-class MyApplication: public Platform::WindowlessGlxApplication {
+class MyApplication: public Platform::WindowlessApplication {
public:
MyApplication(const Arguments& arguments);
int exec() override;
};
-MyApplication::MyApplication(const Arguments& arguments): Platform::WindowlessGlxApplication(arguments) {}
+MyApplication::MyApplication(const Arguments& arguments): Platform::WindowlessApplication(arguments) {}
int MyApplication::exec() {
Debug() << "OpenGL version:" << Context::current()->versionString();
@@ -120,23 +153,31 @@ int MyApplication::exec() {
}
// main() function implementation
-MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(MyApplication)
+MAGNUM_WINDOWLESSAPPLICATION_MAIN(MyApplication)
@endcode
@section platform-compilation Compilation with CMake
Barebone compilation consists just of finding %Magnum library with required
-`*Application` component, compilation of the executable and linking the
-libraries to it:
+`*Application` component, adding %Magnum's `${MAGNUM_INCLUDE_DIRS}` and application-specific `${MAGNUM_GLUTAPPLICATION_INCLUDE_DIRS}` to include path, compilation of the
+executable and linking `${MAGNUM_LIBRARIES}` and `${MAGNUM_GLUTAPPLICATION_LIBRARIES}`
+to it.
+
+Again, to simplify porting, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}`
+and `${MAGNUM_WAPPLICATION_LIBRARIES}` aliases (or `${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}`, `${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` for windowless applications), but
+only if only one application (windowless application) component is requested to
+avoid ambiguity. Changing the code to use different toolkit is then matter of
+replacing only the requested `*Application` component.
+
@code
find_package(Magnum REQUIRED GlutApplication)
-include_directories(${MAGNUM_INCLUDE_DIRS})
+include_directories(${MAGNUM_INCLUDE_DIRS} ${MAGNUM_APPLICATION_INCLUDE_DIRS})
add_executable(myapplication MyApplication.cpp)
target_link_libraries(myapplication
${MAGNUM_LIBRARIES}
- ${MAGNUM_GLUTAPPLICATION_LIBRARIES})
+ ${MAGNUM_APPLICATION_LIBRARIES})
@endcode
@section platform-configuration Specifying configuration
@@ -147,20 +188,20 @@ window size 800x600 pixels). If you want something else, you can pass
constructor. Using method chaining it can be done conveniently like this:
@code
MyApplication::MyApplication(int& argc, char** argv):
- Platform::GlutApplication(argc, argv, Configuration()
+ Platform::Application(argc, argv, Configuration()
.setTitle("My Application")
.setSize({800, 600})
- {
+{
// ...
}
@endcode
However, sometimes you would need to configure the application based on some
configuration file or system introspection. In that case you can pass `nullptr`
-instead of Configuration instance and then specify it later with
-@ref GlutApplication::createContext() "createContext()":
+instead of @ref GlutApplication::Configuration "Configuration" instance and
+then specify it later with @ref GlutApplication::createContext() "createContext()":
@code
-MyApplication::MyApplication(int& argc, char** argv): Platform::GlutApplication(argc, argv, nullptr) {
+MyApplication::MyApplication(int& argc, char** argv): Platform::Application(argc, argv, nullptr) {
// ...
createContext(Configuration()
@@ -173,12 +214,12 @@ MyApplication::MyApplication(int& argc, char** argv): Platform::GlutApplication(
If the context creation in constructor or @ref GlutApplication::createContext() "createContext()"
fails, the application exits. However, it is also possible to negotiate the
-context using @ref GlutApplication::tryCreateContext() "tryCreateContext()". The
-only difference is that this function returns `false` instead of exiting. You
-can for example try enabling MSAA and if the context creation fails, fall back
-to no-AA rendering:
+context using @ref GlutApplication::tryCreateContext() "tryCreateContext()".
+The only difference is that this function returns `false` instead of exiting.
+You can for example try enabling MSAA and if the context creation fails, fall
+back to no-AA rendering:
@code
-MyApplication::MyApplication(int& argc, char** argv): Platform::GlutApplication(argc, argv, nullptr) {
+MyApplication::MyApplication(int& argc, char** argv): Platform::Application(argc, argv, nullptr) {
// ...
Configuration conf;
@@ -192,5 +233,6 @@ MyApplication::MyApplication(int& argc, char** argv): Platform::GlutApplication(
}
@endcode
+- Next page: @ref types
*/
}}
diff --git a/doc/portability.dox b/doc/portability.dox
index d2b2870d7..1596e55d0 100644
--- a/doc/portability.dox
+++ b/doc/portability.dox
@@ -175,19 +175,9 @@ can just switch to another base class and in many cases you won't need to
change any other code. It has its limitations, though - some toolkits don't
support all keys, mouse movement events etc.
-In most cases the entry point is classic `main()` function, but some platforms
-(e.g. Native Client) have different requirements. To make things easier, entry
-points are handled using macros, which take care of the rest.
-
-If exactly one `*Application` or `*Windowless*Application` header is included,
-the application class is aliased to `Platform::Application` or
-`Platform::WindowlessApplication` and the macro is aliased to
-`MAGNUM_APPLICATION_MAIN()` or `MAGNUM_WINDOWLESSAPPLICATION_MAIN()` to
-simplify porting. The same is with CMake code, if exactly one `*Application` or
-`Windowless*Application` component , the libraries and include dirs are
-available in `MAGNUM_APPLICATION_LIBRARIES` / `MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES`
-and `MAGNUM_APPLICATION_INCLUDE_DIRS` / `MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS`
-variables.
+As mentioned in @ref platform, all the classes, macros and CMake variables have
+generic aliases, thus using different toolkit is in most cases only matter of
+replacing two lines of code.
Example application, which targets both embedded Linux (using plain X and EGL)
and desktop (using SDL2 toolkit). Thanks to static polymorphism most of the
diff --git a/doc/scenegraph.dox b/doc/scenegraph.dox
index 3d59a8849..739d52ce8 100644
--- a/doc/scenegraph.dox
+++ b/doc/scenegraph.dox
@@ -26,30 +26,41 @@ namespace Magnum { namespace SceneGraph {
/** @page scenegraph Using scene graph
@brief Overview of scene management capabilities.
-@tableofcontents
+- Previous page: @ref transformations
+- Next page: @ref shapes
%Scene graph provides way to hiearchically manage your objects, their
-transformation, physics interaction, animation and rendering. There are
-naturally many possible combinations (2D vs. 3D, different transformation
-representations, animated vs. static, object can have collision shape,
-participate in physics events, have forward vs. deferred rendering...). To
-make everything possible without combinatiorial explosion and allow the users
-to provide their own features, scene graph in %Magnum is composed of three
-main components:
+transformation, physics interaction, animation and rendering. The library is
+contained in @ref SceneGraph namespace, see its documentation for more
+information about building and usage with CMake.
+
+@tableofcontents
+
+There are naturally many possible feature combinations (2D vs. 3D, different
+transformation representations, animated vs. static, object can have collision
+shape, participate in physics events, have forward vs. deferred rendering...)
+and to make everything possible without combinatiorial explosion and allow the
+users to provide their own features, scene graph in %Magnum is composed of
+three main components:
- objects, providing parent/children hierarchy
- transformations, implementing particular transformation type
- features, providing rendering capabilities, collision detection, physics
etc.
+@note Fully contained applications with initial scene graph setup are available
+ in `scenegraph2D` and `scenegraph3D` branches of
+ [Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) repository.
+
@section scenegraph-transformation Transformations
Transformation handles object position, rotation etc. and its basic property
is dimension count (2D or 3D) and underlying floating-point type.
-@note All classes in SceneGraph are templated on underlying type. However, in
- most cases Float is used and thus nearly all classes have convenience
- aliases so you don't have to explicitly specify it.
+@note All classes in @ref SceneGraph are templated on underlying type. However,
+ in most cases @ref Magnum::Float "Float" is used and thus nearly all
+ classes have convenience aliases so you don't have to explicitly specify
+ it.
%Scene graph has implementation of transformations in both 2D and 3D, using
either matrices or combination of position and rotation. Each implementation
@@ -60,24 +71,23 @@ won't allow you to scale or shear objects, but are more memory efficient than
matrices.
It's also possible to implement your own transformation class for specific
-needs, see @ref AbstractTransformation-subclassing
-"AbstractTransformation documentation" for more information.
+needs, see source of other transformation classes for more information.
@section scenegraph-hierarchy Scene hierarchy
-%Scene hierarchy is skeleton part of scene graph. In the root there is Scene
-and its children are Object instances. The hierarchy has some transformation
-type, identical for all objects (because for example having part of the tree
-in 2D and part in 3D just wouldn't make sense). Common usage is to typedef
-%Scene and %Object with desired transformation type to save unnecessary typing
-later:
+%Scene hierarchy is skeleton part of scene graph. In the root there is
+@ref Scene and its children are @ref Object instances. The hierarchy has some
+transformation type, identical for all objects (because for example having part
+of the tree in 2D and part in 3D just wouldn't make sense). Common usage is to
+typedef %Scene and %Object with desired transformation type to save unnecessary
+typing later:
@code
typedef SceneGraph::Scene Scene3D;
typedef SceneGraph::Object Object3D;
@endcode
Then you can start building the hierarchy by *parenting* one object to another.
-Parent object can be either passed in constructor or using Object::setParent().
+Parent object can be either passed in constructor or using @ref Object::setParent().
%Scene is always root object, so it naturally cannot have parent object.
@code
Scene3D scene;
@@ -86,10 +96,10 @@ auto first = new Object3D(&scene);
auto second = new Object3D(first);
@endcode
-%Object children can be accessed using Object::firstChild() and
-Object::lastChild(), then you can traverse siblings (objects with the same
-parent) with Object::previousSibling() and Object::nextSibling(). For example
-all children of an object can be traversed the following way:
+%Object children can be accessed using @ref Object::firstChild() and
+@ref Object::lastChild(), then you can traverse siblings (objects with the same
+parent) with @ref Object::previousSibling() and @ref Object::nextSibling(). For
+example all children of an object can be traversed the following way:
@code
Object3D* o;
for(Object3D* child = o->firstChild(); child; child = child->nextSibling()) {
@@ -127,9 +137,9 @@ Object3D* o;
new MyFeature(o);
@endcode
-Features of an object can be accessed using Object::firstFeature() and
-Object::lastFeature(), then you can traverse the features using
-AbstractFeature::previousFeature() and AbstractFeature::nextFeature(),
+Features of an object can be accessed using @ref Object::firstFeature() and
+@ref Object::lastFeature(), then you can traverse the features using
+@ref AbstractFeature::previousFeature() and @ref AbstractFeature::nextFeature(),
similarly to traversing object children:
@code
Object3D* o;
@@ -144,11 +154,11 @@ Active features require the user to implement some virtual function (for
example to draw the object on screen or perform animation step). To make things
convenient, features can be added directly to object itself using multiple
inheritance, so you can conveniently add all the active features you want and
-implement needed functions in your own Object subclass without having to
+implement needed functions in your own @ref Object subclass without having to
subclass each feature individually (and making the code overly verbose).
Simplified example:
@code
-class Bomb: public Object3D, SceneGraph::Drawable3D, SceneGraph:.Animable3D {
+class Bomb: public Object3D, SceneGraph::Drawable3D, SceneGraph::Animable3D {
public:
Bomb(Object3D* parent): Object3D(parent), SceneGraph::Drawable3D(*this), SceneGraph::Animable3D(*this) {}
@@ -179,20 +189,21 @@ objects etc. To avoid computing the transformations from scratch every time,
the feature can cache them.
The cached data stay until the object is marked as dirty - that is by changing
-transformation, changing parent or explicitly calling Object::setDirty(). If
-the object is marked as dirty, all its children are marked as dirty too and
-AbstractFeature::markDirty() is called on every feature. Calling
-Object::setClean() cleans the dirty object and all its dirty parents.
-The function goes through all object features and calls AbstractFeature::clean()
-or AbstractFeature::cleanInverted() depending on which caching is enabled on
-given feature. If the object is already clean, Object::setClean() does nothing.
-
-Most probably you will need caching in Object itself -- which doesn't support
-it on its own -- however you can take advantage of multiple inheritance and
-implement it using AbstractFeature. In order to have caching, you must enable
-it first, because by default the caching is disabled. You can enable it using
-AbstractFeature::setCachedTransformations() and then implement corresponding
-cleaning function(s):
+transformation, changing parent or explicitly calling @ref Object::setDirty().
+If the object is marked as dirty, all its children are marked as dirty too and
+@ref AbstractFeature::markDirty() is called on every feature. Calling
+@ref Object::setClean() cleans the dirty object and all its dirty parents.
+The function goes through all object features and calls @ref AbstractFeature::clean()
+or @ref AbstractFeature::cleanInverted() depending on which caching is enabled
+on given feature. If the object is already clean, @ref Object::setClean() does
+nothing.
+
+Most probably you will need caching in @ref Object itself -- which doesn't
+support it on its own -- however you can take advantage of multiple inheritance
+and implement it using @ref AbstractFeature. In order to have caching, you must
+enable it first, because by default the caching is disabled. You can enable it
+using @ref AbstractFeature::setCachedTransformations() and then implement
+corresponding cleaning function(s):
@code
class CachingObject: public Object3D, SceneGraph::AbstractFeature3D {
public:
@@ -211,9 +222,9 @@ class CachingObject: public Object3D, SceneGraph::AbstractFeature3D {
@endcode
When you need to use the cached value, you can explicitly request the cleanup
-by calling Object::setClean(). Camera, for example, calls it automatically
-before it starts rendering, as it needs its own inverse transformation to
-properly draw the objects.
+by calling @ref Object::setClean(). @ref Camera3D "Camera", for example, calls
+it automatically before it starts rendering, as it needs its own inverse
+transformation to properly draw the objects.
See @ref AbstractFeature-subclassing-caching for more information.
@@ -284,7 +295,7 @@ wouldn't help either:
@code
class MyObject: MyFeature, public Object3D {
public:
- MyObject(Object3D* parent): Object3D(parent), MyFeature(this) {}
+ MyObject(Object3D* parent): Object3D(parent), MyFeature(*this) {}
// crash on destruction!
};
@@ -292,5 +303,8 @@ class MyObject: MyFeature, public Object3D {
On destruction, Object3D destructor is called first, deleting MyFeature,
which is wrong, because MyFeature is in the same object. After that (if the
program didn't already crash) destructor of MyFeature is called (again).
+
+- Previous page: @ref transformations
+- Next page: @ref shapes
*/
}}
diff --git a/doc/shapes.dox b/doc/shapes.dox
index 37bc127ca..78de697db 100644
--- a/doc/shapes.dox
+++ b/doc/shapes.dox
@@ -26,13 +26,19 @@ namespace Magnum { namespace Shapes {
/** @page shapes Collision detection
@brief Collection of simple shapes for high performance collision detection.
+- Previous page: @ref scenegraph
+- Next page: @ref debug-tools
+
The essential thing in collision detection is to define a complex object with
-collection of simple shapes, for which it is easy to detect collisions. These
-shapes can be either one-, two- or three-dimensional and they can be grouped
-together using various operations.
+collection of simple shapes, for which it is easy to detect collisions. The
+library is contained in @ref Shapes namespace, see its documentation for more
+information about building and usage with CMake.
@tableofcontents
+These shapes can be either one-, two- or three-dimensional and they can be
+grouped together using various operations.
+
@section shapes-collection Available shapes
%Magnum provides a set of simple shapes for collision detection, similarly to
@@ -140,5 +146,8 @@ auto shape = Shapes::Shape(object, {{}, 23.0f});
See also @ref scenegraph for introduction.
+- Previous page: @ref scenegraph
+- Next page: @ref debug-tools
+
*/
}}}
diff --git a/doc/transformations.dox b/doc/transformations.dox
index 138adb951..14ccd13f5 100644
--- a/doc/transformations.dox
+++ b/doc/transformations.dox
@@ -24,16 +24,22 @@
namespace Magnum { namespace Math {
/** @page transformations 2D and 3D transformations
-
@brief Introduction to essential operations on vectors and points.
-@tableofcontents
+- Previous page: @ref matrix-vector
+- Next page: @ref scenegraph
Transformations are essential operations involved in scene management -- object
-relations, hierarchies, animations etc. %Magnum provides classes for
-transformations in both 2D and 3D. Each class is suited for different purposes,
-but their usage is nearly the same to make your life simpler. This page will
-explain the basic operation and differences between various representations.
+relations, hierarchies, animations etc. They extend basic vectors and matrices
+in @ref Math namespace, see its documentation for more information about usage
+with CMake.
+
+@tableofcontents
+
+%Magnum provides classes for transformations in both 2D and 3D. Each class is
+suited for different purposes, but their usage is nearly the same to make your
+life simpler. This page will explain the basic operation and differences
+between various representations.
@section transformations-representation Representing transformations
@@ -310,5 +316,8 @@ are always of unit length, thus normalizing them reduces the drift.
DualQuaternion transformation;
transformation = transformation.normalized();
@endcode
+
+- Previous page: @ref matrix-vector
+- Next page: @ref scenegraph
*/
}}
diff --git a/doc/types.dox b/doc/types.dox
index 3ddb332a6..3dae4a703 100644
--- a/doc/types.dox
+++ b/doc/types.dox
@@ -24,15 +24,20 @@
namespace Magnum {
/** @page types Type system
+@brief Type aliases, naming and compatibility with OpenGL and GLSL types.
-@brief Type aliases, naming and compatibility with OpenGL and GLSL types
+- Previous page: @ref platform
+- Next page: @ref matrix-vector
+
+The root @ref Magnum namespace defines a few aliases for essential types. See
+its documentation for more information about usage with CMake.
@section types-builtin Builtin types
%Magnum provides typedefs for builtin integral and floating-point arithmetic
-types to ensure portability (e.g. Int is *always* 32bit), maintain consistency
-and reduce confusion (e.g. `std::int32_t`, `int` and `GLint` all refer to the
-same type).
+types to ensure portability (e.g. @ref Int is *always* 32bit), maintain
+consistency and reduce confusion (e.g. `std::int32_t`, `int` and `GLint` all
+refer to the same type).
| %Magnum type | Size | Equivalent GLSL type |
| ------------------ | -------------- | -------------------- |
@@ -52,9 +57,10 @@ types which cannot be directly passed to GLSL shaders (such as `long double`)
have no typedefs.
Types from the above table are then used to define other types. All following
-types are aliases of corresponding types in Math namespace. No suffix after type
-name means @ref Float underlying type, `ui` means @ref UnsignedInt underlying
-type, `i` is @ref Int underlying type and `d` is for @ref Double underlying type.
+types are aliases of corresponding types in @ref Math namespace. No suffix
+after type name means @ref Float underlying type, `ui` means @ref UnsignedInt
+underlying type, `i` is @ref Int underlying type and `d` is for @ref Double
+underlying type.
@section types-matrix Matrix/vector types
@@ -65,20 +71,20 @@ type, `i` is @ref Int underlying type and `d` is for @ref Double underlying type
| @ref Vector2i, @ref Vector3i, @ref Vector4i | `ivec2`, `ivec3`, `ivec4` |
| @ref Vector2d, @ref Vector3d, @ref Vector4d | `dvec2`, `dvec3`, `dvec4` |
-| %Magnum matrix type | Equivalent GLSL type |
-| --------------------------------- | ------------------------------------ |
-| @ref Matrix2 or @ref Matrix2d | `mat2`/`mat2x2` or `dmat2`/`dmat2x2` |
-| @ref Matrix3 or @ref Matrix3d | `mat3`/`mat3x3` or `dmat3`/`dmat3x3` |
-| @ref Matrix4 or @ref Matrix4d | `mat4`/`mat4x4` or `dmat4`/`dmat4x4` |
-| @ref Matrix2x3 or @ref Matrix2x3d | `mat2x3` or `dmat2x3` |
-| @ref Matrix3x2 or @ref Matrix3x2d | `mat3x2` or `dmat3x2` |
-| @ref Matrix2x4 or @ref Matrix2x4d | `mat2x4` or `dmat2x4` |
-| @ref Matrix4x2 or @ref Matrix4x2d | `mat4x2` or `dmat4x2` |
-| @ref Matrix3x4 or @ref Matrix3x4d | `mat3x4` or `dmat3x4` |
-| @ref Matrix4x3 or @ref Matrix4x3d | `mat4x3` or `dmat4x3` |
+| %Magnum matrix type | Equivalent GLSL type |
+| ---------------------------------------------------------------- | ------------------------------------ |
+| @ref Matrix2x2 or @ref Matrix2x2d | `mat2`/`mat2x2` or `dmat2`/`dmat2x2` |
+| @ref Matrix3 / @ref Matrix3x3 or @ref Matrix3d / @ref Matrix3x3d | `mat3`/`mat3x3` or `dmat3`/`dmat3x3` |
+| @ref Matrix4 / @ref Matrix4x4 or @ref Matrix4d / @ref Matrix4x4d | `mat4`/`mat4x4` or `dmat4`/`dmat4x4` |
+| @ref Matrix2x3 or @ref Matrix2x3d | `mat2x3` or `dmat2x3` |
+| @ref Matrix3x2 or @ref Matrix3x2d | `mat3x2` or `dmat3x2` |
+| @ref Matrix2x4 or @ref Matrix2x4d | `mat2x4` or `dmat2x4` |
+| @ref Matrix4x2 or @ref Matrix4x2d | `mat4x2` or `dmat4x2` |
+| @ref Matrix3x4 or @ref Matrix3x4d | `mat3x4` or `dmat3x4` |
+| @ref Matrix4x3 or @ref Matrix4x3d | `mat4x3` or `dmat4x3` |
Any super- or sub-class of the same size and underlying type can be used
-equivalently (e.g. Math::Vector or Color3 instead of @ref Vector3).
+equivalently (e.g. @ref Math::Vector or @ref Color3 instead of @ref Vector3).
@section types-other Other types
@@ -95,5 +101,7 @@ quaternion to matrix).
For your convenience, there is also alias for class with often used constants --
@ref Constants or @ref Constantsd.
+- Previous page: @ref platform
+- Next page: @ref matrix-vector
*/
}
diff --git a/doc/unsupported.dox b/doc/unsupported.dox
index 3fb080cdf..e4e371880 100644
--- a/doc/unsupported.dox
+++ b/doc/unsupported.dox
@@ -25,7 +25,7 @@
/** @page unsupported Unsupported OpenGL features
Some functionality, which is either soon-to-be deprecated or isn't proven to
-add any performance gains, is not supported in %Magnum.
+add any performance gains, is not supported in %Magnum. See also @ref deprecated-gl.
@section unsupported-features Unsupported features
@@ -48,3 +48,15 @@ add any performance gains, is not supported in %Magnum.
doesn't make any full-screen postprocessing easier, as shaders are excluded.
*/
+
+/** @page deprecated-gl Deprecated OpenGL API list
+
+See also @ref unsupported and @ref deprecated.
+
+*/
+
+/** @page deprecated Deprecated list
+
+See also @ref deprecated-gl.
+
+*/
diff --git a/external/OpenGL/GL/gl_magnum.c b/external/OpenGL/GL/gl_magnum.c
index d1d89afb6..3276c865c 100644
--- a/external/OpenGL/GL/gl_magnum.c
+++ b/external/OpenGL/GL/gl_magnum.c
@@ -4,27 +4,15 @@
#include "gl_magnum.h"
#if defined(__APPLE__)
-#include
+#include
-static void* AppleGLGetProcAddress (const GLubyte *name)
+static void* AppleGLGetProcAddress (const char *name)
{
- static const struct mach_header* image = NULL;
- NSSymbol symbol;
- char* symbolName;
+ static void* image = NULL;
if (NULL == image)
- {
- image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR);
- }
- /* prepend a '_' for the Unix C symbol mangling convention */
- symbolName = malloc(strlen((const char*)name) + 2);
- strcpy(symbolName+1, (const char*)name);
- symbolName[0] = '_';
- symbol = NULL;
- /* if (NSIsSymbolNameDefined(symbolName))
- symbol = NSLookupAndBindSymbol(symbolName); */
- symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL;
- free(symbolName);
- return symbol ? NSAddressOfSymbol(symbol) : NULL;
+ image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY);
+
+ return image ? dlsym(image, name) : NULL;
}
#endif /* __APPLE__ */
diff --git a/external/Optional/optional.hpp b/external/Optional/optional.hpp
index aca993222..69b9f1c4b 100644
--- a/external/Optional/optional.hpp
+++ b/external/Optional/optional.hpp
@@ -155,7 +155,9 @@ template inline constexpr typename std::remove_reference::type&& co
# define ASSERTED_EXPRESSION(CHECK, EXPR) ((CHECK) ? (EXPR) : (fail(#CHECK, __FILE__, __LINE__), (EXPR)))
inline void fail(const char* expr, const char* file, unsigned line)
{
- # if defined __clang__ || defined __GNU_LIBRARY__
+ # if defined(EMSCRIPTEN) && EMSCRIPTEN
+ __assert_fail(expr, file, line, "");
+ # elif defined __clang__ || defined __GNU_LIBRARY__
__assert(expr, file, line);
# elif defined __GNUC__
_assert(expr, file, line);
diff --git a/modules/FindCorrade.cmake b/modules/FindCorrade.cmake
index 6aa24e864..e62d66519 100644
--- a/modules/FindCorrade.cmake
+++ b/modules/FindCorrade.cmake
@@ -27,6 +27,8 @@
# mode for GCC 4.5
# CORRADE_GCC44_COMPATIBILITY - Defined if compiled with compatibility
# mode for GCC 4.4
+# CORRADE_BUILD_DEPRECATED - Defined if compiled with deprecated APIs
+# included
# CORRADE_BUILD_STATIC - Defined if compiled as static libraries
# CORRADE_TARGET_NACL - Defined if compiled for Google Chrome
# Native Client
@@ -128,9 +130,14 @@ find_path(CORRADE_INCLUDE_DIR
# CMake module dir
find_path(_CORRADE_MODULE_DIR
NAMES UseCorrade.cmake CorradeLibSuffix.cmake
- PATHS ${CMAKE_ROOT}/Modules
PATH_SUFFIXES share/cmake/Corrade)
+# If not found, try system module dir
+find_path(_CORRADE_MODULE_DIR
+ NAMES UseCorrade.cmake CorradeLibSuffix.cmake
+ PATHS ${CMAKE_ROOT}/Modules
+ NO_CMAKE_FIND_ROOT_PATH)
+
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Corrade DEFAULT_MSG
CORRADE_UTILITY_LIBRARY
@@ -165,6 +172,10 @@ string(FIND "${_corradeConfigure}" "#define CORRADE_GCC47_COMPATIBILITY" _GCC47_
if(NOT _GCC47_COMPATIBILITY EQUAL -1)
set(CORRADE_GCC47_COMPATIBILITY 1)
endif()
+string(FIND "${_corradeConfigure}" "#define CORRADE_BUILD_DEPRECATED" _BUILD_DEPRECATED)
+if(NOT _BUILD_DEPRECATED EQUAL -1)
+ set(CORRADE_BUILD_DEPRECATED 1)
+endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_BUILD_STATIC" _BUILD_STATIC)
if(NOT _BUILD_STATIC EQUAL -1)
set(CORRADE_BUILD_STATIC 1)
diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake
index b950d1026..c6223bf79 100644
--- a/modules/FindMagnum.cmake
+++ b/modules/FindMagnum.cmake
@@ -20,7 +20,7 @@
# components. The base library depends on Corrade and OpenGL libraries (or
# OpenGL ES libraries). Additional dependencies are specified by the
# components. The optional components are:
-# Audio - Audio library (depends on OpenAL library)
+# Audio - Audio library
# DebugTools - DebugTools library (depends on MeshTools, Primitives,
# SceneGraph, Shaders and Shapes components)
# MeshTools - MeshTools library
@@ -30,14 +30,13 @@
# Shapes - Shapes library (depends on SceneGraph component)
# Text - Text library (depends on TextureTools component)
# TextureTools - TextureTools library
-# GlutApplication - GLUT application (depends on GLUT library)
-# GlxApplication - GLX application (depends on GLX and X11 libraries)
-# NaClApplication - NaCl application (only if targeting Google Chrome
-# Native Client)
-# Sdl2Application - SDL2 application (depends on SDL2 library)
-# XEglApplication - X/EGL application (depends on EGL and X11 libraries)
-# WindowlessGlxApplication - Windowless GLX application (depends on GLX
-# and X11 libraries)
+# GlutApplication - GLUT application
+# GlxApplication - GLX application
+# NaClApplication - NaCl application
+# Sdl2Application - SDL2 application
+# XEglApplication - X/EGL application
+# WindowlessNaClApplication - Windowless NaCl application
+# WindowlessGlxApplication - Windowless GLX application
# Example usage with specifying additional components is:
# find_package(Magnum [REQUIRED|COMPONENTS]
# MeshTools Primitives GlutApplication)
@@ -52,11 +51,13 @@
# / MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS to simplify porting.
#
# Features of found Magnum library are exposed in these variables:
-# MAGNUM_BUILD_STATIC - Defined if compiled as static libraries
-# MAGNUM_TARGET_GLES - Defined if compiled for OpenGL ES
-# MAGNUM_TARGET_GLES2 - Defined if compiled for OpenGL ES 2.0
-# MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0
-# MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES
+# MAGNUM_BUILD_DEPRECATED - Defined if compiled with deprecated APIs
+# included
+# MAGNUM_BUILD_STATIC - Defined if compiled as static libraries
+# MAGNUM_TARGET_GLES - Defined if compiled for OpenGL ES
+# MAGNUM_TARGET_GLES2 - Defined if compiled for OpenGL ES 2.0
+# MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0
+# MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES
# emulation on desktop OpenGL
#
# Additionally these variables are defined for internal usage:
@@ -76,7 +77,7 @@
# installation directory
# MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR - Importer plugin installation
# directory
-# MAGNUM_PLUGINS_AUDIOIMPORTER_INSTALL_DIR - Audio omporter plugin
+# MAGNUM_PLUGINS_AUDIOIMPORTER_INSTALL_DIR - Audio omporter plugin
# installation directory
# MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR - Installation dir for CMake
# Find* modules
@@ -123,6 +124,10 @@ find_path(MAGNUM_INCLUDE_DIR
# Configuration
file(READ ${MAGNUM_INCLUDE_DIR}/magnumConfigure.h _magnumConfigure)
+string(FIND "${_magnumConfigure}" "#define MAGNUM_BUILD_DEPRECATED" _BUILD_DEPRECATED)
+if(NOT _BUILD_DEPRECATED EQUAL -1)
+ set(MAGNUM_BUILD_DEPRECATED 1)
+endif()
string(FIND "${_magnumConfigure}" "#define MAGNUM_BUILD_STATIC" _BUILD_STATIC)
if(NOT _BUILD_STATIC EQUAL -1)
set(MAGNUM_BUILD_STATIC 1)
diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h
index da4256007..c6504d974 100644
--- a/src/AbstractShaderProgram.h
+++ b/src/AbstractShaderProgram.h
@@ -309,12 +309,14 @@ class MAGNUM_EXPORT AbstractShaderProgram {
*/
static Int maxVertexAttributes();
+ #ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copydoc maxVertexAttributes()
* @deprecated Use @ref Magnum::AbstractShaderProgram::maxVertexAttributes() "maxVertexAttributes()"
* instead.
*/
static Int maxSupportedVertexAttributeCount() { return maxVertexAttributes(); }
+ #endif
#ifndef MAGNUM_TARGET_GLES
/**
@@ -544,7 +546,7 @@ class MAGNUM_EXPORT AbstractShaderProgram {
*
* Binds attribute to location which is used later for binding vertex
* buffers.
- * @deprecated Preferred usage is to specify attribute location
+ * @deprecated_gl Preferred usage is to specify attribute location
* explicitly in the shader instead of using this function. See
* @ref AbstractShaderProgram-attribute-location "class documentation"
* for more information.
@@ -562,7 +564,7 @@ class MAGNUM_EXPORT AbstractShaderProgram {
* Binds fragment data to location which is used later for framebuffer
* operations. See also Framebuffer::BlendFunction for more
* information about using color input index.
- * @deprecated Preferred usage is to specify attribute location
+ * @deprecated_gl Preferred usage is to specify attribute location
* explicitly in the shader instead of using this function. See
* @ref AbstractShaderProgram-attribute-location "class documentation"
* for more information.
@@ -604,7 +606,7 @@ class MAGNUM_EXPORT AbstractShaderProgram {
* @brief Get uniform location
* @param name Uniform name
*
- * @deprecated Preferred usage is to specify uniform location
+ * @deprecated_gl Preferred usage is to specify uniform location
* explicitly in the shader instead of using this function. See
* @ref AbstractShaderProgram-uniform-location "class documentation"
* for more information.
diff --git a/src/AbstractTexture.cpp b/src/AbstractTexture.cpp
index efed4f597..1a9278b81 100644
--- a/src/AbstractTexture.cpp
+++ b/src/AbstractTexture.cpp
@@ -234,6 +234,9 @@ void AbstractTexture::bindInternal() {
}
void AbstractTexture::initializeContextBasedFunctionality(Context& context) {
+ /* Resize bindings array to hold all possible layers */
+ context.state().texture->bindings.resize(maxLayers());
+
#ifndef MAGNUM_TARGET_GLES
if(context.isExtensionSupported()) {
Debug() << "AbstractTexture: using" << Extensions::GL::EXT::direct_state_access::string() << "features";
diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h
index 38e4272e0..6147dfc10 100644
--- a/src/AbstractTexture.h
+++ b/src/AbstractTexture.h
@@ -115,12 +115,14 @@ class MAGNUM_EXPORT AbstractTexture {
*/
static Int maxLayers();
+ #ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief maxLayers()
* @deprecated Use @ref Magnum::AbstractTexture::maxLayers() "maxLayers()"
* instead.
*/
static Int maxSupportedLayerCount() { return maxLayers(); }
+ #endif
#ifndef MAGNUM_TARGET_GLES
/**
diff --git a/src/Audio/Audio.cpp b/src/Audio/Audio.cpp
index 25c70e5e4..fa382b100 100644
--- a/src/Audio/Audio.cpp
+++ b/src/Audio/Audio.cpp
@@ -31,7 +31,12 @@ namespace Magnum { namespace Audio {
/* Verify types */
static_assert(std::is_same::value, "ALubyte is not the same as UnsignedByte");
+/** @todo Why `ALbyte` is defined as `char` and not `signed char` on OSX? */
+#ifndef __APPLE__
static_assert(std::is_same::value, "ALbyte is not the same as Byte");
+#else
+static_assert(std::is_signed::value && sizeof(ALbyte) == 1, "ALbyte does not have the same characteristics as Byte");
+#endif
static_assert(std::is_same::value, "ALushort is not the same as UnsignedShort");
static_assert(std::is_same::value, "ALshort is not the same as Short");
static_assert(std::is_same::value, "ALuint is not the same as UnsignedInt");
diff --git a/src/Audio/CMakeLists.txt b/src/Audio/CMakeLists.txt
index ba125c954..3f1a20870 100644
--- a/src/Audio/CMakeLists.txt
+++ b/src/Audio/CMakeLists.txt
@@ -47,7 +47,10 @@ set(MagnumAudio_HEADERS
add_library(MagnumAudio ${SHARED_OR_STATIC} ${MagnumAudio_SOURCES})
target_link_libraries(MagnumAudio ${CORRADE_PLUGINMANAGER_LIBRARIES} ${OPENAL_LIBRARY})
-install(TARGETS MagnumAudio DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
+install(TARGETS MagnumAudio
+ RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
+ LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
+ ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumAudio_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Audio)
if(BUILD_TESTS)
diff --git a/src/Buffer.h b/src/Buffer.h
index 18810d0b2..57437c452 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -319,7 +319,7 @@ class MAGNUM_EXPORT Buffer {
/**
* @brief Memory mapping access
*
- * @deprecated Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
+ * @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead, as it has more complete set of features.
* @see map(MapAccess), mapSub()
* @requires_es_extension %Extension @es_extension{OES,mapbuffer} or
@@ -642,8 +642,7 @@ class MAGNUM_EXPORT Buffer {
/**
* @brief Set buffer data
- * @param size Data size
- * @param data Pointer to data
+ * @param data Data
* @param usage %Buffer usage
* @return Reference to self (for method chaining)
*
@@ -653,28 +652,20 @@ class MAGNUM_EXPORT Buffer {
* @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferData} or
* @fn_gl_extension{NamedBufferData,EXT,direct_state_access}
*/
- Buffer& setData(GLsizeiptr size, const GLvoid* data, Usage usage) {
- (this->*dataImplementation)(size, data, usage);
+ Buffer& setData(Containers::ArrayReference data, Usage usage) {
+ (this->*dataImplementation)(data.size(), data, usage);
return *this;
}
+ #ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief Set buffer data
- * @param data Fixed-size array with data
- * @param usage %Buffer usage
- * @return Reference to self (for method chaining)
- *
- * @see setData(GLsizeiptr, const GLvoid*, Usage).
+ * @deprecated Use @ref Magnum::Buffer::setData(Containers::ArrayReference, Usage) "setData(Containers::ArrayReference, Usage)"
+ * instead.
*/
- #ifdef CORRADE_GCC46_COMPATIBILITY
- #define size size_ /* With GCC 4.6 it conflicts with size(). WTF. */
- #endif
- template Buffer& setData(const T(&data)[size], Usage usage) {
- setData(size*sizeof(T), data, usage);
- return *this;
+ Buffer& setData(GLsizeiptr size, const GLvoid* data, Usage usage) {
+ return setData({data, std::size_t(size)}, usage);
}
- #ifdef CORRADE_GCC46_COMPATIBILITY
- #undef size
#endif
/**
@@ -686,21 +677,20 @@ class MAGNUM_EXPORT Buffer {
* @see setData(GLsizeiptr, const GLvoid*, Usage)
*/
template Buffer& setData(const std::vector& data, Usage usage) {
- setData(data.size()*sizeof(T), data.data(), usage);
+ setData({data.data(), data.size()}, usage);
return *this;
}
/** @overload */
template Buffer& setData(const std::array& data, Usage usage) {
- setData(data.size()*sizeof(T), data.data(), usage);
+ setData({data.data(), data.size()}, usage);
return *this;
}
/**
* @brief Set buffer subdata
* @param offset Offset in the buffer
- * @param size Data size
- * @param data Pointer to data
+ * @param data Data
* @return Reference to self (for method chaining)
*
* If @extension{EXT,direct_state_access} is not available and the
@@ -709,28 +699,20 @@ class MAGNUM_EXPORT Buffer {
* @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferSubData}
* or @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access}
*/
- Buffer& setSubData(GLintptr offset, GLsizeiptr size, const GLvoid* data) {
- (this->*subDataImplementation)(offset, size, data);
+ Buffer& setSubData(GLintptr offset, Containers::ArrayReference data) {
+ (this->*subDataImplementation)(offset, data.size(), data);
return *this;
}
+ #ifdef MAGNUM_BUILD_DEPRECATED
/**
* @brief Set buffer subdata
- * @param offset Offset in the buffer
- * @param data Fixed-size array with data
- * @return Reference to self (for method chaining)
- *
- * @see setSubData(GLintptr, GLsizeiptr, const GLvoid*)
+ * @deprecated Use @ref Magnum::Buffer::setSubData(GLintptr, Containers::ArrayReference) "setSubData(GLintptr, Containers::ArrayReference)"
+ * instead.
*/
- #ifdef CORRADE_GCC46_COMPATIBILITY
- #define size size_ /* With GCC 4.6 it conflicts with size(). WTF. */
- #endif
- template Buffer& setSubData(GLintptr offset, const T(&data)[size]) {
- setSubData(offset, size*sizeof(T), data);
- return *this;
+ Buffer& setSubData(GLintptr offset, GLsizeiptr size, const GLvoid* data) {
+ return setSubData(offset, {data, std::size_t(size)});
}
- #ifdef CORRADE_GCC46_COMPATIBILITY
- #undef size
#endif
/**
@@ -742,13 +724,13 @@ class MAGNUM_EXPORT Buffer {
* @see setSubData(GLintptr, GLsizeiptr, const GLvoid*)
*/
template Buffer& setSubData(GLintptr offset, const std::vector& data) {
- setSubData(offset, data.size()*sizeof(T), data.data());
+ setSubData(offset, {data.data(), data.size()});
return *this;
}
/** @overload */
template Buffer& setSubData(GLintptr offset, const std::array& data) {
- setSubData(offset, data.size()*sizeof(T), data.data());
+ setSubData(offset, {data.data(), data.size()});
return *this;
}
@@ -791,7 +773,7 @@ class MAGNUM_EXPORT Buffer {
* If @extension{EXT,direct_state_access} is not available and the
* buffer is not already bound somewhere, it is bound to hinted target
* before the operation.
- * @deprecated Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
+ * @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead, as it has more complete set of features.
* @see @ref minMapAlignment(), @ref unmap(), @ref setTargetHint(),
* @fn_gl{BindBuffer} and @fn_gl{MapBuffer} or
@@ -815,7 +797,7 @@ class MAGNUM_EXPORT Buffer {
*
* If the buffer is not already bound somewhere, it is bound to hinted
* target before the operation.
- * @deprecated Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
+ * @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead, as it has more complete set of features.
* @see unmapSub(), setTargetHint(), @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub}
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
diff --git a/src/BufferImage.cpp b/src/BufferImage.cpp
index 35edf27d9..9099845d8 100644
--- a/src/BufferImage.cpp
+++ b/src/BufferImage.cpp
@@ -31,7 +31,7 @@ template void BufferImage::setData(const typ
_format = format;
_type = type;
_size = size;
- _buffer.setData(pixelSize()*size.product(), data, usage);
+ _buffer.setData({data, pixelSize()*size.product()}, usage);
}
#ifndef DOXYGEN_GENERATING_OUTPUT
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 60fae1f64..c3b7b0688 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -122,7 +122,6 @@ set(Magnum_HEADERS
Extensions.h
Framebuffer.h
Image.h
- ImageFormat.h
ImageReference.h
Magnum.h
Mesh.h
@@ -136,7 +135,6 @@ set(Magnum_HEADERS
ResourceManager.h
Sampler.h
Shader.h
- Swizzle.h
Texture.h
TextureFormat.h
Timeline.h
@@ -144,6 +142,13 @@ set(Magnum_HEADERS
magnumVisibility.h)
+# Deprecated headers
+if(BUILD_DEPRECATED)
+ set(Magnum_HEADERS ${Magnum_HEADERS}
+ ImageFormat.h
+ Swizzle.h)
+endif()
+
# Desktop-only headers and libraries
if(NOT TARGET_GLES)
set(Magnum_HEADERS ${Magnum_HEADERS}
@@ -191,7 +196,10 @@ else()
endif()
target_link_libraries(Magnum ${Magnum_LIBS})
-install(TARGETS Magnum DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
+install(TARGETS Magnum
+ RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
+ LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
+ ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${Magnum_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magnumConfigure.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR})
@@ -251,7 +259,10 @@ if(BUILD_TESTS)
# On Windows we need to install first and then run the tests to avoid "DLL
# not found" hell, thus we need to install this too
if(WIN32 AND NOT CMAKE_CROSSCOMPILING)
- install(TARGETS MagnumMathTestLib MagnumTestLib DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
+ install(TARGETS MagnumMathTestLib MagnumTestLib
+ RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
+ LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
+ ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
endif()
add_subdirectory(Test)
diff --git a/src/Color.h b/src/Color.h
index 0c3de3ac4..dc0ca3108 100644
--- a/src/Color.h
+++ b/src/Color.h
@@ -202,13 +202,6 @@ template class BasicColor3: public Math::Vector3 {
/** @brief Copy constructor */
constexpr BasicColor3(const Math::Vector<3, T>& other): Math::Vector3(other) {}
- T& r() { return Math::Vector3::x(); } /**< @brief R component */
- constexpr T r() const { return Math::Vector3::x(); } /**< @overload */
- T& g() { return Math::Vector3::y(); } /**< @brief G component */
- constexpr T g() const { return Math::Vector3::y(); } /**< @overload */
- T& b() { return Math::Vector3::z(); } /**< @brief B component */
- constexpr T b() const { return Math::Vector3::z(); } /**< @overload */
-
/**
* @brief Convert to HSV
*
@@ -336,42 +329,24 @@ class BasicColor4: public Math::Vector4 {
/** @brief Copy constructor */
constexpr BasicColor4(const Math::Vector<4, T>& other): Math::Vector4(other) {}
- T& r() { return Math::Vector4::x(); } /**< @brief R component */
- constexpr T r() const { return Math::Vector4::x(); } /**< @overload */
- T& g() { return Math::Vector4::y(); } /**< @brief G component */
- constexpr T g() const { return Math::Vector4::y(); } /**< @overload */
- T& b() { return Math::Vector4::z(); } /**< @brief B component */
- constexpr T b() const { return Math::Vector4::z(); } /**< @overload */
- T& a() { return Math::Vector4::w(); } /**< @brief A component */
- constexpr T a() const { return Math::Vector4::w(); } /**< @overload */
-
- /**
- * @brief RGB part of the vector
- * @return First three components of the vector
- *
- * @see swizzle()
- */
- BasicColor3& rgb() { return BasicColor3::from(Math::Vector4::data()); }
- constexpr BasicColor3 rgb() const { return BasicColor3::from(Math::Vector4::data()); } /**< @overload */
-
/** @copydoc BasicColor3::toHSV() */
constexpr HSV toHSV() const {
- return Implementation::toHSV(rgb());
+ return Implementation::toHSV(Math::Vector4::rgb());
}
/** @copydoc BasicColor3::hue() */
constexpr Math::Deg hue() const {
- return Implementation::hue(rgb());
+ return Implementation::hue(Math::Vector4::rgb());
}
/** @copydoc BasicColor3::saturation() */
constexpr FloatingPointType saturation() const {
- return Implementation::saturation(rgb());
+ return Implementation::saturation(Math::Vector4::rgb());
}
/** @copydoc BasicColor3::value() */
constexpr FloatingPointType value() const {
- return Implementation::value(rgb());
+ return Implementation::value(Math::Vector4::rgb());
}
MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(4, BasicColor4)
@@ -392,6 +367,13 @@ template inline Debug operator<<(Debug debug, const BasicColor4& val
return debug << static_cast&>(value);
}
+namespace Math { namespace Implementation {
+ template struct TypeForSize<3, BasicColor3> { typedef BasicColor3 Type; };
+ template struct TypeForSize<3, BasicColor4> { typedef BasicColor3 Type; };
+ template struct TypeForSize<4, BasicColor3> { typedef BasicColor4 Type; };
+ template struct TypeForSize<4, BasicColor4> { typedef BasicColor4 Type; };
+}}
+
}
namespace Corrade { namespace Utility {
diff --git a/src/ColorFormat.h b/src/ColorFormat.h
index a1150e10f..918ff0d42 100644
--- a/src/ColorFormat.h
+++ b/src/ColorFormat.h
@@ -74,7 +74,7 @@ enum class ColorFormat: GLenum {
/**
* Floating-point luminance channel. The value is used for all RGB
* channels.
- * @deprecated Included for compatibility reasons only, use
+ * @deprecated_gl Included for compatibility reasons only, use
* @ref Magnum::ColorFormat "ColorFormat::Red" instead.
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
* @ref Magnum::ColorFormat "ColorFormat::Red" instead.
@@ -98,7 +98,7 @@ enum class ColorFormat: GLenum {
/**
* Floating-point luminance and alpha channel. First value is used for all
* RGB channels, second value is used for alpha channel.
- * @deprecated Included for compatibility reasons only, use
+ * @deprecated_gl Included for compatibility reasons only, use
* @ref Magnum::ColorFormat "ColorFormat::RG" instead.
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
* @ref Magnum::ColorFormat "ColorFormat::RG" instead.
diff --git a/src/DebugTools/CMakeLists.txt b/src/DebugTools/CMakeLists.txt
index d348e3b8b..987e07a5e 100644
--- a/src/DebugTools/CMakeLists.txt
+++ b/src/DebugTools/CMakeLists.txt
@@ -62,7 +62,10 @@ target_link_libraries(MagnumDebugTools
MagnumShaders
MagnumShapes)
-install(TARGETS MagnumDebugTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
+install(TARGETS MagnumDebugTools
+ RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}
+ LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}
+ ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumDebugTools_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/DebugTools)
if(BUILD_TESTS)
diff --git a/src/DebugTools/Test/CapsuleRendererTest.cpp b/src/DebugTools/Test/CapsuleRendererTest.cpp
index 4c0f7d762..0ec537c9c 100644
--- a/src/DebugTools/Test/CapsuleRendererTest.cpp
+++ b/src/DebugTools/Test/CapsuleRendererTest.cpp
@@ -55,9 +55,9 @@ void CapsuleRendererTest::zeroLength2D() {
const Vector2 a(0.5f, 3.0f);
std::array transformation = Implementation::capsuleRendererTransformation<2>(a, a, 3.5f);
- const auto scaling = Math::Matrix<2, Float>::fromDiagonal(Vector2(3.5f));
+ const auto scaling = Matrix2x2::fromDiagonal(Vector2(3.5f));
CORRADE_COMPARE(transformation[0].rotationScaling(), scaling);
- CORRADE_COMPARE(transformation[1].rotationScaling(), (Math::Matrix<2, Float>::fromDiagonal({3.5f, 0.0f})));
+ CORRADE_COMPARE(transformation[1].rotationScaling(), Matrix2x2::fromDiagonal({3.5f, 0.0f}));
CORRADE_COMPARE(transformation[2].rotationScaling(), scaling);
CORRADE_COMPARE(transformation[0].translation(), a);
@@ -94,9 +94,9 @@ void CapsuleRendererTest::zeroLength3D() {
const Vector3 a(0.5f, 3.0f, 7.0f);
std::array transformation = Implementation::capsuleRendererTransformation<3>(a, a, 3.5f);
- const auto scaling = Math::Matrix<3, Float>::fromDiagonal(Vector3(3.5f));
+ const auto scaling = Matrix3x3::fromDiagonal(Vector3(3.5f));
CORRADE_COMPARE(transformation[0].rotationScaling(), scaling);
- CORRADE_COMPARE(transformation[1].rotationScaling(), (Math::Matrix<3, Float>::fromDiagonal({3.5f, 0.0f, 3.5f})));
+ CORRADE_COMPARE(transformation[1].rotationScaling(), Matrix3x3::fromDiagonal({3.5f, 0.0f, 3.5f}));
CORRADE_COMPARE(transformation[2].rotationScaling(), scaling);
CORRADE_COMPARE(transformation[0].translation(), a);
diff --git a/src/DebugTools/Test/CylinderRendererTest.cpp b/src/DebugTools/Test/CylinderRendererTest.cpp
index 958003f96..9c18c51fa 100644
--- a/src/DebugTools/Test/CylinderRendererTest.cpp
+++ b/src/DebugTools/Test/CylinderRendererTest.cpp
@@ -55,7 +55,7 @@ void CylinderRendererTest::zeroLength2D() {
const Vector2 a(0.5f, 3.0f);
const Matrix3 transformation = Implementation::cylinderRendererTransformation<2>(a, a, 3.5f);
- CORRADE_COMPARE(transformation.rotationScaling(), (Math::Matrix<2, Float>::fromDiagonal({3.5f, 0.0f})));
+ CORRADE_COMPARE(transformation.rotationScaling(), Matrix2x2::fromDiagonal({3.5f, 0.0f}));
CORRADE_COMPARE(transformation.translation(), a);
}
@@ -76,7 +76,7 @@ void CylinderRendererTest::zeroLength3D() {
const Vector3 a(0.5f, 3.0f, 7.0f);
const Matrix4 transformation = Implementation::cylinderRendererTransformation<3>(a, a, 3.5f);
- CORRADE_COMPARE(transformation.rotationScaling(), (Math::Matrix<3, Float>::fromDiagonal({3.5f, 0.0f, 3.5f})));
+ CORRADE_COMPARE(transformation.rotationScaling(), Matrix3x3::fromDiagonal({3.5f, 0.0f, 3.5f}));
CORRADE_COMPARE(transformation.translation(), a);
}
diff --git a/src/Extensions.h b/src/Extensions.h
index e9fce378a..98b20519a 100644
--- a/src/Extensions.h
+++ b/src/Extensions.h
@@ -42,8 +42,9 @@ and string(), but these structs are better suited for compile-time decisions
rather than %Extension instances. See Context::isExtensionSupported() for
example usage.
-This namespace is built by default and found by default in CMake. See
-@ref building and @ref cmake for more information.
+This namespace is built by default. To use it, you need to add `${MAGNUM_INCLUDE_DIRS}`
+to include path and link to `${MAGNUM_LIBRARIES}`. See @ref building and
+@ref cmake for more information.
@see MAGNUM_ASSERT_EXTENSION_SUPPORTED()
@todo Manual indices for extensions, this has gaps
*/
diff --git a/src/ImageFormat.h b/src/ImageFormat.h
index 803b6372c..5ec6e8a31 100644
--- a/src/ImageFormat.h
+++ b/src/ImageFormat.h
@@ -31,20 +31,24 @@
#include "ColorFormat.h"
+#ifdef MAGNUM_BUILD_DEPRECATED
namespace Magnum {
/**
@copybrief ColorFormat
-@deprecated Use @ref ColorFormat instead.
+@deprecated Use @ref Magnum::ColorFormat "ColorFormat" instead.
*/
typedef ColorFormat ImageFormat;
/**
@copybrief ColorType
-@deprecated Use @ref ColorType instead.
+@deprecated Use @ref Magnum::ColorType "ColorType" instead.
*/
typedef ColorType ImageType;
}
+#else
+#error
+#endif
#endif
diff --git a/src/Magnum.h b/src/Magnum.h
index 2d5e8302e..4bb9a4943 100644
--- a/src/Magnum.h
+++ b/src/Magnum.h
@@ -65,11 +65,22 @@ using Corrade::Utility::Warning;
using Corrade::Utility::Error;
#ifdef DOXYGEN_GENERATING_OUTPUT
+/**
+@brief Build with deprecated API included
+
+Defined if the library contains deprecated API (which will be removed in the
+future). To preserve backward compatibility, %Magnum is by default built with
+deprecated API included.
+@see @ref building
+*/
+#define MAGNUM_BUILD_DEPRECATED
+/* (enabled by default) */
+
/**
@brief Static library build
Defined if built as static libraries. Default are shared libraries.
-@see @ref building-corrade
+@see @ref building
*/
#define MAGNUM_BUILD_STATIC
#undef MAGNUM_BUILD_STATIC
@@ -174,32 +185,100 @@ typedef Math::Vector3 Vector3i;
/** @brief Four-component signed integer vector */
typedef Math::Vector4 Vector4i;
-/** @brief 2x2 float matrix */
-typedef Math::Matrix<2, Float> Matrix2;
+/**
+@brief 3x3 float transformation matrix
-/** @brief 3x3 float matrix */
+@see @ref Matrix3x3
+*/
typedef Math::Matrix3 Matrix3;
-/** @brief 4x4 float matrix */
+/**
+@brief 4x4 float transformation matrix
+
+@see @ref Matrix4x4
+*/
typedef Math::Matrix4 Matrix4;
+/** @brief 2x2 float matrix */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix2x2 Matrix2x2;
+#else
+typedef Math::Matrix<2, Float> Matrix2x2;
+#endif
+
+#ifdef MAGNUM_BUILD_DEPRECATED
+/**
+@copybrief Matrix2x2
+@deprecated Use @ref Magnum::Matrix2x2 "Matrix2x2" instead.
+*/
+typedef Math::Matrix<2, Float> Matrix2;
+#endif
+
+/**
+@brief 3x3 float matrix
+
+Note that this is different from @ref Matrix3, which contains additional
+functions for transformations in 2D.
+*/
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix3x3 Matrix3x3;
+#else
+typedef Math::Matrix<3, Float> Matrix3x3;
+#endif
+
+/**
+@brief 4x4 float matrix
+
+Note that this is different from @ref Matrix4, which contains additional
+functions for transformations in 3D.
+*/
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix4x4 Matrix4x4;
+#else
+typedef Math::Matrix<4, Float> Matrix4x4;
+#endif
+
/** @brief Float matrix with 2 columns and 3 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix2x3 Matrix2x3;
+#else
typedef Math::RectangularMatrix<2, 3, Float> Matrix2x3;
+#endif
/** @brief Float matrix with 3 columns and 2 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix3x2 Matrix3x2;
+#else
typedef Math::RectangularMatrix<3, 2, Float> Matrix3x2;
+#endif
/** @brief Float matrix with 2 columns and 4 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix2x4 Matrix2x4;
+#else
typedef Math::RectangularMatrix<2, 4, Float> Matrix2x4;
+#endif
/** @brief Float matrix with 4 columns and 2 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix4x2 Matrix4x2;
+#else
typedef Math::RectangularMatrix<4, 2, Float> Matrix4x2;
+#endif
/** @brief Float matrix with 3 columns and 4 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix3x4 Matrix3x4;
+#else
typedef Math::RectangularMatrix<3, 4, Float> Matrix3x4;
+#endif
/** @brief Float matrix with 4 columns and 3 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix4x3 Matrix4x3;
+#else
typedef Math::RectangularMatrix<4, 3, Float> Matrix4x3;
+#endif
/** @brief Float complex number */
typedef Math::Complex Complex;
@@ -249,32 +328,100 @@ typedef Math::Vector3 Vector3d;
/** @brief Four-component double vector */
typedef Math::Vector4 Vector4d;
-/** @brief 2x2 double matrix */
-typedef Math::Matrix<2, Double> Matrix2d;
+/**
+@brief 3x3 double transformation matrix
-/** @brief 3x3 double matrix */
+@see @ref Matrix3x3d
+*/
typedef Math::Matrix3 Matrix3d;
-/** @brief 4x4 double matrix */
+/**
+@brief 4x4 double transformation matrix
+
+@see @ref Matrix4x4d
+*/
typedef Math::Matrix4 Matrix4d;
+/** @brief 2x2 double matrix */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix2x2 Matrix2x2d;
+#else
+typedef Math::Matrix<2, Double> Matrix2x2d;
+#endif
+
+#ifdef MAGNUM_BUILD_DEPRECATED
+/**
+@copybrief Matrix2x2d
+@deprecated Use @ref Magnum::Matrix2x2d "Matrix2x2d" instead.
+*/
+typedef Math::Matrix<2, Double> Matrix2d;
+#endif
+
+/**
+@brief 3x3 double matrix
+
+Note that this is different from @ref Matrix3d, which contains additional
+functions for transformations in 2D.
+*/
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix3x3 Matrix3x3d;
+#else
+typedef Math::Matrix<3, Double> Matrix3x3d;
+#endif
+
+/**
+@brief 4x4 double matrix
+
+Note that this is different from @ref Matrix4d, which contains additional
+functions for transformations in 3D.
+*/
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix4x4 Matrix4x4d;
+#else
+typedef Math::Matrix<4, Double> Matrix4x4d;
+#endif
+
/** @brief Double matrix with 2 columns and 3 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix2x3 Matrix2x3d;
+#else
typedef Math::RectangularMatrix<2, 3, Double> Matrix2x3d;
+#endif
/** @brief Double matrix with 3 columns and 2 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix3x2 Matrix3x2d;
+#else
typedef Math::RectangularMatrix<3, 2, Double> Matrix3x2d;
+#endif
/** @brief Double matrix with 2 columns and 4 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix2x4 Matrix2x4d;
+#else
typedef Math::RectangularMatrix<2, 4, Double> Matrix2x4d;
+#endif
/** @brief Double matrix with 4 columns and 2 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix4x2 Matrix4x2d;
+#else
typedef Math::RectangularMatrix<4, 2, Double> Matrix4x2d;
+#endif
/** @brief Double matrix with 3 columns and 4 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix3x4 Matrix3x4d;
+#else
typedef Math::RectangularMatrix<3, 4, Double> Matrix3x4d;
+#endif
/** @brief Double matrix with 4 columns and 3 rows */
+#ifndef CORRADE_GCC46_COMPATIBILITY
+typedef Math::Matrix4x3 Matrix4x3d;
+#else
typedef Math::RectangularMatrix<4, 3, Double> Matrix4x3d;
+#endif
/** @brief Double complex number */
typedef Math::Complex Complexd;
@@ -423,11 +570,4 @@ class Timeline;
}
-namespace std {
- #ifndef DOXYGEN_GENERATING_OUTPUT
- template struct hash;
- #endif
- template<> struct hash;
-}
-
#endif
diff --git a/src/Math/Algorithms/Test/GaussJordanTest.cpp b/src/Math/Algorithms/Test/GaussJordanTest.cpp
index 80ef9c1e5..b20652c18 100644
--- a/src/Math/Algorithms/Test/GaussJordanTest.cpp
+++ b/src/Math/Algorithms/Test/GaussJordanTest.cpp
@@ -36,7 +36,7 @@ class GaussJordanTest: public Corrade::TestSuite::Tester {
void invert();
};
-typedef RectangularMatrix<4, 4, Float> Matrix4;
+typedef RectangularMatrix<4, 4, Float> Matrix4x4;
typedef Vector<4, Float> Vector4;
GaussJordanTest::GaussJordanTest() {
@@ -45,32 +45,32 @@ GaussJordanTest::GaussJordanTest() {
}
void GaussJordanTest::singular() {
- Matrix4 a(Vector4(1.0f, 2.0f, 3.0f, 4.0f),
- Vector4(2.0f, 3.0f, -7.0f, 11.0f),
- Vector4(2.0f, 4.0f, 6.0f, 8.0f),
- Vector4(1.0f, 2.0f, 7.0f, 40.0f));
+ Matrix4x4 a(Vector4(1.0f, 2.0f, 3.0f, 4.0f),
+ Vector4(2.0f, 3.0f, -7.0f, 11.0f),
+ Vector4(2.0f, 4.0f, 6.0f, 8.0f),
+ Vector4(1.0f, 2.0f, 7.0f, 40.0f));
RectangularMatrix<4, 1, Float> t;
CORRADE_VERIFY(!gaussJordanInPlaceTransposed(a, t));
}
void GaussJordanTest::invert() {
- Matrix4 a(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
- Vector4(4.0f, 4.0f, 7.0f, 3.0f),
- Vector4(7.0f, -1.0f, 8.0f, 0.0f),
- Vector4(9.0f, 4.0f, 5.0f, 9.0f));
-
- Matrix4 expectedInverse(Vector4(-60/103.0f, 71/103.0f, -4/103.0f, 3/103.0f),
- Vector4(-66/103.0f, 109/103.0f, -25/103.0f, -7/103.0f),
- Vector4(177/412.0f, -97/206.0f, 53/412.0f, -7/206.0f),
- Vector4(259/412.0f, -185/206.0f, 31/412.0f, 27/206.0f));
-
- Matrix4 a2(a);
- Matrix4 inverse = Matrix4::fromDiagonal(Vector4(1.0f));
+ Matrix4x4 a(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
+ Vector4(4.0f, 4.0f, 7.0f, 3.0f),
+ Vector4(7.0f, -1.0f, 8.0f, 0.0f),
+ Vector4(9.0f, 4.0f, 5.0f, 9.0f));
+
+ Matrix4x4 expectedInverse(Vector4(-60/103.0f, 71/103.0f, -4/103.0f, 3/103.0f),
+ Vector4(-66/103.0f, 109/103.0f, -25/103.0f, -7/103.0f),
+ Vector4(177/412.0f, -97/206.0f, 53/412.0f, -7/206.0f),
+ Vector4(259/412.0f, -185/206.0f, 31/412.0f, 27/206.0f));
+
+ Matrix4x4 a2(a);
+ Matrix4x4 inverse = Matrix4x4::fromDiagonal(Vector4(1.0f));
CORRADE_VERIFY(gaussJordanInPlace(a2, inverse));
CORRADE_COMPARE(inverse, expectedInverse);
- CORRADE_COMPARE(a*inverse, Matrix4::fromDiagonal(Vector4(1.0f)));
+ CORRADE_COMPARE(a*inverse, Matrix4x4::fromDiagonal(Vector4(1.0f)));
}
}}}}
diff --git a/src/Math/Algorithms/Test/GramSchmidtTest.cpp b/src/Math/Algorithms/Test/GramSchmidtTest.cpp
index 28700089d..494615329 100644
--- a/src/Math/Algorithms/Test/GramSchmidtTest.cpp
+++ b/src/Math/Algorithms/Test/GramSchmidtTest.cpp
@@ -36,7 +36,7 @@ class GramSchmidtTest: public Corrade::TestSuite::Tester {
void orthonormalize();
};
-typedef RectangularMatrix<3, 3, Float> Matrix3;
+typedef RectangularMatrix<3, 3, Float> Matrix3x3;
typedef Vector<3, Float> Vector3;
GramSchmidtTest::GramSchmidtTest() {
@@ -45,11 +45,11 @@ GramSchmidtTest::GramSchmidtTest() {
}
void GramSchmidtTest::orthogonalize() {
- Matrix3 m(Vector3(3.0f, 5.0f, 1.0f),
- Vector3(4.0f, 4.0f, 7.0f),
- Vector3(7.0f, -1.0f, -3.0f));
+ Matrix3x3 m(Vector3(3.0f, 5.0f, 1.0f),
+ Vector3(4.0f, 4.0f, 7.0f),
+ Vector3(7.0f, -1.0f, -3.0f));
- Matrix3 orthogonalized = Algorithms::gramSchmidtOrthogonalize(m);
+ Matrix3x3 orthogonalized = Algorithms::gramSchmidtOrthogonalize(m);
/* Verify the first vector is in direction of first original */
CORRADE_COMPARE(orthogonalized[0], m[0]);
@@ -62,18 +62,18 @@ void GramSchmidtTest::orthogonalize() {
CORRADE_COMPARE(Vector3::dot(orthogonalized[1], orthogonalized[2]), 0.0f);
/* Just to be sure */
- Matrix3 expected(Vector3( 3.0f, 5.0f, 1.0f),
- Vector3(0.657143f, -1.571429f, 5.885714f),
- Vector3(6.086759f, -3.3379f, -1.570777f));
+ Matrix3x3 expected(Vector3( 3.0f, 5.0f, 1.0f),
+ Vector3(0.657143f, -1.571429f, 5.885714f),
+ Vector3(6.086759f, -3.3379f, -1.570777f));
CORRADE_COMPARE(orthogonalized, expected);
}
void GramSchmidtTest::orthonormalize() {
- Matrix3 m(Vector3(3.0f, 5.0f, 8.0f),
- Vector3(4.0f, 4.0f, 7.0f),
- Vector3(7.0f, -1.0f, 8.0f));
+ Matrix3x3 m(Vector3(3.0f, 5.0f, 8.0f),
+ Vector3(4.0f, 4.0f, 7.0f),
+ Vector3(7.0f, -1.0f, 8.0f));
- Matrix3 orthonormalized = Algorithms::gramSchmidtOrthonormalize(m);
+ Matrix3x3 orthonormalized = Algorithms::gramSchmidtOrthonormalize(m);
/* Verify the first vector is in direction of first original */
CORRADE_COMPARE(orthonormalized[0], m[0].normalized());
@@ -89,9 +89,9 @@ void GramSchmidtTest::orthonormalize() {
CORRADE_COMPARE(Vector3::dot(orthonormalized[1], orthonormalized[2]), 0.0f);
/* Just to be sure */
- Matrix3 expected(Vector3( 0.303046f, 0.505076f, 0.808122f),
- Vector3( 0.928316f, -0.348119f, -0.130544f),
- Vector3(-0.215388f, -0.789754f, 0.574367f));
+ Matrix3x3 expected(Vector3( 0.303046f, 0.505076f, 0.808122f),
+ Vector3( 0.928316f, -0.348119f, -0.130544f),
+ Vector3(-0.215388f, -0.789754f, 0.574367f));
CORRADE_COMPARE(orthonormalized, expected);
}
diff --git a/src/Math/Math.h b/src/Math/Math.h
index 77b237b9a..ab239d11b 100644
--- a/src/Math/Math.h
+++ b/src/Math/Math.h
@@ -30,6 +30,8 @@
#include
+#include "corradeConfigure.h"
+
namespace Magnum { namespace Math {
/** @todo Denormals to zero */
@@ -42,12 +44,26 @@ template class DualComplex;
template class DualQuaternion;
template class Matrix;
+#ifndef CORRADE_GCC46_COMPATIBILITY
+template using Matrix2x2 = Matrix<2, T>;
+template using Matrix3x3 = Matrix<3, T>;
+template using Matrix4x4 = Matrix<4, T>;
+#endif
+
template class Matrix3;
template class Matrix4;
template class Quaternion;
template class RectangularMatrix;
+#ifndef CORRADE_GCC46_COMPATIBILITY
+template using Matrix2x3 = RectangularMatrix<2, 3, T>;
+template using Matrix3x2 = RectangularMatrix<3, 2, T>;
+template using Matrix2x4 = RectangularMatrix<2, 4, T>;
+template using Matrix4x2 = RectangularMatrix<4, 2, T>;
+template using Matrix3x4 = RectangularMatrix<3, 4, T>;
+template using Matrix4x3 = RectangularMatrix<4, 3, T>;
+#endif
template class, class> class Unit;
template class Deg;
diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h
index 39a5d4bd8..b1e7313f0 100644
--- a/src/Math/Matrix.h
+++ b/src/Math/Matrix.h
@@ -44,7 +44,7 @@ namespace Implementation {
See @ref matrix-vector for brief introduction.
@configurationvalueref{Magnum::Math::Matrix}
-@see Magnum::Matrix2, Magnum::Matrix2d
+@see @ref Matrix2x2, @ref Matrix3x3, @ref Matrix4x4
*/
template class Matrix: public RectangularMatrix {
public:
@@ -89,9 +89,9 @@ template class Matrix: public RectangularMatrix floatingPoint({1.3f, 2.7f},
+ * Matrix2x2 floatingPoint({1.3f, 2.7f},
* {-15.0f, 7.0f});
- * Matrix<2, Byte> integral(floatingPoint);
+ * Matrix2x2 integral(floatingPoint);
* // integral == {{1, 2}, {-15, 7}}
* @endcode
*/
@@ -184,6 +184,40 @@ template class Matrix: public RectangularMatrix%Matrix<2, T>. See @ref Matrix for more
+information.
+@note Not available on GCC < 4.7. Use %Matrix<2, T> instead.
+@see @ref Magnum::Matrix2x2, @ref Magnum::Matrix2x2d
+*/
+template using Matrix2x2 = Matrix<2, T>;
+
+/**
+@brief 3x3 matrix
+
+Convenience alternative to %Matrix<3, T>. See @ref Matrix for more
+information. Note that this is different from @ref Matrix3, which contains
+additional functions for transformations in 2D.
+@note Not available on GCC < 4.7. Use %Matrix<3, T> instead.
+@see @ref Magnum::Matrix3x3, @ref Magnum::Matrix3x3d
+*/
+template using Matrix3x3 = Matrix<3, T>;
+
+/**
+@brief 4x4 matrix
+
+Convenience alternative to %Matrix<4, T>. See @ref Matrix for more
+information. Note that this is different from @ref Matrix4, which contains
+additional functions for transformations in 3D.
+@note Not available on GCC < 4.7. Use %Matrix<3, T> instead.
+@see @ref Magnum::Matrix4x4, @ref Magnum::Matrix4x4d
+*/
+template using Matrix4x4 = Matrix<4, T>;
+#endif
+
MAGNUM_MATRIX_OPERATOR_IMPLEMENTATION(Matrix)
/** @debugoperator{Magnum::Math::Matrix} */
diff --git a/src/Math/RectangularMatrix.h b/src/Math/RectangularMatrix.h
index 4baff2d57..b0d03d52d 100644
--- a/src/Math/RectangularMatrix.h
+++ b/src/Math/RectangularMatrix.h
@@ -48,9 +48,8 @@ Vector.
The data are stored in column-major order, to reflect that, all indices in
math formulas are in reverse order (i.e. @f$ \boldsymbol A_{ji} @f$ instead
of @f$ \boldsymbol A_{ij} @f$).
-@see Magnum::Matrix2x3, Magnum::Matrix3x2, Magnum::Matrix2x4, Magnum::Matrix4x2,
- Magnum::Matrix3x4, Magnum::Matrix4x3, Magnum::Matrix2x3d, Magnum::Matrix3x2d,
- Magnum::Matrix2x4d, Magnum::Matrix4x2d, Magnum::Matrix3x4d, Magnum::Matrix4x3d
+@see @ref Matrix2x3, @ref Matrix3x2, @ref Matrix2x4, @ref Matrix4x2,
+ @ref Matrix3x4, @ref Matrix4x3
*/
template class RectangularMatrix {
static_assert(cols != 0 && rows != 0, "RectangularMatrix cannot have zero elements");
@@ -396,6 +395,74 @@ template class RectangularMatrix {
Vector _data[cols];
};
+#ifndef CORRADE_GCC46_COMPATIBILITY
+/**
+@brief Matrix with 2 columns and 3 rows
+
+Convenience alternative to %RectangularMatrix<2, 3, T>. See
+@ref RectangularMatrix for more information.
+@note Not available on GCC < 4.7. Use %RectangularMatrix<2, 3, T>
+ instead.
+@see @ref Magnum::Matrix2x3, @ref Magnum::Matrix2x3d
+*/
+template using Matrix2x3 = RectangularMatrix<2, 3, T>;
+
+/**
+@brief Matrix with 3 columns and 2 rows
+
+Convenience alternative to %RectangularMatrix<3, 2, T>. See
+@ref RectangularMatrix for more information.
+@note Not available on GCC < 4.7. Use %RectangularMatrix<3, 2, T>
+ instead.
+@see @ref Magnum::Matrix3x2, @ref Magnum::Matrix3x2d
+*/
+template using Matrix3x2 = RectangularMatrix<3, 2, T>;
+
+/**
+@brief Matrix with 2 columns and 4 rows
+
+Convenience alternative to %RectangularMatrix<2, 4, T>. See
+@ref RectangularMatrix for more information.
+@note Not available on GCC < 4.7. Use %RectangularMatrix<2, 4, T>
+ instead.
+@see @ref Magnum::Matrix2x4, @ref Magnum::Matrix2x4d
+*/
+template using Matrix2x4 = RectangularMatrix<2, 4, T>;
+
+/**
+@brief Matrix with 4 columns and 2 rows
+
+Convenience alternative to %RectangularMatrix<4, 2, T>. See
+@ref RectangularMatrix for more information.
+@note Not available on GCC < 4.7. Use %RectangularMatrix<4, 2, T>
+ instead.
+@see @ref Magnum::Matrix4x2, @ref Magnum::Matrix4x2d
+*/
+template using Matrix4x2 = RectangularMatrix<4, 2, T>;
+
+/**
+@brief Matrix with 3 columns and 4 rows
+
+Convenience alternative to %RectangularMatrix<3, 4, T>. See
+@ref RectangularMatrix for more information.
+@note Not available on GCC < 4.7. Use %RectangularMatrix<3, 4, T>
+ instead.
+@see @ref Magnum::Matrix3x4, @ref Magnum::Matrix3x4d
+*/
+template using Matrix3x4 = RectangularMatrix<3, 4, T>;
+
+/**
+@brief Matrix with 4 columns and 3 rows
+
+Convenience alternative to %RectangularMatrix<4, 3, T>. See
+@ref RectangularMatrix for more information.
+@note Not available on GCC < 4.7. Use %RectangularMatrix<4, 3, T>
+ instead.
+@see @ref Magnum::Matrix4x3, @ref Magnum::Matrix4x3d
+*/
+template using Matrix4x3 = RectangularMatrix<4, 3, T>;
+#endif
+
/** @relates RectangularMatrix
@brief Multiply number with matrix
diff --git a/src/Math/Swizzle.h b/src/Math/Swizzle.h
index 1ac9746b3..0a8606ffa 100644
--- a/src/Math/Swizzle.h
+++ b/src/Math/Swizzle.h
@@ -44,12 +44,20 @@ namespace Implementation {
template struct Component: public ComponentAtPosition {};
template struct Component: public ComponentAtPosition {};
template struct Component: public ComponentAtPosition {};
+ template struct Component: public ComponentAtPosition {};
+ template struct Component: public ComponentAtPosition {};
+ template struct Component: public ComponentAtPosition {};
+ template struct Component: public ComponentAtPosition {};
template struct Component {
template constexpr static T value(const Math::Vector&) { return T(0); }
};
template struct Component {
template constexpr static T value(const Math::Vector&) { return T(1); }
};
+
+ template struct TypeForSize {
+ typedef Math::Vector Type;
+ };
}
/**
@@ -57,23 +65,22 @@ namespace Implementation {
Creates new vector from given components. Example:
@code
-Vector4 original(-1, 2, 3, 4);
+Vector4i original(-1, 2, 3, 4);
auto vec = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original);
// vec == { 4, 1, 0, -1, 2, 3 }
@endcode
-You can use letters `x`, `y`, `z`, `w` for addressing components or letters
-`0` and `1` for zero and one. Count of elements is unlimited, but must be at
-least one.
-
-See also Magnum::swizzle() which has some added convenience features not
-present in this lightweight implementation for Math namespace.
-
-@see @ref matrix-vector-component-access, Vector4::xyz(),
- Vector4::xy(), Vector3::xy()
+You can use letters `x`, `y`, `z`, `w` and `r`, `g`, `b`, `a` for addressing
+components or letters `0` and `1` for zero and one. Count of elements is
+unlimited, but must be at least one. If the resulting vector is two, three or
+four-component, corresponding @ref Math::Vector2, @ref Math::Vector3,
+@ref Math::Vector4, @ref Color3 or @ref Color4 specialization is returned.
+
+@see @ref matrix-vector-component-access, @ref Vector4::xyz(),
+ @ref Vector4::xy(), @ref Vector3::xy(), @ref Color4::rgb()
*/
-template constexpr Vector swizzle(const Vector& vector) {
- return {Implementation::Component::value(vector)...};
+template constexpr typename Implementation::TypeForSize::Type swizzle(const T& vector) {
+ return {Implementation::Component::value(vector)...};
}
}}
diff --git a/src/Math/Test/ComplexTest.cpp b/src/Math/Test/ComplexTest.cpp
index ca5af8f47..6f9fd6521 100644
--- a/src/Math/Test/ComplexTest.cpp
+++ b/src/Math/Test/ComplexTest.cpp
@@ -100,7 +100,7 @@ typedef Math::Rad Rad;
typedef Math::Complex Complex;
typedef Math::Vector2 Vector2;
typedef Math::Matrix3 Matrix3;
-typedef Math::Matrix<2, Float> Matrix2;
+typedef Math::Matrix<2, Float> Matrix2x2;
void ComplexTest::construct() {
constexpr Complex a(0.5f, -3.7f);
@@ -280,7 +280,7 @@ void ComplexTest::rotation() {
void ComplexTest::matrix() {
Complex a = Complex::rotation(Deg(37.0f));
- Matrix2 m = Matrix3::rotation(Deg(37.0f)).rotationScaling();
+ Matrix2x2 m = Matrix3::rotation(Deg(37.0f)).rotationScaling();
CORRADE_COMPARE(a.toMatrix(), m);
diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp
index 778f78e3a..f774392e7 100644
--- a/src/Math/Test/Matrix3Test.cpp
+++ b/src/Math/Test/Matrix3Test.cpp
@@ -90,7 +90,7 @@ class Matrix3Test: public Corrade::TestSuite::Tester {
typedef Math::Deg Deg;
typedef Math::Matrix3 Matrix3;
typedef Math::Matrix3 Matrix3i;
-typedef Math::Matrix<2, Float> Matrix2;
+typedef Math::Matrix<2, Float> Matrix2x2;
typedef Math::Vector3 Vector3;
typedef Math::Vector2 Vector2;
@@ -274,8 +274,8 @@ void Matrix3Test::projection() {
}
void Matrix3Test::fromParts() {
- constexpr Matrix2 rotationScaling(Vector2(3.0f, 5.0f),
- Vector2(4.0f, 4.0f));
+ constexpr Matrix2x2 rotationScaling(Vector2(3.0f, 5.0f),
+ Vector2(4.0f, 4.0f));
constexpr Vector2 translation(7.0f, -1.0f);
constexpr Matrix3 a = Matrix3::from(rotationScaling, translation);
@@ -288,10 +288,10 @@ void Matrix3Test::rotationScalingPart() {
constexpr Matrix3 a({3.0f, 5.0f, 8.0f},
{4.0f, 4.0f, 7.0f},
{7.0f, -1.0f, 8.0f});
- constexpr Matrix2 b = a.rotationScaling();
+ constexpr Matrix2x2 b = a.rotationScaling();
- CORRADE_COMPARE(b, Matrix2(Vector2(3.0f, 5.0f),
- Vector2(4.0f, 4.0f)));
+ CORRADE_COMPARE(b, Matrix2x2(Vector2(3.0f, 5.0f),
+ Vector2(4.0f, 4.0f)));
}
void Matrix3Test::rotationNormalizedPart() {
@@ -308,34 +308,34 @@ void Matrix3Test::rotationNormalizedPart() {
Matrix3 b({ 0.965926f, 0.258819f, 1.0f},
{-0.258819f, 0.965926f, 3.0f},
{ 0.0f, 0.0f, 1.0f});
- CORRADE_COMPARE(b.rotationNormalized(), Matrix2(Vector2( 0.965926f, 0.258819f),
- Vector2(-0.258819f, 0.965926f)));
+ CORRADE_COMPARE(b.rotationNormalized(), Matrix2x2(Vector2( 0.965926f, 0.258819f),
+ Vector2(-0.258819f, 0.965926f)));
}
void Matrix3Test::rotationPart() {
Matrix3 rotation = Matrix3::rotation(Deg(15.0f));
- Matrix2 expectedRotationPart(Vector2( 0.965926f, 0.258819f),
- Vector2(-0.258819f, 0.965926f));
+ Matrix2x2 expectedRotationPart(Vector2( 0.965926f, 0.258819f),
+ Vector2(-0.258819f, 0.965926f));
/* For rotation and translation this is the same as rotationScaling() */
Matrix3 rotationTranslation = rotation*Matrix3::translation({2.0f, 5.0f});
- Matrix2 rotationTranslationPart = rotationTranslation.rotation();
+ Matrix2x2 rotationTranslationPart = rotationTranslation.rotation();
CORRADE_COMPARE(rotationTranslationPart, rotationTranslation.rotationScaling());
CORRADE_COMPARE(rotationTranslationPart, expectedRotationPart);
/* Test uniform scaling */
Matrix3 rotationScaling = rotation*Matrix3::scaling(Vector2(3.0f));
- Matrix2 rotationScalingPart = rotationScaling.rotation();
+ Matrix2x2 rotationScalingPart = rotationScaling.rotation();
CORRADE_COMPARE(rotationScalingPart.determinant(), 1.0f);
- CORRADE_COMPARE(rotationScalingPart*rotationScalingPart.transposed(), Matrix2());
+ CORRADE_COMPARE(rotationScalingPart*rotationScalingPart.transposed(), Matrix2x2());
CORRADE_COMPARE(rotationScalingPart, expectedRotationPart);
/* Fails on non-uniform scaling */
std::ostringstream o;
Error::setOutput(&o);
- Matrix2 rotationScaling2 = (rotation*Matrix3::scaling(Vector2::yScale(3.5f))).rotation();
+ Matrix2x2 rotationScaling2 = (rotation*Matrix3::scaling(Vector2::yScale(3.5f))).rotation();
CORRADE_COMPARE(o.str(), "Math::Matrix3::rotation(): the matrix doesn't have uniform scaling\n");
- CORRADE_COMPARE(rotationScaling2, Matrix2());
+ CORRADE_COMPARE(rotationScaling2, Matrix2x2());
}
void Matrix3Test::uniformScalingPart() {
diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp
index 0ccfbc13f..5a5065608 100644
--- a/src/Math/Test/Matrix4Test.cpp
+++ b/src/Math/Test/Matrix4Test.cpp
@@ -98,7 +98,7 @@ typedef Math::Deg Deg;
typedef Math::Rad Rad;
typedef Math::Matrix4 Matrix4;
typedef Math::Matrix4 Matrix4i;
-typedef Math::Matrix<3, Float> Matrix3;
+typedef Math::Matrix<3, Float> Matrix3x3;
typedef Math::Vector3 Vector3;
Matrix4Test::Matrix4Test() {
@@ -353,9 +353,9 @@ void Matrix4Test::perspectiveProjectionFov() {
}
void Matrix4Test::fromParts() {
- constexpr Matrix3 rotationScaling(Vector3(3.0f, 5.0f, 8.0f),
- Vector3(4.0f, 4.0f, 7.0f),
- Vector3(7.0f, -1.0f, 8.0f));
+ constexpr Matrix3x3 rotationScaling(Vector3(3.0f, 5.0f, 8.0f),
+ Vector3(4.0f, 4.0f, 7.0f),
+ Vector3(7.0f, -1.0f, 8.0f));
constexpr Vector3 translation(9.0f, 4.0f, 5.0f);
constexpr Matrix4 a = Matrix4::from(rotationScaling, translation);
@@ -370,11 +370,11 @@ void Matrix4Test::rotationScalingPart() {
{4.0f, 4.0f, 7.0f, 3.0f},
{7.0f, -1.0f, 8.0f, 0.0f},
{9.0f, 4.0f, 5.0f, 9.0f});
- constexpr Matrix3 b = a.rotationScaling();
+ constexpr Matrix3x3 b = a.rotationScaling();
- CORRADE_COMPARE(b, Matrix3(Vector3(3.0f, 5.0f, 8.0f),
- Vector3(4.0f, 4.0f, 7.0f),
- Vector3(7.0f, -1.0f, 8.0f)));
+ CORRADE_COMPARE(b, Matrix3x3(Vector3(3.0f, 5.0f, 8.0f),
+ Vector3(4.0f, 4.0f, 7.0f),
+ Vector3(7.0f, -1.0f, 8.0f)));
}
void Matrix4Test::rotationNormalizedPart() {
@@ -392,36 +392,36 @@ void Matrix4Test::rotationNormalizedPart() {
{ 0.47987163f, 0.59757638f, 0.6423595f, 3.0f},
{-0.80181062f, 0.0015183985f, 0.59757638f, 4.0f},
{ 0.0f, 0.0f, 0.0f, 1.0f});
- CORRADE_COMPARE(b.rotationNormalized(), Matrix3(Vector3( 0.35612214f, -0.80181062f, 0.47987163f),
- Vector3( 0.47987163f, 0.59757638f, 0.6423595f),
- Vector3(-0.80181062f, 0.0015183985f, 0.59757638f)));
+ CORRADE_COMPARE(b.rotationNormalized(), Matrix3x3(Vector3( 0.35612214f, -0.80181062f, 0.47987163f),
+ Vector3( 0.47987163f, 0.59757638f, 0.6423595f),
+ Vector3(-0.80181062f, 0.0015183985f, 0.59757638f)));
}
void Matrix4Test::rotationPart() {
Matrix4 rotation = Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized());
- Matrix3 expectedRotationPart(Vector3( 0.35612214f, -0.80181062f, 0.47987163f),
- Vector3( 0.47987163f, 0.59757638f, 0.6423595f),
- Vector3(-0.80181062f, 0.0015183985f, 0.59757638f));
+ Matrix3x3 expectedRotationPart(Vector3( 0.35612214f, -0.80181062f, 0.47987163f),
+ Vector3( 0.47987163f, 0.59757638f, 0.6423595f),
+ Vector3(-0.80181062f, 0.0015183985f, 0.59757638f));
/* For rotation and translation this is the same as rotationScaling() */
Matrix4 rotationTranslation = rotation*Matrix4::translation({2.0f, 5.0f, -3.0f});
- Matrix3 rotationTranslationPart = rotationTranslation.rotation();
+ Matrix3x3 rotationTranslationPart = rotationTranslation.rotation();
CORRADE_COMPARE(rotationTranslationPart, rotationTranslation.rotationScaling());
CORRADE_COMPARE(rotationTranslationPart, expectedRotationPart);
/* Test uniform scaling */
Matrix4 rotationScaling = rotation*Matrix4::scaling(Vector3(3.0f));
- Matrix3 rotationScalingPart = rotationScaling.rotation();
+ Matrix3x3 rotationScalingPart = rotationScaling.rotation();
CORRADE_COMPARE(rotationScalingPart.determinant(), 1.0f);
- CORRADE_COMPARE(rotationScalingPart*rotationScalingPart.transposed(), Matrix3());
+ CORRADE_COMPARE(rotationScalingPart*rotationScalingPart.transposed(), Matrix3x3());
CORRADE_COMPARE(rotationScalingPart, expectedRotationPart);
/* Fails on non-uniform scaling */
std::ostringstream o;
Error::setOutput(&o);
- Matrix3 rotationScaling2 = (rotation*Matrix4::scaling(Vector3::yScale(3.5f))).rotation();
+ Matrix3x3 rotationScaling2 = (rotation*Matrix4::scaling(Vector3::yScale(3.5f))).rotation();
CORRADE_COMPARE(o.str(), "Math::Matrix4::rotation(): the matrix doesn't have uniform scaling\n");
- CORRADE_COMPARE(rotationScaling2, Matrix3());
+ CORRADE_COMPARE(rotationScaling2, Matrix3x3());
}
void Matrix4Test::uniformScalingPart() {
diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp
index 3f6a81e8b..2f9d0c226 100644
--- a/src/Math/Test/MatrixTest.cpp
+++ b/src/Math/Test/MatrixTest.cpp
@@ -82,9 +82,9 @@ class MatrixTest: public Corrade::TestSuite::Tester {
void configuration();
};
-typedef Matrix<4, Float> Matrix4;
-typedef Matrix<4, Int> Matrix4i;
-typedef Matrix<3, Float> Matrix3;
+typedef Matrix<4, Float> Matrix4x4;
+typedef Matrix<4, Int> Matrix4x4i;
+typedef Matrix<3, Float> Matrix3x3;
typedef Vector<4, Float> Vector4;
typedef Vector<4, Int> Vector4i;
typedef Vector<3, Float> Vector3;
@@ -116,37 +116,37 @@ MatrixTest::MatrixTest() {
void MatrixTest::construct() {
#ifndef CORRADE_GCC44_COMPATIBILITY
- constexpr Matrix4 a = {Vector4(3.0f, 5.0f, 8.0f, -3.0f),
- Vector4(4.5f, 4.0f, 7.0f, 2.0f),
- Vector4(1.0f, 2.0f, 3.0f, -1.0f),
- Vector4(7.9f, -1.0f, 8.0f, -1.5f)};
+ constexpr Matrix4x4 a = {Vector4(3.0f, 5.0f, 8.0f, -3.0f),
+ Vector4(4.5f, 4.0f, 7.0f, 2.0f),
+ Vector4(1.0f, 2.0f, 3.0f, -1.0f),
+ Vector4(7.9f, -1.0f, 8.0f, -1.5f)};
#else
/* Ambiguity with default copy constructor */
- constexpr Matrix4 a(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
- Vector4(4.5f, 4.0f, 7.0f, 2.0f),
- Vector4(1.0f, 2.0f, 3.0f, -1.0f),
- Vector4(7.9f, -1.0f, 8.0f, -1.5f));
+ constexpr Matrix4x4 a(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
+ Vector4(4.5f, 4.0f, 7.0f, 2.0f),
+ Vector4(1.0f, 2.0f, 3.0f, -1.0f),
+ Vector4(7.9f, -1.0f, 8.0f, -1.5f));
#endif
- CORRADE_COMPARE(a, Matrix4(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
- Vector4(4.5f, 4.0f, 7.0f, 2.0f),
- Vector4(1.0f, 2.0f, 3.0f, -1.0f),
- Vector4(7.9f, -1.0f, 8.0f, -1.5f)));
+ CORRADE_COMPARE(a, Matrix4x4(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
+ Vector4(4.5f, 4.0f, 7.0f, 2.0f),
+ Vector4(1.0f, 2.0f, 3.0f, -1.0f),
+ Vector4(7.9f, -1.0f, 8.0f, -1.5f)));
}
void MatrixTest::constructIdentity() {
- Matrix4 identity;
- Matrix4 identity2(Matrix4::Identity);
- Matrix4 identity3(Matrix4::Identity, 4.0f);
+ Matrix4x4 identity;
+ Matrix4x4 identity2(Matrix4x4::Identity);
+ Matrix4x4 identity3(Matrix4x4::Identity, 4.0f);
- Matrix4 identityExpected(Vector4(1.0f, 0.0f, 0.0f, 0.0f),
- Vector4(0.0f, 1.0f, 0.0f, 0.0f),
- Vector4(0.0f, 0.0f, 1.0f, 0.0f),
- Vector4(0.0f, 0.0f, 0.0f, 1.0f));
+ Matrix4x4 identityExpected(Vector4(1.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 1.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f));
- Matrix4 identity3Expected(Vector4(4.0f, 0.0f, 0.0f, 0.0f),
- Vector4(0.0f, 4.0f, 0.0f, 0.0f),
- Vector4(0.0f, 0.0f, 4.0f, 0.0f),
- Vector4(0.0f, 0.0f, 0.0f, 4.0f));
+ Matrix4x4 identity3Expected(Vector4(4.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 4.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 4.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 4.0f));
CORRADE_COMPARE(identity, identityExpected);
CORRADE_COMPARE(identity2, identityExpected);
@@ -154,30 +154,29 @@ void MatrixTest::constructIdentity() {
}
void MatrixTest::constructZero() {
- constexpr Matrix4 a(Matrix4::Zero);
- CORRADE_COMPARE(a, Matrix4(Vector4(0.0f, 0.0f, 0.0f, 0.0f),
- Vector4(0.0f, 0.0f, 0.0f, 0.0f),
- Vector4(0.0f, 0.0f, 0.0f, 0.0f),
- Vector4(0.0f, 0.0f, 0.0f, 0.0f)));
+ constexpr Matrix4x4 a(Matrix4x4::Zero);
+ CORRADE_COMPARE(a, Matrix4x4(Vector4(0.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 0.0f)));
}
void MatrixTest::constructConversion() {
- constexpr Matrix4 a(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
- Vector4(4.5f, 4.0f, 7.0f, 2.0f),
- Vector4(1.0f, 2.0f, 3.0f, -1.0f),
- Vector4(7.9f, -1.0f, 8.0f, -1.5f));
+ constexpr Matrix4x4 a(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
+ Vector4(4.5f, 4.0f, 7.0f, 2.0f),
+ Vector4(1.0f, 2.0f, 3.0f, -1.0f),
+ Vector4(7.9f, -1.0f, 8.0f, -1.5f));
#ifndef CORRADE_GCC46_COMPATIBILITY
- constexpr Matrix4i b(a);
- #else
- Matrix4i b(a); /* Not constexpr under GCC < 4.7 */
+ constexpr /* Not constexpr under GCC < 4.7 */
#endif
- CORRADE_COMPARE(b, Matrix4i(Vector4i(3, 5, 8, -3),
- Vector4i(4, 4, 7, 2),
- Vector4i(1, 2, 3, -1),
- Vector4i(7, -1, 8, -1)));
+ Matrix4x4i b(a);
+ CORRADE_COMPARE(b, Matrix4x4i(Vector4i(3, 5, 8, -3),
+ Vector4i(4, 4, 7, 2),
+ Vector4i(1, 2, 3, -1),
+ Vector4i(7, -1, 8, -1)));
/* Implicit conversion is not allowed */
- CORRADE_VERIFY(!(std::is_convertible::value));
+ CORRADE_VERIFY(!(std::is_convertible::value));
}
void MatrixTest::constructCopy() {
@@ -185,22 +184,22 @@ void MatrixTest::constructCopy() {
Vector4(4.5f, 4.0f, 7.0f, 2.0f),
Vector4(1.0f, 2.0f, 3.0f, -1.0f),
Vector4(7.9f, -1.0f, 8.0f, -1.5f));
- constexpr Matrix4 b(a);
- CORRADE_COMPARE(b, Matrix4(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
- Vector4(4.5f, 4.0f, 7.0f, 2.0f),
- Vector4(1.0f, 2.0f, 3.0f, -1.0f),
- Vector4(7.9f, -1.0f, 8.0f, -1.5f)));
+ constexpr Matrix4x4 b(a);
+ CORRADE_COMPARE(b, Matrix4x4(Vector4(3.0f, 5.0f, 8.0f, -3.0f),
+ Vector4(4.5f, 4.0f, 7.0f, 2.0f),
+ Vector4(1.0f, 2.0f, 3.0f, -1.0f),
+ Vector4(7.9f, -1.0f, 8.0f, -1.5f)));
}
void MatrixTest::convert() {
constexpr Mat3 a{{1.5f, 2.0f, -3.5f,
2.0f, -3.1f, 0.4f,
9.5f, -1.5f, 0.1f}};
- constexpr Matrix3 b(Vector3(1.5f, 2.0f, -3.5f),
- Vector3(2.0f, -3.1f, 0.4f),
- Vector3(9.5f, -1.5f, 0.1f));
+ constexpr Matrix3x3 b(Vector3(1.5f, 2.0f, -3.5f),
+ Vector3(2.0f, -3.1f, 0.4f),
+ Vector3(9.5f, -1.5f, 0.1f));
- constexpr Matrix3 c(b);
+ constexpr Matrix3x3 c(b);
CORRADE_COMPARE(c, b);
#ifndef CORRADE_GCC46_COMPATIBILITY
@@ -211,25 +210,25 @@ void MatrixTest::convert() {
CORRADE_COMPARE(d.a[i], a.a[i]);
/* Implicit conversion is not allowed */
- CORRADE_VERIFY(!(std::is_convertible::value));
+ CORRADE_VERIFY(!(std::is_convertible::value));
{
#ifdef CORRADE_GCC44_COMPATIBILITY
CORRADE_EXPECT_FAIL("GCC 4.4 doesn't have explicit conversion operators");
#endif
- CORRADE_VERIFY(!(std::is_convertible::value));
+ CORRADE_VERIFY(!(std::is_convertible::value));
}
}
void MatrixTest::isOrthogonal() {
- CORRADE_VERIFY(!Matrix3(Vector3(1.0f, 0.0f, 0.0f),
- Vector3(0.0f, 1.0f, 0.0f),
- Vector3(0.0f, 0.1f, 1.0f)).isOrthogonal());
- CORRADE_VERIFY(!Matrix3(Vector3(1.0f, 0.0f, 0.0f),
- Vector3(0.0f, 1.0f, 0.0f),
- Vector3(0.0f, 1.0f, 0.0f)).isOrthogonal());
- CORRADE_VERIFY(Matrix3(Vector3(1.0f, 0.0f, 0.0f),
- Vector3(0.0f, 1.0f, 0.0f),
- Vector3(0.0f, 0.0f, 1.0f)).isOrthogonal());
+ CORRADE_VERIFY(!Matrix3x3(Vector3(1.0f, 0.0f, 0.0f),
+ Vector3(0.0f, 1.0f, 0.0f),
+ Vector3(0.0f, 0.1f, 1.0f)).isOrthogonal());
+ CORRADE_VERIFY(!Matrix3x3(Vector3(1.0f, 0.0f, 0.0f),
+ Vector3(0.0f, 1.0f, 0.0f),
+ Vector3(0.0f, 1.0f, 0.0f)).isOrthogonal());
+ CORRADE_VERIFY(Matrix3x3(Vector3(1.0f, 0.0f, 0.0f),
+ Vector3(0.0f, 1.0f, 0.0f),
+ Vector3(0.0f, 0.0f, 1.0f)).isOrthogonal());
}
void MatrixTest::trace() {
@@ -245,14 +244,14 @@ void MatrixTest::trace() {
}
void MatrixTest::ij() {
- Matrix4 original(Vector4( 0.0f, 1.0f, 2.0f, 3.0f),
- Vector4( 4.0f, 5.0f, 6.0f, 7.0f),
- Vector4( 8.0f, 9.0f, 10.0f, 11.0f),
- Vector4(12.0f, 13.0f, 14.0f, 15.0f));
+ Matrix4x4 original(Vector4( 0.0f, 1.0f, 2.0f, 3.0f),
+ Vector4( 4.0f, 5.0f, 6.0f, 7.0f),
+ Vector4( 8.0f, 9.0f, 10.0f, 11.0f),
+ Vector4(12.0f, 13.0f, 14.0f, 15.0f));
- Matrix3 skipped(Vector3( 0.0f, 1.0f, 3.0f),
- Vector3( 8.0f, 9.0f, 11.0f),
- Vector3(12.0f, 13.0f, 15.0f));
+ Matrix3x3 skipped(Vector3( 0.0f, 1.0f, 3.0f),
+ Vector3( 8.0f, 9.0f, 11.0f),
+ Vector3(12.0f, 13.0f, 15.0f));
CORRADE_COMPARE(original.ij(1, 2), skipped);
}
@@ -270,33 +269,33 @@ void MatrixTest::determinant() {
}
void MatrixTest::inverted() {
- Matrix4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
- Vector4(4.0f, 4.0f, 7.0f, 3.0f),
- Vector4(7.0f, -1.0f, 8.0f, 0.0f),
- Vector4(9.0f, 4.0f, 5.0f, 9.0f));
+ Matrix4x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
+ Vector4(4.0f, 4.0f, 7.0f, 3.0f),
+ Vector4(7.0f, -1.0f, 8.0f, 0.0f),
+ Vector4(9.0f, 4.0f, 5.0f, 9.0f));
- Matrix4 inverse(Vector4(-60/103.0f, 71/103.0f, -4/103.0f, 3/103.0f),
- Vector4(-66/103.0f, 109/103.0f, -25/103.0f, -7/103.0f),
- Vector4(177/412.0f, -97/206.0f, 53/412.0f, -7/206.0f),
- Vector4(259/412.0f, -185/206.0f, 31/412.0f, 27/206.0f));
+ Matrix4x4 inverse(Vector4(-60/103.0f, 71/103.0f, -4/103.0f, 3/103.0f),
+ Vector4(-66/103.0f, 109/103.0f, -25/103.0f, -7/103.0f),
+ Vector4(177/412.0f, -97/206.0f, 53/412.0f, -7/206.0f),
+ Vector4(259/412.0f, -185/206.0f, 31/412.0f, 27/206.0f));
- Matrix4 _inverse = m.inverted();
+ Matrix4x4 _inverse = m.inverted();
CORRADE_COMPARE(_inverse, inverse);
- CORRADE_COMPARE(_inverse*m, Matrix4());
+ CORRADE_COMPARE(_inverse*m, Matrix4x4());
}
void MatrixTest::invertedOrthogonal() {
std::ostringstream o;
Error::setOutput(&o);
- Matrix3 a(Vector3(Constants::sqrt3()/2.0f, 0.5f, 0.0f),
- Vector3(-0.5f, Constants::sqrt3()/2.0f, 0.0f),
- Vector3(0.0f, 0.0f, 1.0f));
+ Matrix3x3 a(Vector3(Constants::sqrt3()/2.0f, 0.5f, 0.0f),
+ Vector3(-0.5f, Constants::sqrt3()/2.0f, 0.0f),
+ Vector3(0.0f, 0.0f, 1.0f));
(a*2).invertedOrthogonal();
CORRADE_COMPARE(o.str(), "Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal\n");
- CORRADE_COMPARE(a.invertedOrthogonal()*a, Matrix3());
+ CORRADE_COMPARE(a.invertedOrthogonal()*a, Matrix3x3());
CORRADE_COMPARE(a.invertedOrthogonal(), a.inverted());
}
@@ -357,10 +356,10 @@ void MatrixTest::subclass() {
}
void MatrixTest::debug() {
- Matrix4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
- Vector4(4.0f, 4.0f, 7.0f, 3.0f),
- Vector4(7.0f, -1.0f, 8.0f, 0.0f),
- Vector4(9.0f, 4.0f, 5.0f, 9.0f));
+ Matrix4x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
+ Vector4(4.0f, 4.0f, 7.0f, 3.0f),
+ Vector4(7.0f, -1.0f, 8.0f, 0.0f),
+ Vector4(9.0f, 4.0f, 5.0f, 9.0f));
std::ostringstream o;
Debug(&o) << m;
@@ -370,7 +369,7 @@ void MatrixTest::debug() {
" 4, 3, 0, 9)\n");
o.str({});
- Debug(&o) << "a" << Matrix4() << "b" << Matrix4();
+ Debug(&o) << "a" << Matrix4x4() << "b" << Matrix4x4();
CORRADE_COMPARE(o.str(), "a Matrix(1, 0, 0, 0,\n"
" 0, 1, 0, 0,\n"
" 0, 0, 1, 0,\n"
@@ -383,15 +382,15 @@ void MatrixTest::debug() {
void MatrixTest::configuration() {
Corrade::Utility::Configuration c;
- Matrix4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
- Vector4(4.0f, 4.0f, 7.0f, 3.125f),
- Vector4(7.0f, -1.0f, 8.0f, 0.0f),
- Vector4(9.0f, 4.0f, 5.0f, 9.55f));
+ Matrix4x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f),
+ Vector4(4.0f, 4.0f, 7.0f, 3.125f),
+ Vector4(7.0f, -1.0f, 8.0f, 0.0f),
+ Vector4(9.0f, 4.0f, 5.0f, 9.55f));
std::string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55");
c.setValue("matrix", m);
CORRADE_COMPARE(c.value("matrix"), value);
- CORRADE_COMPARE(c.value("matrix"), m);
+ CORRADE_COMPARE(c.value("matrix"), m);
}
}}}
diff --git a/src/Math/Test/QuaternionTest.cpp b/src/Math/Test/QuaternionTest.cpp
index 1ab42012f..1d4413861 100644
--- a/src/Math/Test/QuaternionTest.cpp
+++ b/src/Math/Test/QuaternionTest.cpp
@@ -69,7 +69,7 @@ class QuaternionTest: public Corrade::TestSuite::Tester {
typedef Math::Deg Deg;
typedef Math::Rad Rad;
-typedef Math::Matrix<3, Float> Matrix3;
+typedef Math::Matrix<3, Float> Matrix3x3;
typedef Math::Matrix4 Matrix4;
typedef Math::Quaternion Quaternion;
typedef Math::Vector3 Vector3;
@@ -283,7 +283,7 @@ void QuaternionTest::matrix() {
Vector3 axis = Vector3(1.0f, -3.0f, 5.0f).normalized();
Quaternion q = Quaternion::rotation(Deg(37.0f), axis);
- Matrix3 m = Matrix4::rotation(Deg(37.0f), axis).rotationScaling();
+ Matrix3x3 m = Matrix4::rotation(Deg(37.0f), axis).rotationScaling();
/* Verify that negated quaternion gives the same rotation */
CORRADE_COMPARE(q.toMatrix(), m);
@@ -299,7 +299,7 @@ void QuaternionTest::matrix() {
CORRADE_COMPARE(Quaternion::fromMatrix(m), q);
/* Trace < 0 */
- Matrix3 m2 = Matrix4::rotation(Deg(130.0f), axis).rotationScaling();
+ Matrix3x3 m2 = Matrix4::rotation(Deg(130.0f), axis).rotationScaling();
Quaternion q2 = Quaternion::rotation(Deg(130.0f), axis);
CORRADE_VERIFY(m2.trace() < 0.0f);
CORRADE_COMPARE(Quaternion::fromMatrix(m2), q2);
diff --git a/src/Math/Test/RectangularMatrixTest.cpp b/src/Math/Test/RectangularMatrixTest.cpp
index 4da3c411f..f3a591ecf 100644
--- a/src/Math/Test/RectangularMatrixTest.cpp
+++ b/src/Math/Test/RectangularMatrixTest.cpp
@@ -90,8 +90,8 @@ class RectangularMatrixTest: public Corrade::TestSuite::Tester {
typedef RectangularMatrix<4, 3, Float> Matrix4x3;
typedef RectangularMatrix<3, 4, Float> Matrix3x4;
-typedef RectangularMatrix<2, 2, Float> Matrix2;
-typedef RectangularMatrix<2, 2, Int> Matrix2i;
+typedef RectangularMatrix<2, 2, Float> Matrix2x2;
+typedef RectangularMatrix<2, 2, Int> Matrix2x2i;
typedef Vector<4, Float> Vector4;
typedef Vector<3, Float> Vector3;
typedef Vector<2, Float> Vector2;
@@ -152,19 +152,19 @@ void RectangularMatrixTest::constructDefault() {
}
void RectangularMatrixTest::constructConversion() {
- constexpr Matrix2 a(Vector2( 1.3f, 2.7f),
- Vector2(-15.0f, 7.0f));
+ constexpr Matrix2x2 a(Vector2( 1.3f, 2.7f),
+ Vector2(-15.0f, 7.0f));
#ifndef CORRADE_GCC46_COMPATIBILITY
- constexpr Matrix2i b(a);
+ constexpr Matrix2x2i b(a);
#else
- Matrix2i b(a); /* Not constexpr under GCC < 4.7 */
+ Matrix2x2i b(a); /* Not constexpr under GCC < 4.7 */
#endif
- CORRADE_COMPARE(b, Matrix2i(Vector2i( 1, 2),
- Vector2i(-15, 7)));
+ CORRADE_COMPARE(b, Matrix2x2i(Vector2i( 1, 2),
+ Vector2i(-15, 7)));
/* Implicit conversion is not allowed */
- CORRADE_VERIFY(!(std::is_convertible::value));
+ CORRADE_VERIFY(!(std::is_convertible::value));
}
void RectangularMatrixTest::constructFromData() {
@@ -273,28 +273,28 @@ void RectangularMatrixTest::row() {
}
void RectangularMatrixTest::compare() {
- Matrix2 a(Vector2(1.0f, -3.0f),
- Vector2(5.0f, -10.0f));
- Matrix2 b(Vector2(1.0f + TypeTraits::epsilon()/2, -3.0f),
- Vector2(5.0f, -10.0f));
- Matrix2 c(Vector2(1.0f, -1.0f + TypeTraits::epsilon()*2),
- Vector2(5.0f, -10.0f));
+ Matrix2x2 a(Vector2(1.0f, -3.0f),
+ Vector2(5.0f, -10.0f));
+ Matrix2x2 b(Vector2(1.0f + TypeTraits::epsilon()/2, -3.0f),
+ Vector2(5.0f, -10.0f));
+ Matrix2x2 c(Vector2(1.0f, -1.0f + TypeTraits::epsilon()*2),
+ Vector2(5.0f, -10.0f));
CORRADE_VERIFY(a == b);
CORRADE_VERIFY(a != c);
- Matrix2i ai(Vector2i(1, -3),
- Vector2i(5, -10));
- Matrix2i bi(Vector2i(1, -2),
- Vector2i(5, -10));
+ Matrix2x2i ai(Vector2i(1, -3),
+ Vector2i(5, -10));
+ Matrix2x2i bi(Vector2i(1, -2),
+ Vector2i(5, -10));
CORRADE_VERIFY(ai == ai);
CORRADE_VERIFY(ai != bi);
}
void RectangularMatrixTest::negative() {
- Matrix2 matrix(Vector2(1.0f, -3.0f),
- Vector2(5.0f, -10.0f));
- Matrix2 negated(Vector2(-1.0f, 3.0f),
- Vector2(-5.0f, 10.0f));
+ Matrix2x2 matrix(Vector2(1.0f, -3.0f),
+ Vector2(5.0f, -10.0f));
+ Matrix2x2 negated(Vector2(-1.0f, 3.0f),
+ Vector2(-5.0f, 10.0f));
CORRADE_COMPARE(-matrix, negated);
}
@@ -317,20 +317,20 @@ void RectangularMatrixTest::addSubtract() {
}
void RectangularMatrixTest::multiplyDivide() {
- Matrix2 matrix(Vector2(1.0f, 2.0f),
- Vector2(3.0f, 4.0f));
- Matrix2 multiplied(Vector2(-1.5f, -3.0f),
- Vector2(-4.5f, -6.0f));
+ Matrix2x2 matrix(Vector2(1.0f, 2.0f),
+ Vector2(3.0f, 4.0f));
+ Matrix2x2 multiplied(Vector2(-1.5f, -3.0f),
+ Vector2(-4.5f, -6.0f));
CORRADE_COMPARE(matrix*-1.5f, multiplied);
CORRADE_COMPARE(-1.5f*matrix, multiplied);
CORRADE_COMPARE(multiplied/-1.5f, matrix);
/* Divide vector with number and inverse */
- Matrix2 divisor(Vector2( 1.0f, 2.0f),
- Vector2(-4.0f, 8.0f));
- Matrix2 result(Vector2( 1.0f, 0.5f),
- Vector2(-0.25f, 0.125f));
+ Matrix2x2 divisor(Vector2( 1.0f, 2.0f),
+ Vector2(-4.0f, 8.0f));
+ Matrix2x2 result(Vector2( 1.0f, 0.5f),
+ Vector2(-0.25f, 0.125f));
CORRADE_COMPARE(1.0f/divisor, result);
}
diff --git a/src/Math/Test/SwizzleTest.cpp b/src/Math/Test/SwizzleTest.cpp
index 5f01b4e62..19968ca72 100644
--- a/src/Math/Test/SwizzleTest.cpp
+++ b/src/Math/Test/SwizzleTest.cpp
@@ -34,6 +34,7 @@ class SwizzleTest: public Corrade::TestSuite::Tester {
void components();
void constants();
+ void rgba();
void sizes();
};
@@ -42,6 +43,7 @@ typedef Vector<4, Int> Vector4i;
SwizzleTest::SwizzleTest() {
addTests({&SwizzleTest::components,
&SwizzleTest::constants,
+ &SwizzleTest::rgba,
&SwizzleTest::sizes});
}
@@ -55,6 +57,11 @@ void SwizzleTest::constants() {
CORRADE_COMPARE(a, Vector4i(1, 7, 0, 4));
}
+void SwizzleTest::rgba() {
+ constexpr auto a = swizzle<'b', 'r', 'a', 'g'>(Vector4i(2, 4, 5, 7));
+ CORRADE_COMPARE(a, Vector4i(5, 2, 7, 4));
+}
+
void SwizzleTest::sizes() {
constexpr auto a = swizzle<'y', 'x', 'x'>(Math::Vector<2, Int>(1, 2));
CORRADE_COMPARE(a, (Math::Vector<3, Int>(2, 1, 1)));
diff --git a/src/Math/Test/Vector2Test.cpp b/src/Math/Test/Vector2Test.cpp
index 848968a80..52a9b97e8 100644
--- a/src/Math/Test/Vector2Test.cpp
+++ b/src/Math/Test/Vector2Test.cpp
@@ -26,7 +26,7 @@
#include
#include
-#include "Math/Vector3.h"
+#include "Math/Vector3.h" /* Vector3 used in Vector2::cross() */
struct Vec2 {
float x, y;
@@ -67,7 +67,9 @@ class Vector2Test: public Corrade::TestSuite::Tester {
void axes();
void scales();
void perpendicular();
+ void aspectRatio();
+ void swizzleType();
void debug();
void configuration();
};
@@ -90,7 +92,9 @@ Vector2Test::Vector2Test() {
&Vector2Test::axes,
&Vector2Test::scales,
&Vector2Test::perpendicular,
+ &Vector2Test::aspectRatio,
+ &Vector2Test::swizzleType,
&Vector2Test::debug,
&Vector2Test::configuration});
}
@@ -205,6 +209,17 @@ void Vector2Test::perpendicular() {
CORRADE_COMPARE(Vector2::xAxis().perpendicular(), Vector2::yAxis());
}
+void Vector2Test::aspectRatio() {
+ const Vector2 a(3.0f, 4.0f);
+ CORRADE_COMPARE(a.aspectRatio(), 0.75f);
+}
+
+void Vector2Test::swizzleType() {
+ constexpr Vector<4, Int> orig;
+ constexpr auto a = swizzle<'y', 'a'>(orig);
+ CORRADE_VERIFY((std::is_same::value));
+}
+
void Vector2Test::debug() {
std::ostringstream o;
Debug(&o) << Vector2(0.5f, 15.0f);
diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp
index 7ebb20eb8..e30f60a57 100644
--- a/src/Math/Test/Vector3Test.cpp
+++ b/src/Math/Test/Vector3Test.cpp
@@ -69,6 +69,7 @@ class Vector3Test: public Corrade::TestSuite::Tester {
void scales();
void twoComponent();
+ void swizzleType();
void debug();
void configuration();
};
@@ -176,16 +177,25 @@ void Vector3Test::convert() {
void Vector3Test::access() {
Vector3 vec(1.0f, -2.0f, 5.0f);
CORRADE_COMPARE(vec.x(), 1.0f);
+ CORRADE_COMPARE(vec.r(), 1.0f);
CORRADE_COMPARE(vec.y(), -2.0f);
+ CORRADE_COMPARE(vec.g(), -2.0f);
CORRADE_COMPARE(vec.z(), 5.0f);
+ CORRADE_COMPARE(vec.b(), 5.0f);
constexpr Vector3 cvec(1.0f, -2.0f, 5.0f);
constexpr Float x = cvec.x();
+ constexpr Float r = cvec.r();
constexpr Float y = cvec.y();
+ constexpr Float g = cvec.g();
constexpr Float z = cvec.z();
+ constexpr Float b = cvec.b();
CORRADE_COMPARE(x, 1.0f);
+ CORRADE_COMPARE(r, 1.0f);
CORRADE_COMPARE(y, -2.0f);
+ CORRADE_COMPARE(g, -2.0f);
CORRADE_COMPARE(z, 5.0f);
+ CORRADE_COMPARE(b, 5.0f);
}
void Vector3Test::cross() {
@@ -224,6 +234,12 @@ void Vector3Test::twoComponent() {
CORRADE_COMPARE(d, 2.0f);
}
+void Vector3Test::swizzleType() {
+ constexpr Vector<4, Int> orig;
+ constexpr auto b = swizzle<'y', 'z', 'a'>(orig);
+ CORRADE_VERIFY((std::is_same::value));
+}
+
void Vector3Test::debug() {
std::ostringstream o;
Debug(&o) << Vector3(0.5f, 15.0f, 1.0f);
diff --git a/src/Math/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp
index fc345eeb5..c055870a5 100644
--- a/src/Math/Test/Vector4Test.cpp
+++ b/src/Math/Test/Vector4Test.cpp
@@ -67,6 +67,7 @@ class Vector4Test: public Corrade::TestSuite::Tester {
void threeComponent();
void twoComponent();
+ void swizzleType();
void debug();
void configuration();
};
@@ -90,6 +91,7 @@ Vector4Test::Vector4Test() {
&Vector4Test::threeComponent,
&Vector4Test::twoComponent,
+ &Vector4Test::swizzleType,
&Vector4Test::debug,
&Vector4Test::configuration});
}
@@ -174,24 +176,37 @@ void Vector4Test::convert() {
void Vector4Test::access() {
Vector4 vec(1.0f, -2.0f, 5.0f, 0.5f);
CORRADE_COMPARE(vec.x(), 1.0f);
+ CORRADE_COMPARE(vec.r(), 1.0f);
CORRADE_COMPARE(vec.y(), -2.0f);
+ CORRADE_COMPARE(vec.g(), -2.0f);
CORRADE_COMPARE(vec.z(), 5.0f);
+ CORRADE_COMPARE(vec.b(), 5.0f);
CORRADE_COMPARE(vec.w(), 0.5f);
+ CORRADE_COMPARE(vec.a(), 0.5f);
constexpr Vector4 cvec(1.0f, -2.0f, 5.0f, 0.5f);
constexpr Float x = cvec.x();
+ constexpr Float r = cvec.r();
constexpr Float y = cvec.y();
+ constexpr Float g = cvec.g();
constexpr Float z = cvec.z();
+ constexpr Float b = cvec.b();
constexpr Float w = cvec.w();
+ constexpr Float a = cvec.a();
CORRADE_COMPARE(x, 1.0f);
+ CORRADE_COMPARE(r, 1.0f);
CORRADE_COMPARE(y, -2.0f);
+ CORRADE_COMPARE(g, -2.0f);
CORRADE_COMPARE(z, 5.0f);
+ CORRADE_COMPARE(b, 5.0f);
CORRADE_COMPARE(w, 0.5f);
+ CORRADE_COMPARE(a, 0.5f);
}
void Vector4Test::threeComponent() {
Vector4 a(1.0f, 2.0f, 3.0f, 4.0f);
CORRADE_COMPARE(a.xyz(), Vector3(1.0f, 2.0f, 3.0f));
+ CORRADE_COMPARE(a.rgb(), Vector3(1.0f, 2.0f, 3.0f));
constexpr Vector4 b(1.0f, 2.0f, 3.0f, 4.0f);
constexpr Vector3 c = b.xyz();
@@ -211,6 +226,12 @@ void Vector4Test::twoComponent() {
CORRADE_COMPARE(d, 1.0f);
}
+void Vector4Test::swizzleType() {
+ constexpr Vector4i orig;
+ constexpr auto c = swizzle<'y', 'a', 'y', 'x'>(orig);
+ CORRADE_VERIFY((std::is_same::value));
+}
+
void Vector4Test::debug() {
std::ostringstream o;
Debug(&o) << Vector4(0.5f, 15.0f, 1.0f, 1.0f);
diff --git a/src/Math/Vector2.h b/src/Math/Vector2.h
index c6ba1ecfc..229e48e20 100644
--- a/src/Math/Vector2.h
+++ b/src/Math/Vector2.h
@@ -138,6 +138,15 @@ template class Vector2: public Vector<2, T> {
*/
Vector2 perpendicular() const { return {-y(), x()}; }
+ /**
+ * @brief Aspect ratio
+ *
+ * Returns quotient of the two elements. @f[
+ * a = \frac{v_x}{v_y}
+ * @f]
+ */
+ T aspectRatio() const { return x()/y(); }
+
MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(2, Vector2)
};
@@ -148,6 +157,11 @@ template inline Corrade::Utility::Debug operator<<(Corrade::Utility::De
return debug << static_cast&>(value);
}
+namespace Implementation {
+ template struct TypeForSize;
+ template struct TypeForSize<2, T> { typedef Math::Vector2 Type; };
+}
+
}}
namespace Corrade { namespace Utility {
diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h
index f43875c89..be129bd4c 100644
--- a/src/Math/Vector3.h
+++ b/src/Math/Vector3.h
@@ -149,13 +149,55 @@ template class Vector3: public Vector<3, T> {
/** @brief Copy constructor */
constexpr Vector3(const Vector<3, T>& other): Vector<3, T>(other) {}
- T& x() { return (*this)[0]; } /**< @brief X component */
+
+ /**
+ * @brief X component
+ *
+ * @see @ref r()
+ */
+ T& x() { return (*this)[0]; }
constexpr T x() const { return (*this)[0]; } /**< @overload */
- T& y() { return (*this)[1]; } /**< @brief Y component */
+
+ /**
+ * @brief Y component
+ *
+ * @see @ref g()
+ */
+ T& y() { return (*this)[1]; }
constexpr T y() const { return (*this)[1]; } /**< @overload */
- T& z() { return (*this)[2]; } /**< @brief Z component */
+
+ /**
+ * @brief Z component
+ *
+ * @see @ref b()
+ */
+ T& z() { return (*this)[2]; }
constexpr T z() const { return (*this)[2]; } /**< @overload */
+ /**
+ * @brief R component
+ *
+ * Equivalent to @ref x().
+ */
+ T& r() { return x(); }
+ constexpr T r() const { return x(); } /**< @overload */
+
+ /**
+ * @brief G component
+ *
+ * Equivalent to @ref y().
+ */
+ T& g() { return y(); }
+ constexpr T g() const { return y(); } /**< @overload */
+
+ /**
+ * @brief B component
+ *
+ * Equivalent to @ref z().
+ */
+ T& b() { return z(); }
+ constexpr T b() const { return z(); } /**< @overload */
+
/**
* @brief XY part of the vector
* @return First two components of the vector
@@ -175,6 +217,10 @@ template inline Corrade::Utility::Debug operator<<(Corrade::Utility::De
return debug << static_cast