Browse Source

Merge branch 'master' into compatibility

Vladimír Vondruš 11 years ago
parent
commit
75b60396f5
  1. 16
      CMakeLists.txt
  2. 2
      CONTRIBUTING.md
  3. 2
      COPYING
  4. 16
      CREDITS.md
  5. 15
      Doxyfile
  6. 12
      README.md
  7. 2
      doc/best-practices.dox
  8. 101
      doc/building.dox
  9. 73
      doc/cmake.dox
  10. 10
      doc/coding-style.dox
  11. 12
      doc/compilation-speedup.dox
  12. 18
      doc/debug-tools.dox
  13. 3
      doc/features.dox
  14. 1
      doc/generated/.gitattributes
  15. 67
      doc/generated/CMakeLists.txt
  16. 47
      doc/generated/README.md
  17. 20
      doc/generated/configure.h.cmake
  18. 54
      doc/generated/hello.cpp
  19. 301
      doc/generated/shaders.cpp
  20. BIN
      doc/generated/vector-distancefield.png
  21. BIN
      doc/generated/vector.png
  22. 79
      doc/generated/vector.svg
  23. BIN
      doc/getting-started-blue.png
  24. 21
      doc/getting-started.dox
  25. BIN
      doc/getting-started.png
  26. 20
      doc/mainpage.dox
  27. 22
      doc/matrix-vector.dox
  28. 19
      doc/method-chaining.dox
  29. 119
      doc/namespaces.dox
  30. 41
      doc/opengl-mapping.dox
  31. 51
      doc/opengl-support.dox
  32. 6
      doc/opengl.dox
  33. 50
      doc/platform.dox
  34. 38
      doc/plugins.dox
  35. 12
      doc/portability.dox
  36. 314
      doc/scenegraph.dox
  37. BIN
      doc/shaders-distancefieldvector.png
  38. BIN
      doc/shaders-flat.png
  39. BIN
      doc/shaders-meshvisualizer.png
  40. BIN
      doc/shaders-phong.png
  41. BIN
      doc/shaders-vector.png
  42. BIN
      doc/shaders-vertexcolor.png
  43. 136
      doc/shaders.dox
  44. 22
      doc/shapes.dox
  45. 2
      doc/tips.dox
  46. 220
      doc/transformations.dox
  47. 6
      doc/troubleshooting.dox
  48. 12
      doc/types.dox
  49. 2
      doc/utilities.dox
  50. 10
      modules/CMakeLists.txt
  51. 130
      modules/FindCorrade.cmake
  52. 9
      modules/FindEGL.cmake
  53. 171
      modules/FindMagnum.cmake
  54. 9
      modules/FindOpenGLES2.cmake
  55. 9
      modules/FindOpenGLES3.cmake
  56. 2
      modules/FindSDL2.cmake
  57. 26
      modules/MagnumConfig.cmake
  58. 15
      package/archlinux/PKGBUILD
  59. 22
      package/archlinux/PKGBUILD-android-arm
  60. 22
      package/archlinux/PKGBUILD-android-x86
  61. 18
      package/archlinux/PKGBUILD-clang
  62. 19
      package/archlinux/PKGBUILD-clang-libc++
  63. 22
      package/archlinux/PKGBUILD-emscripten
  64. 14
      package/archlinux/PKGBUILD-es2
  65. 17
      package/archlinux/PKGBUILD-es2desktop
  66. 14
      package/archlinux/PKGBUILD-es3
  67. 17
      package/archlinux/PKGBUILD-es3desktop
  68. 19
      package/archlinux/PKGBUILD-gcc47
  69. 18
      package/archlinux/PKGBUILD-mingw-w64
  70. 26
      package/archlinux/PKGBUILD-nacl-glibc
  71. 26
      package/archlinux/PKGBUILD-nacl-newlib
  72. 24
      package/archlinux/PKGBUILD-release
  73. 1
      package/archlinux/magnum-git/.gitignore
  74. 28
      package/archlinux/magnum-git/PKGBUILD
  75. 158
      package/ci/jenkins-clang-analyzer.xml
  76. 103
      package/ci/jenkins-clang-sanitizer-gltests.xml
  77. 176
      package/ci/jenkins-clang-sanitizer.xml
  78. 2
      package/ci/jenkins-mingw-w64.xml
  79. 4
      package/ci/jenkins.xml
  80. 8
      package/debian/control
  81. 2
      package/debian/copyright
  82. 1
      package/debian/rules
  83. 39
      package/gentoo/dev-libs/magnum/magnum-9999.ebuild
  84. 2
      src/CMakeLists.txt
  85. 233
      src/Magnum/AbstractFramebuffer.cpp
  86. 211
      src/Magnum/AbstractFramebuffer.h
  87. 2
      src/Magnum/AbstractImage.cpp
  88. 2
      src/Magnum/AbstractImage.h
  89. 2
      src/Magnum/AbstractObject.cpp
  90. 4
      src/Magnum/AbstractObject.h
  91. 2
      src/Magnum/AbstractQuery.cpp
  92. 17
      src/Magnum/AbstractQuery.h
  93. 6
      src/Magnum/AbstractResourceLoader.h
  94. 317
      src/Magnum/AbstractShaderProgram.cpp
  95. 800
      src/Magnum/AbstractShaderProgram.h
  96. 505
      src/Magnum/AbstractTexture.cpp
  97. 238
      src/Magnum/AbstractTexture.h
  98. 8
      src/Magnum/Array.h
  99. 329
      src/Magnum/Attribute.cpp
  100. 657
      src/Magnum/Attribute.h
  101. Some files were not shown because too many files have changed in this diff Show More

16
CMakeLists.txt

@ -1,7 +1,7 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
@ -23,7 +23,7 @@
# DEALINGS IN THE SOFTWARE.
#
cmake_minimum_required(VERSION 2.8.8)
cmake_minimum_required(VERSION 2.8.9)
project(Magnum)
# Find Corrade first so we can check on the target
@ -36,8 +36,6 @@ option(TARGET_GLES "Build for OpenGL ES instead of desktop OpenGL" OFF)
cmake_dependent_option(TARGET_GLES2 "Build for OpenGL ES 2" ON "TARGET_GLES" OFF)
cmake_dependent_option(TARGET_DESKTOP_GLES "Build for OpenGL ES on desktop" OFF "TARGET_GLES" OFF)
option(WITH_FIND_MODULE "Install FindMagnum.cmake module into CMake's module dir (might require admin privileges)" OFF)
# Parts of the library
option(WITH_AUDIO "Build Audio library" OFF)
option(WITH_DEBUGTOOLS "Build DebugTools library" ON)
@ -72,7 +70,7 @@ elseif(CORRADE_TARGET_APPLE)
elseif(CORRADE_TARGET_UNIX)
option(WITH_GLXAPPLICATION "Build GlxApplication library" OFF)
cmake_dependent_option(WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON)
cmake_dependent_option(WITH_XEGLAPPLICATION "Build XEglApplication library" OFF "TARGET_GLES" OFF)
option(WITH_XEGLAPPLICATION "Build XEglApplication library" OFF)
option(WITH_GLXCONTEXT "Build GlxContext library" OFF)
# Windows-specific application libraries
@ -112,7 +110,8 @@ if(BUILD_DEPRECATED)
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_STATIC_PIC "Build static libraries and plugins with position-independent code" OFF)
option(BUILD_PLUGINS_STATIC "Build static plugins (default are dynamic)" OFF)
option(BUILD_TESTS "Build unit tests." OFF)
cmake_dependent_option(BUILD_GL_TESTS "Build unit tests for OpenGL code." OFF "BUILD_TESTS" OFF)
if(BUILD_TESTS)
@ -135,6 +134,7 @@ endif()
# meaningless on Emscripten and too inconvenient on Android
if(CORRADE_TARGET_NACL_NEWLIB OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
set(BUILD_STATIC ON)
set(BUILD_PLUGINS_STATIC ON)
endif()
if(BUILD_STATIC)
@ -182,11 +182,11 @@ else()
endif()
# Installation paths
include(CorradeLibSuffix)
include(${CORRADE_LIB_SUFFIX_MODULE})
set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(MAGNUM_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/magnum)
set(MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR ${CMAKE_ROOT}/Modules)
set(MAGNUM_CMAKE_MODULE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/cmake/Magnum)
set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum)
set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumExternal)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumPlugins)

2
CONTRIBUTING.md

@ -44,7 +44,7 @@ Code contribution
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Copyright © YEAR YOUR_NAME <your@mail.com>

2
COPYING

@ -1,4 +1,4 @@
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a

16
CREDITS.md

@ -1,9 +1,15 @@
Third-party components
----------------------
* **flextGL** extension loader generator -- https://github.com/ginkgo/flextGL,
Copyright © 2011 Thomas Weber, licensed under
[MIT license](https://raw.githubusercontent.com/ginkgo/flextGL/master/COPYING)
Not mentioning OpenGL API and platform-specific toolkits.
* Magnum internally uses code generated using **flextGL** extension loader
generator -- https://github.com/ginkgo/flextGL. Copyright © 2011 Thomas
Weber, licensed under [MIT license](https://raw.githubusercontent.com/ginkgo/flextGL/master/COPYING)
* The `Platform::GlutApplication` class uses **freeGLUT** library --
http://freeglut.sourceforge.net/, licensed under MIT license.
* The `Platform::Sdl2Application` class uses **SDL2** library --
https://www.libsdl.org/, licensed under [ZLIB license](http://www.gzip.org/zlib/zlib_license.html)
Contributors to Magnum library
------------------------------
@ -21,5 +27,9 @@ Contributors to Magnum library
Debian package
* Olga Turanksaya ([@olga-python](https://github.com/olga-python)) -- Gentoo
ebuild
* [@wivlaro](https://github.com/wivlaro) -- numerous bug reports, Mac OS X
fixes, feature improvements
* Squareys ([@Squareys](https://github.com/Squareys)) -- bug reports,
documentation improvements
Big thanks to everyone involved!

15
Doxyfile

@ -233,13 +233,13 @@ TAB_SIZE = 8
# newlines.
ALIASES = \
"debugoperator{1}=@relates \1\n@brief Debug output operator @xrefitem debugoperators \"Debug output operator\" \"Debug output operators for custom types\" Allows printing @ref \1 with @ref Corrade::Utility::Debug and friends." \
"debugoperator{1}=@relatesalso \1\n@brief Debug output operator @xrefitem debugoperators \"Debug output operator\" \"Debug output operators for custom types\" Allows printing @ref \1 with @ref Corrade::Utility::Debug and friends." \
"debugoperatorenum{1}=\n@brief Debug output operator @xrefitem debugoperators \"Debug output operator\" \"Debug output operators for custom types\" Allows printing @ref \1 with @ref Corrade::Utility::Debug and friends." \
"debugoperatorclassenum{2}=@relates \1\n@brief Debug output operator @xrefitem debugoperators \"Debug output operator\" \"Debug output operators for custom types\" Allows printing @ref \2 with @ref Corrade::Utility::Debug and friends." \
"debugoperatorclassenum{2}=@relatesalso \1\n@brief Debug output operator @xrefitem debugoperators \"Debug output operator\" \"Debug output operators for custom types\" Allows printing @ref \2 with @ref Corrade::Utility::Debug and friends." \
"configurationvalueref{1}=@see @ref configurationvalues \"Corrade::Utility::ConfigurationValue<\1>\"" \
"configurationvalue{1}=@brief %Configuration value parser and writer @xrefitem configurationvalues \"Configuration value parser and writer\" \"Configuration value parsers and writers for custom types\" Allows parsing and writing \1 from and to Corrade::Utility::Configuration." \
"collisionoccurenceoperator{2}=@relates \1\n@brief %Collision occurence of %\1 and %\2\n@see \2::operator%(const \1&) const" \
"collisionoperator{2}=@relates \1\n@brief %Collision of %\1 and %\2\n@see \2::operator/(const \1&) const" \
"configurationvalue{1}=@brief Configuration value parser and writer @xrefitem configurationvalues \"Configuration value parser and writer\" \"Configuration value parsers and writers for custom types\" Allows parsing and writing \1 from and to Corrade::Utility::Configuration." \
"collisionoccurenceoperator{2}=@relatesalso \1\n@brief Collision occurence of \1 and \2\n@see \2::operator%(const \1&) const" \
"collisionoperator{2}=@relatesalso \1\n@brief Collision of \1 and \2\n@see \2::operator/(const \1&) const" \
"todoc=@xrefitem todoc \"Documentation todo\" \"Documentation-related todo list\"" \
"fn_gl{1}=<a href=\"http://www.opengl.org/sdk/docs/man4/xhtml/gl\1.xml\">gl\1()</a>" \
"fn_gl2{2}=<a href=\"http://www.opengl.org/sdk/docs/man4/xhtml/gl\2.xml\">gl\1()</a>" \
@ -342,7 +342,7 @@ MARKDOWN_SUPPORT = YES
# or globally by setting AUTOLINK_SUPPORT to NO.
# The default value is: YES.
AUTOLINK_SUPPORT = YES
AUTOLINK_SUPPORT = NO
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
# to include (a tag file for) the STL sources as input, then you should set this
@ -2000,7 +2000,8 @@ INCLUDE_FILE_PATTERNS =
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED = DOXYGEN_GENERATING_OUTPUT \
MAGNUM_BUILD_DEPRECATED CORRADE_DEPRECATED(message)= \
CORRADE_DEPRECATED(message)= CORRADE_DEPRECATED_ENUM(message)= \
MAGNUM_BUILD_DEPRECATED \
MAGNUM_EXPORT= \
MAGNUM_AUDIO_EXPORT= \
MAGNUM_DEBUGTOOLS_EXPORT= \

12
README.md

@ -1,6 +1,7 @@
Magnum is 2D/3D graphics engine written in C++11 and modern OpenGL. Its goal is
to simplify low-level graphics development and interaction with OpenGL using
recent C++11 features and to abstract away platform-specific issues.
Magnum is 2D/3D graphics engine written in C++11/C++14 and modern OpenGL. Its
goal is to simplify low-level graphics development and interaction with OpenGL
using recent C++11/C++14 features and to abstract away platform-specific
issues.
DESIGN GOALS
============
@ -89,7 +90,7 @@ Minimal dependencies
>= 3.1. On Windows you can use **MinGW**. GCC 4.5, 4.4 and **MSVC** 2013
support involves some ugly workarounds and thus is available only in
`compatibility` branch.
* **CMake** >= 2.8.8
* **CMake** >= 2.8.9
* **Corrade** - Plugin management and utility library. You can get it at
https://github.com/mosra/corrade.
@ -161,6 +162,8 @@ separate repositories.
* **libRocket integration** -- integrates Magnum as rendering backend into
[libRocket](https://github.com/libRocket/libRocket) GUI library:
https://github.com/miguelmartin75/Magnum-libRocket
* **Magnum Inspector** -- Gtk-based inspector window running alongside Magnum
https://github.com/wivlaro/magnum-inspector
CONTACT
=======
@ -170,6 +173,7 @@ idea? Feel free to visit my website or contact me at:
* Website -- http://mosra.cz/blog/magnum.php
* GitHub -- https://github.com/mosra/magnum
* IRC -- join `#magnum-engine` channel on freenode
* Google Groups -- https://groups.google.com/forum/#!forum/magnum-engine
* Twitter -- https://twitter.com/czmosra
* E-mail -- mosra@centrum.cz

2
doc/best-practices.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a

101
doc/building.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -26,7 +26,7 @@
namespace Magnum {
/** @page building Downloading and building
@brief Guide how to download and build %Magnum on different platforms.
@brief Guide how to download and build Magnum on different platforms.
@tableofcontents
@ -37,7 +37,7 @@ Minimal set of tools and libraries required for building is:
>= 3.1. On Windows you can use **MinGW**. GCC 4.5, 4.4 and **MSVC** 2013
support involves some ugly workarounds and thus is available only in
`compatibility` branch.
- **CMake** >= 2.8.8
- **CMake** >= 2.8.9
- **Corrade** - Plugin management and utility library. See
@ref building-corrade "Corrade download and installation guide" for more
information.
@ -137,26 +137,24 @@ Installation to given prefix can be done from within QtCreator by adding new
The libraries are build as shared by default. If you are developing for
platform which doesn't support shared libraries or if you just want to link
them statically, enable `BUILD_STATIC` to build the libraries as static. If you
plan to use them with shared libraries later, enable also position-independent
code with `BUILD_STATIC_PIC`. If you want to build with another compiler (e.g.
Clang), pass `-DCMAKE_CXX_COMPILER=clang++` to CMake.
them statically, enable `BUILD_STATIC` to build the libraries as static.
Building of static plugins is controlled with separate `BUILD_PLUGINS_STATIC`
variable. If you plan to use the static libraries and plugins with shared
libraries later, enable also position-independent code with `BUILD_STATIC_PIC`.
If you want to build with another compiler (e.g. Clang), pass
`-DCMAKE_CXX_COMPILER=clang++` to CMake.
Libraries and static plugins built in `Debug` configuration (e.g. with
`CMAKE_BUILD_TYPE` set to `Debug`) have `-d` suffix to make it possible to have
both debug and release libraries installed alongside each other. *Dynamic*
plugins in `Debug` configuration are installed to `magnum-d` subdirectory
instead of `magnum`. Headers and other files are the same for both. The library
and plugin distinction is handled semi-automatically when using %Magnum in
and plugin distinction is handled semi-automatically when using Magnum in
depending projects, see @ref cmake for more information.
%Magnum by default does not install `FindMagnum.cmake`, as you should bundle
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
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.
@ -182,7 +180,7 @@ parameters you can specify which parts will be built and which not:
- `WITH_AUDIO` - @ref Audio library. Depends on **OpenAL** library, not built
by default.
- `WITH_DEBUGTOOLS` - @ref DebugTools library. Enables also building of
%MeshTools, %Primitives, %SceneGraph, %Shaders and %Shapes libraries.
MeshTools, Primitives, SceneGraph, Shaders and Shapes libraries.
- `WITH_MESHTOOLS` - @ref MeshTools library. Enabled automatically if
`WITH_DEBUGTOOLS` is enabled.
- `WITH_PRIMITIVES` - @ref Primitives library. Enabled automatically if
@ -191,9 +189,9 @@ parameters you can specify which parts will be built and which not:
`WITH_DEBUGTOOLS` or `WITH_SHAPES` is enabled.
- `WITH_SHADERS` - @ref Shaders library. Enabled automatically if
`WITH_DEBUGTOOLS` is enabled.
- `WITH_SHAPES` - @ref Shapes library. Enables also building of %SceneGraph
- `WITH_SHAPES` - @ref Shapes library. Enables also building of SceneGraph
library. Enabled automatically if `WITH_DEBUGTOOLS` is enabled.
- `WITH_TEXT` - @ref Text library. Enables also building of %TextureTools
- `WITH_TEXT` - @ref Text library. Enables also building of TextureTools
library.
- `WITH_TEXTURETOOLS` - @ref TextureTools library. Enabled automatically if
`WITH_TEXT` or `WITH_DISTANCEFIELDCONVERTER` is enabled.
@ -229,12 +227,12 @@ on Linux, Mac OS X and Windows, also disabled by default:
information about the engine and OpenGL capabilities.
- `WITH_DISTANCEFIELDCONVERTER` - @ref magnum-distancefieldconverter "magnum-distancefieldconverter"
executable for converting black&white images to distance field textures.
Enables also building of %TextureTools library.
Enables also building of TextureTools library.
- `WITH_FONTCONVERTER` - @ref magnum-fontconverter "magnum-fontconverter"
executable for converting fonts to raster ones. Enables also building of
%Text library.
Text library.
%Magnum also contains a set of dependency-less plugins for importing essential
Magnum also contains a set of dependency-less plugins for importing essential
file formats. Additional plugins are provided in separate plugin repository,
see @ref building-plugins for more information. None of the plugins is built by
default.
@ -285,9 +283,9 @@ be build by running
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 %Corrade with generated documentation is placed in
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`
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.
@ -310,10 +308,7 @@ build. The package is also in AUR under the same name.
There are also a few development PKGBUILDs in `package/archlinux`, which allow
you to build and install the package directly from source tree without
downloading anything. The native PKGBUILDs also contain `check()` function
which will run all unit tests before packaging. You need to build them from
project root:
makepkg -p package/archlinux/<file>
which will run all unit tests before packaging.
@subsection building-packages-gentoo Gentoo ebuilds
@ -336,7 +331,7 @@ features, for example), modify the last entry in `debian/rules`.
@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
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.
@ -364,11 +359,13 @@ You will need MinGW32 versions of the compiler and all dependent libraries
Then create build directory and run cmake and build command in it. You may need
to modify the `basic-mingw32.cmake` file and `CMAKE_INSTALL_PREFIX` to suit
your distribution filesystem hierarchy.
your distribution filesystem hierarchy and specify path where Corrade is
installed in `CMAKE_PREFIX_PATH`.
mkdir build-win && cd build-win
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../toolchains/archlinux/basic-mingw32.cmake \
-DCMAKE_PREFIX_PATH=/usr/i486-mingw32 \
-DCMAKE_INSTALL_PREFIX=/usr/i486-mingw32
cmake --build .
@ -392,13 +389,15 @@ Then create build directories for x86-32 and x86-64 and run cmake and build
command in them. The toolchains need access to the platform file, so be sure to
properly set **absolute** path to `modules/` directory containing
`Platform/NaCl.cmake`. Also adapt `CMAKE_INSTALL_PREFIX` to the same value as
in `NACL_PREFIX` in toolchain file.
in `NACL_PREFIX` in toolchain file and specify path where Corrade is installed
in `CMAKE_PREFIX_PATH`.
mkdir build-nacl-x86-32 && cd build-nacl-x86-32
cmake .. \
-DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-32.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/usr/nacl \
-DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_NACLAPPLICATION=ON \
-DLIB_SUFFIX=/32
@ -409,6 +408,7 @@ in `NACL_PREFIX` in toolchain file.
-DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-64.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/usr/nacl \
-DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_NACLAPPLICATION=ON
cmake --build .
@ -427,9 +427,9 @@ 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 libraries only to simplify porting and they are generally
slower, thus `BUILD_STATIC` is implicitly enabled.
to path where Emscripten is installed. Default is `/usr/lib/emscripten`.
Emscripten supports dynamic libraries only to simplify porting and they are
generally slower, thus `BUILD_STATIC` is implicitly enabled.
Then create build directory and run cmake and build command in it. The
toolchain needs access to its platform file, so be sure to properly set
@ -441,7 +441,8 @@ Also set `CMAKE_INSTALL_PREFIX` to path contained in `EMSCRIPTEN_TOOLCHAIN_PATH`
-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 \
-DCMAKE_PREFIX_PATH=/usr/lib/emscripten/system \
-DCMAKE_INSTALL_PREFIX=/usr/lib/emscripten/system \
-DWITH_SDL2APPLICATION=ON
cmake --build .
@ -468,7 +469,8 @@ where NDK is installed. Default is `/opt/android-ndk`. Adapt also
Then create build directory and run cmake and build command in it. The
toolchain needs access to its platform file, so be sure to properly set **absolute**
path to `modules/` directory containing `Platform/Android.cmake`. Also set
`CMAKE_INSTALL_PREFIX` to `/usr` subdirectory of `ANDROID_SYSROOT`.
`CMAKE_INSTALL_PREFIX` to `/usr` subdirectory of `ANDROID_SYSROOT` and specify
path where Corrade is installed in `CMAKE_PREFIX_PATH`.
Note that `BUILD_STATIC` is implicitly enabled, because manually loading all
depending shared libraries using JNI would be too inconvenient. Decision
@ -480,6 +482,7 @@ between OpenGL ES 2.0 and ES 3.0 is left up to the user (i.e. you need to set
-DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-ARM.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/opt/android-ndk/platforms/android-19/arch-arm/usr \
-DCMAKE_INSTALL_PREFIX=/opt/android-ndk/platforms/android-19/arch-arm/usr \
-DTARGET_GLES=ON -DTARGET_GLES2=ON
cmake --build .
@ -489,6 +492,7 @@ between OpenGL ES 2.0 and ES 3.0 is left up to the user (i.e. you need to set
-DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-x86.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/opt/android-ndk/platforms/android-19/arch-x86/usr \
-DCMAKE_INSTALL_PREFIX=/opt/android-ndk/platforms/android-19/arch-x86/usr \
-DTARGET_GLES=ON -DTARGET_GLES2=ON
cmake --build .
@ -504,16 +508,18 @@ named `PKGBUILD-android-arm` and `PKGBUILD-android-x86`, see
In `package/ci/` there are `jenkins.xml` and `jenkins-gltests.xml` files
containing job configuration, one for build and non-GL tests and the other for
GL tests only. Setup your Jenkins server, enable the **Git** and **Text-finder**
plugin and download the CLI application from here:
GL tests only. Setup your Jenkins server, enable the **Git** and
**Text-finder** plugin and download the CLI application from here (replace
`localhost:8080` with your server name):
http://your-jenkins-server/cli
http://localhost:8080/cli
Then add new jobs or update existing ones (replace `<command>` with `create-job`
or `update-job`).
Then add new jobs or update existing ones (update path to the `*.jar` file,
replace `localhost:8080` with your server name, replace `update-job` with
`create-job` if the job doesn't exist yet).
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-Compatibility < jenkins.xml
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-Compatibility-GLTests < jenkins-gltests.xml
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-Compatibility < package/ci/jenkins.xml
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-Compatibility-GLTests < package/ci/jenkins-gltests.xml
Build is done using **Ninja** build system and everything possible is enabled,
thus you need also **SDL2**, **GLUT** and **OpenAL** libraries. It expects that
@ -525,15 +531,22 @@ in `axes/hudson.matrix.TextAxis` or via the web interface later.
Magnum-Compatibility-GLTests depend on active X11 session, thus they should be
run from Jenkins instance running on graphical user session.
Clang Analyzer and *Sanitizer checks are also available. They both require **Clang**,
Analyzer job additionally requires **clang-analyzer** tool.
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-ClangAnalyzer < package/ci/jenkins-clang-analyzer.xml
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-ClangSanitizer < package/ci/jenkins-clang-sanitizer.xml
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-ClangSanitizer-GLTests < package/ci/jenkins-clang-sanitizer-gltests.xml
There is also MinGW-w64, Emscripten, NaCl and Android configuration, add or
update them with the commands below. See @ref building-crosscompiling for more
information about setting up the crosscompilers and `toolchains/` submodule.
For Emscripten you need also **Node.js** installed to run the tests.
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-MinGW-w64 < jenkins-mingw-w64.xml
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-Emscripten < jenkins-emscripten.xml
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-NaCl < jenkins-nacl.xml
java -jar jenkins-cli.jar -s http://your-jenkins-server <command> Magnum-Android < jenkins-android.xml
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-MinGW-w64 < package/ci/jenkins-mingw-w64.xml
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-Emscripten < package/ci/jenkins-emscripten.xml
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-NaCl < package/ci/jenkins-nacl.xml
java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-Android < package/ci/jenkins-android.xml
*/
}

73
doc/cmake.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -25,14 +25,14 @@
namespace Magnum {
/** @page cmake Usage with CMake
@brief Guide how to find and use %Magnum with CMake build system
@brief Guide how to find and use Magnum with CMake build system
%Magnum uses CMake build system for both building and integration into your
Magnum uses CMake build system for both building and integration into your
projects. The logic is in module `FindMagnum.cmake` distributed with the engine
in `modules/` directory, you are encouraged to copy it along with
`FindCorrade.cmake` into your project and add path to the files to
`CMAKE_MODULE_PATH`. Otherwise, if CMake won't be able to find this file in
predefined locations, it will error out even if %Magnum might be installed on
predefined locations, it will error out even if Magnum might be installed on
the system. If you plan to use Magnum on OpenGL ES, you may also need
`FindOpenGLES2.cmake` or `FindOpenGLES3.cmake` and in some cases also
`FindEGL.cmake`.
@ -50,17 +50,17 @@ Basic usage is:
find_package(Magnum REQUIRED)
This command tries to find base %Magnum library and then defines these
This command tries to find base Magnum library and then defines these
variables:
- `MAGNUM_FOUND` -- Whether the library was found
- `MAGNUM_LIBRARIES` -- %Magnum library and dependent libraries
- `MAGNUM_LIBRARIES` -- Magnum library and dependent libraries
- `MAGNUM_INCLUDE_DIRS` -- Root include dir and include dirs of dependencies
- `MAGNUM_PLUGINS_DEBUG_DIR` -- Base directory with dynamic plugins for debug
builds, defaults to `magnum-d/` subdirectory of dir where %Magnum library
builds, defaults to `magnum-d/` subdirectory of dir where Magnum library
was found
- `MAGNUM_PLUGINS_RELEASE_DIR` -- Base directory with dynamic plugins for
release builds, defaults to `magnum/` subdirectory of dir where %Magnum
release builds, defaults to `magnum/` subdirectory of dir where Magnum
library was found
- `MAGNUM_PLUGINS_DIR` -- Base directory with dynamic plugins, defaults to
`MAGNUM_PLUGINS_RELEASE_DIR` in release builds and multi-configuration
@ -80,32 +80,31 @@ variables:
dynamic audio importer plugins
However, this command will try to find only the base library, not the optional
components. The base library depends on %Corrade and OpenGL libraries (or
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` -- @ref Audio library
- `%DebugTools` -- @ref DebugTools library (depends on `%MeshTools`,
`%Primitives`, `%SceneGraph`, `%Shaders` and `%Shapes` components)
- `%MeshTools` -- @ref MeshTools library
- `%Primitives` -- @ref Primitives library
- `%SceneGraph` -- @ref SceneGraph library
- `%Shaders` -- @ref Shaders library
- `%Shapes` -- @ref Shapes library (depends on `%SceneGraph` component)
- `%Text` -- @ref Text library (depends on `%TextureTools` component)
- `%TextureTools` -- @ref TextureTools library
- `Audio` -- @ref Audio library
- `DebugTools` -- @ref DebugTools library
- `MeshTools` -- @ref MeshTools library
- `Primitives` -- @ref Primitives library
- `SceneGraph` -- @ref SceneGraph library
- `Shaders` -- @ref Shaders library
- `Shapes` -- @ref Shapes library
- `Text` -- @ref Text library
- `TextureTools` -- @ref TextureTools library
Platform namespace is split into more components:
- `%GlutApplication` -- @ref Platform::GlutApplication "GlutApplication"
- `%GlxApplication` -- @ref Platform::GlxApplication "GlxApplication"
- `%NaClApplication` -- @ref Platform::NaClApplication "NaClApplication"
- `%Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application"
- `%XEglApplication` -- @ref Platform::XEglApplication "XEglApplication"
- `%WindowlessCglApplication` -- @ref Platform::WindowlessCglApplication "WindowlessCglApplication"
- `%WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication"
- `%WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
- `%WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication"
- `GlutApplication` -- @ref Platform::GlutApplication "GlutApplication"
- `GlxApplication` -- @ref Platform::GlxApplication "GlxApplication"
- `NaClApplication` -- @ref Platform::NaClApplication "NaClApplication"
- `Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application"
- `XEglApplication` -- @ref Platform::XEglApplication "XEglApplication"
- `WindowlessCglApplication` -- @ref Platform::WindowlessCglApplication "WindowlessCglApplication"
- `WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication"
- `WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
- `WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication"
For manual context creation (without application wrappers) there are also
platform-specific context libraries (see @ref platform-custom for more
@ -126,17 +125,14 @@ loads them dynamically. However, if they are built as static (see
executable and then explicitly imported. Also if you are going to use them as
dependencies, you need to find the dependency and then link to it.
- `MagnumFont` -- @ref Text::MagnumFont "MagnumFont" plugin (depends on
`%Text` component and `TgaImporter` plugin)
- `MagnumFont` -- @ref Text::MagnumFont "MagnumFont" plugin
- `MagnumFontConverter` -- @ref Text::MagnumFontConverter "MagnumFontConverter"
plugin (depends on `%Text` component and `%TgaImageConverter` plugin)
- `ObjImporter` -- @ref Trade::ObjImporter "ObjImporter" plugin (depends on
`%MeshTools` component)
plugin
- `ObjImporter` -- @ref Trade::ObjImporter "ObjImporter" plugin
- `TgaImageConverter` -- @ref Trade::TgaImageConverter "TgaImageConverter"
plugin
- `TgaImporter` -- @ref Trade::TgaImporter "TgaImporter" plugin
- `WavAudioImporter` -- @ref Audio::WavImporter "WavAudioImporter" plugin
(depends on `%Audio` component)
Note that [each namespace](namespaces.html), all @ref Platform libraries and
each plugin class contain more detailed information about dependencies,
@ -172,7 +168,7 @@ You can make use of @ref corrade-cmake "CORRADE_IS_DEBUG_BUILD" preprocessor
variable along with `MAGNUM_PLUGINS_*_DEBUG_DIR` / `MAGNUM_PLUGINS_*_RELEASE_DIR`
variables to decide in preprocessing step.
Features of found %Magnum library are exposed in these CMake variables, they
Features of found Magnum library are exposed in these CMake variables, they
are also available as preprocessor variables if including
@ref Magnum/Magnum.h "Magnum/Magnum.h":
@ -187,12 +183,7 @@ are also available as preprocessor variables if including
emulation on desktop OpenGL
- `MAGNUM_TARGET_WEBGL` --- Defined if compiled for WebGL
If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable also
contains path directly to Magnum directory (i.e. for includes without `Magnum/`
prefix) and `MAGNUM_PLUGINS_INCLUDE_DIR` contains include dir for plugins (i.e.
for includes without `MagnumPlugins/` prefix).
%Corrade library provides also its own set of CMake macros and variables, see
Corrade library provides also its own set of CMake macros and variables, see
@ref corrade-cmake "its documentation" for more information.
@ref cmake-plugins "Plugins repository" and @ref cmake-integration "Integration library"
have also their own CMake modules.

10
doc/coding-style.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -54,11 +54,11 @@ have `*.hpp` extension (hinting that they are something between `*.h` and
@subsubsection coding-style-cpp-types Builtin types
Use %Magnum's own type aliases for public API (e.g. @ref UnsignedInt, see
Use Magnum's own type aliases for public API (e.g. @ref UnsignedInt, see
@ref types for more information), but use specific types when interacting with
third party libraries and OpenGL (e.g. `GLuint`) and rely only on implicit
conversions when converting between them. This helps avoiding sign, truncation
and other issues, e.g. `%Math::%Vector2<GLsizei>` will implicitly convert to
and other issues, e.g. `Math::Vector2<GLsizei>` will implicitly convert to
@ref Vector2i if and only if @ref Int is the same type as `GLsizei`.
@subsubsection coding-style-cpp-naming Naming
@ -100,7 +100,7 @@ void setPolygonMode(PolygonMode mode);
Additionally to @c \@todoc, @c \@debugoperator, @c \@debugoperatorenum,
@c \@debugoperatorclassenum, @c \@configurationvalue and
@c \@configurationvalueref (same as in %Corrade), these are defined:
@c \@configurationvalueref (same as in Corrade), these are defined:
@subsubsection coding-style-documentation-commands-collisionoperator Shape collision operators
@ -196,7 +196,7 @@ All classes and functions using those commands are cross-referenced in page
In detailed documentation the text should be always first, the blocks are then
ordered by their importance. Various @c \@note, @c \@attention and @c \@warning
blocks to highlight some information are always first, then @c \@see block with
links to related stuff, where related %Magnum functions are first and links to
links to related stuff, where related Magnum functions are first and links to
related GL API last, then various support information such as
@c \@requires_glXX, @c \@requires_es_extension etc. (first desktop GL, then ES,
then WebGL), after that @c \@deprecated_gl and @c \@deprecated information and

12
doc/compilation-speedup.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -30,7 +30,7 @@ namespace Magnum {
@section compilation-forward-declarations Forward declarations instead of includes
Essential thing when speeding up compilation is reducing number of `#``include`
directives in both headers and source files. %Magnum is strictly applying this
directives in both headers and source files. Magnum is strictly applying this
policy in all header files, so all types which are not directly used in the
header have only forward declarations.
@ -55,19 +55,19 @@ available, each namespace has its own:
@section compilation-speedup-templates Templates
Many things in %Magnum are templated to allow handling of various types and
Many things in Magnum are templated to allow handling of various types and
sizes of data, for example whole scene graph can operate either with @ref Float
or @ref Double data type. However, having templated classes and function
usually means that the compiler compiles the whole templated code again in each
compilation unit (i.e. source file). In linking stage of the application or
library the duplicates are just thrown out, which is a waste of compilation
time. A few techniques are employed in %Magnum to avoid this.
time. A few techniques are employed in Magnum to avoid this.
@subsection compilation-speedup-hpp Template headers and implementation files
When templated code is too large, it is not stored in header file, but in
so-called *template implementation file*. Generally, all header files in
%Magnum have `*.h` extension and all source files have `*.cpp` extension.
Magnum have `*.h` extension and all source files have `*.cpp` extension.
Template implementation files have `*.hpp` extension, hinting that they are
something between `*.h` and `*.cpp` files.
@ -111,7 +111,7 @@ precious compilation time.
Keyword `extern template` is a new thing in C++11, attempting to solve
compilation time problems related to templated code. However, on some compilers
it causes conflicting symbol errors when used on whole classes, thus in %Magnum
it causes conflicting symbol errors when used on whole classes, thus in Magnum
it's used only for specific functions.
This is completely transparent to end user, so no special care is needed.

18
doc/debug-tools.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -39,16 +39,16 @@ information about building and usage with CMake.
@section debug-tools-renderers Debug renderers
%Debug renderers provide a way to visualize objects and object features in
Debug renderers provide a way to visualize objects and object features in
@ref scenegraph "scene graph" without the need to mess around with meshes and
shaders. They are implemented as object features, so you can attach any number
of them to any object.
Basic usage involves instancing DebugTools::ResourceManager and keeping it for
for the whole lifetime of debug renderers. Next you need some SceneGraph::DrawableGroup
instance. You can use the same group as for the rest of your scene, but
preferrably use dedicated one for debug renderers, so you can easily enable or
disable debug rendering.
Basic usage involves instancing @ref DebugTools::ResourceManager and keeping it
for the whole lifetime of debug renderers. Next you need some
@ref SceneGraph::DrawableGroup instance. You can use the same group as for the
rest of your scene, but preferrably use dedicated one for debug renderers, so
you can easily enable or disable debug rendering.
Next step is to create configuration for your debug renderers and create
particular debug renderer. The configuration is managed using the resource
@ -58,7 +58,7 @@ same options with more renderers. If no options are specified or resource with
given key doesn't exist, default fallback is used.
Example usage: visualizing object position, rotation and scaling using
DebugTools::ObjectRenderer:
@link DebugTools::ObjectRenderer @endlink:
@code
// Global instance of debug resource manager, drawable group for the renderers
DebugTools::ResourceManager manager;
@ -75,7 +75,7 @@ Object3D* object;
new DebugTools::ObjectRenderer2D(*object, "my", debugDrawables);
@endcode
See DebugTools::ObjectRenderer and DebugTools::ShapeRenderer for more
See @ref DebugTools::ObjectRenderer and @ref DebugTools::ShapeRenderer for more
information.
- Previous page: @ref shapes

3
doc/features.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -32,6 +32,7 @@ namespace Magnum {
- @subpage matrix-vector -- @copybrief matrix-vector
- @subpage transformations -- @copybrief transformations
- @subpage plugins -- @copybrief plugins
- @subpage shaders -- @copybrief shaders
- @subpage scenegraph -- @copybrief scenegraph
- @subpage shapes -- @copybrief shapes
- @subpage debug-tools -- @copybrief debug-tools

1
doc/generated/.gitattributes vendored

@ -0,0 +1 @@
vector.svg -diff

67
doc/generated/CMakeLists.txt

@ -0,0 +1,67 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
cmake_minimum_required(VERSION 2.8.9)
project(MyApplication)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../modules/")
find_package(Magnum REQUIRED
MeshTools
Primitives
Shaders
Sdl2Application)
if(CORRADE_TARGET_APPLE)
find_package(Magnum REQUIRED WindowlessCglApplication)
elseif(CORRADE_TARGET_UNIX)
find_package(Magnum REQUIRED WindowlessGlxApplication)
elseif(CORRADE_TARGET_WINDOWS)
find_package(Magnum REQUIRED WindowlessWglApplication)
else()
message(FATAL_ERROR "No windowless application available on this platform")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CORRADE_CXX_FLAGS}")
include_directories(${MAGNUM_INCLUDE_DIRS}
${MAGNUM_APPLICATION_INCLUDE_DIRS}
${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS})
add_executable(hello hello.cpp)
target_link_libraries(hello
${MAGNUM_LIBRARIES}
${MAGNUM_APPLICATION_LIBRARIES})
add_executable(shaders shaders.cpp)
target_link_libraries(shaders
${MAGNUM_LIBRARIES}
${MAGNUM_MESHTOOLS_LIBRARIES}
${MAGNUM_PRIMITIVES_LIBRARIES}
${MAGNUM_SHADERS_LIBRARIES}
${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES})

47
doc/generated/README.md

@ -0,0 +1,47 @@
Source files for images in Magnum documentation
-----------------------------------------------
Compile and install Magnum with `Sdl2Application`, windowless application for
your platform and `magnum-distancefieldconverter` utility and any `PngImporter`
and `PngImageConverter` plugins from Magnum Plugins.
Create build dir, point CMake to this directory and compile the executables:
mkdir build-doc
cd build-doc
cmake ../doc/generated
cmake --build .
### "Getting started" image
Displayed by the `hello` executable. Run the app and take screenshot using
KSnapshot (including decorations, 880x707). Similarly for the gray version. The
resulting files should be resized to half the size and without alpha channel
using imagemagick:
```bash
mogrify -flatten -background '#ffffff' -resize 440 getting-started.png
mogrify -flatten -background '#ffffff' -resize 440 getting-started-blue.png
```
The output printed by the application can be used to update the example output
in `doc/getting-started.dox`.
### Shader images
Generated by the `shaders` executable. Must be run in this directory, the
output is put into `doc/` directory. The executable requires two textures:
- `vector.png`, generated as full-page PNG output at 90 DPI from `vector.svg`,
converted to pure grayscale using imagemagick:
```bash
mogrify -flatten -background '#ffffff' -format grayscale vector.png
```
- `vector-distancefield.png`, generated as full-page PNG output at 360 DPI
(1024x1024) and then processed through `magnum-distancefieldconverter`
```bash
magnum-distancefieldconverter --importer PngImporter --converter PngImageConverter --output-size "64 64" --radius 16 vector-src.png vector-distancefield.png
```

20
src/Magnum/Shaders/magnumShadersResourceImport.hpp → doc/generated/configure.h.cmake

@ -1,9 +1,7 @@
#ifndef Magnum_Shaders_magnumShadersResourceImport_hpp
#define Magnum_Shaders_magnumShadersResourceImport_hpp
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -25,16 +23,10 @@
DEALINGS IN THE SOFTWARE.
*/
#include "Magnum/configure.h"
#ifdef MAGNUM_BUILD_STATIC
#ifdef MAGNUM_BUILD_DEPRECATED
#include "Magnum/Shaders/resourceImport.hpp"
#else
#error use Magnum/Shaders/resourceImport.hpp instead
#endif
#ifdef CORRADE_IS_DEBUG_BUILD
#define MAGNUM_PLUGINS_IMAGECONVERTER_DIR "${MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR}"
#define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}"
#else
#error this header is available only in static build
#endif
#define MAGNUM_PLUGINS_IMAGECONVERTER_DIR "${MAGNUM_PLUGINS_IMAGECONVERTER_DIR}"
#define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DIR}"
#endif

54
doc/generated/hello.cpp

@ -0,0 +1,54 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <Magnum/Color.h>
#include <Magnum/DefaultFramebuffer.h>
#include <Magnum/Context.h>
#include <Magnum/Renderer.h>
#include <Magnum/Version.h>
#include <Magnum/Platform/Sdl2Application.h>
using namespace Magnum;
class Hello: public Platform::Application {
public:
explicit Hello(const Arguments& arguments);
private:
void drawEvent() override;
};
Hello::Hello(const Arguments& arguments): Platform::Application(arguments) {
Renderer::setClearColor(Color3::fromHSV(216.0_degf, 0.85f, 1.0f));
Debug() << "Hello! This application is running on" << Context::current()->version()
<< "using" << Context::current()->rendererString();
}
void Hello::drawEvent() {
defaultFramebuffer.clear(FramebufferClear::Color);
swapBuffers();
}
MAGNUM_APPLICATION_MAIN(Hello)

301
doc/generated/shaders.cpp

@ -0,0 +1,301 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Directory.h>
#ifdef CORRADE_TARGET_APPLE
#include <Magnum/Platform/WindowlessCglApplication.h>
#elif defined(CORRADE_TARGET_UNIX)
#include <Magnum/Platform/WindowlessGlxApplication.h>
#elif defined(CORRADE_TARGET_WINDOWS)
#include <Magnum/Platform/WindowlessWglApplication.h>
#else
#error No windowless application available on this platform
#endif
#include <Magnum/Buffer.h>
#include <Magnum/Framebuffer.h>
#include <Magnum/Image.h>
#include <Magnum/Mesh.h>
#include <Magnum/Renderbuffer.h>
#include <Magnum/RenderbufferFormat.h>
#include <Magnum/MeshTools/Compile.h>
#include <Magnum/MeshTools/Interleave.h>
#include <Magnum/Primitives/Square.h>
#include <Magnum/Primitives/Circle.h>
#include <Magnum/Primitives/Icosphere.h>
#include <Magnum/Primitives/UVSphere.h>
#include <Magnum/Shaders/Flat.h>
#include <Magnum/Shaders/MeshVisualizer.h>
#include <Magnum/Shaders/Phong.h>
#include <Magnum/Shaders/VertexColor.h>
#include <Magnum/Shaders/Vector.h>
#include <Magnum/Shaders/DistanceFieldVector.h>
#include <Magnum/Trade/AbstractImageConverter.h>
#include <Magnum/Trade/ImageData.h>
#include <Magnum/Trade/MeshData2D.h>
#include <Magnum/Trade/MeshData3D.h>
#include <Magnum/Trade/AbstractImporter.h>
#include <Magnum/Renderer.h>
#include <Magnum/ColorFormat.h>
#include <Magnum/Texture.h>
#include <Magnum/TextureFormat.h>
#include "configure.h"
using namespace Magnum;
struct ShaderVisualizer: Platform::WindowlessApplication {
using Platform::WindowlessApplication::WindowlessApplication;
int exec() override;
std::string phong();
std::string meshVisualizer();
std::string flat();
std::string vertexColor();
std::string vector();
std::string distanceFieldVector();
std::unique_ptr<Trade::AbstractImporter> _importer;
};
namespace {
constexpr const Vector2i ImageSize{256};
}
int ShaderVisualizer::exec() {
PluginManager::Manager<Trade::AbstractImageConverter> converterManager{MAGNUM_PLUGINS_IMAGECONVERTER_DIR};
std::unique_ptr<Trade::AbstractImageConverter> converter = converterManager.loadAndInstantiate("PngImageConverter");
if(!converter) {
Error() << "Cannot load image converter plugin";
std::exit(1);
}
PluginManager::Manager<Trade::AbstractImporter> importerManager{MAGNUM_PLUGINS_IMPORTER_DIR};
_importer = importerManager.loadAndInstantiate("PngImporter");
if(!_importer) {
Error() << "Cannot load image importer plugin";
std::exit(1);
}
Renderbuffer multisampleColor, multisampleDepth;
multisampleColor.setStorageMultisample(16, RenderbufferFormat::RGBA8, ImageSize);
multisampleDepth.setStorageMultisample(16, RenderbufferFormat::DepthComponent24, ImageSize);
Framebuffer multisampleFramebuffer{{{}, ImageSize}};
multisampleFramebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, multisampleColor)
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, multisampleDepth)
.bind();
CORRADE_INTERNAL_ASSERT(multisampleFramebuffer.checkStatus(FramebufferTarget::Draw) == Framebuffer::Status::Complete);
Renderbuffer color;
color.setStorage(RenderbufferFormat::RGBA8, ImageSize);
Framebuffer framebuffer{{{}, ImageSize}};
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color);
Renderer::enable(Renderer::Feature::DepthTest);
for(auto fun: {&ShaderVisualizer::phong,
&ShaderVisualizer::meshVisualizer,
&ShaderVisualizer::flat,
&ShaderVisualizer::vertexColor,
&ShaderVisualizer::vector,
&ShaderVisualizer::distanceFieldVector}) {
multisampleFramebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth);
std::string filename = (this->*fun)();
AbstractFramebuffer::blit(multisampleFramebuffer, framebuffer, framebuffer.viewport(), FramebufferBlit::Color);
Image2D result = framebuffer.read(framebuffer.viewport(), {ColorFormat::RGBA, ColorType::UnsignedByte});
converter->exportToFile(result, Utility::Directory::join("../", "shaders-" + filename));
}
_importer.reset();
return 0;
}
namespace {
const auto Projection = Matrix4::perspectiveProjection(35.0_degf, 1.0f, 0.001f, 100.0f);
const auto Transformation = Matrix4::translation(Vector3::zAxis(-5.0f));
const auto BaseColor = Color3::fromHSV(216.0_degf, 0.85f, 1.0f);
const auto OutlineColor = Color3{0.95f};
}
std::string ShaderVisualizer::phong() {
std::unique_ptr<Buffer> vertices, indices;
Mesh mesh;
std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::UVSphere::solid(16, 32), BufferUsage::StaticDraw);
Shaders::Phong shader;
shader.setAmbientColor(Color3(0.025f))
.setDiffuseColor(BaseColor)
.setShininess(200.0f)
.setLightPosition({5.0f, 5.0f, 7.0f})
.setProjectionMatrix(Projection)
.setTransformationMatrix(Transformation)
.setNormalMatrix(Transformation.rotationScaling());
mesh.draw(shader);
return "phong.png";
}
std::string ShaderVisualizer::meshVisualizer() {
std::unique_ptr<Buffer> vertices, indices;
Mesh mesh;
std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::Icosphere::solid(1), BufferUsage::StaticDraw);
const Matrix4 projection = Projection*Transformation*
Matrix4::rotationZ(13.7_degf)*
Matrix4::rotationX(-12.6_degf);
Shaders::MeshVisualizer shader{Shaders::MeshVisualizer::Flag::Wireframe};
shader.setColor(BaseColor)
.setWireframeColor(OutlineColor)
.setViewportSize(Vector2{ImageSize})
.setTransformationProjectionMatrix(projection);
mesh.draw(shader);
return "meshvisualizer.png";
}
std::string ShaderVisualizer::flat() {
std::unique_ptr<Buffer> vertices, indices;
Mesh mesh;
std::tie(mesh, vertices, indices) = MeshTools::compile(Primitives::UVSphere::solid(16, 32), BufferUsage::StaticDraw);
Shaders::Flat3D shader;
shader.setColor(BaseColor)
.setTransformationProjectionMatrix(Projection*Transformation);
mesh.draw(shader);
return "flat.png";
}
std::string ShaderVisualizer::vertexColor() {
Trade::MeshData3D sphere = Primitives::UVSphere::solid(32, 64);
/* Color vertices nearest to given position */
auto target = Vector3{2.0f, 2.0f, 7.0f}.normalized();
std::vector<Color3> colors;
colors.reserve(sphere.positions(0).size());
for(Vector3 position: sphere.positions(0))
colors.push_back(Color3::fromHSV(Math::lerp(240.0_degf, 420.0_degf, Math::max(1.0f - (position - target).length(), 0.0f)), 0.85f, 0.85f));
Buffer vertices, indices;
vertices.setData(MeshTools::interleave(sphere.positions(0), colors), BufferUsage::StaticDraw);
indices.setData(sphere.indices(), BufferUsage::StaticDraw);
Mesh mesh;
mesh.setPrimitive(MeshPrimitive::Triangles)
.setCount(sphere.indices().size())
.addVertexBuffer(vertices, 0, Shaders::VertexColor3D::Position{}, Shaders::VertexColor3D::Color{})
.setIndexBuffer(indices, 0, Mesh::IndexType::UnsignedInt);
Shaders::VertexColor3D shader;
shader.setTransformationProjectionMatrix(Projection*Transformation);
mesh.draw(shader);
return "vertexcolor.png";
}
std::string ShaderVisualizer::vector() {
std::optional<Trade::ImageData2D> image;
if(!_importer->openFile("vector.png") || !(image = _importer->image2D(0))) {
Error() << "Cannot open vector.png";
return "vector.png";
}
Texture2D texture;
texture.setMinificationFilter(Sampler::Filter::Linear)
.setMagnificationFilter(Sampler::Filter::Linear)
.setWrapping(Sampler::Wrapping::ClampToEdge)
.setStorage(1, TextureFormat::RGBA8, image->size())
.setSubImage(0, {}, *image);
Mesh mesh;
std::unique_ptr<Buffer> vertices;
std::tie(mesh, vertices, std::ignore) = MeshTools::compile(Primitives::Square::solid(Primitives::Square::TextureCoords::Generate), BufferUsage::StaticDraw);
Shaders::Vector2D shader;
shader.setColor(BaseColor)
.setVectorTexture(texture)
.setTransformationProjectionMatrix({});
Renderer::enable(Renderer::Feature::Blending);
Renderer::setBlendFunction(Renderer::BlendFunction::One, Renderer::BlendFunction::OneMinusSourceAlpha);
Renderer::setBlendEquation(Renderer::BlendEquation::Add, Renderer::BlendEquation::Add);
mesh.draw(shader);
Renderer::disable(Renderer::Feature::Blending);
return "vector.png";
}
std::string ShaderVisualizer::distanceFieldVector() {
std::optional<Trade::ImageData2D> image;
if(!_importer->openFile("vector-distancefield.png") || !(image = _importer->image2D(0))) {
Error() << "Cannot open vector-distancefield.png";
return "distancefieldvector.png";
}
Texture2D texture;
texture.setMinificationFilter(Sampler::Filter::Linear)
.setMagnificationFilter(Sampler::Filter::Linear)
.setWrapping(Sampler::Wrapping::ClampToEdge)
.setStorage(1, TextureFormat::RGBA8, image->size())
.setSubImage(0, {}, *image);
Mesh mesh;
std::unique_ptr<Buffer> vertices;
std::tie(mesh, vertices, std::ignore) = MeshTools::compile(Primitives::Square::solid(Primitives::Square::TextureCoords::Generate), BufferUsage::StaticDraw);
Shaders::DistanceFieldVector2D shader;
shader.setColor(BaseColor)
.setOutlineColor(OutlineColor)
.setOutlineRange(0.6f, 0.4f)
.setVectorTexture(texture)
.setTransformationProjectionMatrix({});
Renderer::enable(Renderer::Feature::Blending);
Renderer::setBlendFunction(Renderer::BlendFunction::One, Renderer::BlendFunction::OneMinusSourceAlpha);
Renderer::setBlendEquation(Renderer::BlendEquation::Add, Renderer::BlendEquation::Add);
mesh.draw(shader);
Renderer::disable(Renderer::Feature::Blending);
return "distancefieldvector.png";
}
MAGNUM_WINDOWLESSAPPLICATION_MAIN(ShaderVisualizer)

BIN
doc/generated/vector-distancefield.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

BIN
doc/generated/vector.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

79
doc/generated/vector.svg

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="256"
height="256"
id="svg2"
inkscape:label="Pozadí"
version="1.1"
inkscape:version="0.48.5 r10040"
sodipodi:docname="vector.svg"
inkscape:export-filename="/home/mosra/Code/magnum/doc/generated/vector-src.png"
inkscape:export-xdpi="360"
inkscape:export-ydpi="360">
<defs
id="defs3" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="-237.32667"
inkscape:cy="-18.708048"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-bbox="true"
inkscape:bbox-nodes="true"
inkscape:snap-page="true"
inkscape:window-width="1920"
inkscape:window-height="1032"
inkscape:window-x="0"
inkscape:window-y="-3"
inkscape:window-maximized="1" />
<metadata
id="metadata6">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Vrstva 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-796.36218)">
<path
style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 0 0 L 0 256 L 256 256 L 256 0 L 0 0 z M 46.6875 46.6875 L 209.3125 46.6875 L 209.3125 209.3125 L 46.6875 209.3125 L 46.6875 46.6875 z M 135.125 66.25 C 134.53123 66.246321 133.92211 66.267756 133.3125 66.28125 C 128.81077 66.38089 123.86475 66.93425 118.5 67.96875 C 112.50196 69.12551 106.69229 70.52905 101.03125 72.125 C 95.370175 73.72119 86.598411 76.61946 74.71875 80.84375 L 80.03125 108.4375 L 88.03125 106.875 L 89.9375 91.78125 C 97.554333 85.94102 104.75392 82.37554 111.5625 81.0625 C 122.82897 78.89002 129.81157 84.68966 132.46875 98.46875 L 135.65625 115.09375 L 120.90625 118.3125 C 106.86533 121.35644 96.799574 124.78386 90.71875 128.5625 C 84.622264 132.26023 80.328739 137.04676 77.84375 142.90625 C 75.343124 148.6848 74.936953 155.87706 76.59375 164.46875 C 80.970188 187.16391 94.944487 196.23592 118.53125 191.6875 C 123.71865 190.68722 128.70615 188.887 133.5 186.28125 C 138.30937 183.75653 143.44361 179.73379 148.9375 174.21875 L 153.34375 182.4375 L 195.40625 174.34375 L 193.84375 166.3125 L 181.84375 165.59375 L 167.53125 91.3125 C 164.33251 74.72501 153.53187 66.364045 135.125 66.25 z M 137.75 125.9375 L 145.625 166.78125 C 139.68766 170.86859 133.98036 173.46843 128.46875 174.53125 C 124.57809 175.28152 121.08804 174.27327 118.03125 171.5 C 114.97438 168.72676 112.79727 163.85839 111.46875 156.96875 C 109.82755 148.45813 110.11058 142.01291 112.375 137.625 C 114.7204 133.22158 119.79398 130.12166 127.59375 128.28125 L 137.75 125.9375 z "
transform="translate(0,796.36218)"
id="rect3786" />
<flowRoot
xml:space="preserve"
id="flowRoot2984"
style="font-size:40px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sans"
transform="translate(0,852.36218)"><flowRegion
id="flowRegion2986"><rect
id="rect2988"
width="109.28571"
height="93.214287"
x="46.42857"
y="64.285713" /></flowRegion><flowPara
id="flowPara2990"></flowPara></flowRoot> </g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
doc/getting-started-blue.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

21
doc/getting-started.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -25,7 +25,7 @@
namespace Magnum {
/** @page getting-started Getting started
@brief Get started with %Magnum in matter of minutes.
@brief Get started with Magnum in matter of minutes.
@tableofcontents
@ -42,7 +42,7 @@ parameter.
@section getting-started-bootstrap Download bootstrap project
Setting up a new project can be pretty gruesome and nobody likes repeating the
same process every time. %Magnum provides "bootstrap" project structures for
same process every time. Magnum provides "bootstrap" project structures for
many use cases, helping you get up and running in no time.
The [bootstrap repository](https://github.com/mosra/magnum-bootstrap) is
@ -67,7 +67,7 @@ so the compatibility mode gets properly detected and used.
@section getting-started-review Review project structure
The base project consists of just six files in two subfolders. %Magnum uses
The base project consists of just six files in two subfolders. Magnum uses
CMake build system, see @ref cmake for more information.
modules/FindCorrade.cmake
@ -83,7 +83,7 @@ project-wide `CMakeLists.txt`. It just sets up project name, specifies module
directory and delegates everything important to `CMakeLists.txt` in `src/`
subdirectory.
@code
cmake_minimum_required(VERSION 2.8.8)
cmake_minimum_required(VERSION 2.8.9)
project(MyApplication)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules/")
@ -94,7 +94,7 @@ add_subdirectory(src)
Directory `modules/` contains CMake modules for finding the needed
dependencies. Unlike modules for finding e.g. OpenGL, which are part of
standard CMake installation, these aren't part of it and thus must be
distributed with the project. These files are just verbatim copied from %Magnum
distributed with the project. These files are just verbatim copied from Magnum
repository.
Directory `src/` contains the actual project. To keep things simple, the
@ -130,7 +130,7 @@ MAGNUM_APPLICATION_MAIN(MyApplication)
The application essentially does nothing, just clears screen framebuffer to
default (dark gray) color and then does buffer swap to actually display it on
the screen. `CMakeLists.txt` finds %Magnum, sets up compiler flags, creates the
the screen. `CMakeLists.txt` finds Magnum, sets up compiler flags, creates the
executable and links it to all needed libraries:
@code
find_package(Magnum REQUIRED Sdl2Application)
@ -176,7 +176,7 @@ everything is ready to be built.
If CMake isn't able to find the dependencies on Windows, you might want to look
at @ref building-windows. If CMake complains about `Sdl2Application` missing,
you forgot to enable `WITH_SDL2APPLICATION` when building %Magnum,
you forgot to enable `WITH_SDL2APPLICATION` when building Magnum,
@ref getting-started-download "go back and fix it".
@image html getting-started.png
@ -196,7 +196,7 @@ First include the needed headers:
And in the constructor (which is currently empty) change the clear color and
print something to debug output:
@code
Renderer::setClearColor({0.07f, 0.44f, 0.73f});
Renderer::setClearColor(Color3::fromHSV(216.0_degf, 0.85f, 1.0f));
Debug() << "Hello! This application is running on" << Context::current()->version()
<< "using" << Context::current()->rendererString();
@ -205,7 +205,7 @@ Debug() << "Hello! This application is running on" << Context::current()->versio
After rebuilding and starting the application, the clear color changes to
blueish one and something like this would be printed to the console:
> Hello! This application is running on OpenGL 3.3 using Geforce GT 330M
> Hello! This application is running on OpenGL 4.5 using GeForce GT 740M
@image html getting-started-blue.png
@image latex getting-started-blue.png
@ -223,6 +223,7 @@ experimenting on your own!
- @subpage building
- @subpage building-plugins
- @subpage building-integration
- @subpage building-examples
- @subpage cmake
- @subpage cmake-plugins
- @subpage cmake-integration

BIN
doc/getting-started.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

20
doc/mainpage.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -26,9 +26,10 @@
namespace Magnum {
/** @mainpage
%Magnum is 2D/3D graphics engine written in C++11 and modern OpenGL. Its goal
is to simplify low-level graphics development and interaction with OpenGL using
recent C++11 features and to abstract away platform-specific issues.
Magnum is 2D/3D graphics engine written in C++11/C++14 and modern OpenGL. Its
goal is to simplify low-level graphics development and interaction with OpenGL
using recent C++11/C++14 features and to abstract away platform-specific
issues.
@section mainpage-design-goals Design goals
@ -37,19 +38,19 @@ recent C++11 features and to abstract away platform-specific issues.
usually just an afterthought, if it is present at all. If you want to do
your next project in 2D only, you have to either relearn another engine
from scratch or emulate it in 3D, leaving many things overly complicated.
%Magnum treats 2D equivalently to 3D so you can reuse what you already
Magnum treats 2D equivalently to 3D so you can reuse what you already
learned for 3D and even combine 2D and 3D in one project.
- **Forward compatibility**
If newer technology makes things faster, simpler or more intuitive, it is
the way to go. %Magnum by default relies on decent C++11 support and modern
the way to go. Magnum by default relies on decent C++11 support and modern
OpenGL features and if some feature isn't available, it tries to emulate it
using older functionality. However, you are not restricted to use the older
functionality directly, if you really want to.
- **Intuitive, but not restrictive API**
Scripting languages are often preferred to C/C++ because they are designed
to have less complicated APIs and less boilerplate code. %Magnum is
to have less complicated APIs and less boilerplate code. Magnum is
designed with intuitivity in mind, but also with speed and static checks
that strongly-typed native code offers. It wraps OpenGL into less verbose
and more type-safe API, which is easier to use. Usually the most common way
@ -114,6 +115,7 @@ Feel free to get more information or contact the author at:
- Website -- http://mosra.cz/blog/magnum.php
- GitHub -- https://github.com/mosra/magnum
- IRC -- join `#magnum-engine` channel on freenode
- Google Groups -- https://groups.google.com/forum/#!forum/magnum-engine
- Twitter -- https://twitter.com/czmosra
- E-mail -- mosra@centrum.cz
@ -121,10 +123,10 @@ Feel free to get more information or contact the author at:
@section mainpage-license License
%Magnum is licensed under MIT/Expat license:
Magnum is licensed under MIT/Expat license:
>
> Copyright © 2010, 2011, 2012, 2013, 2014
> Copyright © 2010, 2011, 2012, 2013, 2014, 2015
> Vladimír Vondruš &lt;mosra@centrum.cz&gt;
>
> Permission is hereby granted, free of charge, to any person obtaining a

22
doc/matrix-vector.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -31,7 +31,7 @@ namespace Magnum {
- 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. They
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.
@ -40,10 +40,10 @@ information about usage with CMake.
@section matrix-vector-hierarchy Matrix and vector classes
%Magnum has three main matrix and vector classes: @ref Math::RectangularMatrix,
Magnum has three main matrix and vector classes: @ref Math::RectangularMatrix,
(square) @ref Math::Matrix and @ref Math::Vector. To achieve greatest code
reuse, %Matrix is internally square %RectangularMatrix and %RectangularMatrix
is internally array of one or more %Vector instances. Both vectors and matrices
reuse, Matrix is internally square RectangularMatrix and RectangularMatrix
is internally array of one or more Vector instances. Both vectors and matrices
can have arbitrary size (known at compile time) and can store any arithmetic
type.
@ -53,14 +53,14 @@ vector and matrix sizes there are specialized classes @ref Math::Matrix3 and
@ref Math::Vector2, @ref Math::Vector3 and @ref Math::Vector4, implementing
direct access to named components. Functions of each class try to return the
most specialized type known to make subsequent operations more convenient --
columns of %RectangularMatrix are returned as %Vector, but when accessing
columns of e.g. %Matrix3, they are returned as %Vector3.
columns of RectangularMatrix are returned as Vector, but when accessing
columns of e.g. Matrix3, they are returned as Vector3.
There are also even more specialized subclasses, e.g. @ref Color3 and
@ref Color4 for color handling and conversion.
Commonly used types have convenience aliases in @ref Magnum namespace, so you
can write e.g. `%Vector3i` instead of `%Math::Vector3<Int>`. See @ref types and
can write e.g. `Vector3i` instead of `Math::Vector3<Int>`. See @ref types and
namespace documentation for more information.
@section matrix-vector-construction Constructing matrices and vectors
@ -198,7 +198,7 @@ available component-wise operations.
@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);
@ -214,7 +214,7 @@ Vector3 b = a*Vector3(-0.5f, 2.0f, -7.0f); // b == {-0.5f, 4.0f, -21.0f}
When working with integral vectors (i.e. 24bit RGB values), it is often
desirable to multiply them with floating-point values but with integral result.
In %Magnum all mulitplication/division operations involving integral vectors
In Magnum all mulitplication/division operations involving integral vectors
will have integral result, you need to convert both arguments to the same
floating-point type to have floating-point result.
@code
@ -315,7 +315,7 @@ auto b = Math::denormalize<UnsignedByte>(0.89f); // 226
@section matrix-vector-column-major Matrices are column-major and vectors are columns
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
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 @ref Math::RectangularMatrix

19
doc/method-chaining.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -33,12 +33,12 @@ feature which allows you to chain method calls one after another without
repeatedly specifying variable the method is called on. Its primary goal is to
reduce unnecessary repeated names, improving code readability.
%Magnum uses this feature mainly for configuring OpenGL objects (such as
Magnum uses this feature mainly for configuring OpenGL objects (such as
various mesh and framebuffer options, shader uniforms etc.). Because OpenGL was
designed with "bind-to-modify" approach, most configuration calls internally
need to bind the object first and only after that change the parameters (unless
@extension{EXT,direct_state_access} extension is available to avoid this). To
reduce unneeded bind calls, %Magnum binds the object only if it is not already
reduce unneeded bind calls, Magnum binds the object only if it is not already
bound somewhere. Method chaining encourages you to configure whole object in
one run, effectively reducing the number of needed bindings. Consider the
following example:
@ -74,13 +74,14 @@ carBumpTexture.setStorage(5, TextureFormat::RGB8)
.generateMipmap();
@endcode
Method chaining is not used on non-configuring functions, such as Framebuffer::clear()
or Mesh::draw(), as these won't be commonly used in conjunction with other
functions anyway.
Method chaining is not used on non-configuring functions, such as
@ref Framebuffer::clear() or @ref Mesh::draw(), as these won't be commonly used
in conjunction with other functions anyway.
Method chaining is also used in SceneGraph and other libraries and in some cases
it allows you to just "configure and forget" without even saving the created
object to some variable, for example when adding static object to an scene:
Method chaining is also used in @ref SceneGraph and other libraries and in some
cases it allows you to just "configure and forget" without even saving the
created object to some variable, for example when adding static object to an
scene:
@code
Scene3D scene;

119
doc/namespaces.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -24,21 +24,21 @@
*/
/** @dir magnum/src/Magnum
* @brief Namespace Magnum (part of @ref building "Magnum library")
* @brief Namespace @ref Magnum (part of @ref building "Magnum library")
*/
/** @namespace Magnum
@brief Root namespace
Contains classes for interacting with OpenGL.
This library is built as part of %Magnum by default. To use it, you need to
find `%Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
This library is built as part of Magnum by default. To use it, you need to
find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more
information.
*/
/** @dir Magnum/Platform
* @brief Namespace Magnum::Platform
* @brief Namespace @ref Magnum::Platform
*/
/** @namespace Magnum::Platform
@brief Platform-specific application and context creation
@ -46,9 +46,9 @@ information.
Base classes for creating applications with various toolkits.
Parts of this namespace are built if `WITH_*APPLICATION` is enabled when
building %Magnum, with each library having specific toolkit dependencies and
building Magnum, with each library having specific toolkit dependencies and
platform requirements. To use particular application library, you need to
request given `*Application` component of `%Magnum` package in CMake, add
request given `*Application` component of `Magnum` package 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
@ -56,58 +56,58 @@ information.
*/
/** @dir Magnum/Math
* @brief Namespace Magnum::Math
* @brief Namespace @ref Magnum::Math
*/
/** @namespace Magnum::Math
@brief %Math library
@brief Math library
Template classes for matrix and vector calculations.
This library is built as part of %Magnum by default. To use it, you need to
find `%Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
This library is built as part of Magnum by default. To use it, you need to
find `Magnum` package, 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 Magnum/Math/Algorithms
* @brief Namespace Magnum::Math::Algorithms
* @brief Namespace @ref Magnum::Math::Algorithms
*/
/** @namespace Magnum::Math::Algorithms
@brief %Algorithms
@brief Algorithms
Various matrix and vector algorithms.
This library is built as part of %Magnum by default. To use it, you need to
find `%Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
This library is built as part of Magnum by default. To use it, you need to
find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more
information.
*/
/** @dir Magnum/Math/Geometry
* @brief Namespace Magnum::Math::Geometry
* @brief Namespace @ref Magnum::Math::Geometry
*/
/** @namespace Magnum::Math::Geometry
@brief %Geometry library
@brief Geometry library
Functions for computing intersections, distances, areas and volumes.
This library is built as part of %Magnum by default. To use it, you need to
find `%Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
This library is built as part of Magnum by default. To use it, you need to
find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more
information.
*/
/** @dir Magnum/Audio
* @brief Namespace Magnum::Audio
* @brief Namespace @ref Magnum::Audio
*/
/** @namespace Magnum::Audio
@brief %Audio playback
@brief Audio playback
Audio import, playback and integration with @ref SceneGraph.
This library depends on **OpenAL** library. It is built if `WITH_AUDIO` is
enabled when building %Magnum. To use this library, you need to request
`%Audio` component of `%Magnum` package in CMake, add `${MAGNUM_AUDIO_INCLUDE_DIRS}`
enabled when building Magnum. To use this library, you need to request
`Audio` component of `Magnum` package 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 enabled separately, see
particular `*Importer` class documentation, @ref building-plugins,
@ -115,100 +115,99 @@ particular `*Importer` class documentation, @ref building-plugins,
*/
/** @dir Magnum/DebugTools
* @brief Namespace Magnum::DebugTools
* @brief Namespace @ref Magnum::DebugTools
*/
/** @namespace Magnum::DebugTools
@brief %Debug tools
@brief Debug tools
Debugging helpers, renderers and profilers.
This library is built if `WITH_DEBUGTOOLS` is enabled when building %Magnum. To
use this library, you need to request `%DebugTools` component of `%Magnum`
This library is built if `WITH_DEBUGTOOLS` is enabled when building Magnum. To
use this library, you need to request `DebugTools` component of `Magnum`
package in CMake and link to `${MAGNUM_DEBUGTOOLS_LIBRARIES}`. See
@ref building, @ref cmake and @ref debug-tools for more information.
*/
/** @dir Magnum/MeshTools
* @brief Namespace Magnum::MeshTools
* @brief Namespace @ref Magnum::MeshTools
*/
/** @namespace Magnum::MeshTools
@brief %Mesh tools
@brief Mesh tools
Tools for generating, optimizing and cleaning meshes.
This library is built if `WITH_MESHTOOLS` is enabled when building %Magnum. To
use this library, you need to request `%MeshTools` component of `%Magnum`
This library is built if `WITH_MESHTOOLS` is enabled when building Magnum. To
use this library, you need to request `MeshTools` component of `Magnum`
package in CMake and link to `${MAGNUM_MESHTOOLS_LIBRARIES}`. See @ref building
and @ref cmake for more information.
*/
/** @dir Magnum/Primitives
* @brief Namespace Magnum::Primitives
* @brief Namespace @ref Magnum::Primitives
*/
/** @namespace Magnum::Primitives
@brief Primitive library
Basic primitives for testing purposes.
This library is built if `WITH_PRIMITIVES` is enabled when building %Magnum. To
use this library, you need to request `%Primitives` component of `%Magnum`
This library is built if `WITH_PRIMITIVES` is enabled when building Magnum. To
use this library, you need to request `Primitives` component of `Magnum`
package in CMake and link to `${MAGNUM_PRIMITIVES_LIBRARIES}`. See
@ref building and @ref cmake for more information.
*/
/** @dir Magnum/SceneGraph
* @brief Namespace Magnum::SceneGraph
* @brief Namespace @ref Magnum::SceneGraph
*/
/**
@namespace Magnum::SceneGraph
@brief %Scene graph library
/** @namespace Magnum::SceneGraph
@brief Scene graph library
Managing object hierarchy, transformations and interactions.
This library is built if `WITH_SCENEGRAPH` is enabled when building %Magnum. To
use this library, you need to request `%SceneGraph` component of `%Magnum`
This library is built if `WITH_SCENEGRAPH` is enabled when building Magnum. To
use this library, you need to request `SceneGraph` component of `Magnum`
package in CMake and link to `${MAGNUM_SCENEGRAPH_LIBRARIES}`. See
@ref building, @ref cmake and @ref scenegraph for more information.
*/
/** @dir Magnum/Shaders
* @brief Namespace Magnum::Shaders
* @brief Namespace @ref Magnum::Shaders
*/
/** @namespace Magnum::Shaders
@brief Builtin shaders
Collection of shaders for easy prototyping and basic usage.
This library is built if `WITH_SHADERS` is enabled when building %Magnum. To
use this library, you need to request `%Shaders` component of `%Magnum` package
This library is built if `WITH_SHADERS` is enabled when building Magnum. To
use this library, you need to request `Shaders` component of `Magnum` package
in CMake and link to `${MAGNUM_MESHTOOLS_SHADERS}`. See @ref building and
@ref cmake for more information.
@ref cmake and @ref shaders for more information.
*/
/** @dir Magnum/Shapes
* @brief Namespace Magnum::Shapes
* @brief Namespace @ref Magnum::Shapes
*/
/** @namespace Magnum::Shapes
@brief %Shape library
@brief Shape library
Collision detection system.
This library is built if `WITH_SHAPES` is enabled when building %Magnum. To use
this library, you need to request `%Shapes` component of `%Magnum` package in
This library is built if `WITH_SHAPES` is enabled when building Magnum. To use
this library, you need to request `Shapes` component of `Magnum` package in
CMake and link to `${MAGNUM_SHAPES_LIBRARIES}`. See @ref building, @ref cmake
and @ref shapes for more information.
*/
/** @dir Magnum/Text
* @brief Namespace Magnum::Text
* @brief Namespace @ref Magnum::Text
*/
/** @namespace Magnum::Text
@brief %Text rendering
@brief Text rendering
Font texture creation and text layouting.
This library is built if `WITH_TEXT` is enabled when building %Magnum. To use
this library, you need to request `%Text` component of `%Magnum` package in
This library is built if `WITH_TEXT` is enabled when building Magnum. To use
this library, you need to request `Text` component of `Magnum` package in
CMake and link to `${MAGNUM_TEXT_LIBRARIES}`. See @ref building and @ref cmake
for more information. Additional plugins are enabled separately, see particular
`*Font` and `*FontConverter` class documentation, @ref building-plugins,
@ -216,21 +215,21 @@ for more information. Additional plugins are enabled separately, see particular
*/
/** @dir Magnum/TextureTools
* @brief Namespace Magnum::TextureTools
* @brief Namespace @ref Magnum::TextureTools
*/
/** @namespace Magnum::TextureTools
@brief %Texture tools
@brief Texture tools
Tools for generating, compressing and optimizing textures.
This library is built if `WITH_TEXTURETOOLS` is enabled when building %Magnum.
To use this library, you need to request `%TextureTools` component of `%Magnum`
This library is built if `WITH_TEXTURETOOLS` is enabled when building Magnum.
To use this library, you need to request `TextureTools` component of `Magnum`
package in CMake and link to `${MAGNUM_TEXTURETOOLS_LIBRARIES}`. See
@ref building and @ref cmake for more information.
*/
/** @dir Magnum/Trade
* @brief Namespace Magnum::Trade
* @brief Namespace @ref Magnum::Trade
*/
/** @namespace Magnum::Trade
@brief Data format exchange
@ -238,8 +237,8 @@ package in CMake and link to `${MAGNUM_TEXTURETOOLS_LIBRARIES}`. See
Contains plugin interfaces for importing data of various formats and classes
for direct access to the data.
This library is built as part of %Magnum by default. To use it, you need to
find `%Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
This library is built as part of Magnum by default. To use it, you need to
find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more
information. Additional plugins are enabled separately, see particular
`*Importer` and `*ImageConverter` class documentation, @ref building-plugins,
@ -247,5 +246,5 @@ information. Additional plugins are enabled separately, see particular
*/
/** @dir magnum/src/MagnumPlugins
* @brief %Magnum plugins (part of @ref building "Magnum library")
* @brief Magnum plugins (part of @ref building "Magnum library")
*/

41
doc/opengl-mapping.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -26,7 +26,7 @@
namespace Magnum {
/** @page opengl-mapping OpenGL command mapping
@brief List of OpenGL commands corresponding to particular %Magnum API.
@brief List of OpenGL commands corresponding to particular Magnum API.
@tableofcontents
@ -53,10 +53,10 @@ OpenGL function | Matching API
@fn_gl{BeginConditionalRender}, `glEndConditionalRender()` | @ref SampleQuery::beginConditionalRender(), \n @ref SampleQuery::endConditionalRender()
@fn_gl{BeginQuery}, `glEndQuery()` | @ref PrimitiveQuery::begin(), \n @ref SampleQuery::begin(), \n @ref TimeQuery::begin(), \n @ref AbstractQuery::end()
@fn_gl{BeginQueryIndexed}, `glEndQueryIndexed()` | |
@fn_gl{BeginTransformFeedback}, `glEndTransformFeedback()` | |
@fn_gl{BeginTransformFeedback}, `glEndTransformFeedback()` | @ref TransformFeedback::begin(), @ref TransformFeedback::end()
@fn_gl{BindAttribLocation} | @ref AbstractShaderProgram::bindAttributeLocation()
@fn_gl{BindBuffer} | not needed, handled internally in @ref Buffer and elsewhere
@fn_gl{BindBufferBase}, \n @fn_gl{BindBuffersBase}, \n @fn_gl{BindBufferRange}, \n @fn_gl{BindBuffersRange} | @ref Buffer::bind(), \n @ref Buffer::unbind()
@fn_gl{BindBufferBase}, \n @fn_gl{BindBuffersBase}, \n @fn_gl{BindBufferRange}, \n @fn_gl{BindBuffersRange} | @ref Buffer::bind(), \n @ref Buffer::unbind(), \n @ref TransformFeedback::attachBuffer(), \n @ref TransformFeedback::attachBuffers()
@fn_gl{BindFragDataLocation} | @ref AbstractShaderProgram::bindFragmentDataLocation()
@fn_gl{BindFragDataLocationIndexed} | @ref AbstractShaderProgram::bindFragmentDataLocationIndexed()
@fn_gl{BindFramebuffer} | @ref Framebuffer::bind()
@ -65,7 +65,7 @@ OpenGL function | Matching API
@fn_gl{BindRenderbuffer} | not needed, handled internally in @ref Renderbuffer
@fn_gl{BindSampler}, \n @fn_gl{BindSamplers} | |
@fn_gl{BindTexture}, \n @fn_gl{BindTextureUnit}, \n @fn_gl{BindTextures}, \n @fn_gl_extension{BindMultiTexture,EXT,direct_state_access} | @ref AbstractTexture::bind()
@fn_gl{BindTransformFeedback} | |
@fn_gl{BindTransformFeedback} | not needed, handled internally in @ref TransformFeedback
@fn_gl{BindVertexArray} | not needed, handled internally in @ref Mesh
@fn_gl{BindVertexBuffer}, \n `glVertexArrayVertexBuffer()`, \n @fn_gl_extension{VertexArrayBindVertexBuffer,EXT,direct_state_access} \n @fn_gl{BindVertexBuffers}, \n `glVertexArrayVertexBuffers()` | |
@fn_gl{BlendColor} | @ref Renderer::setBlendColor()
@ -110,8 +110,8 @@ OpenGL function | Matching API
OpenGL function | Matching API
--------------------------------------- | ------------
@fn_gl{DebugMessageCallback} | @ref DebugMessage::setCallback()
@fn_gl{DebugMessageControl} | @ref DebugMessage::setEnabled()
@fn_gl{DebugMessageCallback} | @ref DebugOutput::setCallback()
@fn_gl{DebugMessageControl} | @ref DebugOutput::setEnabled()
@fn_gl{DebugMessageInsert}, \n @fn_gl_extension2{InsertEventMarker,EXT,debug_marker}, \n @fn_gl_extension{StringMarker,GREMEDY,string_marker} | @ref DebugMessage::insert()
@fn_gl{DepthFunc} | @ref Renderer::setDepthFunction()
@fn_gl{DepthMask} | @ref Renderer::setDepthMask()
@ -209,9 +209,9 @@ OpenGL function | Matching API
@fn_gl{GetTexImage}, \n `glGetnTexImage()`, \n @fn_gl_extension{GetnTexImage,ARB,robustness}, \n `glGetTextureImage()`, \n @fn_gl_extension{GetTextureImage,EXT,direct_state_access} | @ref Texture::image(), \n @ref TextureArray::image(), \n @ref CubeMapTexture::image(), \n @ref CubeMapTextureArray::image(), \n @ref RectangleTexture::image()
@fn_gl{GetTexLevelParameter}, \n `glGetTextureLevelParameter()`, \n @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} | @ref Texture::imageSize(), \n @ref TextureArray::imageSize(), \n @ref CubeMapTexture::imageSize(), \n @ref CubeMapTextureArray::imageSize(), \n @ref RectangleTexture::imageSize()
@fn_gl{GetTexParameter}, \n `glGetTextureParameter()`, \n @fn_gl_extension{GetTextureParameter,EXT,direct_state_access} | |
@fn_gl{GetTextureSubImage} | |
@fn_gl{GetTransformFeedback} | |
@fn_gl{GetTransformFeedbackVarying} | |
@fn_gl{GetTextureSubImage} | @ref Texture::subImage(), \n @ref TextureArray::subImage(), \n @ref CubeMapTexture::image(), \n @ref CubeMapTexture::subImage(), \n @ref CubeMapTextureArray::subImage(), \n @ref RectangleTexture::subImage()
@fn_gl{GetTransformFeedback} | not queryable, @ref TransformFeedback::attachBuffer() and @ref TransformFeedback::attachBuffers() setters only
@fn_gl{GetTransformFeedbackVarying} | not queryable, @ref AbstractShaderProgram::setTransformFeedbackOutputs() setter only
@fn_gl{GetUniform}, \n `glGetnUniform()`, \n @fn_gl_extension{GetnUniform,ARB,robustness} | not queryable, @ref AbstractShaderProgram::setUniform() setter only
@fn_gl{GetUniformBlockIndex} | |
@fn_gl{GetUniformIndices} | |
@ -267,7 +267,7 @@ OpenGL function | Matching API
OpenGL function | Matching API
--------------------------------------- | ------------
@fn_gl{PatchParameter} | |
@fn_gl{PauseTransformFeedback}, @fn_gl{ResumeTransformFeedback} | |
@fn_gl{PauseTransformFeedback}, @fn_gl{ResumeTransformFeedback} | @ref TransformFeedback::pause(), @ref TransformFeedback::resume()
@fn_gl{PixelStore} | |
@fn_gl{PointParameter} | |
@fn_gl{PointSize} | @ref Renderer::setPointSize()
@ -277,7 +277,8 @@ OpenGL function | Matching API
@fn_gl{ProgramBinary} | |
@fn_gl{ProgramParameter} | @ref AbstractShaderProgram::setRetrievableBinary(), \n @ref AbstractShaderProgram::setSeparable()
@fn_gl{ProvokingVertex} | @ref Renderer::setProvokingVertex()
@fn_gl{PushDebugGroup}, @fn_gl{PopDebugGroup} | |
@fn_gl{PushDebugGroup}, \n @fn_gl_extension2{PushGroupMarker,EXT,debug_marker} | @ref DebugGroup::push()
@fn_gl{PopDebugGroup}, \n @fn_gl_extension2{PopGroupMarker,EXT,debug_marker} | @ref DebugGroup::pop()
@subsection opengl-mapping-functions-q Q
@ -317,7 +318,7 @@ OpenGL function | Matching API
OpenGL function | Matching API
--------------------------------------- | ------------
@fn_gl{TexBuffer}, \n `glTextureBuffer()`, \n @fn_gl_extension{TextureBuffer,EXT,direct_state_access}, \n @fn_gl{TexBufferRange}, \n `glTextureBufferRange()`, \n @fn_gl_extension{TextureBufferRange,EXT,direct_state_access} | @ref BufferTexture::setBuffer()
@fn_gl{TexImage1D}, \n @fn_gl_extension{TextureImage1D,EXT,direct_state_access} \n @fn_gl{TexImage2D}, \n @fn_gl_extension{TextureImage2D,EXT,direct_state_access}, \n @fn_gl{TexImage3D}, \n @fn_gl_extension{TextureImage3D,EXT,direct_state_access} | @ref Texture::setImage(), \n @ref TextureArray::setImage(), \n @ref CubeMapTexture::setImage(), \n @ref CubeMapTextureArray::setImage(), \n @ref RectangleTexture::setImage()
@fn_gl{TexImage1D}, \n @fn_gl{TexImage2D}, \n @fn_gl{TexImage3D} | @ref Texture::setImage(), \n @ref TextureArray::setImage(), \n @ref CubeMapTexture::setImage(), \n @ref CubeMapTextureArray::setImage(), \n @ref RectangleTexture::setImage()
@fn_gl{TexImage2DMultisample}, \n @fn_gl{TexImage3DMultisample} | @ref MultisampleTexture::setStorage()
@fn_gl{TexParameter}, \n `glTextureParameter()`, \n @fn_gl_extension{TextureParameter,EXT,direct_state_access} | @ref Texture::setBaseLevel() "*Texture::setBaseLevel()", \n @ref Texture::setMaxLevel() "*Texture::setMaxLevel()", \n @ref Texture::setMinificationFilter() "*Texture::setMinificationFilter()", \n @ref Texture::setMagnificationFilter() "*Texture::setMagnificationFilter()", \n @ref Texture::setMinLod() "*Texture::setMinLod()", \n @ref Texture::setMaxLod() "*Texture::setMaxLod()", \n @ref Texture::setLodBias() "*Texture::setLodBias()", \n @ref Texture::setWrapping() "*Texture::setWrapping()", \n @ref Texture::setBorderColor() "*Texture::setBorderColor()", \n @ref Texture::setMaxAnisotropy() "*Texture::setMaxAnisotropy()", \n @ref Texture::setSRGBDecode() "*Texture::setSRGBDecode()", \n @ref Texture::setSwizzle() "*Texture::setSwizzle()", \n @ref Texture::setCompareMode() "*Texture::setCompareMode()", \n @ref Texture::setCompareFunction() "*Texture::setCompareFunction()", \n @ref Texture::setDepthStencilMode() "*Texture::setDepthStencilMode()"
@fn_gl{TexStorage1D}, \n `glTextureStorage1D()`, \n @fn_gl_extension{TextureStorage1D,EXT,direct_state_access}, \n @fn_gl{TexStorage2D}, \n `glTextureStorage2D()`, \n @fn_gl_extension{TextureStorage2D,EXT,direct_state_access}, \n @fn_gl{TexStorage3D}, \n `glTextureStorage3D()`, \n @fn_gl_extension{TextureStorage3D,EXT,direct_state_access} | @ref Texture::setStorage(), \n @ref TextureArray::setStorage(), \n @ref CubeMapTexture::setStorage(), \n @ref CubeMapTextureArray::setStorage(), \n @ref RectangleTexture::setStorage()
@ -325,8 +326,8 @@ OpenGL function | Matching API
@fn_gl{TexSubImage1D}, \n `glTextureSubImage1D()`, \n @fn_gl_extension{TextureSubImage1D,EXT,direct_state_access}, \n @fn_gl{TexSubImage2D}, \n `glTextureSubImage2D()`, \n @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}, \n @fn_gl{TexSubImage3D}, \n `glTextureSubImage3D()`, \n @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access} | @ref Texture::setSubImage(), \n @ref TextureArray::setSubImage(), \n @ref CubeMapTexture::setSubImage(), \n @ref CubeMapTextureArray::setSubImage(), \n @ref RectangleTexture::setSubImage()
@fn_gl{TextureBarrier} | |
@fn_gl{TextureView} | |
@fn_gl{TransformFeedbackBufferBase}, \n @fn_gl{TransformFeedbackBufferRange} | |
@fn_gl{TransformFeedbackVaryings} | |
@fn_gl{TransformFeedbackBufferBase}, \n @fn_gl{TransformFeedbackBufferRange} | @ref TransformFeedback::attachBuffer(), \n @ref TransformFeedback::attachBuffers()
@fn_gl{TransformFeedbackVaryings} | @ref AbstractShaderProgram::setTransformFeedbackOutputs()
@subsection opengl-mapping-functions-u U
@ -410,9 +411,9 @@ OpenGL function | Matching API
@def_gl{MAX_COMPUTE_WORK_GROUP_COUNT} | |
@def_gl{MAX_COMPUTE_WORK_GROUP_INVOCATIONS} | @ref AbstractShaderProgram::maxComputeWorkGroupInvocations()
@def_gl{MAX_COMPUTE_WORK_GROUP_SIZE} | |
@def_gl{MAX_DEBUG_LOGGED_MESSAGES} | @ref DebugMessage::maxLoggedMessages()
@def_gl{MAX_DEBUG_MESSAGE_LENGTH} | @ref DebugMessage::maxMessageLength()
@def_gl{MAX_DEBUG_GROUP_STACK_DEPTH} | |
@def_gl{MAX_DEBUG_LOGGED_MESSAGES} | @ref DebugOutput::maxLoggedMessages()
@def_gl{MAX_DEBUG_MESSAGE_LENGTH} | @ref DebugOutput::maxMessageLength()
@def_gl{MAX_DEBUG_GROUP_STACK_DEPTH} | @ref DebugGroup::maxStackDepth()
@def_gl{MAX_CLIP_DISTANCES} | |
@def_gl{MAX_CULL_DISTANCES} | |
@def_gl{MAX_COMBINED_CLIP_AND_CULL_DISTANCES} | |
@ -438,6 +439,10 @@ OpenGL function | Matching API
@def_gl{MAX_TEXTURE_BUFFER_SIZE} | @ref BufferTexture::maxSize()
@def_gl_extension{MAX_TEXTURE_MAX_ANISOTROPY,EXT,texture_filter_anisotropic} | @ref Sampler::maxMaxAnisotropy()
@def_gl{MAX_TEXTURE_LOD_BIAS} | @ref AbstractTexture::maxLodBias()
@def_gl{MAX_TRANSFORM_FEEDBACK_BUFFERS} | @ref TransformFeedback::maxBuffers()
@def_gl{MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS} | @ref TransformFeedback::maxInterleavedComponents()
@def_gl{MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS} | @ref TransformFeedback::maxSeparateAttributes()
@def_gl{MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS} | @ref TransformFeedback::maxSeparateComponents()
@def_gl{MAX_UNIFORM_BLOCK_SIZE} | @ref AbstractShaderProgram::maxUniformBlockSize()
@def_gl{MAX_UNIFORM_BUFFER_BINDINGS} | @ref Buffer::maxUniformBindings()
@def_gl{MAX_UNIFORM_LOCATIONS} | @ref AbstractShaderProgram::maxUniformLocations()

51
doc/opengl-support.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -50,7 +50,7 @@ following:
@todo @extension{EXT,texture_array} overlaps with @extension{ARB,framebuffer_object}
@todo Add @extension{ARB,depth_buffer_float} and implement the missing @fn_gl{DepthRange} function, but keep (and implement) @extension{NV,depth_buffer_float} for non-linear depth buffer
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 1.30 | done
@extension{ARB,map_buffer_range} | done
@ -70,13 +70,13 @@ GLSL 1.30 | done
@extension{EXT,texture_shared_exponent} | done
@extension{EXT,draw_buffers2} | |
@extension{EXT,texture_integer} | done (GL 3.0 subset)
@extension{EXT,transform_feedback} | |
@extension{EXT,transform_feedback} | done
@extension{NV,depth_buffer_float} | |
@extension{NV,conditional_render} | done
@subsection opengl-support-31 OpenGL 3.1
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 1.40 | done
@extension{ARB,texture_rectangle} | done
@ -89,7 +89,7 @@ GLSL 1.40 | done
@subsection opengl-support-32 OpenGL 3.2
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 1.50 | done
@extension{ARB,geometry_shader4} | missing layered attachments
@ -104,7 +104,7 @@ GLSL 1.50 | done
@subsection opengl-support-33 OpenGL 3.3
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 3.30 | done
@extension{ARB,instanced_arrays} | done
@ -120,7 +120,7 @@ GLSL 3.30 | done
@subsection opengl-support-40 OpenGL 4.0
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 4.00 | done
@extension{ARB,draw_buffers_blend} | |
@ -134,12 +134,12 @@ GLSL 4.00 | done
@extension{ARB,shader_subroutine} | |
@extension{ARB,tessellation_shader} | missing some limit queries and patch parameter specification function
@extension{ARB,texture_buffer_object_rgb32} | done
@extension{ARB,transform_feedback2} | |
@extension{ARB,transform_feedback3} | |
@extension{ARB,transform_feedback2} | missing transform feedback draw
@extension{ARB,transform_feedback3} | only advanced interleaving
@subsection opengl-support-41 OpenGL 4.1
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 4.10 | done
@extension{ARB,ES2_compatibility} | only float depth clear
@ -151,7 +151,7 @@ GLSL 4.10 | done
@subsection opengl-support-42 OpenGL 4.2
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 4.20 | done
@extension{ARB,texture_compression_bptc} | done
@ -169,7 +169,7 @@ GLSL 4.20 | done
@subsection opengl-support-43 OpenGL 4.3
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 4.30 | done
@extension{ARB,arrays_of_arrays} | done (shading language only)
@ -177,7 +177,7 @@ GLSL 4.30 | done
@extension{ARB,clear_buffer_object} | |
@extension{ARB,compute_shader} | |
@extension{ARB,copy_image} | |
@extension{KHR,debug} (also in ES) | missing log retrieval, sync, pipeline, transform feedback and sampler label and debug groups
@extension{KHR,debug} (also in ES) | missing log retrieval, sync, pipeline and sampler label
@extension{ARB,explicit_uniform_location} | done
@extension{ARB,fragment_layer_viewport} | done (shading language only)
@extension{ARB,framebuffer_no_attachments} | |
@ -200,7 +200,7 @@ GLSL 4.30 | done
@todo Also fallback to @extension{AMD,query_buffer_object}
@todo @extension{AMD,pinned_memory} "fallback" for @extension{ARB,buffer_storage}
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 4.40 | done
@def_gl{MAX_VERTEX_ATTRIB_STRIDE} | |
@ -215,7 +215,7 @@ GLSL 4.40 | done
@subsection opengl-support-45 OpenGL 4.5
%Extension | Status
Extension | Status
------------------------------------------- | ------
GLSL 4.50 | done
@extension{ARB,ES3_1_compatibility} | |
@ -223,8 +223,8 @@ GLSL 4.50 | done
@extension{ARB,conditional_render_inverted} | done
@extension{ARB,cull_distance} | |
@extension{ARB,derivative_control} | done (shading language only)
@extension{ARB,direct_state_access} | object creation subset only
@extension{ARB,get_texture_sub_image} | |
@extension{ARB,direct_state_access} | done for implemented functionality (except VAOs)
@extension{ARB,get_texture_sub_image} | missing compressed texture queries
@extension{ARB,shader_texture_image_samples} | done (shading language only)
@extension{ARB,texture_barrier} | |
@extension{KHR,context_flush_control} (also in ES) | |
@ -232,7 +232,7 @@ GLSL 4.50 | done
@subsection opengl-support-extensions ARB / Khronos OpenGL extensions
%Extension | Status
Extension | Status
------------------------------------------- | ------
@extension{ARB,robustness} | done
@extension3{KHR,texture_compression_astc_ldr,texture_compression_astc_hdr} (also in ES) | |
@ -255,7 +255,7 @@ GLSL 4.50 | done
@todo @extension{ATI,meminfo}, @extension{NVX,gpu_memory_info}, GPU temperature
@todo @extension{AMD,performance_monitor}, @extension{INTEL,performance_query}
%Extension | Status
Extension | Status
------------------------------------------- | ------
@extension{AMD,vertex_shader_layer} | done (shading language only)
@extension{AMD,shader_trinary_minmax} | done (shading language only)
@ -265,8 +265,8 @@ GLSL 4.50 | done
@extension{EXT,direct_state_access} | done for implemented functionality
@extension{EXT,texture_sRGB_decode} (also in ES) | done
@extension{EXT,shader_integer_mix} (also in ES) | done (shading language only)
@extension2{EXT,debug_label} (also in ES) | missing pipeline, transform feedback and sampler label
@extension2{EXT,debug_marker} (also in ES) | missing marker groups
@extension2{EXT,debug_label} (also in ES) | missing pipeline and sampler label
@extension2{EXT,debug_marker} (also in ES) | done
@extension{GREMEDY,string_marker} | done
@subsection opengl-support-es20 OpenGL ES 2.0
@ -286,7 +286,7 @@ supported. ESSL 3.10 is supported.
@subsection opengl-support-es30-extensions OpenGL ES 2.0 extensions to match ES 3.0 functionality
%Extension | Status
Extension | Status
------------------------------------------- | ------
@es_extension{ANGLE,framebuffer_blit} | done
@es_extension{ANGLE,framebuffer_multisample} | done
@ -323,6 +323,7 @@ supported. ESSL 3.10 is supported.
@es_extension{OES,texture_float_linear} | done
@es_extension2{OES,texture_half_float,OES_texture_float} | done
@es_extension{OES,texture_float} | done
@es_extension{OES,texture_npot} | done (nothing to do)
@es_extension{OES,vertex_half_float} | done
@es_extension{OES,packed_depth_stencil} | done
@es_extension{OES,depth_texture} | done
@ -339,7 +340,7 @@ Only extensions not already listed in above tables are included here.
@todo Support also IMG_multisampled_render_to_texture? It has different enum
values (!)
%Extension | Status
Extension | Status
------------------------------------------- | ------
@es_extension{APPLE,texture_format_BGRA8888} | done
@es_extension{CHROMIUM,map_sub} | only buffer mapping
@ -365,7 +366,7 @@ Only extensions not already listed in above tables are included here.
@section opengl-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. See also
add any performance gains, is not supported in Magnum. See also
@ref opengl-deprecated.
@subsection opengl-unsupported-features Unsupported features
@ -375,7 +376,7 @@ add any performance gains, is not supported in %Magnum. See also
not supported. The only exception are features that are needed for some
OpenGL ES 2.0 implementations (such as luminance texture formats).
- State queries (various `glIs*()`, `glGet*()` functions) are not supported.
%Magnum API is designed to prevent the need for majority of them, many of
Magnum API is designed to prevent the need for majority of them, many of
them are tracked internally to avoid redundant state changes and in many
cases it is easier to set the state to some value rather than query it and
then decide on the result. For detailed state introspection please use

6
doc/opengl.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -26,7 +26,7 @@
/** @page opengl OpenGL
@brief State of OpenGL support, version and extension requirements.
The following table maps OpenGL function names to %Magnum API, useful for
The following table maps OpenGL function names to Magnum API, useful for
developers with existing OpenGL background. Note that, as reverse mapping, each
function documentation also contains list of OpenGL functions used.
@ -43,7 +43,7 @@ The engine requires at least OpenGL 2.1 or OpenGL ES 2.0, but some specific
functionality has greater requirements. Following are lists of features
requiring specific OpenGL version. In most cases it is also specified which
extension is required, so if given hardware supports required extension, it
doesn't need to have required OpenGL version too (e.g. `ARB_vertex_array_object`
doesn't need to have required OpenGL version too (e.g. @extension{ARB,vertex_array_object}
is supported on older Intel GPUs even if they are capable of OpenGL 2.1 only).
- @subpage requires-gl30

50
doc/platform.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -23,13 +23,13 @@
DEALINGS IN THE SOFTWARE.
*/
namespace Magnum { namespace Platform {
namespace Magnum {
/** @page platform Platform support
@brief Integration into windowing toolkits and creation of windowless contexts.
- Next page: @ref types
@ref Platform namespace contains classes integrating %Magnum engine into
@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
@ -48,14 +48,14 @@ Windowed applications provide a window and keyboard and mouse handling. The
de-facto standard and most widely used toolkit is SDL2, which is implemented in
@ref Platform::Sdl2Application. As said above, the usage is similar for all
toolkits, you must provide one-argument constructor and implement at least
@ref Sdl2Application::drawEvent() "drawEvent()" function. The class can be then
used directly in `main()`, but for convenience and portability it's better to
use @ref MAGNUM_SDL2APPLICATION_MAIN() macro.
@ref Platform::Sdl2Application::drawEvent() "drawEvent()" function. The class
can be then used directly in `main()`, but for convenience and portability it's
better to use @ref MAGNUM_SDL2APPLICATION_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 <tt>#</tt>`include` statement (and changing
then matter of replacing only the `#``include` statement (and changing
one line in CMake build script, as you see later).
Barebone application implementation which will just clear the window to dark
@ -103,8 +103,8 @@ MAGNUM_APPLICATION_MAIN(MyApplication)
By default the application doesn't respond to window size changes in any way,
as the window has fixed size in most cases. To respond to size change for
example by resizing the default framebuffer, you need to reimplement
@ref Sdl2Application::viewportEvent() "viewportEvent()" function and pass the
new size to the framebuffer:
@ref Platform::Sdl2Application::viewportEvent() "viewportEvent()" function and
pass the new size to the framebuffer:
@code
class MyApplication: public Platform::Application {
// ...
@ -125,12 +125,12 @@ void MyApplication::viewportEvent(const Vector2i& size) {
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. %Magnum provides windowless applications for X11-based Unix, OS X and
ones. Magnum provides windowless applications for X11-based Unix, OS X and
Windows. To make things simple, as an example we will use only
@ref Platform::WindowlessGlxApplication, see link for bootstrap application
below for fully portable example.
You need to implement just @ref WindowlessGlxApplication::exec() "exec()"
You need to implement just @ref Platform::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.
@ -139,7 +139,7 @@ Similarly as with windowed applications, to simplify the porting, the library
provides `Platform::WindowlessApplication` typedef and `MAGNUM_WINDOWLESSAPPLICATION_MAIN()`
macro, but only if just one windowless application header is included. Changing
the code to use different toolkit is then matter of replacing only the
<tt>#</tt>`include` statement. Aliases for windowless applications are
`#``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.).
@ -182,8 +182,8 @@ MAGNUM_WINDOWLESSAPPLICATION_MAIN(MyApplication)
@section platform-compilation Compilation with CMake
Barebone compilation consists just of finding %Magnum library with required
`*Application` component, adding %Magnum's `${MAGNUM_INCLUDE_DIRS}` and
Barebone compilation consists just of finding Magnum library with required
`*Application` component, adding Magnum's `${MAGNUM_INCLUDE_DIRS}` and
application-specific `${MAGNUM_SDL2APPLICATION_INCLUDE_DIRS}` to include path,
compilation of the executable and linking `${MAGNUM_LIBRARIES}` and
`${MAGNUM_SDL2APPLICATION_LIBRARIES}` to it.
@ -194,7 +194,7 @@ and `${MAGNUM_APPLICATION_LIBRARIES}` aliases (or `${MAGNUM_WINDOWLESSAPPLICATIO
only if only one application (windowless application) component is requested to
avoid ambiguity. Changing the build script to use different toolkit is then
matter of replacing only the requested `*Application` component (and one
<tt>#</tt>`include` line in the actual code, as said above).
`#``include` line in the actual code, as said above).
@code
find_package(Magnum REQUIRED Sdl2Application)
@ -211,8 +211,9 @@ target_link_libraries(myapplication
By default the application is created with some reasonable defaults (e.g.
window size 800x600 pixels). If you want something else, you can pass
@ref Sdl2Application::Configuration "Configuration" instance to application
constructor. Using method chaining it can be done conveniently like this:
@ref Platform::Sdl2Application::Configuration "Configuration" instance to
application constructor. Using method chaining it can be done conveniently like
this:
@code
MyApplication::MyApplication(int& argc, char** argv):
Platform::Application(argc, argv, Configuration()
@ -225,8 +226,8 @@ MyApplication::MyApplication(int& argc, char** argv):
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 @ref Sdl2Application::Configuration "Configuration" instance and
then specify it later with @ref Sdl2Application::createContext() "createContext()":
instead of @ref Platform::Sdl2Application::Configuration "Configuration"
instance and then specify it later with @ref Platform::Sdl2Application::createContext() "createContext()":
@code
MyApplication::MyApplication(int& argc, char** argv): Platform::Application(argc, argv, nullptr) {
// ...
@ -239,9 +240,9 @@ MyApplication::MyApplication(int& argc, char** argv): Platform::Application(argc
}
@endcode
If the context creation in constructor or @ref Sdl2Application::createContext() "createContext()"
If the context creation in constructor or @ref Platform::Sdl2Application::createContext() "createContext()"
fails, the application exits. However, it is also possible to negotiate the
context using @ref Sdl2Application::tryCreateContext() "tryCreateContext()".
context using @ref Platform::Sdl2Application::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:
@ -263,7 +264,7 @@ MyApplication::MyApplication(int& argc, char** argv): Platform::Application(argc
@section platform-custom Using custom platform toolkits
In case you want to use some not-yet-supported toolkit or you don't want to use
the application wrappers in @ref Platform namespace, you can initialize %Magnum
the application wrappers in @ref Platform namespace, you can initialize Magnum
manually. First create OpenGL context and then create instance of
@ref Platform::Context class, which will take care of proper initialization and
feature detection. The instance must be alive for whole application lifetime.
@ -287,6 +288,9 @@ int main(int argc, char** argv) {
}
@endcode
@attention Currently Magnum is limited to single OpenGL context, which must be
always set as current.
On majority of platforms the @ref Platform::Context class does GL function
pointer loading using platform-specific APIs. In that case you also need to
find particular `*Context` library, add its include dir and then link to it.
@ -319,4 +323,4 @@ target_link_libraries(myapplication
- Next page: @ref types
*/
}}
}

38
doc/plugins.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -25,12 +25,12 @@
namespace Magnum {
/** @page plugins Loading and using plugins
@brief Extending %Magnum with additional functionality
@brief Extending Magnum with additional functionality
- Previous page: @ref transformations
- Next page: @ref scenegraph
- Next page: @ref shaders
The base %Magnum library contains math support, scene graph implementation and
The base Magnum library contains math support, scene graph implementation and
is able to interact with graphics and audio hardware. However, the base library
doesn't provide any functions for dealing with specific file formats, as there
are simply too many formats to have them included directly in the library.
@ -52,7 +52,7 @@ might not be available on all platforms.
@section plugins-types Plugin interfaces
%Magnum contains these plugin interfaces:
Magnum contains these plugin interfaces:
- @ref Trade::AbstractImporter -- importers for general 2D and 3D scene,
mesh, material, texture and image data. See `*Importer` classes in
@ -81,7 +81,7 @@ for given plugin interface, for example @ref Trade::AbstractImporter. You must
set particular plugin directory, from which the manager will load and
instantiate the plugins. To save you from hardcoding the value into your
application source, the plugin directory is provided as `MAGNUM_PLUGINS_DIR`
CMake variable. The default is set to %Magnum install location, but you can
CMake variable. The default is set to Magnum install location, but you can
change it through CMake to anything else. The `MAGNUM_PLUGINS_IMPORTER_DIR`,
`MAGNUM_PLUGINS_IMAGECONVERTER_DIR`, `MAGNUM_PLUGINS_FONT_DIR`,
`MAGNUM_PLUGINS_FONTCONVERTER_DIR`, `MAGNUM_PLUGINS_AUDIOIMPORTER_DIR`
@ -98,10 +98,11 @@ to these:
In case you are using multi-configuration build system (such as Visual Studio
or XCode), CMake cannot provide separate plugin directory for debug and release
build and you have to do it on your own in preprocessing step using
@ref corrade-cmake "CORRADE_IS_DEBUG_BUILD" variable. This will ensure that you
use debug plugin directory for debug build on multi-configuration build sytems
and fall back to autodetection for the rest:
build and you have to select between `MAGNUM_PLUGINS_*_DIR` and
`MAGNUM_PLUGINS_*_DEBUG_DIR` based on @ref corrade-cmake "CORRADE_IS_DEBUG_BUILD"
preprocessor variable. This will ensure that you use debug plugin directory for
debug build on multi-configuration build sytems and fall back to autodetection
for the rest:
@code
#ifdef CORRADE_IS_DEBUG_BUILD
#define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}"
@ -110,6 +111,11 @@ and fall back to autodetection for the rest:
#endif
@endcode
However, if you want to use only one (debug/release) plugin version for both
debug and release configurations of the application, you need to edit
`MAGNUM_PLUGINS_DIR` or `MAGNUM_PLUGINS_DEBUG_DIR` using CMake and point them
to directory containing desired plugin version.
Then process the file in your `CMakeLists.txt`. The result
(`${MAGNUM_PLUGINS_IMPORTER_DIR}` / `${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}` gets
replaced with the actual value) is put into build directory, so don't forget to
@ -129,12 +135,12 @@ lifetime of all plugin instances created from it.
// ...
{
PluginManager::Manager<Trade::AbstractImporter> manager(MAGNUM_PLUGINS_IMPORTER_DIR);
if(!(manager.load("TgaImporter") & PluginManager::LoadState::Loaded)) {
Error() << "Cannot load TgaImporter plugin from" << manager.pluginDirectory();
PluginManager::Manager<Trade::AbstractImporter> manager{MAGNUM_PLUGINS_IMPORTER_DIR};
std::unique_ptr<Trade::AbstractImporter> tgaImporter = manager.loadAndInstantiate("TgaImporter");
if(!tgaImporter) {
Error() << "Cannot load importer plugin from" << manager.pluginDirectory();
std::exit(1);
}
std::unique_ptr<Trade::AbstractImporter> tgaImporter = manager.instance("TgaImporter");
// Use the plugin...
@ -202,7 +208,7 @@ int main(int argc, char** argv) {
@section plugins-develop Developing your own plugins
See class documentation of particular plugin interfaces for more information
about subclassing. The %Corrade's @ref plugin-management "plugin management tutorial"
about subclassing. The Corrade's @ref plugin-management "plugin management tutorial"
contains more information about plugin compilation and registering.
If you want to develop a plugin which depends on another, you need to find the
@ -211,7 +217,7 @@ to how static plugins are found above. See @ref cmake and @ref cmake-plugins
for more information.
- Previous page: @ref transformations
- Next page: @ref scenegraph
- Next page: @ref shaders
*/
}

12
doc/portability.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -31,7 +31,7 @@ namespace Magnum {
@section portability-target Target-specific code
If %Magnum is compiled with e.g. OpenGL ES 2.0 support, some features present
If Magnum is compiled with e.g. OpenGL ES 2.0 support, some features present
in desktop version are not available. It means that some classes, functions
and enum values are simply not included in headers. It is designed this way to
make porting easier -- it is better to fail at compile time on e.g. undefined
@ -60,10 +60,10 @@ also @ref requires-gl, @ref requires-gles20 and @ref requires-gles30.
@section portability-compiler Compiler- and platform-specific code
%Magnum is attempting to be future-proof and as intuitive for users as
Magnum is attempting to be future-proof and as intuitive for users as
possible. Many features from C++11 are used to simplify things and make them
faster and more secure, but on the other hand it requires fairly recent
compiler with good enough support of the new standard. Currently %Magnum is
compiler with good enough support of the new standard. Currently Magnum is
written with GCC 4.8 and Clang 3.1 in mind, but support for some other
compilers is also available and handled by Corrade library. See @ref Corrade.h
for more information.
@ -108,7 +108,7 @@ MAGNUM_ASSERT_EXTENSION_SUPPORTED(GL::ARB::geometry_shader4);
@endcode
Each class, function or enum value is marked accordingly if it needs specific
extension or specific OpenGL version. Various classes in %Magnum are taking
extension or specific OpenGL version. Various classes in Magnum are taking
advantage of some extensions and enable faster code paths if given extension is
available, but also have proper fallback when it's not, see for example
@ref AbstractShaderProgram-performance-optimization "AbstractShaderProgram",
@ -117,7 +117,7 @@ available, but also have proper fallback when it's not, see for example
@section portability-shaders Writing portable shaders
%Shaders are probably the most painful thing to port. There are many issues to
Shaders are probably the most painful thing to port. There are many issues to
address - different shader syntax (`in`/`out` vs. `attribute` and `varying`
etc.), explicit vs. implicit methods to specify vertex attribute, uniform and
texture uniform locations, required precision qualifiers in OpenGL ES etc.

314
doc/scenegraph.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -23,14 +23,14 @@
DEALINGS IN THE SOFTWARE.
*/
namespace Magnum { namespace SceneGraph {
namespace Magnum {
/** @page scenegraph Using scene graph
@brief Overview of scene management capabilities.
- Previous page: @ref plugins
- Previous page: @ref shaders
- Next page: @ref shapes
%Scene graph provides way to hiearchically manage your objects, their
Scene graph provides way to hiearchically manage your objects, their
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.
@ -41,7 +41,7 @@ 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
users to provide their own features, scene graph in Magnum is composed of
three main components:
- objects, providing parent/children hierarchy
@ -56,114 +56,154 @@ three main components:
@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 @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
has its own advantages and disadvantages -- for example when using matrices
you can have nearly arbitrary transformations, but composing transformations
and computing their inverse is costly operation. On the other hand quaternions
won't allow you to scale or shear objects, but are more memory efficient than
matrices.
is dimension count (2D or 3D) and underlying floating-point type. All classes
in @ref SceneGraph are templated on underlying type. However, in most cases
@ref Float "Float" is used and thus nearly all classes have convenience aliases
so you don't have to explicitly specify it.
Scene graph has various transformation implementations for both 2D and 3D. Each
implementation has its own advantages and disadvantages -- for example when
using matrices you can have nearly arbitrary transformations, but composing
transformations, computing their inverse and accounting for floating-point
drift is rather costly operation. On the other hand quaternions won't allow you
to scale or shear objects, but have far better performance characteristics.
It's also possible to implement your own transformation class for specific
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
@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:
needs, see source of builtin transformation classes for more information.
Magnum provides the following transformation classes. See documentation of each
class for more detailed information:
- @ref SceneGraph::BasicMatrixTransformation2D "SceneGraph::MatrixTransformation2D" --
arbitrary 2D transformations but with slow inverse transformations and no
floating-point drift reduction
- @ref SceneGraph::BasicMatrixTransformation3D "SceneGraph::MatrixTransformation3D" --
arbitrary 3D transformations but with slow inverse transformations and no
floating-point drift reduction
- @ref SceneGraph::BasicRigidMatrixTransformation2D "SceneGraph::RigidMatrixTransformation2D" --
2D translation, rotation and reflection (no scaling), with relatively fast
inverse transformations and floating-point drift reduction
- @ref SceneGraph::BasicRigidMatrixTransformation3D "SceneGraph::RigidMatrixTransformation3D" --
3D translation, rotation and reflection (no scaling), with relatively fast
inverse transformations and floating-point drift reduction
- @ref SceneGraph::BasicDualComplexTransformation "SceneGraph::DualComplexTransformation" --
2D translation and rotation with fast inverse transformations and
floating-point drift reduction
- @ref SceneGraph::BasicDualQuaternionTransformation "SceneGraph::DualQuaternionTransformation" --
3D translation and rotation with fast inverse transformation and
floating-point drift reduction
- @ref SceneGraph::TranslationTransformation "SceneGraph::TranslationTransformation*D" --
Just 2D/3D translation (no rotation, scaling or anything else)
Common usage of transformation classes is to typedef Scene and Object with
desired transformation type to save unnecessary typing later:
@code
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D> Scene3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> 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 @ref Object::setParent().
%Scene is always root object, so it naturally cannot have parent object.
@attention Note that you have to include both @ref Magnum/SceneGraph/Object.h
and desired transformation class (e.g. @ref Magnum/SceneGraph/MatrixTransformation3D.h)
to be able to use the resulting type.
The object type is subclassed from the transformation type and so the
`Object3D` type will then contain all members from both @ref SceneGraph::Object
and @ref SceneGraph::MatrixTransformation3D. For convenience you can use method
chaining:
@code
Scene3D scene;
auto first = new Object3D(&scene);
auto second = new Object3D(first);
Object3D object;
object.setParent(&scene)
.rotateY(15.0_degf)
.translate(Vector3::xAxis(5.0f));
@endcode
%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:
@section scenegraph-hierarchy Scene hierarchy
Scene hierarchy is skeleton part of scene graph. In the root there is
@ref SceneGraph::Scene and its children are @ref SceneGraph::Object instances.
Whole hierarchy has one 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).
Then you can start building the hierarchy by *parenting* one object to another.
Parent object can be either passed in constructor or set using
@ref SceneGraph::Object::setParent(). Scene is always root object, so it
naturally cannot have parent object. Parent and children relationships can be
observed through @ref SceneGraph::Object::parent() and
@ref SceneGraph::Object::children().
@code
Object3D* o;
for(Object3D* child = o->firstChild(); child; child = child->nextSibling()) {
// ...
}
Scene3D scene;
Object3D* first = new Object3D{&scene};
Object3D* second = new Object3D{first};
@endcode
The hierarchy takes care of memory management - when an object is destroyed,
The hierarchy takes care of memory management -- when an object is destroyed,
all its children are destroyed too. See detailed explanation of
@ref scenegraph-object-construction-order "construction and destruction order"
for information about possible issues.
The object is derived from the transformation you specified earlier in the
`typedef`, so you can directly transform the objects using methods of given
transformation implementation. %Scene, as a root object, cannot have any
transformation. For convenience you can use method chaining:
below for information about possible issues. To reflect the implicit memory
management in the code better, you can use @ref SceneGraph::Object::addChild()
instead of the naked `new` call in the code above:
@code
auto next = new Object3D;
next->setParent(another)
.translate(Vector3::yAxis(3.0f))
.rotateY(35.0_degf);
Scene3D scene;
Object3D& first = scene.addChild<Object3D>();
Object3D& second = first.addChild<Object3D>();
@endcode
@section scenegraph-features Object features
The object itself handles only parent/child relationship and transformation.
To make the object renderable, animatable, add collision shape to it etc., you
To make the object renderable, animable, add collision shape to it etc., you
have to add a *feature* to it.
Each feature takes reference to holder object in constructor, so adding a
feature to an object might look just like this, as in some cases you don't even
need to keep the pointer to it:
@code
Object3D* o;
new MyFeature(o);
@endcode
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:
Magnum provides the following builtin features. See documentation of each class
for more detailed information and usage examples:
- @ref SceneGraph::AbstractCamera "SceneGraph::Camera*D" -- Handles
projection matrix, aspect ratio correction etc.. Used for rendering parts
of the scene.
- @ref SceneGraph::Drawable "SceneGraph::Drawable*D" -- Adds drawing
functionality to given object. Group of drawables can be then rendered
using the camera feature.
- @ref SceneGraph::Animable "SceneGraph::Animable*D" -- Adds animation
functionality to given object. Group of animables can be then controlled
using @ref SceneGraph::AnimableGroup "SceneGraph::AnimableGroup*D".
- @ref Shapes::Shape -- Adds collision shape to given object. Group of shapes
can be then controlled using @ref Shapes::ShapeGroup "Shapes::ShapeGroup*D".
See @ref shapes for more information.
- @ref DebugTools::ObjectRenderer "DebugTools::ObjectRenderer*D",
@ref DebugTools::ShapeRenderer "DebugTools::ShapeRenderer*D",
@ref DebugTools::ForceRenderer "DebugTools::ForceRenderer*D" -- Visualize
object properties, object shape or force vector for debugging purposes. See
@ref debug-tools for more information.
Each feature takes reference to *holder object* in constructor, so adding a
feature to an object might look just like the following, as in some cases you
don't even need to keep the pointer to it. List of object features is
accessible through @ref SceneGraph::Object::features().
@code
Object3D* o;
for(Object3D::FeatureType feature = o->firstFeature(); feature; feature = feature->nextFeature()) {
// ...
}
Object3D& o;
new MyFeature{o, ...};
@endcode
Some features are passive, some active. Passive features can be just added to
an object like above, without any additional work (for example collision shape).
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 @ref Object subclass without having to
subclass each feature individually (and making the code overly verbose).
Simplified example:
an object, with no additional work except for possible configuration (for
example collision shape). 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 @ref SceneGraph::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 BouncingBall: public Object3D, SceneGraph::Drawable3D, SceneGraph::Animable3D {
public:
Bomb(Object3D* parent): Object3D(parent), SceneGraph::Drawable3D(*this), SceneGraph::Animable3D(*this) {}
explicit BouncingBall(Object3D* parent): Object3D{parent}, SceneGraph::Drawable3D{*this}, SceneGraph::Animable3D{*this} {}
protected:
private:
// drawing implementation for Drawable feature
void draw(...) override;
@ -179,55 +219,111 @@ feature list.
Similarly to object hierarchy, when destroying object, all its features (both
member and inherited) are destroyed. See detailed explanation of
@ref scenegraph-feature-construction-order "construction and destruction order"
for information about possible issues.
for information about possible issues. Also, there is a
@ref SceneGraph::AbstractObject::addFeature() counterpart to
@ref SceneGraph::Object::addChild():
@code
Object3D& o;
o.addFeature<MyFeature>(...);
@endcode
@section scenegraph-caching Transformation caching
@subsection scenegraph-features-caching Transformation caching in features
Some features need to operate with absolute transformations and their
inversions - for example camera needs its inverse transformation to render the
inversions -- for example camera needs its inverse transformation to render the
scene, collision detection needs to know about positions of surrounding
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 @ref Object::setDirty().
The cached data stay until the object is marked as dirty -- that is by changing
transformation, changing parent or explicitly calling @ref SceneGraph::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):
@ref SceneGraph::AbstractFeature::markDirty() is called on every feature.
Calling @ref SceneGraph::Object::setClean() cleans the dirty object and all its
dirty parents. The function goes through all object features and calls
@ref SceneGraph::AbstractFeature::clean() or
@ref SceneGraph::AbstractFeature::cleanInverted() depending on which caching is
enabled on given feature. If the object is already clean,
@ref SceneGraph::Object::setClean() does nothing.
Most probably you will need caching in @ref SceneGraph::Object itself -- which
doesn't support it on its own -- however you can take advantage of multiple
inheritance and implement it using @ref SceneGraph::AbstractFeature. In order
to have caching, you must enable it first, because by default the caching is
disabled. You can enable it using @ref SceneGraph::AbstractFeature::setCachedTransformations()
and then implement corresponding cleaning function(s):
@code
class CachingObject: public Object3D, SceneGraph::AbstractFeature3D {
public:
CachingObject(Object3D* parent): SceneGraph::AbstractFeature3D(*this) {
explicit CachingObject(Object3D* parent): Object3D{parent}, SceneGraph::AbstractFeature3D{*this} {
setCachedTransformations(SceneGraph::CachedTransformation::Absolute);
}
protected:
void clean(const Matrix4& absoluteTransformation) override {
absolutePosition = absoluteTransformation.translation();
_absolutePosition = absoluteTransformation.translation();
}
private:
Vector3 absolutePosition;
Vector3 _absolutePosition;
};
@endcode
When you need to use the cached value, you can explicitly request the cleanup
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.
by calling @ref SceneGraph::Object::setClean(). @ref SceneGraph::Camera3D "Camera",
for example, calls it automatically before it starts rendering, as it needs its
own inverse transformation to properly draw the objects.
@subsection scenegraph-features-transformation Polymorphic access to object transformation
Features by default have access only to @ref SceneGraph::AbstractObject, which
doesn't know about any particular transformation implementation. This has the
advantage that features don't have to be implemented for all possible
transformation implementations. But, as a consequence, it is impossible to
transform the object using only pointer to @ref SceneGraph::AbstractObject.
To solve this, the transformation classes are subclassed from interfaces
sharing common functionality, so the feature can use that interface instead of
being specialized for all relevant transformation implementations. The
following interfaces are available, each having its own set of virtual
functions to control the transformation:
- @ref SceneGraph::AbstractTransformation "SceneGraph::AbstractTransformation*D" --
base for all transformations
- @ref SceneGraph::AbstractTranslation "SceneGraph::AbstractTranslation*D" --
base for all transformations providing translation
- @ref SceneGraph::AbstractBasicTranslationRotation2D "SceneGraph::AbstractTranslationRotation2D",
@ref SceneGraph::AbstractBasicTranslationRotation3D "SceneGraph::AbstractTranslationRotation3D" --
base for all transformations providing translation and rotation
- @ref SceneGraph::AbstractBasicTranslationRotationScaling2D "SceneGraph::AbstractBasicTranslationRotationScaling2D",
@ref SceneGraph::AbstractBasicTranslationRotationScaling3D "SceneGraph::AbstractBasicTranslationRotationScaling3D" --
base for all transformations providing translation, rotation and scaling
These interfaces provide virtual functions which can be used to modify object
transformations. The virtual calls are used only when calling through the
interface and not when using the concrete implementation directly to avoid
negative performance effects. There are no functions to retrieve object
transformation, you need to use the above transformation caching mechanism for
that.
In the following example we are able to get pointer to both
@ref SceneGraph::AbstractObject and needed transformation from one
constructor parameter using small trick:
@code
class TransformingFeature: public SceneGraph::AbstractFeature3D {
public:
template<class T> TransformingFeature(SceneGraph::Object<T>& object):
SceneGraph::AbstractFeature3D(object), transformation(object) {}
See @ref SceneGraph-AbstractFeature-subclassing-caching for more information.
private:
SceneGraph::AbstractTranslationRotation3D& transformation;
};
@endcode
If we take for example @ref SceneGraph::Object "SceneGraph::Object<MatrixTransformation3D>",
it is derived from @ref SceneGraph::AbstractObject "SceneGraph::AbstractObject3D"
and @ref SceneGraph::BasicMatrixTransformation3D "SceneGraph::MatrixTransformation3D",
thus the reference to @ref SceneGraph::AbstractBasicTranslationRotation3D "SceneGraph::AbstractTranslationRotation3D",
is automatically extracted from the reference in our constructor.
@section scenegraph-construction-order Construction and destruction order
@ -267,7 +363,7 @@ because `object` is created on stack. If this doesn't already crash, the
When destroying the object, all its features are destroyed. For features added
as member it's no issue, features added using multiple inheritance must be
inherited after the %Object class:
inherited after the Object class:
@code
class MyObject: public Object3D, MyFeature {
public:
@ -305,7 +401,7 @@ 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 plugins
- Previous page: @ref shaders
- Next page: @ref shapes
*/
}}
}

BIN
doc/shaders-distancefieldvector.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
doc/shaders-flat.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
doc/shaders-meshvisualizer.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
doc/shaders-phong.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
doc/shaders-vector.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
doc/shaders-vertexcolor.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

136
doc/shaders.dox

@ -0,0 +1,136 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
namespace Magnum {
/** @page shaders Builtin shaders
@brief Overview and basic usage of builtin shaders.
- Previous page: @ref plugins
- Next page: @ref scenegraph
@tableofcontents
Magnum contains a set of general-purpose shaders for easy prototyping, UI
rendering and data visualization/debugging in both 2D and 3D scenes. The
following shaders are available, see documentation of each class for sample
output and example setup:
- @ref Shaders::Flat "Shaders::Flat*D" -- flat shading using single color or
texture
- @ref Shaders::Vector "Shaders::Vector*D" -- colored vector graphics
- @ref Shaders::DistanceFieldVector "Shaders::DistanceFieldVector*D" --
colored and outlined vector graphics
- @ref Shaders::VertexColor "Shaders::VertexColor*D" -- vertex-colored meshes
- @ref Shaders::Phong -- Phong shading using colors or textures, 3D only
- @ref Shaders::MeshVisualizer -- wireframe visualization, 3D only
All the builtin shaders can be used on unextended OpenGL 2.1 and OpenGL ES 2.0
/ WebGL 1.0, but they try to use the most recent technology available to have
them as efficient as possible on every configuration.
@section shaders-usage Usage
Shader usage is divided into two parts: configuring vertex attributes in the
mesh and configuring the shader itself.
Each shader expects some set of vertex attributes, thus when adding vertex
buffer into the mesh, you need to specify which shader attributes are on which
position in the buffer. See @ref Mesh::addVertexBuffer() for details and usage
examples. Example mesh configuration for @ref Shaders::Phong shader:
@code
struct Vertex {
Vector3 position;
Vector3 normal;
Vector2 textureCoordinates;
};
Vertex data[] = { ... };
Buffer vertices;
vertices.setData(data, BufferUsage::StaticDraw);
Mesh mesh;
mesh.addVertexBuffer(vertices, 0,
Shaders::Phong::Position{},
Shaders::Phong::Normal{},
Shaders::Phong::TextureCoordinates{});
@endcode
Each shader then has its own set of configuration functions. Some configuration
is static, specified commonly as flags in constructor, directly affecting
compiled shader code. Other configuration is specified through uniforms and
various binding points, commonly exposed through various setters. Example
configuration and rendering using @ref Shaders::Phong "Shaders::Phong":
@code
Matrix4 transformationMatrix, projectionMatrix;
Texture2D diffuseTexture, specularTexture;
Shaders::Phong shader{Shaders::Phong::DiffuseTexture};
shader.setDiffuseTexture(diffuseTexture)
.setLightPosition({5.0f, 5.0f, 7.0f})
.setTransformationMatrix(transformationMatrix)
.setNormalMatrix(transformationMatrix.rotation())
.setProjectionMatrix(projectionMatrix);
mesh.draw(shader);
@endcode
@section shaders-generic Generic vertex attributes
Many shaders share the same vertex attribute definitions, such as positions,
normals, texture coordinates etc. It's thus possible to configure the mesh
for *generic* shader and then render it with any compatible shader. Definition
of generic attributes is available in @ref Shaders::Generic class.
Configuration of the above mesh using generic attributes could then look like
this:
@code
mesh.addVertexBuffer(vertices, 0,
Shaders::Generic3D::Position{},
Shaders::Generic3D::Normal{},
Shaders::Generic3D::TextureCoordinates{});
@endcode
Note that in this particular case both configurations are equivalent, because
@ref Shaders::Phong also uses generic vertex attribute definitions.
Then you can render the mesh using @ref Shaders::Phong shader like above, or
use for example @ref Shaders::Flat3D or even @ref Shaders::MeshVisualizer with
the same mesh reconfiguration. The unused attributes will be simply ignored.
@code
Shaders::MeshVisualizer visualizerShader{Shaders::MeshVisualizer::Wireframe};
visualizerShader.setColor(Color3::fromHSV(216.0_degf, 0.85f, 1.0f))
.setWireframeColor(Color3{0.95f})
.setViewportSize(defaultFramebuffer.viewport().size())
.setTransformationProjectionMatrix(projectionMatrix*transformationMatrix);
mesh.draw(visualizerShader);
@endcode
The @ref MeshTools::compile() utility configures meshes using generic vertex
attribute definitions to make them usable with any shader.
- Previous page: @ref plugins
- Next page: @ref scenegraph
*/
}

22
doc/shapes.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE.
*/
namespace Magnum { namespace Shapes {
namespace Magnum {
/** @page shapes Collision detection
@brief Collection of simple shapes for high performance collision detection.
@ -42,7 +42,7 @@ grouped together using various operations.
@section shapes-collection Available shapes
%Magnum provides a set of simple shapes for collision detection, similarly to
Magnum provides a set of simple shapes for collision detection, similarly to
what is found in many other collision detection libraries. Additionally some
shapes are provided in inverted form -- e.g. inverted box detects collisions on
outside instead of inside, which might be useful for example to create bounds
@ -55,7 +55,7 @@ around platformer game level.
- @ref Shapes::LineSegment "Shapes::LineSegment*D" -- @copybrief Shapes::LineSegment
Because of numerical instability it's not possible to detect collisions of
line and point. %Collision of two lines can be detected only in 2D.
line and point. Collision of two lines can be detected only in 2D.
@subsection shapes-2D Two-dimensional shapes
@ -76,7 +76,7 @@ is least efficient.
@section shapes-composition Creating shape compositions
%Shapes can be composed together using one of three available logical
Shapes can be composed together using one of three available logical
operations: AND, OR and NOT. These operations are mapped to `&&`, `||` and `!`
operators, so for example creating negation of logical OR of line segment and
point is simple as this:
@ -110,7 +110,7 @@ Shapes::Composition3D composition = simplified && (sphere || box);
@section shapes-collisions Detecting shape collisions
%Shape pairs which have collision occurence detection implemented can be tested
Shape pairs which have collision occurence detection implemented can be tested
for collision using the `%` operator. The operator returns boolean describing
whether the collision happened or not. Example:
@code
@ -124,9 +124,9 @@ As this is useful for e.g. menu handling and simple particle systems, for
serious physics you often need more information like contact point, separation
normal and penetration depth. For shape pairs which have implemented this
detailed collision detection you can use the `/` operator, which returns
@ref Collision object. Note that unlike with the `%` operator mentioned above,
this operation is not commutative. See @ref Collision class documentation for
more information about the returned data. Example:
@ref Shapes::Collision object. Note that unlike with the `%` operator mentioned
above, this operation is not commutative. See @ref Shapes::Collision class
documentation for more information about the returned data. Example:
@code
const Shapes::Collision3D c = point/sphere;
if(c) {
@ -137,7 +137,7 @@ if(c) {
@section shapes-scenegraph Integration with scene graph
%Shape can be attached to object in the scene using @ref Shapes::Shape feature.
Shape can be attached to object in the scene using @ref Shapes::Shape feature.
In conjunction with @ref Shapes::ShapeGroup you can use
@ref Shapes::Shape::collides() and @ref Shapes::Shape::collision() similarly to
the `%` and `/` operators above. Please note that the shape group caches the
@ -173,4 +173,4 @@ debugging purposes. See also @ref scenegraph for introduction.
- Next page: @ref debug-tools
*/
}}}
}

2
doc/tips.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a

220
doc/transformations.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE.
*/
namespace Magnum { namespace Math {
namespace Magnum {
/** @page transformations 2D and 3D transformations
@brief Introduction to essential operations on vectors and points.
@ -37,7 +37,7 @@ with CMake.
@tableofcontents
%Magnum provides classes for transformations in both 2D and 3D. Each class is
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.
@ -45,61 +45,63 @@ between various representations.
@section transformations-representation Representing transformations
The first and most straightforward way to represent transformations is to use
homogeneous transformation matrix, i.e. Matrix3 for 2D and Matrix4 for 3D. The
matrices are able to represent all possible types of transformations -- rotation,
translation, scaling, reflection etc. and also projective transformation, thus
they are used at the very core of graphics pipeline and are supported natively
in OpenGL.
On the other hand, matrices need 9 or 16 floats to represent the transformation,
which has implications on both memory usage and performance (relatively slow
matrix multiplication). It is also relatively hard to extract transformation
properties (such as rotation angle/axis) from them, interpolate between them or
compute inverse transformation. They suffer badly from so-called floating-point
drift -- e.g. after a few combined rotations the transformation won't be pure
rotation anymore, but will involve also a bit of scaling, shearing and whatnot.
However, you can trade some transformation features for improved performance and
better behavior -- for just a rotation you can use Complex in 2D and Quaternion
in 3D, or DualComplex and DualQuaternion if you want also translation. It is not
possible to represent scaling, reflection or other transformations with them,
but they occupy only 2 or 4 floats (4 or 8 floats in dual versions), can be
easily inverted and interpolated and have many other awesome properties. However,
they are not magic so they also suffer slightly from floating-point drift, but
not too much and the drift can be accounted for more easily than with matrices.
homogeneous transformation matrix, i.e. @ref Matrix3 for 2D and @ref Matrix4
for 3D. The matrices are able to represent all possible types of
transformations -- rotation, translation, scaling, reflection etc. and also
projective transformation, thus they are used at the very core of graphics
pipeline and are supported natively in OpenGL.
On the other hand, matrices need 9 or 16 floats to represent the
transformation, which has implications on both memory usage and performance
(relatively slow matrix multiplication). It is also relatively hard to extract
transformation properties (such as rotation angle/axis) from them, interpolate
between them or compute inverse transformation. They suffer badly from
so-called floating-point drift -- e.g. after a few combined rotations the
transformation won't be pure rotation anymore, but will involve also a bit of
scaling, shearing and whatnot.
However, you can trade some transformation features for improved performance
and better behavior -- for just a rotation you can use @ref Complex in 2D and
@ref Quaternion in 3D, or @ref DualComplex and @ref DualQuaternion if you want
also translation. It is not possible to represent scaling, reflection or other
transformations with them, but they occupy only 2 or 4 floats (4 or 8 floats in
dual versions), can be easily inverted and interpolated and have many other
awesome properties. However, they are not magic so they also suffer slightly
from floating-point drift, but not too much and the drift can be accounted for
more easily than with matrices.
@section transformations-types Transformation types
Transformation matrices and (dual) complex numbers or quaternions have completely
different internals, but they share the same API to achieve the same things,
greatly simplifying their usage. In many cases it is even possible to hot-swap
the transformation class type without changing any function calls.
Transformation matrices and (dual) complex numbers or quaternions have
completely different internals, but they share the same API to achieve the same
things, greatly simplifying their usage. In many cases it is even possible to
hot-swap the transformation class type without changing any function calls.
@subsection transformations-default Default (identity) transformation
Default-constructed Matrix3, Matrix4, Complex, Quaternion, DualComplex and
DualQuaternion represent identity transformation, so you don't need to worry
about them in initialization.
Default-constructed @ref Matrix3, @ref Matrix4, @ref Complex, @ref Quaternion,
@ref DualComplex and @ref DualQuaternion represent identity transformation, so
you don't need to worry about them in initialization.
@subsection transformations-rotation Rotation
2D rotation is represented solely by its angle in counterclockwise direction and
rotation transformation can be created by calling Matrix3::rotation(),
Complex::rotation() or DualComplex::rotation(), for example:
2D rotation is represented solely by its angle in counterclockwise direction
and rotation transformation can be created by calling @ref Matrix3::rotation(),
@ref Complex::rotation() or @ref DualComplex::rotation(), for example:
@code
auto a = Matrix3::rotation(23.0_degf);
auto b = Complex::rotation(Rad(Constants::pi()/2));
auto b = Complex::rotation(Rad(Constants::piHalf()));
auto c = DualComplex::rotation(-1.57_radf);
@endcode
3D rotation is represented by angle and (three-dimensional) axis. The rotation
can be created by calling Matrix4::rotation(), Quaternion::rotation() or
DualQuaternion::rotation(). The axis must be always of unit length to avoid
redundant normalization. Shortcuts Vector3::xAxis(), Vector3::yAxis() and
Vector3::zAxis() are provided for convenience. %Matrix representation has also
Matrix4::rotationX(), Matrix4::rotationY() and Matrix4::rotationZ() which are
faster than using the generic function for rotation around primary axes.
Examples:
can be created by calling @ref Matrix4::rotation(), @ref Quaternion::rotation()
or @ref DualQuaternion::rotation(). The axis must be always of unit length to
avoid redundant normalization. Shortcuts @ref Vector3::xAxis(),
@ref Vector3::yAxis() and @ref Vector3::zAxis() are provided for convenience.
Matrix representation has also @ref Matrix4::rotationX(),
@ref Matrix4::rotationY() and @ref Matrix4::rotationZ() which are faster than
using the generic function for rotation around primary axes. Examples:
@code
auto a = Quaternion::rotation(60.0_degf, Vector3::xAxis());
auto b = DualQuaternion::rotation(-1.0_degf, Vector3(1.0f, 0.5f, 3.0f).normalized());
@ -114,16 +116,17 @@ then translating back. Read below for more information.
@subsection transformations-translation Translation
2D translation is defined by two-dimensional vector and can be created with
Matrix3::translation() or DualComplex::translation(). You can use Vector2::xAxis()
or Vector2::yAxis() to translate only along given axis. Examples:
@ref Matrix3::translation() or @ref DualComplex::translation(). You can use
@ref Vector2::xAxis() or @ref Vector2::yAxis() to translate only along given
axis. Examples:
@code
auto a = Matrix3::translation(Vector2::xAxis(-5.0f));
auto b = DualComplex::translation({-1.0f, 0.5f});
@endcode
3D translation is defined by three-dimensional vector and can be created with
Matrix4::translation() or DualQuaternion::translation(). You can use
Vector3::xAxis() and friends also here. Examples:
@ref Matrix4::translation() or @ref DualQuaternion::translation(). You can use
@ref Vector3::xAxis() and friends also here. Examples:
@code
auto a = Matrix4::translation(vector);
auto b = DualQuaternion::translation(Vector3::zAxis(1.3f));
@ -132,11 +135,11 @@ auto b = DualQuaternion::translation(Vector3::zAxis(1.3f));
@subsection transformations-scaling Scaling and reflection
Scaling is defined by two- or three-dimensional vector and is represented by
matrices. You can create it with Matrix3::scaling() or Matrix4::scaling(). You
can use Vector3::xScale(), Vector3::yScale(), Vector3::zScale() or their 2D
counterparts to scale along one axis and leave the rest unchanged or call
explicit one-parameter vector constructor to scale uniformly on all axes.
Examples:
matrices. You can create it with @ref Matrix3::scaling() or @ref Matrix4::scaling().
You can use @ref Vector3::xScale(), @ref Vector3::yScale(), @ref Vector3::zScale()
or their 2D counterparts to scale along one axis and leave the rest unchanged
or call explicit one-parameter vector constructor to scale uniformly on all
axes. Examples:
@code
auto a = Matrix3::scaling(Vector2::xScale(2.0f));
auto b = Matrix4::scaling({2.0f, -2.0f, 1.5f});
@ -145,8 +148,9 @@ auto c = Matrix4::scaling(Vector3(10.0f));
Reflections are defined by normal along which to reflect (i.e., two- or
three-dimensional vector of unit length) and they are also represented by
matrices. Reflection is created with Matrix3::reflection() or Matrix4::reflection().
You can use Vector3::xAxis() and friends also here. Examples:
matrices. Reflection is created with @ref Matrix3::reflection() or
@ref Matrix4::reflection(). You can use @ref Vector3::xAxis() and friends also
here. Examples:
@code
auto a = Matrix3::reflection(Vector2::yAxis());
auto b = Matrix4::reflection(axis.normalized());
@ -161,15 +165,15 @@ operations more expensive, so it's not implemented.
@subsection transformations-projective Projective transformations
Projective transformations eploit the full potential of transformation matrices.
In 2D there is only one projection type, which can be created with Matrix3::projection()
and it is defined by area which will be projected into unit rectangle. In 3D
there is orthographic projection, created with Matrix4::orthographicProjection()
and defined by volume to project into unit cube, and perspective projection.
Perspective projection is created with Matrix4::perspectiveProjection() and is
defined either by field-of-view, aspect ratio and distance to near and far plane
of view frustum or by size of near plane, its distance and distance to far
plane. Some examples:
Projective transformations eploit the full potential of transformation
matrices. In 2D there is only one projection type, which can be created with
@ref Matrix3::projection() and it is defined by area which will be projected
into unit rectangle. In 3D there is orthographic projection, created with
@ref Matrix4::orthographicProjection() and defined by volume to project into
unit cube, and perspective projection. Perspective projection is created with
@ref Matrix4::perspectiveProjection() and is defined either by field-of-view,
aspect ratio and distance to near and far plane of view frustum or by size of
near plane, its distance and distance to far plane. Some examples:
@code
auto a = Matrix3::projection({4.0f, 3.0f});
auto b = Matrix4::orthographicProjection({4.0f, 3.0f, 100.0f});
@ -191,33 +195,34 @@ auto b = Matrix4::translation(Vector3::yAxis(5.0f))*
Matrix4::rotationY(25.0_degf);
@endcode
Inverse transformation can be computed using Matrix3::inverted(), Matrix4::inverted(),
Complex::inverted(), Quaternion::inverted(), DualComplex::inverted() or
DualQuaternion::inverted(). %Matrix inversion is quite costly, so if your
transformation involves only translation and rotation, you can use faster
alternatives Matrix3::invertedRigid() and Matrix4::invertedRigid(). If you are
sure that the (dual) complex number or (dual) quaternion is of unit length, you
can use Complex::invertedNormalized(), Quaternion::invertedNormalized(),
DualComplex::invertedNormalized() or DualQuaternion::invertedNormalized() which
is a little bit faster, because it doesn't need to renormalize the result.
Inverse transformation can be computed using @ref Matrix3::inverted(),
@ref Matrix4::inverted(), @ref Complex::inverted(), @ref Quaternion::inverted(),
@ref DualComplex::inverted() or @ref DualQuaternion::inverted(). Matrix
inversion is quite costly, so if your transformation involves only translation
and rotation, you can use faster alternatives @ref Matrix3::invertedRigid() and
@ref Matrix4::invertedRigid(). If you are sure that the (dual) complex number
or (dual) quaternion is of unit length, you can use @ref Complex::invertedNormalized(),
@ref Quaternion::invertedNormalized(), @ref DualComplex::invertedNormalized()
or @ref DualQuaternion::invertedNormalized() which is a little bit faster,
because it doesn't need to renormalize the result.
@section transformations-transforming Transforming vectors and points
Transformations can be used directly for transforming vectors and points. %Vector
transformation does not involve translation, in 2D can be done using
Matrix3::transformVector() and Complex::transformVector(), in 3D using
Matrix4::transformVector() and Quaternion::transformVector(). For transformation
with normalized quaternion you can use faster alternative Quaternion::transformVectorNormalized().
Example:
Transformations can be used directly for transforming vectors and points.
Vector transformation does not involve translation, in 2D can be done using
@ref Matrix3::transformVector() and @ref Complex::transformVector(), in 3D
using @ref Matrix4::transformVector() and @ref Quaternion::transformVector().
For transformation with normalized quaternion you can use faster alternative
@ref Quaternion::transformVectorNormalized(). Example:
@code
auto transformation = Matrix3::rotation(-30.0_degf)*Matrix3::scaling(Vector2(3.0f));
Vector2 transformed = transformation.transformVector({1.5f, -7.9f});
@endcode
Point transformation involves also translation, in 2D is done with
Matrix3::transformPoint() and DualComplex::transformPoint(), in 3D with
Matrix4::transformPoint() and DualQuaternion::transformPoint(). Also here you
can use faster alternative Quaternion::transformPointNormalized():
@ref Matrix3::transformPoint() and @ref DualComplex::transformPoint(), in 3D
with @ref Matrix4::transformPoint() and @ref DualQuaternion::transformPoint().
Also here you can use faster alternative @ref DualQuaternion::transformPointNormalized():
@code
auto transformation = DualQuaternion::rotation(-30.0_degf, Vector3::xAxis())*
DualQuaternion::translation(Vector3::yAxis(3.0f));
@ -239,22 +244,23 @@ Matrix3 b;
auto rotation = b.rotation();
Float xTranslation = b.translation().x();
@endcode
Extracting scaling and rotation from arbitrary transformation matrices is harder
and can be done using Algorithms::svd(). Extracting rotation angle (and axis in
3D) from rotation part is possible using by converting it to complex number or
quaternion, see below.
Extracting scaling and rotation from arbitrary transformation matrices is
harder and can be done using @ref Math::Algorithms::svd(). Extracting rotation
angle (and axis in 3D) from rotation part is possible using by converting it to
complex number or quaternion, see below.
You can also recreate transformation matrix from rotation and translation parts:
You can also recreate transformation matrix from rotation and translation
parts:
@code
Matrix3 c = Matrix3::from(rotation, {1.0f, 3.0f});
@endcode
%Complex numbers and quaternions are far better in this regard and they allow
you to extract rotation angle using Complex::angle() or Quaternion::angle() or
rotation axis in 3D using Quaternion::axis(). Their dual versions allow to
extract both rotation and translation part using DualComplex::rotation() const,
DualQuaternion::rotation() const, DualComplex::translation() const and
DualQuaternion::translation() const.
Complex numbers and quaternions are far better in this regard and they allow
you to extract rotation angle using @ref Complex::angle() or
@ref Quaternion::angle() or rotation axis in 3D using @ref Quaternion::axis().
Their dual versions allow to extract both rotation and translation part using
@ref DualComplex::rotation() const, @ref DualQuaternion::rotation() const,
@ref DualComplex::translation() const and @ref DualQuaternion::translation() const.
@code
DualComplex a;
Rad rotationAngle = a.rotation().angle();
@ -264,9 +270,10 @@ Quaternion b;
Vector3 rotationAxis = b.axis();
@endcode
You can convert Complex and Quaternion to rotation matrix using Complex::toMatrix()
and Quaternion::toMatrix() or their dual version to rotation and translation
matrix using DualComplex::toMatrix() and DualQuaternion::toMatrix():
You can convert Complex and Quaternion to rotation matrix using
@ref Complex::toMatrix() and @ref Quaternion::toMatrix() or their dual version
to rotation and translation matrix using @ref DualComplex::toMatrix() and
@ref DualQuaternion::toMatrix():
@code
Quaternion a;
auto rotation = Matrix4::from(a.toMatrix(), {});
@ -276,9 +283,9 @@ Matrix3 transformation = b.toMatrix();
@endcode
Conversion the other way around is possible only from rotation matrices using
Complex::fromMatrix() or Quaternion::fromMatrix() and from rotation and
translation matrices using DualComplex::fromMatrix() and
DualQuaternion::fromMatrix():
@ref Complex::fromMatrix() or @ref Quaternion::fromMatrix() and from rotation
and translation matrices using @ref DualComplex::fromMatrix() and
@ref DualQuaternion::fromMatrix():
@code
Matrix3 rotation;
auto a = Complex::fromMatrix(rotation.rotationScaling());
@ -300,19 +307,20 @@ accumulate rounding errors and behave strangely. For transformation matrices
this can't always be fixed, because they can represent any transformation (and
thus no algorithm can't tell if the transformation is in expected form or not).
If you restrict yourselves (e.g. only uniform scaling and no skew), the matrix
can be reorthogonalized using Algorithms::gramSchmidtOrthogonalize() (or
Algorithms::gramSchmidtOrthonormalize(), if you don't have any scaling). You can
also use Algorithms::svd() to more precisely (but way more slowly) account for
the drift. Example:
can be reorthogonalized using @ref Math::Algorithms::gramSchmidtOrthogonalize()
(or @ref Math::Algorithms::gramSchmidtOrthonormalize(), if you don't have any
scaling). You can also use @ref Math::Algorithms::svd() to more precisely (but
way more slowly) account for the drift. Example:
@code
Matrix4 transformation;
Math::Algorithms::gramSchmidtOrthonormalizeInPlace(transformation);
@endcode
For quaternions and complex number this problem can be solved far more easily
using Complex::normalized(), Quaternion::normalized(), DualComplex::normalized()
and DualQuaternion::normalized(). Transformation quaternions and complex numbers
are always of unit length, thus normalizing them reduces the drift.
using @ref Complex::normalized(), @ref Quaternion::normalized(),
@ref DualComplex::normalized() and @ref DualQuaternion::normalized().
Transformation quaternions and complex numbers are always of unit length, thus
normalizing them reduces the drift.
@code
DualQuaternion transformation;
transformation = transformation.normalized();
@ -321,4 +329,4 @@ transformation = transformation.normalized();
- Previous page: @ref matrix-vector
- Next page: @ref plugins
*/
}}
}

6
doc/troubleshooting.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -30,13 +30,13 @@ namespace Magnum {
@section troubleshooting-building Building issues
If your project suddenly stops building after %Magnum upgrade, check these
If your project suddenly stops building after Magnum upgrade, check these
things:
- If the building fails on CMake step, be sure that you have up-to-date
`FindCorrade.cmake`, `FindMagnum.cmake` and other CMake modules in your
project (`FindSDL2.cmake`). They are contained in `modules/` directory of
%Magnum sources (and sources of other projects) also are installed into
Magnum sources (and sources of other projects) also are installed into
`share/cmake/Magnum`.
- In some cases when the changes done to build system are too drastic,
recreating the build dir or clearing CMake cache is needed, but this is

12
doc/types.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -35,12 +35,12 @@ its documentation for more information about usage with CMake.
@section types-builtin Builtin types
%Magnum provides typedefs for builtin integral and floating-point arithmetic
Magnum provides typedefs for builtin integral and floating-point arithmetic
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 |
| Magnum type | Size | Equivalent GLSL type |
| ------------------ | -------------- | -------------------- |
| @ref UnsignedByte | 8bit unsigned | |
| @ref Byte | 8bit signed | |
@ -65,14 +65,14 @@ underlying type.
@section types-matrix Matrix/vector types
| %Magnum vector type | Equivalent GLSL type |
| Magnum vector type | Equivalent GLSL type |
| ---------------------------------------------- | ------------------------- |
| @ref Vector2, @ref Vector3, @ref Vector4 | `vec2`, `vec3`, `vec4` |
| @ref Vector2ui, @ref Vector3ui, @ref Vector4ui | `uvec2`, `uvec3`, `uvec4` |
| @ref Vector2i, @ref Vector3i, @ref Vector4i | `ivec2`, `ivec3`, `ivec4` |
| @ref Vector2d, @ref Vector3d, @ref Vector4d | `dvec2`, `dvec3`, `dvec4` |
| %Magnum matrix type | Equivalent GLSL type |
| 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` |
@ -103,7 +103,7 @@ to the internal data array.
@section types-special Special types
%Magnum has special type for strongly-typed representation of angles, namely
Magnum has special type for strongly-typed representation of angles, namely
the @ref Deg and @ref Rad classes (or @ref Degd and @ref Radd with @ref Double
as underlying type). Their only purpose is to avoid common degree-vs-radian
bugs (i.e. entering degree value where radians should be) and make the

2
doc/utilities.dox

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a

10
modules/CMakeLists.txt

@ -1,7 +1,7 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
@ -23,6 +23,8 @@
# DEALINGS IN THE SOFTWARE.
#
if(WITH_FIND_MODULE)
install(FILES FindMagnum.cmake DESTINATION ${MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR})
endif()
set(Magnum_MODULES
FindMagnum.cmake
MagnumConfig.cmake)
install(FILES ${Magnum_MODULES} DESTINATION ${MAGNUM_CMAKE_MODULE_INSTALL_DIR})

130
modules/FindCorrade.cmake

@ -14,6 +14,7 @@
# CORRADE_TESTSUITE_LIBRARIES - TestSuite library and dependent
# libraries
# CORRADE_RC_EXECUTABLE - Resource compiler executable
# CORRADE_LIB_SUFFIX_MODULE - Path to CorradeLibSuffix.cmake module
# The package is found if either debug or release version of each library is
# found. If both debug and release libraries are found, proper version is
# chosen based on actual build configuration of the project (i.e. Debug build
@ -26,9 +27,9 @@
# single-configuration build systems (such as Makefiles) this information is
# not needed and thus the variable is not defined in any case.
#
# Corrade configures the compiler to use C++11 standard. Additionally you can
# use CORRADE_CXX_FLAGS to enable additional pedantic set of warnings and
# enable hidden visibility by default.
# Corrade configures the compiler to use C++11 standard (if it is not already
# configured to do so). Additionally you can use CORRADE_CXX_FLAGS to enable
# additional pedantic set of warnings and enable hidden visibility by default.
#
# Features of found Corrade library are exposed in these variables:
# CORRADE_GCC47_COMPATIBILITY - Defined if compiled with compatibility
@ -57,10 +58,6 @@
# CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten
# CORRADE_TARGET_ANDROID - Defined if compiled for Android
#
# If CORRADE_BUILD_DEPRECATED is defined, the CORRADE_INCLUDE_DIR variable also
# contains path directly to Corrade directory (i.e. for includes without
# `Corrade/` prefix).
#
# Corrade provides these macros and functions:
#
#
@ -119,12 +116,14 @@
# CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found
# CORRADE_*_LIBRARY_RELEASE - Release version of given library, if
# found
# CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included
# automatically)
#
#
# This file is part of Corrade.
#
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
@ -174,7 +173,7 @@ endforeach()
find_program(CORRADE_RC_EXECUTABLE corrade-rc)
# Include dir
find_path(_CORRADE_INCLUDE_DIR
find_path(CORRADE_INCLUDE_DIR
NAMES Corrade/PluginManager Corrade/Utility)
# CMake module dir
@ -182,19 +181,13 @@ find_path(_CORRADE_MODULE_DIR
NAMES UseCorrade.cmake CorradeLibSuffix.cmake
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
CORRADE_INTERCONNECT_LIBRARY
CORRADE_PLUGINMANAGER_LIBRARY
CORRADE_TESTSUITE_LIBRARY
_CORRADE_INCLUDE_DIR
CORRADE_INCLUDE_DIR
CORRADE_RC_EXECUTABLE
_CORRADE_MODULE_DIR)
@ -202,75 +195,37 @@ if(NOT CORRADE_FOUND)
return()
endif()
# Configuration
file(READ ${_CORRADE_INCLUDE_DIR}/Corrade/configure.h _corradeConfigure)
# Compatibility?
string(FIND "${_corradeConfigure}" "#define CORRADE_GCC47_COMPATIBILITY" _GCC47_COMPATIBILITY)
if(NOT _GCC47_COMPATIBILITY EQUAL -1)
set(CORRADE_GCC47_COMPATIBILITY 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_GCC46_COMPATIBILITY" _GCC46_COMPATIBILITY)
if(NOT _GCC46_COMPATIBILITY EQUAL -1)
set(CORRADE_GCC46_COMPATIBILITY 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_GCC45_COMPATIBILITY" _GCC45_COMPATIBILITY)
if(NOT _GCC45_COMPATIBILITY EQUAL -1)
set(CORRADE_GCC45_COMPATIBILITY 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_GCC44_COMPATIBILITY" _GCC44_COMPATIBILITY)
if(NOT _GCC44_COMPATIBILITY EQUAL -1)
set(CORRADE_GCC44_COMPATIBILITY 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_MSVC2013_COMPATIBILITY" _MSVC2013_COMPATIBILITY)
if(NOT _MSVC2013_COMPATIBILITY EQUAL -1)
set(CORRADE_MSVC2013_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)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_UNIX" _TARGET_UNIX)
if(NOT _TARGET_UNIX EQUAL -1)
set(CORRADE_TARGET_UNIX 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_APPLE" _TARGET_APPLE)
if(NOT _TARGET_APPLE EQUAL -1)
set(CORRADE_TARGET_APPLE 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_WINDOWS" _TARGET_WINDOWS)
if(NOT _TARGET_WINDOWS EQUAL -1)
set(CORRADE_TARGET_WINDOWS 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_NACL" _TARGET_NACL)
if(NOT _TARGET_NACL EQUAL -1)
set(CORRADE_TARGET_NACL 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_NACL_NEWLIB" _TARGET_NACL_NEWLIB)
if(NOT _TARGET_NACL_NEWLIB EQUAL -1)
set(CORRADE_TARGET_NACL_NEWLIB 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_NACL_GLIBC" _TARGET_NACL_GLIBC)
if(NOT _TARGET_NACL_GLIBC EQUAL -1)
set(CORRADE_TARGET_NACL_GLIBC 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_EMSCRIPTEN" _TARGET_EMSCRIPTEN)
if(NOT _TARGET_EMSCRIPTEN EQUAL -1)
set(CORRADE_TARGET_EMSCRIPTEN 1)
endif()
string(FIND "${_corradeConfigure}" "#define CORRADE_TARGET_ANDROID" _TARGET_ANDROID)
if(NOT _TARGET_ANDROID EQUAL -1)
set(CORRADE_TARGET_ANDROID 1)
# Read flags from fonfiguration
file(READ ${CORRADE_INCLUDE_DIR}/Corrade/configure.h _corradeConfigure)
set(_corradeFlags
GCC47_COMPATIBILITY
GCC46_COMPATIBILITY
GCC45_COMPATIBILITY
GCC44_COMPATIBILITY
MSVC2013_COMPATIBILITY
BUILD_DEPRECATED
BUILD_STATIC
TARGET_UNIX
TARGET_APPLE
TARGET_WINDOWS
TARGET_NACL
TARGET_NACL_NEWLIB
TARGET_NACL_GLIBC
TARGET_EMSCRIPTEN
TARGET_ANDROID)
foreach(_corradeFlag ${_corradeFlags})
string(FIND "${_corradeConfigure}" "#define CORRADE_${_corradeFlag}" _corrade_${_corradeFlag})
if(NOT _corrade_${_corradeFlag} EQUAL -1)
set(CORRADE_${_corradeFlag} 1)
endif()
endforeach()
set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARY})
set(CORRADE_INTERCONNECT_LIBRARIES ${CORRADE_INTERCONNECT_LIBRARY} ${CORRADE_UTILITY_LIBRARIES})
set(CORRADE_PLUGINMANAGER_LIBRARIES ${CORRADE_PLUGINMANAGER_LIBRARY} ${CORRADE_UTILITY_LIBRARIES})
set(CORRADE_TESTSUITE_LIBRARIES ${CORRADE_TESTSUITE_LIBRARY} ${CORRADE_UTILITY_LIBRARIES})
set(CORRADE_USE_MODULE ${_CORRADE_MODULE_DIR}/UseCorrade.cmake)
set(CORRADE_LIB_SUFFIX_MODULE ${_CORRADE_MODULE_DIR}/CorradeLibSuffix.cmake)
# At least static build needs this
if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL_GLIBC)
@ -282,20 +237,7 @@ if(CORRADE_TARGET_ANDROID)
set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARIES} log)
endif()
mark_as_advanced(_CORRADE_INCLUDE_DIR
_CORRADE_MODULE_DIR)
# Add Corrade dir to include path if this is deprecated build
if(CORRADE_BUILD_DEPRECATED)
set(CORRADE_INCLUDE_DIR ${_CORRADE_INCLUDE_DIR} ${CORRADE_INCLUDE_DIR}/Corrade)
else()
set(CORRADE_INCLUDE_DIR ${_CORRADE_INCLUDE_DIR})
endif()
# Include our module dir, if we have any
if(NOT "${_CORRADE_MODULE_DIR}" STREQUAL "${CMAKE_ROOT}/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${_CORRADE_MODULE_DIR}")
endif()
mark_as_advanced(_CORRADE_MODULE_DIR)
# Finalize the finding process
include(UseCorrade)
include(${CORRADE_USE_MODULE})

9
modules/FindEGL.cmake

@ -10,7 +10,7 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
@ -37,12 +37,9 @@ find_library(EGL_LIBRARY EGL)
# Include dir
find_path(EGL_INCLUDE_DIR
NAMES egl.h
PATH_SUFFIXES EGL
)
NAMES EGL/egl.h)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("EGL" DEFAULT_MSG
EGL_LIBRARY
EGL_INCLUDE_DIR
)
EGL_INCLUDE_DIR)

171
modules/FindMagnum.cmake

@ -34,23 +34,20 @@
# OpenGL ES libraries). Additional dependencies are specified by the
# components. The optional components are:
# Audio - Audio library
# DebugTools - DebugTools library (depends on MeshTools, Primitives,
# SceneGraph, Shaders and Shapes components)
# DebugTools - DebugTools library
# MeshTools - MeshTools library
# Primitives - Primitives library
# SceneGraph - SceneGraph library
# Shaders - Shaders library
# Shapes - Shapes library (depends on SceneGraph component)
# Text - Text library (depends on TextureTools component)
# Shapes - Shapes library
# Text - Text library
# TextureTools - TextureTools library
# MagnumFont - Magnum bitmap font plugin (depends on Text component
# and TgaImporter plugin)
# MagnumFontConverter - Magnum bitmap font converter plugin (depends on Text
# component and TgaImageConverter plugin)
# MagnumFont - Magnum bitmap font plugin
# MagnumFontConverter - Magnum bitmap font converter plugin
# ObjImporter - OBJ importer plugin
# TgaImageConverter - TGA image converter plugin
# TgaImporter - TGA importer plugin
# WavAudioImporter - WAV audio importer plugin (depends on Audio component)
# WavAudioImporter - WAV audio importer plugin
# GlutApplication - GLUT application
# GlxApplication - GLX application
# NaClApplication - NaCl application
@ -101,11 +98,6 @@
# emulation on desktop OpenGL
# MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL
#
# If MAGNUM_BUILD_DEPRECATED is defined, the MAGNUM_INCLUDE_DIR variable also
# contains path directly to Magnum directory (i.e. for includes without
# Magnum/ prefix) and MAGNUM_PLUGINS_INCLUDE_DIR contains include dir for
# plugins (i.e. for includes without MagnumPlugins/ prefix).
#
# Additionally these variables are defined for internal usage:
# MAGNUM_INCLUDE_DIR - Root include dir (w/o dependencies)
# MAGNUM_LIBRARY - Magnum library (w/o dependencies)
@ -116,6 +108,7 @@
# MAGNUM_*_LIBRARY_RELEASE - Release version of given library, if found
# MAGNUM_BINARY_INSTALL_DIR - Binary installation directory
# MAGNUM_LIBRARY_INSTALL_DIR - Library installation directory
# MAGNUM_DATA_INSTALL_DIR - Data installation directory
# MAGNUM_PLUGINS_[DEBUG|RELEASE]_INSTALL_DIR - Plugin installation directory
# MAGNUM_PLUGINS_FONT_[DEBUG|RELEASE]_INSTALL_DIR - Font plugin installation
# directory
@ -127,8 +120,6 @@
# installation directory
# MAGNUM_PLUGINS_AUDIOIMPORTER_[DEBUG|RELEASE]_INSTALL_DIR - Audio importer
# plugin installation directory
# MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR - Installation dir for CMake Find*
# modules
# MAGNUM_INCLUDE_INSTALL_DIR - Header installation directory
# MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR - Plugin header installation directory
#
@ -136,7 +127,7 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
@ -199,35 +190,20 @@ endif()
# Configuration
file(READ ${MAGNUM_INCLUDE_DIR}/Magnum/configure.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)
endif()
string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_GLES" _TARGET_GLES)
if(NOT _TARGET_GLES EQUAL -1)
set(MAGNUM_TARGET_GLES 1)
endif()
string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_GLES2" _TARGET_GLES2)
if(NOT _TARGET_GLES2 EQUAL -1)
set(MAGNUM_TARGET_GLES2 1)
endif()
string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_GLES3" _TARGET_GLES3)
if(NOT _TARGET_GLES3 EQUAL -1)
set(MAGNUM_TARGET_GLES3 1)
endif()
string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_DESKTOP_GLES" _TARGET_DESKTOP_GLES)
if(NOT _TARGET_DESKTOP_GLES EQUAL -1)
set(MAGNUM_TARGET_DESKTOP_GLES 1)
endif()
string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_WEBGL" _TARGET_WEBGL)
if(NOT _TARGET_WEBGL EQUAL -1)
set(MAGNUM_TARGET_WEBGL 1)
set(_magnumFlags
BUILD_DEPRECATED
BUILD_STATIC
TARGET_GLES
TARGET_GLES2
TARGET_GLES3
TARGET_DESKTOP_GLES
TARGET_WEBGL)
foreach(_magnumFlag ${_magnumFlags})
string(FIND "${_magnumConfigure}" "#define MAGNUM_${_magnumFlag}" _magnum_${_magnumFlag})
if(NOT _magnum_${_magnumFlag} EQUAL -1)
set(MAGNUM_${_magnumFlag} 1)
endif()
endforeach()
# Dependent libraries and includes
set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR}
@ -247,15 +223,44 @@ elseif(MAGNUM_TARGET_GLES3)
set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGLES3_LIBRARY})
endif()
# On Windows and in static builds, *Application libraries need to have
# ${MAGNUM_LIBRARIES} listed in dependencies also after all other library names
# to avoid linker errors. Applicaiton libraries are often last thus it is
# +- sufficient to add it there only.
if(CORRADE_TARGET_WINDOWS OR MAGNUM_BUILD_STATIC)
set(_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY ${MAGNUM_LIBRARIES})
# Ensure that all inter-component dependencies are specified as well
set(_MAGNUM_ADDITIONAL_COMPONENTS )
foreach(component ${Magnum_FIND_COMPONENTS})
string(TOUPPER ${component} _COMPONENT)
# The dependencies need to be sorted by their dependency order as well
if(component STREQUAL Shapes)
set(_MAGNUM_${_COMPONENT}_DEPENDENCIES SceneGraph)
elseif(component STREQUAL Text)
set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TextureTools)
elseif(component STREQUAL DebugTools)
set(_MAGNUM_${_COMPONENT}_DEPENDENCIES MeshTools Primitives SceneGraph Shaders Shapes)
elseif(component STREQUAL MagnumFont)
set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TgaImporter) # and below
elseif(component STREQUAL MagnumFontConverter)
set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TgaImageConverter) # and below
elseif(component STREQUAL ObjImporter)
set(_MAGNUM_${_COMPONENT}_DEPENDENCIES MeshTools)
endif()
if(component MATCHES ".+AudioImporter")
set(_MAGNUM_${_COMPONENT}_DEPENDENCIES Audio)
elseif(component MATCHES ".+(Font|FontConverter)")
set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TextureTools Text)
endif()
list(APPEND _MAGNUM_ADDITIONAL_COMPONENTS ${_MAGNUM_${_COMPONENT}_DEPENDENCIES})
endforeach()
# Join the lists, remove duplicate components
if(_MAGNUM_ADDITIONAL_COMPONENTS)
list(INSERT Magnum_FIND_COMPONENTS 0 ${_MAGNUM_ADDITIONAL_COMPONENTS})
endif()
if(Magnum_FIND_COMPONENTS)
list(REMOVE_DUPLICATES Magnum_FIND_COMPONENTS)
endif()
# Additional components
# Find all components
foreach(component ${Magnum_FIND_COMPONENTS})
string(TOUPPER ${component} _COMPONENT)
@ -352,7 +357,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
endif()
# Applications
if(${component} MATCHES .+Application)
if(${component} MATCHES ".+Application")
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform)
# Android application dependencies
@ -411,13 +416,8 @@ foreach(component ${Magnum_FIND_COMPONENTS})
endif()
endif()
# Common application dependencies
set(_MAGNUM_${_COMPONENT}_LIBRARIES
${_MAGNUM_${_COMPONENT}_LIBRARIES}
${_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY})
# Context libraries
elseif(${component} MATCHES .+Context)
elseif(${component} MATCHES ".+Context")
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Context.h)
@ -454,6 +454,8 @@ foreach(component ${Magnum_FIND_COMPONENTS})
unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif()
# No special setup for DebugTools library
# Mesh tools library
elseif(${component} STREQUAL MeshTools)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h)
@ -462,13 +464,17 @@ foreach(component ${Magnum_FIND_COMPONENTS})
elseif(${component} STREQUAL Primitives)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Cube.h)
# No special setup for SceneGraph library
# No special setup for Shaders library
# No special setup for Shapes library
# No special setup for Text library
# TextureTools library
elseif(${component} STREQUAL TextureTools)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Atlas.h)
endif()
# The plugins don't have any dependencies, nothing additional to do for
# them
# No special setup for plugins
# Try to find the includes
if(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES)
@ -477,10 +483,30 @@ foreach(component ${Magnum_FIND_COMPONENTS})
PATHS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX})
endif()
# Add inter-project dependencies, mark the component as not found if
# any dependency is not found
set(_MAGNUM_${_COMPONENT}_DEPENDENCY_LIBRARIES )
set(_MAGNUM_${_COMPONENT}_DEPENDENCY_INCLUDE_DIRS )
foreach(dependency ${_MAGNUM_${_COMPONENT}_DEPENDENCIES})
string(TOUPPER ${dependency} _DEPENDENCY)
if(MAGNUM_${_DEPENDENCY}_LIBRARY)
list(APPEND _MAGNUM_${_COMPONENT}_DEPENDENCY_LIBRARIES ${MAGNUM_${_DEPENDENCY}_LIBRARY} ${_MAGNUM_${_DEPENDENCY}_LIBRARIES})
list(APPEND _MAGNUM_${_COMPONENT}_DEPENDENCY_INCLUDE_DIRS ${MAGNUM_${_DEPENDENCY}_INCLUDE_DIRS})
else()
unset(MAGNUM_${_DEPENDENCY}_LIBRARY)
endif()
endforeach()
# Decide if the library was found
if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR)
set(MAGNUM_${_COMPONENT}_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARY} ${_MAGNUM_${_COMPONENT}_LIBRARIES})
set(MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${_MAGNUM_${_COMPONENT}_INCLUDE_DIRS})
set(MAGNUM_${_COMPONENT}_LIBRARIES
${MAGNUM_${_COMPONENT}_LIBRARY}
${_MAGNUM_${_COMPONENT}_LIBRARIES}
${_MAGNUM_${_COMPONENT}_DEPENDENCY_LIBRARIES}
${MAGNUM_LIBRARIES})
set(MAGNUM_${_COMPONENT}_INCLUDE_DIRS
${_MAGNUM_${_COMPONENT}_INCLUDE_DIRS}
${_MAGNUM_${_COMPONENT}_DEPENDENCY_INCLUDE_DIRS})
set(Magnum_${component}_FOUND TRUE)
@ -493,7 +519,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
# Global aliases for Windowless*Application and *Application
# components. If already set, unset them to avoid ambiguity.
if(${component} MATCHES Windowless.+Application)
if(${component} MATCHES "Windowless.+Application")
if(NOT DEFINED MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES AND NOT DEFINED MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS)
set(MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES})
set(MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS})
@ -501,7 +527,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
unset(MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES)
unset(MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS)
endif()
elseif(${component} MATCHES .+Application)
elseif(${component} MATCHES ".+Application")
if(NOT DEFINED MAGNUM_APPLICATION_LIBRARIES AND NOT DEFINED MAGNUM_APPLICATION_INCLUDE_DIRS)
set(MAGNUM_APPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES})
set(MAGNUM_APPLICATION_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS})
@ -513,7 +539,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
# Global aliases for *Context components. If already set, unset them to
# avoid ambiguity.
if(${component} MATCHES .+Context)
if(${component} MATCHES ".+Context")
if(NOT DEFINED MAGNUM_CONTEXT_LIBRARIES AND NOT DEFINED MAGNUM_CONTEXT_INCLUDE_DIRS)
set(MAGNUM_CONTEXT_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES})
set(MAGNUM_CONTEXT_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS})
@ -533,9 +559,10 @@ find_package_handle_standard_args(Magnum
HANDLE_COMPONENTS)
# Installation dirs
include(CorradeLibSuffix)
include(${CORRADE_LIB_SUFFIX_MODULE})
set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(MAGNUM_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/magnum)
set(MAGNUM_PLUGINS_DEBUG_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum-d)
set(MAGNUM_PLUGINS_RELEASE_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum)
set(MAGNUM_PLUGINS_FONT_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}/fonts)
@ -548,7 +575,6 @@ set(MAGNUM_PLUGINS_IMPORTER_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR
set(MAGNUM_PLUGINS_IMPORTER_RELEASE_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_INSTALL_DIR}/importers)
set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}/audioimporters)
set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_INSTALL_DIR}/audioimporters)
set(MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR ${CMAKE_ROOT}/Modules)
set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumPlugins)
mark_as_advanced(FORCE
@ -574,15 +600,6 @@ mark_as_advanced(FORCE
MAGNUM_INCLUDE_INSTALL_DIR
MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR)
# Add Magnum dir to include path and create MAGNUM_PLUGINS_INCLUDE_DIR if this
# is deprecated build
if(MAGNUM_BUILD_DEPRECATED)
set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIRS}
${MAGNUM_INCLUDE_DIR}/Magnum
${MAGNUM_INCLUDE_DIR}/MagnumExternal)
set(MAGNUM_PLUGINS_INCLUDE_DIR ${MAGNUM_INCLUDE_DIR}/MagnumPlugins)
endif()
# Get base plugin directory from main library location
set(MAGNUM_PLUGINS_DEBUG_DIR ${_MAGNUM_LIBRARY_PATH}/magnum-d
CACHE PATH "Base directory where to look for Magnum plugins for debug builds")

9
modules/FindOpenGLES2.cmake

@ -10,7 +10,7 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
@ -43,12 +43,9 @@ endif()
# Include dir
find_path(OPENGLES2_INCLUDE_DIR
NAMES gl2.h
PATH_SUFFIXES GLES2
)
NAMES GLES2/gl2.h)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("OpenGLES2" DEFAULT_MSG
${OPENGLES2_LIBRARY_NEEDED}
OPENGLES2_INCLUDE_DIR
)
OPENGLES2_INCLUDE_DIR)

9
modules/FindOpenGLES3.cmake

@ -10,7 +10,7 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
@ -42,12 +42,9 @@ find_library(OPENGLES3_LIBRARY NAMES
# Include dir
find_path(OPENGLES3_INCLUDE_DIR
NAMES gl3.h
PATH_SUFFIXES GLES3
)
NAMES GLES3/gl3.h)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("OpenGLES3" DEFAULT_MSG
OPENGLES3_LIBRARY
OPENGLES3_INCLUDE_DIR
)
OPENGLES3_INCLUDE_DIR)

2
modules/FindSDL2.cmake

@ -10,7 +10,7 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a

26
modules/MagnumConfig.cmake

@ -0,0 +1,26 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
include(${CMAKE_CURRENT_LIST_DIR}/FindMagnum.cmake)

15
package/archlinux/PKGBUILD

@ -2,18 +2,20 @@
pkgname=magnum
pkgver=dev
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2')
makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
mkdir -p "$startdir/build"
cd "$startdir/build"
mkdir -p "$_rootdir/build"
cd "$_rootdir/build"
# Disable optimization (saves A LOT of compilation time)
newcxxflags=$(echo $CXXFLAGS | sed s/-O.//g | sed s/-D_FORTIFY_SOURCE=.//g)
@ -26,6 +28,7 @@ build() {
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
@ -45,11 +48,11 @@ build() {
}
check() {
cd "$startdir/build"
cd "$_rootdir/build"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build"
cd "$_rootdir/build"
DESTDIR="$pkgdir/" ninja install
}

22
package/archlinux/PKGBUILD-android-arm

@ -2,28 +2,30 @@
pkgname=android-arm-magnum
pkgver=dev
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (Android ARM)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (Android ARM)"
arch=('any')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('android-arm-corrade')
makedepends=('cmake' 'ninja' 'android-ndk')
options=('!strip' '!buildflags' 'staticlibs')
makedepends=('cmake' 'ninja' 'android-ndk' 'corrade')
options=('!strip' '!buildflags')
_rootdir=$startdir/../../
build() {
if [ ! -d "$startdir/build-android-arm" ] ; then
mkdir "$startdir/build-android-arm"
cd "$startdir/build-android-arm"
if [ ! -d "$_rootdir/build-android-arm" ] ; then
mkdir "$_rootdir/build-android-arm"
cd "$_rootdir/build-android-arm"
cmake .. \
-DCMAKE_MODULE_PATH="$startdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$startdir/toolchains/generic/Android-ARM.cmake" \
-DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Android-ARM.cmake" \
-DTARGET_GLES=ON \
-DTARGET_GLES2=ON \
-G Ninja
fi
cd "$startdir/build-android-arm"
cd "$_rootdir/build-android-arm"
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
@ -38,6 +40,6 @@ build() {
}
package() {
cd "$startdir/build-android-arm"
cd "$_rootdir/build-android-arm"
DESTDIR="$pkgdir/" ninja install/strip
}

22
package/archlinux/PKGBUILD-android-x86

@ -2,28 +2,30 @@
pkgname=android-x86-magnum
pkgver=dev
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (Android x86)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (Android x86)"
arch=('any')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('android-x86-corrade')
makedepends=('cmake' 'ninja' 'android-ndk')
options=('!strip' '!buildflags' 'staticlibs')
makedepends=('cmake' 'ninja' 'android-ndk 'corrade'')
options=('!strip' '!buildflags')
_rootdir=$startdir/../../
build() {
if [ ! -d "$startdir/build-android-x86" ] ; then
mkdir "$startdir/build-android-x86"
cd "$startdir/build-android-x86"
if [ ! -d "$_rootdir/build-android-x86" ] ; then
mkdir "$_rootdir/build-android-x86"
cd "$_rootdir/build-android-x86"
cmake .. \
-DCMAKE_MODULE_PATH="$startdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$startdir/toolchains/generic/Android-x86.cmake" \
-DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Android-x86.cmake" \
-DTARGET_GLES=ON \
-DTARGET_GLES2=ON \
-G Ninja
fi
cd "$startdir/build-android-x86"
cd "$_rootdir/build-android-x86"
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
@ -38,6 +40,6 @@ build() {
}
package() {
cd "$startdir/build-android-x86"
cd "$_rootdir/build-android-x86"
DESTDIR="$pkgdir/" ninja install/strip
}

18
package/archlinux/PKGBUILD-clang

@ -2,26 +2,28 @@
pkgname=magnum
pkgver=dev.clang
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (built with clang)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (built with clang)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2')
makedepends=('cmake' 'clang' 'ninja')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
if [ ! -d "$startdir/build-clang" ] ; then
mkdir "$startdir/build-clang"
cd "$startdir/build-clang"
if [ ! -d "$_rootdir/build-clang" ] ; then
mkdir "$_rootdir/build-clang"
cd "$_rootdir/build-clang"
cmake .. \
-DCMAKE_CXX_COMPILER=clang++ \
-G Ninja
fi
cd "$startdir/build-clang"
cd "$_rootdir/build-clang"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
@ -48,11 +50,11 @@ build() {
}
check() {
cd "$startdir/build-clang"
cd "$_rootdir/build-clang"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build-clang"
cd "$_rootdir/build-clang"
DESTDIR="$pkgdir/" ninja install
}

19
package/archlinux/PKGBUILD-clang-libc++

@ -2,19 +2,21 @@
pkgname=magnum
pkgver=dev.clang.libc++
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (built with clang and libc++)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (built with clang and libc++)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2' 'libc++')
makedepends=('cmake' 'clang' 'ninja')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
if [ ! -d "$startdir/build-clang-libc++" ] ; then
mkdir "$startdir/build-clang-libc++"
cd "$startdir/build-clang-libc++"
if [ ! -d "$_rootdir/build-clang-libc++" ] ; then
mkdir "$_rootdir/build-clang-libc++"
cd "$_rootdir/build-clang-libc++"
cmake .. \
-DCMAKE_CXX_COMPILER=clang++ \
@ -23,7 +25,7 @@ build() {
-G Ninja
fi
cd "$startdir/build-clang-libc++"
cd "$_rootdir/build-clang-libc++"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
@ -32,6 +34,7 @@ build() {
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
@ -50,11 +53,11 @@ build() {
}
check() {
cd "$startdir/build-clang-libc++"
cd "$_rootdir/build-clang-libc++"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build-clang-libc++"
cd "$_rootdir/build-clang-libc++"
DESTDIR="$pkgdir/" ninja install
}

22
package/archlinux/PKGBUILD-emscripten

@ -2,26 +2,28 @@
pkgname=emscripten-magnum
pkgver=dev
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (Emscripten)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (Emscripten)"
arch=('any')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('emscripten-corrade')
makedepends=('cmake' 'ninja' 'emscripten-git')
options=('!strip' '!buildflags' 'staticlibs')
makedepends=('cmake' 'ninja' 'emscripten' 'corrade')
options=('!strip' '!buildflags')
_rootdir=$startdir/../../
build() {
if [ ! -d "$startdir/build-emscripten" ] ; then
mkdir "$startdir/build-emscripten"
cd "$startdir/build-emscripten"
if [ ! -d "$_rootdir/build-emscripten" ] ; then
mkdir "$_rootdir/build-emscripten"
cd "$_rootdir/build-emscripten"
cmake .. \
-DCMAKE_MODULE_PATH="$startdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$startdir/toolchains/generic/Emscripten.cmake" \
-DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Emscripten.cmake" \
-G Ninja
fi
cd "$startdir/build-emscripten"
cd "$_rootdir/build-emscripten"
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
@ -36,6 +38,6 @@ build() {
}
package() {
cd "$startdir/build-emscripten"
cd "$_rootdir/build-emscripten"
DESTDIR="$pkgdir/" ninja install
}

14
package/archlinux/PKGBUILD-es2

@ -2,18 +2,20 @@
pkgname=magnum
pkgver=dev.es2
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (OpenGL ES 2.0 version)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (OpenGL ES 2.0 version)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal')
makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
mkdir -p "$startdir/build-es2"
cd "$startdir/build-es2"
mkdir -p "$_rootdir/build-es2"
cd "$_rootdir/build-es2"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
@ -34,11 +36,11 @@ build() {
}
check() {
cd "$startdir/build-es2"
cd "$_rootdir/build-es2"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build-es2"
cd "$_rootdir/build-es2"
DESTDIR="$pkgdir/" ninja install
}

17
package/archlinux/PKGBUILD-es2desktop

@ -2,18 +2,20 @@
pkgname=magnum
pkgver=dev.es2desktop
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (desktop OpenGL ES 2.0 version)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (desktop OpenGL ES 2.0 version)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal')
makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
mkdir -p "$startdir/build-es2desktop"
cd "$startdir/build-es2desktop"
mkdir -p "$_rootdir/build-es2desktop"
cd "$_rootdir/build-es2desktop"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
@ -22,8 +24,9 @@ build() {
-DTARGET_GLES2=ON \
-DTARGET_DESKTOP_GLES=ON \
-DWITH_AUDIO=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
@ -40,11 +43,11 @@ build() {
}
check() {
cd "$startdir/build-es2desktop"
cd "$_rootdir/build-es2desktop"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build-es2desktop"
cd "$_rootdir/build-es2desktop"
DESTDIR="$pkgdir/" ninja install
}

14
package/archlinux/PKGBUILD-es3

@ -2,18 +2,20 @@
pkgname=magnum
pkgver=dev.es3
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (OpenGL ES 3.0 version)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (OpenGL ES 3.0 version)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal')
makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
mkdir -p "$startdir/build-es3"
cd "$startdir/build-es3"
mkdir -p "$_rootdir/build-es3"
cd "$_rootdir/build-es3"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
@ -34,11 +36,11 @@ build() {
}
check() {
cd "$startdir/build-es3"
cd "$_rootdir/build-es3"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build-es3"
cd "$_rootdir/build-es3"
DESTDIR="$pkgdir/" ninja install
}

17
package/archlinux/PKGBUILD-es3desktop

@ -2,18 +2,20 @@
pkgname=magnum
pkgver=dev.es3desktop
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (desktop OpenGL ES 3.0 version)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (desktop OpenGL ES 3.0 version)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal')
makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
mkdir -p "$startdir/build-es3desktop"
cd "$startdir/build-es3desktop"
mkdir -p "$_rootdir/build-es3desktop"
cd "$_rootdir/build-es3desktop"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
@ -22,8 +24,9 @@ build() {
-DTARGET_GLES2=OFF \
-DTARGET_DESKTOP_GLES=ON \
-DWITH_AUDIO=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
@ -40,11 +43,11 @@ build() {
}
check() {
cd "$startdir/build-es3desktop"
cd "$_rootdir/build-es3desktop"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build-es3desktop"
cd "$_rootdir/build-es3desktop"
DESTDIR="$pkgdir/" ninja install
}

19
package/archlinux/PKGBUILD-gcc47

@ -2,26 +2,28 @@
pkgname=magnum
pkgver=dev.gcc47
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (built with GCC 4.7)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (built with GCC 4.7)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2')
makedepends=('cmake' 'ninja' 'gcc47')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
if [ ! -d "$startdir/build-gcc47" ] ; then
mkdir "$startdir/build-gcc47"
cd "$startdir/build-gcc47"
if [ ! -d "$_rootdir/build-gcc47" ] ; then
mkdir "$_rootdir/build-gcc47"
cd "$_rootdir/build-gcc47"
cmake .. \
-DCMAKE_CXX_COMPILER=g++-4.7 \
-G Ninja
fi
cd "$startdir/build-gcc47"
cd "$_rootdir/build-gcc47"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
@ -30,6 +32,7 @@ build() {
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
@ -48,11 +51,11 @@ build() {
}
check() {
cd "$startdir/build-gcc47"
cd "$_rootdir/build-gcc47"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build-gcc47"
cd "$_rootdir/build-gcc47"
DESTDIR="$pkgdir/" ninja install
}

18
package/archlinux/PKGBUILD-mingw-w64

@ -2,17 +2,19 @@
pkgname=mingw-w64-magnum
pkgver=dev
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (mingw-w64)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (mingw-w64)"
arch=('any')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('mingw-w64-crt' 'mingw-w64-corrade' 'mingw-w64-freeglut' 'mingw-w64-sdl2' 'mingw-w64-openal')
makedepends=('mingw-w64-gcc' 'cmake' 'ninja' 'corrade')
options=('!buildflags' '!strip' 'staticlibs')
options=('!buildflags' '!strip')
_rootdir=$startdir/../../
build() {
mkdir -p "$startdir/build-mingw-w64-32"
cd "$startdir/build-mingw-w64-32"
mkdir -p "$_rootdir/build-mingw-w64-32"
cd "$_rootdir/build-mingw-w64-32"
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../toolchains/archlinux/basic-mingw-w64-32.cmake \
@ -36,8 +38,8 @@ build() {
-G Ninja
ninja
mkdir -p "$startdir/build-mingw-w64-64"
cd "$startdir/build-mingw-w64-64"
mkdir -p "$_rootdir/build-mingw-w64-64"
cd "$_rootdir/build-mingw-w64-64"
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../toolchains/archlinux/basic-mingw-w64-64.cmake \
@ -62,9 +64,9 @@ build() {
}
package() {
cd "$startdir/build-mingw-w64-32"
cd "$_rootdir/build-mingw-w64-32"
DESTDIR="$pkgdir/" ninja install/strip
cd "$startdir/build-mingw-w64-64"
cd "$_rootdir/build-mingw-w64-64"
DESTDIR="$pkgdir/" ninja install/strip
}

26
package/archlinux/PKGBUILD-nacl-glibc

@ -2,22 +2,24 @@
pkgname=nacl-magnum
pkgver=dev.glibc
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (NaCl glibc version)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (NaCl glibc version)"
arch=('any')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('nacl-corrade')
makedepends=('nacl-sdk' 'cmake' 'corrade' 'ninja')
options=('!buildflags' '!strip' 'staticlibs')
options=('!strip' '!buildflags')
_rootdir=$startdir/../../
build() {
# Build 32bit
mkdir -p "$startdir/build-nacl-glibc-x86-32"
cd "$startdir/build-nacl-glibc-x86-32"
mkdir -p "$_rootdir/build-nacl-glibc-x86-32"
cd "$_rootdir/build-nacl-glibc-x86-32"
cmake .. \
-DCMAKE_MODULE_PATH="$startdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$startdir/toolchains/generic/NaCl-glibc-x86-32.cmake" \
-DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-glibc-x86-32.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_MAGNUMINFO=OFF \
@ -33,12 +35,12 @@ build() {
ninja
# Build 64bit
mkdir -p "$startdir/build-nacl-glibc-x86-64"
cd "$startdir/build-nacl-glibc-x86-64"
mkdir -p "$_rootdir/build-nacl-glibc-x86-64"
cd "$_rootdir/build-nacl-glibc-x86-64"
cmake .. \
-DCMAKE_MODULE_PATH="$startdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$startdir/toolchains/generic/NaCl-glibc-x86-64.cmake" \
-DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-glibc-x86-64.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_MAGNUMINFO=OFF \
@ -55,11 +57,11 @@ build() {
package() {
# Install 32bit
cd "$startdir/build-nacl-glibc-x86-32"
cd "$_rootdir/build-nacl-glibc-x86-32"
DESTDIR="$pkgdir/" ninja install/strip
# Install 64bit (the headers will be overwritten, but they are (and should
# be) the same for both versions
cd "$startdir/build-nacl-glibc-x86-64"
cd "$_rootdir/build-nacl-glibc-x86-64"
DESTDIR="$pkgdir/" ninja install/strip
}

26
package/archlinux/PKGBUILD-nacl-newlib

@ -2,22 +2,24 @@
pkgname=nacl-magnum
pkgver=dev.newlib
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (NaCl newlib version)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (NaCl newlib version)"
arch=('any')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('nacl-corrade')
makedepends=('nacl-sdk' 'cmake' 'corrade' 'ninja')
options=('!buildflags' '!strip' 'staticlibs')
options=('!strip' '!buildflags')
_rootdir=$startdir/../../
build() {
# Build 32bit
mkdir -p "$startdir/build-nacl-newlib-x86-32"
cd "$startdir/build-nacl-newlib-x86-32"
mkdir -p "$_rootdir/build-nacl-newlib-x86-32"
cd "$_rootdir/build-nacl-newlib-x86-32"
cmake .. \
-DCMAKE_MODULE_PATH="$startdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$startdir/toolchains/generic/NaCl-newlib-x86-32.cmake" \
-DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-newlib-x86-32.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_MAGNUMINFO=ON \
@ -34,12 +36,12 @@ build() {
ninja
# Build 64bit
mkdir -p "$startdir/build-nacl-newlib-x86-64"
cd "$startdir/build-nacl-newlib-x86-64"
mkdir -p "$_rootdir/build-nacl-newlib-x86-64"
cd "$_rootdir/build-nacl-newlib-x86-64"
cmake .. \
-DCMAKE_MODULE_PATH="$startdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$startdir/toolchains/generic/NaCl-newlib-x86-64.cmake" \
-DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-newlib-x86-64.cmake" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_MAGNUMINFO=ON \
@ -57,11 +59,11 @@ build() {
package() {
# Install 32bit
cd "$startdir/build-nacl-newlib-x86-32"
cd "$_rootdir/build-nacl-newlib-x86-32"
DESTDIR="$pkgdir/" ninja install/strip
# Install 64bit (the headers will be overwritten, but they are (and should
# be) the same for both versions
cd "$startdir/build-nacl-newlib-x86-64"
cd "$_rootdir/build-nacl-newlib-x86-64"
DESTDIR="$pkgdir/" ninja install/strip
}

24
package/archlinux/PKGBUILD-release

@ -2,18 +2,20 @@
pkgname=magnum
pkgver=dev.release
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (debug+release libs)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (debug+release libs)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
depends=('corrade' 'openal' 'sdl2' 'freeglut')
makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs')
options=('!strip')
provides=('magnum-git')
_rootdir=$startdir/../../
build() {
mkdir -p "$startdir/build"
cd "$startdir/build"
mkdir -p "$_rootdir/build"
cd "$_rootdir/build"
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
@ -22,6 +24,7 @@ build() {
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
@ -39,8 +42,8 @@ build() {
-G Ninja
ninja
mkdir -p "$startdir/build-release"
cd "$startdir/build-release"
mkdir -p "$_rootdir/build-release"
cd "$_rootdir/build-release"
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
@ -49,6 +52,7 @@ build() {
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=ON \
@ -66,17 +70,17 @@ build() {
}
check() {
cd "$startdir/build"
cd "$_rootdir/build"
ctest --output-on-failure -j5
cd "$startdir/build-release"
cd "$_rootdir/build-release"
ctest --output-on-failure -j5
}
package() {
cd "$startdir/build"
cd "$_rootdir/build"
DESTDIR="$pkgdir/" ninja install
cd "$startdir/build-release"
cd "$_rootdir/build-release"
DESTDIR="$pkgdir/" ninja install/strip
}

1
package/archlinux/magnum-git/.gitignore vendored

@ -0,0 +1 @@
magnum

28
package/archlinux/magnum-git/PKGBUILD

@ -1,8 +1,8 @@
# Author: mosra <mosra@centrum.cz>
pkgname=magnum-git
pkgver=20140427
pkgver=snapshot.2014.06.r380.gd0a85ee
pkgrel=1
pkgdesc="C++11 and OpenGL 2D/3D graphics engine (Git version)"
pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (Git version)"
arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php"
license=('MIT')
@ -10,33 +10,19 @@ depends=('corrade-git' 'openal' 'sdl2')
makedepends=('cmake' 'git')
provides=('magnum')
conflicts=('magnum')
options=('staticlibs')
_gitroot="git://github.com/mosra/magnum.git"
_gitname="magnum"
source=("git+git://github.com/mosra/magnum.git")
sha1sums=('SKIP')
pkgver() {
date +%Y%m%d
cd "$srcdir/${pkgname%-git}"
git describe --long | sed -r 's/([^-]*-g)/r\1/;s/-/./g'
}
build() {
cd "$srcdir"
msg "Connecting to Git server..."
if [ -d $_gitname ] ; then
cd $_gitname && git pull origin
msg "The local files are updated."
else
git clone $_gitroot $_gitname
fi
msg "Git checkout done."
msg "Starting make..."
mkdir -p "$srcdir/build"
cd "$srcdir/build"
cmake ../$_gitname \
cmake "$srcdir/${pkgname%-git}" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_AUDIO=ON \

158
package/ci/jenkins-clang-analyzer.xml

@ -0,0 +1,158 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description></description>
<logRotator class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</logRotator>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>git://github.com/mosra/magnum.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions>
<hudson.plugins.git.extensions.impl.CloneOption>
<shallow>true</shallow>
<reference></reference>
</hudson.plugins.git.extensions.impl.CloneOption>
</extensions>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>Magnum</customWorkspace>
<axes>
<hudson.matrix.TextAxis>
<name>gl</name>
<values>
<string>desktop</string>
<string>es2</string>
<string>es2desktop</string>
<string>es3</string>
<string>es3desktop</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>compatibility</name>
<values>
<string></string>
<string>deprecated</string>
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>
<![CDATA[
if [ "${compatibility}" = "deprecated" ] ; then
deprecated_build_flag=ON
else
deprecated_build_flag=OFF
fi
if [ ${gl} = "desktop" ] ; then
desktop_flag=ON
es_flag=OFF
windowless_flag=ON
elif [ ${gl} = "es2" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=ON"
desktop_flag=OFF
es_flag=ON
windowless_flag=OFF
elif [ ${gl} = "es2desktop" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=ON -DTARGET_DESKTOP_GLES=ON"
desktop_flag=OFF
es_flag=OFF
windowless_flag=ON
elif [ ${gl} = "es3" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=OFF"
desktop_flag=OFF
es_flag=ON
windowless_flag=OFF
elif [ ${gl} = "es3desktop" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=OFF -DTARGET_DESKTOP_GLES=ON"
desktop_flag=OFF
es_flag=OFF
windowless_flag=ON
fi
mkdir -p build-clang-analyzer-${compatibility}-${gl}
cd build-clang-analyzer-${compatibility}-${gl}
scan-build --use-c++=$(which clang++) cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_FIND_ROOT_PATH=${JENKINS_HOME}/filesystem/clang-analyzer-${compatibility} \
-DCMAKE_INSTALL_PREFIX=${JENKINS_HOME}/filesystem/clang-analyzer-${compatibility}-${gl} \
-DCMAKE_INSTALL_RPATH="${JENKINS_HOME}/filesystem/clang-analyzer-${compatibility}/lib;${JENKINS_HOME}/filesystem/clang-analyzer-${compatibility}-${gl}/lib" \
-DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" \
-DCMAKE_EXE_LINKER_FLAGS=-lc++abi \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=${windowless_flag} \
-DBUILD_DEPRECATED=${deprecated_build_flag} \
${gl_flags} \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=${desktop_flag} \
-DWITH_OBJIMPORTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DWITH_DISTANCEFIELDCONVERTER=${desktop_flag} \
-DWITH_FONTCONVERTER=${desktop_flag} \
-DWITH_MAGNUMINFO=${windowless_flag}
make clean
scan-build --use-c++=$(which clang++) make -j
make install
]]>
</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.plugins.textfinder.TextFinderPublisher plugin="text-finder@1.9">
<regexp>scan-build: \d+ bugs found</regexp>
<succeedIfFound>false</succeedIfFound>
<unstableIfFound>true</unstableIfFound>
<alsoCheckConsoleOutput>true</alsoCheckConsoleOutput>
</hudson.plugins.textfinder.TextFinderPublisher>
</publishers>
<buildWrappers/>
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
<runSequentially>true</runSequentially>
<touchStoneCombinationFilter>
<![CDATA[
compatibility == "deprecated" && gl == "desktop"
]]>
</touchStoneCombinationFilter>
<touchStoneResultCondition>
<name>UNSTABLE</name>
<ordinal>1</ordinal>
<color>YELLOW</color>
<completeBuild>true</completeBuild>
</touchStoneResultCondition>
</executionStrategy>
<childCustomWorkspace>.</childCustomWorkspace>
</matrix-project>

103
package/ci/jenkins-clang-sanitizer-gltests.xml

@ -0,0 +1,103 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description></description>
<logRotator class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</logRotator>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>git://github.com/mosra/magnum.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions>
<hudson.plugins.git.extensions.impl.CloneOption>
<shallow>true</shallow>
<reference></reference>
</hudson.plugins.git.extensions.impl.CloneOption>
</extensions>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>Magnum</customWorkspace>
<axes>
<hudson.matrix.TextAxis>
<name>gl</name>
<values>
<string>desktop</string>
<string>es2desktop</string>
<string>es3desktop</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>compatibility</name>
<values>
<string></string>
<string>deprecated</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>sanitizer</name>
<values>
<string>address</string>
<!-- <string>memory</string> -->
<!-- <string>undefined</string> -->
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>
<![CDATA[
cd build-clang-${sanitizer}sanitizer-${compatibility}-${gl}
ninja
ctest --output-on-failure -R GLTest -j5 || true
]]>
</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.plugins.textfinder.TextFinderPublisher plugin="text-finder@1.9">
<regexp>Errors while running CTest</regexp>
<succeedIfFound>false</succeedIfFound>
<unstableIfFound>true</unstableIfFound>
<alsoCheckConsoleOutput>true</alsoCheckConsoleOutput>
</hudson.plugins.textfinder.TextFinderPublisher>
</publishers>
<buildWrappers/>
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
<runSequentially>true</runSequentially>
<touchStoneCombinationFilter>
<![CDATA[
compatibility == "deprecated" && gl == "desktop" && sanitizer == "address"
]]>
</touchStoneCombinationFilter>
<touchStoneResultCondition>
<name>SUCCESS</name>
<ordinal>0</ordinal>
<color>BLUE</color>
<completeBuild>true</completeBuild>
</touchStoneResultCondition>
</executionStrategy>
<childCustomWorkspace>.</childCustomWorkspace>
</matrix-project>

176
package/ci/jenkins-clang-sanitizer.xml

@ -0,0 +1,176 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description></description>
<logRotator class="hudson.tasks.LogRotator">
<daysToKeep>-1</daysToKeep>
<numToKeep>10</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</logRotator>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM" plugin="git@2.0">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>git://github.com/mosra/magnum.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions>
<hudson.plugins.git.extensions.impl.CloneOption>
<shallow>true</shallow>
<reference></reference>
</hudson.plugins.git.extensions.impl.CloneOption>
</extensions>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<customWorkspace>Magnum</customWorkspace>
<axes>
<hudson.matrix.TextAxis>
<name>gl</name>
<values>
<string>desktop</string>
<string>es2</string>
<string>es2desktop</string>
<string>es3</string>
<string>es3desktop</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>compatibility</name>
<values>
<string></string>
<string>deprecated</string>
</values>
</hudson.matrix.TextAxis>
<hudson.matrix.TextAxis>
<name>sanitizer</name>
<values>
<string>address</string>
<!-- <string>memory</string> -->
<!-- <string>undefined</string> -->
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>
<![CDATA[
if [ "${compatibility}" = "deprecated" ] ; then
deprecated_build_flag=ON
else
deprecated_build_flag=OFF
fi
if [ ${gl} = "desktop" ] ; then
desktop_flag=ON
es_flag=OFF
windowless_flag=ON
elif [ ${gl} = "es2" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=ON"
desktop_flag=OFF
es_flag=ON
windowless_flag=OFF
elif [ ${gl} = "es2desktop" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=ON -DTARGET_DESKTOP_GLES=ON"
desktop_flag=OFF
es_flag=OFF
windowless_flag=ON
elif [ ${gl} = "es3" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=OFF"
desktop_flag=OFF
es_flag=ON
windowless_flag=OFF
elif [ ${gl} = "es3desktop" ] ; then
gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=OFF -DTARGET_DESKTOP_GLES=ON"
desktop_flag=OFF
es_flag=OFF
windowless_flag=ON
fi
mkdir -p build-clang-${sanitizer}sanitizer-${compatibility}-${gl}
cd build-clang-${sanitizer}sanitizer-${compatibility}-${gl}
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_FIND_ROOT_PATH=${JENKINS_HOME}/filesystem/clang-${sanitizer}sanitizer-${compatibility} \
-DCMAKE_INSTALL_PREFIX=${JENKINS_HOME}/filesystem/clang-${sanitizer}sanitizer-${compatibility}-${gl} \
-DCMAKE_INSTALL_RPATH="${JENKINS_HOME}/filesystem/clang-${sanitizer}sanitizer-${compatibility}/lib;${JENKINS_HOME}/filesystem/clang-${sanitizer}sanitizer-${compatibility}-${gl}/lib" \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_FLAGS="-std=c++11 -fsanitize=${sanitizer}" \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=${windowless_flag} \
-DBUILD_DEPRECATED=${deprecated_build_flag} \
${gl_flags} \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=${desktop_flag} \
-DWITH_OBJIMPORTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DWITH_DISTANCEFIELDCONVERTER=${desktop_flag} \
-DWITH_FONTCONVERTER=${desktop_flag} \
-DWITH_MAGNUMINFO=${windowless_flag} \
-G Ninja
ninja
ctest --output-on-failure -E GLTest -j5 || true
ninja install
]]>
</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.BuildTrigger>
<childProjects>Magnum-ClangSanitizer-GLTests</childProjects>
<threshold>
<name>SUCCESS</name>
<ordinal>0</ordinal>
<color>BLUE</color>
<completeBuild>true</completeBuild>
</threshold>
</hudson.tasks.BuildTrigger>
<hudson.plugins.textfinder.TextFinderPublisher plugin="text-finder@1.9">
<regexp>Errors while running CTest</regexp>
<succeedIfFound>false</succeedIfFound>
<unstableIfFound>true</unstableIfFound>
<alsoCheckConsoleOutput>true</alsoCheckConsoleOutput>
</hudson.plugins.textfinder.TextFinderPublisher>
</publishers>
<buildWrappers/>
<executionStrategy class="hudson.matrix.DefaultMatrixExecutionStrategyImpl">
<runSequentially>true</runSequentially>
<touchStoneCombinationFilter>
<![CDATA[
compatibility == "deprecated" && gl == "desktop" && sanitizer == "address"
]]>
</touchStoneCombinationFilter>
<touchStoneResultCondition>
<name>UNSTABLE</name>
<ordinal>1</ordinal>
<color>YELLOW</color>
<completeBuild>true</completeBuild>
</touchStoneResultCondition>
</executionStrategy>
<childCustomWorkspace>.</childCustomWorkspace>
</matrix-project>

2
package/ci/jenkins-mingw-w64.xml

@ -69,7 +69,7 @@ git submodule init
git submodule update
if [ ${libraries} = "static" ] ; then
static_build_flag="-DBUILD_STATIC=ON -DBUILD_STATIC_PIC=ON"
static_build_flag="-DBUILD_STATIC=ON -DBUILD_PLUGINS_STATIC=ON -DBUILD_STATIC_PIC=ON"
fi
if [ "${compatibility}" = "deprecated" ] ; then

4
package/ci/jenkins.xml

@ -88,7 +88,7 @@ else
fi
if [ ${libraries} = "static" ] ; then
static_build_flag="-DBUILD_STATIC=ON -DBUILD_STATIC_PIC=ON"
static_build_flag="-DBUILD_STATIC=ON -DBUILD_PLUGINS_STATIC=ON -DBUILD_STATIC_PIC=ON"
fi
if [ "${compatibility}" = "deprecated" ] ; then
@ -142,7 +142,7 @@ cmake .. \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=${es_flag} \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
-DWITH_MAGNUMFONT=ON \

8
package/debian/control vendored

@ -1,7 +1,7 @@
Source: magnum
Priority: optional
Maintainer: Vladimír Vondruš <mosra@centrum.cz>
Build-Depends: debhelper (>= 9), cmake (>= 2.8.8)
Build-Depends: debhelper (>= 9), cmake (>= 2.8.9)
Standards-Version: 3.9.2
Section: libs
Homepage: http://mosra.cz/blog/magnum.php
@ -11,15 +11,15 @@ Vcs-Browser: https://github.com/mosra/magnum
Package: magnum-dev
Section: libdevel
Architecture: any
Depends: magnum (= ${binary:Version}), corrade-dev, libgl-dev, freeglut3-dev, libopenal-dev
Depends: magnum (= ${binary:Version}), corrade-dev, libgl-dev, freeglut3-dev, libopenal-dev, libsdl2-dev
Description: Magnum development files
Headers and tools needed for developing with Magnum.
Package: magnum
Section: libs
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, corrade, libgl1, freeglut3, libopenal1
Description: C++11 and OpenGL 2D/3D graphics engine
Depends: ${shlibs:Depends}, ${misc:Depends}, corrade, libgl1, freeglut3, libopenal1, libsdl2
Description: C++11/C++14 and OpenGL 2D/3D graphics engine
Magnum is 2D/3D graphics engine written in C++11 and modern OpenGL. Its goal
is to simplify low-level graphics development and interaction with OpenGL
using recent C++11 features and to abstract away platform-specific issues.

2
package/debian/copyright vendored

@ -4,7 +4,7 @@ Upstream-Contact: Vladimír Vondruš <mosra@centrum.cz>
Source: https://github.com/mosra/magnum
Files: *
Copyright: 2010-2014 Vladimír Vondruš <mosra@centrum.cz>
Copyright: 2010-2015 Vladimír Vondruš <mosra@centrum.cz>
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),

1
package/debian/rules vendored

@ -8,6 +8,7 @@ override_dh_auto_configure:
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \

39
package/gentoo/dev-libs/magnum/magnum-9999.ebuild

@ -8,7 +8,7 @@ EGIT_REPO_URI="git://github.com/mosra/magnum.git"
inherit cmake-utils git-r3
DESCRIPTION="C++11 and OpenGL 2D/3D graphics engine"
DESCRIPTION="C++11/C++14 and OpenGL 2D/3D graphics engine"
HOMEPAGE="http://mosra.cz/blog/magnum.php"
LICENSE="MIT"
@ -27,26 +27,25 @@ DEPEND="${RDEPEND}"
src_configure() {
local mycmakeargs=(
-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
-DCMAKE_BUILD_TYPE=Debug \
-DWITH_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \
-DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=ON \
-DWITH_OBJIMPORTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \
-DWITH_TGAIMPORTER=ON \
-DWITH_WAVAUDIOIMPORTER=ON \
-DWITH_DISTANCEFIELDCONVERTER=ON \
-DWITH_FONTCONVERTER=ON \
-DWITH_MAGNUMINFO=ON \
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=ON
-DCMAKE_BUILD_TYPE=Release
-DWITH_AUDIO=ON
-DWITH_GLUTAPPLICATION=ON
-DWITH_GLXAPPLICATION=ON
-DWITH_SDL2APPLICATION=ON
-DWITH_WINDOWLESSGLXAPPLICATION=ON
-DWITH_EGLCONTEXT=ON
-DWITH_GLXCONTEXT=ON
-DWITH_MAGNUMFONT=ON
-DWITH_MAGNUMFONTCONVERTER=ON
-DWITH_OBJIMPORTER=ON
-DWITH_TGAIMAGECONVERTER=ON
-DWITH_TGAIMPORTER=ON
-DWITH_WAVAUDIOIMPORTER=ON
-DWITH_DISTANCEFIELDCONVERTER=ON
-DWITH_FONTCONVERTER=ON
-DWITH_MAGNUMINFO=ON
)
cmake-utils_src_configure
}
# kate: replace-tabs off;

2
src/CMakeLists.txt

@ -1,7 +1,7 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a

233
src/Magnum/AbstractFramebuffer.cpp

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -93,24 +93,45 @@ void AbstractFramebuffer::createIfNotAlready() {
CORRADE_INTERNAL_ASSERT(_created);
}
void AbstractFramebuffer::bind(FramebufferTarget target) {
bindInternal(target);
void AbstractFramebuffer::bind() {
bindInternal(FramebufferTarget::Draw);
setViewportInternal();
}
void AbstractFramebuffer::bindInternal(FramebufferTarget target) {
Implementation::FramebufferState* state = Context::current()->state().framebuffer;
#ifndef MAGNUM_TARGET_GLES2
bindImplementationDefault(target);
#else
(this->*Context::current()->state().framebuffer->bindImplementation)(target);
#endif
}
#ifdef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::bindImplementationSingle(FramebufferTarget) {
Implementation::FramebufferState& state = *Context::current()->state().framebuffer;
CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding);
if(state.readBinding == _id) return;
state.readBinding = state.drawBinding = _id;
/* Binding the framebuffer finally creates it */
_created = true;
glBindFramebuffer(GL_FRAMEBUFFER, _id);
}
#endif
#ifndef MAGNUM_TARGET_GLES2
inline
#endif
void AbstractFramebuffer::bindImplementationDefault(FramebufferTarget target) {
Implementation::FramebufferState& state = *Context::current()->state().framebuffer;
/* If already bound, done, otherwise update tracked state */
if(target == FramebufferTarget::Read) {
if(state->readBinding == _id) return;
state->readBinding = _id;
if(state.readBinding == _id) return;
state.readBinding = _id;
} else if(target == FramebufferTarget::Draw) {
if(state->drawBinding == _id) return;
state->drawBinding = _id;
} else if(target == FramebufferTarget::ReadDraw) {
if(state->readBinding == _id && state->drawBinding == _id) return;
state->readBinding = state->drawBinding = _id;
if(state.drawBinding == _id) return;
state.drawBinding = _id;
} else CORRADE_ASSERT_UNREACHABLE();
/* Binding the framebuffer finally creates it */
@ -119,46 +140,78 @@ void AbstractFramebuffer::bindInternal(FramebufferTarget target) {
}
FramebufferTarget AbstractFramebuffer::bindInternal() {
Implementation::FramebufferState* state = Context::current()->state().framebuffer;
#ifndef MAGNUM_TARGET_GLES2
return bindImplementationDefault();
#else
return (this->*Context::current()->state().framebuffer->bindInternalImplementation)();
#endif
}
#ifdef MAGNUM_TARGET_GLES2
FramebufferTarget AbstractFramebuffer::bindImplementationSingle() {
Implementation::FramebufferState& state = *Context::current()->state().framebuffer;
CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding);
/* Bind the framebuffer, if not already */
if(state.readBinding != _id) {
state.readBinding = state.drawBinding = _id;
/* Binding the framebuffer finally creates it */
_created = true;
glBindFramebuffer(GL_FRAMEBUFFER, _id);
}
return FramebufferTarget{};
}
#endif
#ifndef MAGNUM_TARGET_GLES2
inline
#endif
FramebufferTarget AbstractFramebuffer::bindImplementationDefault() {
Implementation::FramebufferState& state = *Context::current()->state().framebuffer;
/* Return target to which the framebuffer is already bound */
if(state->readBinding == _id && state->drawBinding == _id)
return FramebufferTarget::ReadDraw;
if(state->readBinding == _id)
if(state.readBinding == _id)
return FramebufferTarget::Read;
if(state->drawBinding == _id)
if(state.drawBinding == _id)
return FramebufferTarget::Draw;
/* Or bind it, if not already */
state->readBinding = _id;
state.readBinding = _id;
/* Binding the framebuffer finally creates it */
_created = true;
#ifndef MAGNUM_TARGET_GLES2
glBindFramebuffer(GLenum(FramebufferTarget::Read), _id);
return FramebufferTarget::Read;
#else
if(state->readTarget == FramebufferTarget::ReadDraw) state->drawBinding = _id;
glBindFramebuffer(GLenum(state->readTarget), _id);
return state->readTarget;
#endif
}
void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter) {
void AbstractFramebuffer::blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) {
Context::current()->state().framebuffer->blitImplementation(source, destination, sourceRectangle, destinationRectangle, mask, filter);
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::blitImplementationDefault(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) {
source.bindInternal(FramebufferTarget::Read);
destination.bindInternal(FramebufferTarget::Draw);
#ifndef MAGNUM_TARGET_GLES2
glBlitFramebuffer(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
#else
Context::current()->state().framebuffer->blitImplementation(sourceRectangle, destinationRectangle, mask, filter);
#endif
}
#ifdef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::blitImplementationANGLE(const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) {
#ifndef MAGNUM_TARGET_GLES
void AbstractFramebuffer::blitImplementationDSA(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) {
glBlitNamedFramebuffer(source._id, destination._id, sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
}
#endif
#else
void AbstractFramebuffer::blitImplementationANGLE(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) {
#if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
source.bindInternal(FramebufferTarget::Read);
destination.bindInternal(FramebufferTarget::Draw);
glBlitFramebufferANGLE(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
#else
static_cast<void>(source);
static_cast<void>(destination);
static_cast<void>(sourceRectangle);
static_cast<void>(destinationRectangle);
static_cast<void>(mask);
@ -167,10 +220,14 @@ void AbstractFramebuffer::blitImplementationANGLE(const Range2Di& sourceRectangl
#endif
}
void AbstractFramebuffer::blitImplementationNV(const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) {
void AbstractFramebuffer::blitImplementationNV(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, const FramebufferBlitMask mask, const FramebufferBlitFilter filter) {
#if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
source.bindInternal(FramebufferTarget::Read);
destination.bindInternal(FramebufferTarget::Draw);
glBlitFramebufferNV(sourceRectangle.left(), sourceRectangle.bottom(), sourceRectangle.right(), sourceRectangle.top(), destinationRectangle.left(), destinationRectangle.bottom(), destinationRectangle.right(), destinationRectangle.top(), GLbitfield(mask), GLenum(filter));
#else
static_cast<void>(source);
static_cast<void>(destination);
static_cast<void>(sourceRectangle);
static_cast<void>(destinationRectangle);
static_cast<void>(mask);
@ -181,6 +238,7 @@ void AbstractFramebuffer::blitImplementationNV(const Range2Di& sourceRectangle,
#endif
AbstractFramebuffer& AbstractFramebuffer::setViewport(const Range2Di& rectangle) {
CORRADE_INTERNAL_ASSERT(rectangle != Implementation::FramebufferState::DisengagedViewport);
_viewport = rectangle;
/* Update the viewport if the framebuffer is currently bound */
@ -191,54 +249,55 @@ AbstractFramebuffer& AbstractFramebuffer::setViewport(const Range2Di& rectangle)
}
void AbstractFramebuffer::setViewportInternal() {
Implementation::FramebufferState* state = Context::current()->state().framebuffer;
Implementation::FramebufferState& state = *Context::current()->state().framebuffer;
/* We are using empty viewport to indicate disengaged state */
CORRADE_INTERNAL_ASSERT(_viewport != Range2Di{});
CORRADE_INTERNAL_ASSERT(state->drawBinding == _id);
CORRADE_INTERNAL_ASSERT(_viewport != Implementation::FramebufferState::DisengagedViewport);
CORRADE_INTERNAL_ASSERT(state.drawBinding == _id);
/* Already up-to-date, nothing to do */
if(state->viewport == _viewport)
if(state.viewport == _viewport)
return;
/* Update the state and viewport */
state->viewport = _viewport;
state.viewport = _viewport;
glViewport(_viewport.left(), _viewport.bottom(), _viewport.sizeX(), _viewport.sizeY());
}
void AbstractFramebuffer::clear(FramebufferClearMask mask) {
#ifndef MAGNUM_TARGET_GLES2
AbstractFramebuffer& AbstractFramebuffer::clear(const FramebufferClearMask mask) {
bindInternal(FramebufferTarget::Draw);
#else
bindInternal(Context::current()->state().framebuffer->drawTarget);
#endif
glClear(GLbitfield(mask));
}
void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Image2D& image) {
const Implementation::FramebufferState& state = *Context::current()->state().framebuffer;
return *this;
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::read(const Range2Di& rectangle, Image2D& image) {
bindInternal(FramebufferTarget::Read);
#else
bindInternal(state.readTarget);
#endif
const std::size_t dataSize = image.dataSize(size);
const std::size_t dataSize = image.dataSize(rectangle.size());
char* const data = new char[dataSize];
(state.readImplementation)(offset, size, image.format(), image.type(), dataSize, data);
image.setData(image.format(), image.type(), size, data);
(Context::current()->state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), dataSize, data);
image.setData(image.format(), image.type(), rectangle.size(), data);
}
Image2D AbstractFramebuffer::read(const Range2Di& rectangle, Image2D&& image) {
read(rectangle, image);
return std::move(image);
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, BufferImage2D& image, BufferUsage usage) {
void AbstractFramebuffer::read(const Range2Di& rectangle, BufferImage2D& image, BufferUsage usage) {
bindInternal(FramebufferTarget::Read);
/* If the buffer doesn't have sufficient size, resize it */
/** @todo Explicitly reset also when buffer usage changes */
if(image.size() != size)
image.setData(image.format(), image.type(), size, nullptr, usage);
if(image.size() != rectangle.size())
image.setData(image.format(), image.type(), rectangle.size(), nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
(Context::current()->state().framebuffer->readImplementation)(offset, size, image.format(), image.type(), image.dataSize(size), nullptr);
(Context::current()->state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), image.dataSize(rectangle.size()), nullptr);
}
BufferImage2D AbstractFramebuffer::read(const Range2Di& rectangle, BufferImage2D&& image, BufferUsage usage) {
read(rectangle, image, usage);
return std::move(image);
}
#endif
@ -256,12 +315,24 @@ void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, c
#endif
}
#ifndef MAGNUM_TARGET_GLES
void AbstractFramebuffer::invalidateImplementationDSA(const GLsizei count, const GLenum* const attachments) {
glInvalidateNamedFramebufferData(_id, count, attachments);
}
#endif
#ifndef MAGNUM_TARGET_GLES2
void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&) {}
void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) {
glInvalidateSubFramebuffer(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY());
}
#ifndef MAGNUM_TARGET_GLES
void AbstractFramebuffer::invalidateImplementationDSA(const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) {
glInvalidateNamedFramebufferSubData(_id, count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY());
}
#endif
#endif
GLenum AbstractFramebuffer::checkStatusImplementationDefault(const FramebufferTarget target) {
@ -269,7 +340,18 @@ GLenum AbstractFramebuffer::checkStatusImplementationDefault(const FramebufferTa
return glCheckFramebufferStatus(GLenum(target));
}
#ifdef MAGNUM_TARGET_GLES2
GLenum AbstractFramebuffer::checkStatusImplementationSingle(FramebufferTarget) {
bindInternal(FramebufferTarget{});
return glCheckFramebufferStatus(GL_FRAMEBUFFER);
}
#endif
#ifndef MAGNUM_TARGET_GLES
GLenum AbstractFramebuffer::checkStatusImplementationDSA(const FramebufferTarget target) {
return glCheckNamedFramebufferStatus(_id, GLenum(target));
}
GLenum AbstractFramebuffer::checkStatusImplementationDSAEXT(const FramebufferTarget target) {
_created = true;
return glCheckNamedFramebufferStatusEXT(_id, GLenum(target));
@ -277,11 +359,7 @@ GLenum AbstractFramebuffer::checkStatusImplementationDSAEXT(const FramebufferTar
#endif
void AbstractFramebuffer::drawBuffersImplementationDefault(GLsizei count, const GLenum* buffers) {
#ifndef MAGNUM_TARGET_GLES2
bindInternal(FramebufferTarget::Draw);
#else
bindInternal(Context::current()->state().framebuffer->drawTarget);
#endif
#ifndef MAGNUM_TARGET_GLES2
glDrawBuffers(count, buffers);
@ -295,6 +373,10 @@ void AbstractFramebuffer::drawBuffersImplementationDefault(GLsizei count, const
}
#ifndef MAGNUM_TARGET_GLES
void AbstractFramebuffer::drawBuffersImplementationDSA(const GLsizei count, const GLenum* const buffers) {
glNamedFramebufferDrawBuffers(_id, count, buffers);
}
void AbstractFramebuffer::drawBuffersImplementationDSAEXT(GLsizei count, const GLenum* buffers) {
_created = true;
glFramebufferDrawBuffersEXT(_id, count, buffers);
@ -302,11 +384,7 @@ void AbstractFramebuffer::drawBuffersImplementationDSAEXT(GLsizei count, const G
#endif
void AbstractFramebuffer::drawBufferImplementationDefault(GLenum buffer) {
#ifndef MAGNUM_TARGET_GLES2
bindInternal(FramebufferTarget::Draw);
#else
bindInternal(Context::current()->state().framebuffer->drawTarget);
#endif
#ifndef MAGNUM_TARGET_GLES
glDrawBuffer(buffer);
@ -321,6 +399,10 @@ void AbstractFramebuffer::drawBufferImplementationDefault(GLenum buffer) {
}
#ifndef MAGNUM_TARGET_GLES
void AbstractFramebuffer::drawBufferImplementationDSA(const GLenum buffer) {
glNamedFramebufferDrawBuffer(_id, buffer);
}
void AbstractFramebuffer::drawBufferImplementationDSAEXT(GLenum buffer) {
_created = true;
glFramebufferDrawBufferEXT(_id, buffer);
@ -328,11 +410,7 @@ void AbstractFramebuffer::drawBufferImplementationDSAEXT(GLenum buffer) {
#endif
void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) {
#ifndef MAGNUM_TARGET_GLES2
bindInternal(FramebufferTarget::Read);
#else
bindInternal(Context::current()->state().framebuffer->readTarget);
#endif
#ifndef MAGNUM_TARGET_GLES2
glReadBuffer(buffer);
@ -345,24 +423,27 @@ void AbstractFramebuffer::readBufferImplementationDefault(GLenum buffer) {
}
#ifndef MAGNUM_TARGET_GLES
void AbstractFramebuffer::readBufferImplementationDSA(const GLenum buffer) {
glFramebufferReadBufferEXT(_id, buffer);
}
void AbstractFramebuffer::readBufferImplementationDSAEXT(GLenum buffer) {
_created = true;
glFramebufferReadBufferEXT(_id, buffer);
}
#endif
void AbstractFramebuffer::readImplementationDefault(const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
glReadPixels(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
void AbstractFramebuffer::readImplementationDefault(const Range2Di& rectangle, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
glReadPixels(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), data);
}
void AbstractFramebuffer::readImplementationRobustness(const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
void AbstractFramebuffer::readImplementationRobustness(const Range2Di& rectangle, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
#ifndef MAGNUM_TARGET_GLES
glReadnPixelsARB(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), dataSize, data);
glReadnPixelsARB(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), dataSize, data);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
glReadnPixelsEXT(offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), dataSize, data);
glReadnPixelsEXT(rectangle.min().x(), rectangle.min().y(), rectangle.sizeX(), rectangle.sizeY(), GLenum(format), GLenum(type), dataSize, data);
#else
static_cast<void>(offset);
static_cast<void>(size);
static_cast<void>(rectangle);
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(dataSize);

211
src/Magnum/AbstractFramebuffer.h

@ -3,7 +3,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -30,6 +30,7 @@
*/
#include <Corrade/Containers/EnumSet.h>
#include <Corrade/Utility/Macros.h>
#include "Magnum/Magnum.h"
#include "Magnum/OpenGL.h"
@ -58,15 +59,19 @@ enum class FramebufferClear: GLbitfield {
@see @ref AbstractFramebuffer::clear()
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef Containers::EnumSet<FramebufferClear, GLbitfield,
GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT> FramebufferClearMask;
#else
typedef Containers::EnumSet<FramebufferClear, GLbitfield> FramebufferClearMask;
#endif
/**
@brief Mask for framebuffer blitting
@see @ref AbstractFramebuffer, @ref FramebufferBlitMask
@requires_gl30 %Extension @extension{ARB,framebuffer_object}
@requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
@requires_gl30 Extension @extension{ARB,framebuffer_object}
@requires_gles30 Extension @es_extension{ANGLE,framebuffer_blit} or
@es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
*/
enum class FramebufferBlit: GLbitfield {
@ -96,19 +101,23 @@ enum class FramebufferBlit: GLbitfield {
@brief Mask for framebuffer blitting
@see @ref AbstractFramebuffer::blit()
@requires_gl30 %Extension @extension{ARB,framebuffer_object}
@requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
@requires_gl30 Extension @extension{ARB,framebuffer_object}
@requires_gles30 Extension @es_extension{ANGLE,framebuffer_blit} or
@es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef Containers::EnumSet<FramebufferBlit, GLbitfield,
GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT> FramebufferBlitMask;
#else
typedef Containers::EnumSet<FramebufferBlit, GLbitfield> FramebufferBlitMask;
#endif
/**
@brief %Framebuffer blit filtering
@brief Framebuffer blit filtering
@see @ref AbstractFramebuffer::blit()
@requires_gl30 %Extension @extension{ARB,framebuffer_object}
@requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
@requires_gl30 Extension @extension{ARB,framebuffer_object}
@requires_gles30 Extension @es_extension{ANGLE,framebuffer_blit} or
@es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
*/
enum class FramebufferBlitFilter: GLenum {
@ -117,37 +126,38 @@ enum class FramebufferBlitFilter: GLenum {
};
/**
@brief Target for binding framebuffer
@brief Framebuffer target
@see @ref DefaultFramebuffer::bind(), @ref Framebuffer::bind()
@requires_gl30 %Extension @extension{ARB,framebuffer_object}
@see @ref DefaultFramebuffer::checkStatus(), @ref Framebuffer::checkStatus()
@requires_gl30 Extension @extension{ARB,framebuffer_object}
*/
enum class FramebufferTarget: GLenum {
/**
* For reading only.
* @requires_gles30 %Extension @es_extension{APPLE,framebuffer_multisample},
* @es_extension{ANGLE,framebuffer_blit} or @es_extension{NV,framebuffer_blit}
* in OpenGL ES 2.0
*/
/** Frambebuffer reading target */
#ifndef MAGNUM_TARGET_GLES2
Read = GL_READ_FRAMEBUFFER,
#else
Read = GL_READ_FRAMEBUFFER_APPLE,
#endif
/**
* For drawing only.
* @requires_gles30 %Extension @es_extension{APPLE,framebuffer_multisample},
* @es_extension{ANGLE,framebuffer_blit} or @es_extension{NV,framebuffer_blit}
* in OpenGL ES 2.0
*/
/** Framebuffer drawing target */
#ifndef MAGNUM_TARGET_GLES2
Draw = GL_DRAW_FRAMEBUFFER,
#else
Draw = GL_DRAW_FRAMEBUFFER_APPLE,
#endif
ReadDraw = GL_FRAMEBUFFER /**< For both reading and drawing. */
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* Framebuffer drawing target
* @deprecated Use @ref FramebufferTarget::Draw instead.
*/
ReadDraw CORRADE_DEPRECATED_ENUM("use FramebufferTarget::Draw instead") =
#ifndef MAGNUM_TARGET_GLES2
GL_DRAW_FRAMEBUFFER
#else
GL_DRAW_FRAMEBUFFER_APPLE
#endif
#endif
};
namespace Implementation { struct FramebufferState; }
@ -162,15 +172,19 @@ See @ref DefaultFramebuffer and @ref Framebuffer for more information.
The engine tracks currently bound framebuffer and current viewport to avoid
unnecessary calls to @fn_gl{BindFramebuffer} and @fn_gl{Viewport} when
switching framebuffers. %Framebuffer limits and implementation-defined values
switching framebuffers. Framebuffer limits and implementation-defined values
(such as @ref maxViewportSize()) are cached, so repeated queries don't result
in repeated @fn_gl{Get} calls.
If extension @extension{ARB,direct_state_access} (part of OpenGL 4.5) is
available, @ref blit() function uses DSA to avoid unnecessary call to
@fn_gl{BindFramebuffer}. See its documentation for more information.
If @extension{ARB,robustness} is available, @ref read() operations are
protected from buffer overflow.
*/
class MAGNUM_EXPORT AbstractFramebuffer {
friend struct Implementation::FramebufferState;
friend Implementation::FramebufferState;
public:
/** @todo `GL_IMPLEMENTATION_COLOR_READ_FORMAT`, `GL_IMPLEMENTATION_COLOR_READ_TYPE`, seems to be depending on currently bound FB (aargh) (@extension{ARB,ES2_compatibility}). */
@ -219,14 +233,16 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @param mask Which buffers to perform blit operation on
* @param filter Interpolation filter
*
* Binds @p source framebuffer to @ref FramebufferTarget::Read and
* @p destination framebuffer to @ref FramebufferTarget::Draw and
* performs blitting operation. See @ref DefaultFramebuffer::mapForRead(),
* @ref Framebuffer::mapForRead(), @ref DefaultFramebuffer::mapForDraw()
* and @ref Framebuffer::mapForDraw() for specifying particular buffers
* for blitting operation.
* @see @fn_gl{BlitFramebuffer}
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
* See @ref DefaultFramebuffer::mapForRead(), @ref Framebuffer::mapForRead(),
* @ref DefaultFramebuffer::mapForDraw() and @ref Framebuffer::mapForDraw()
* for specifying particular buffers for blitting operation. If
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) is not
* available, @p source framebuffer is bound to @ref FramebufferTarget::Read
* and @p destination framebuffer to @ref FramebufferTarget::Draw
* before the operation (if not already).
* @see @fn_gl2{BlitNamedFramebuffer,BlitFramebuffer}, eventually
* @fn_gl{BlitFramebuffer}
* @requires_gles30 Extension @es_extension{ANGLE,framebuffer_blit} or
* @es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
* @todo NaCl exports `BlitFramebufferEXT` (although no such extension
* exists for ES)
@ -235,35 +251,37 @@ class MAGNUM_EXPORT AbstractFramebuffer {
/**
* @brief Copy block of pixels
* @param source Source framebuffer
* @param destination Destination framebuffer
* @param rectangle Source and destination rectangle
* @param mask Which buffers to perform blit operation on
*
* Convenience alternative to above function when source rectangle is
* the same as destination rectangle. As the image is copied
* Convenience alternative to the above function when source rectangle
* is the same as destination rectangle. As the image is copied
* pixel-by-pixel, no interpolation is needed and thus
* @ref FramebufferBlitFilter::Nearest filtering is used by default.
* @see @fn_gl{BlitFramebuffer}
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
* @es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
*/
static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& rectangle, FramebufferBlitMask mask) {
blit(source, destination, rectangle, rectangle, mask, FramebufferBlitFilter::Nearest);
}
/**
* @brief Bind framebuffer for rendering
* @brief Bind framebuffer for drawing
*
* Binds the framebuffer and updates viewport to saved dimensions.
* Binds the framebuffer for drawing and updates viewport to saved
* dimensions.
* @see @ref setViewport(), @ref DefaultFramebuffer::mapForRead(),
* @ref Framebuffer::mapForRead(), @ref DefaultFramebuffer::mapForDraw(),
* @ref Framebuffer::mapForDraw(), @fn_gl{BindFramebuffer},
* @fn_gl{Viewport}
* @todo Bind internally to ReadDraw if separate binding points are not
* supported
*/
void bind(FramebufferTarget target);
void bind();
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief bind()
* @deprecated Use parameter-less @ref bind() instead.
*/
CORRADE_DEPRECATED("use parameter-less bind() instead") void bind(FramebufferTarget) {
bind();
}
#endif
/** @brief Viewport rectangle */
Range2Di viewport() const { return _viewport; }
@ -274,7 +292,9 @@ class MAGNUM_EXPORT AbstractFramebuffer {
*
* Saves the viewport to be used at later time in @ref bind(). If the
* framebuffer is currently bound, updates the viewport to given
* rectangle.
* rectangle. Initial value in @ref DefaultFramebuffer is set to cover
* whole window, in @ref Framebuffer the initial value is specified in
* constructor.
* @see @ref maxViewportSize(), @fn_gl{Viewport}
*/
AbstractFramebuffer& setViewport(const Range2Di& rectangle);
@ -282,6 +302,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
/**
* @brief Clear specified buffers in framebuffer
* @param mask Which buffers to clear
* @return Reference to self (for method chaining)
*
* To improve performance you can also use
* @ref DefaultFramebuffer::invalidate() / @ref Framebuffer::invalidate()
@ -291,15 +312,14 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @ref Renderer::setClearStencil(), @fn_gl{BindFramebuffer},
* @fn_gl{Clear}
*/
void clear(FramebufferClearMask mask);
AbstractFramebuffer& clear(FramebufferClearMask mask);
/**
* @brief Read block of pixels from framebuffer to image
* @param offset Offset in the framebuffer
* @param size %Image size
* @param image %Image where to put the data
* @param rectangle Framebuffer rectangle to read
* @param image Image where to put the data
*
* %Image parameters like format and type of pixel data are taken from
* Image parameters like format and type of pixel data are taken from
* given image.
*
* If @extension{ARB,robustness} is available, the operation is
@ -307,15 +327,33 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @see @fn_gl{BindFramebuffer}, @fn_gl{ReadPixels} or
* @fn_gl_extension{ReadnPixels,ARB,robustness}
*/
void read(const Vector2i& offset, const Vector2i& size, Image2D& image);
void read(const Range2Di& rectangle, Image2D& image);
/** @overload
*
* Convenience alternative to the above, example usage:
* @code
* Image2D image = framebuffer.read(framebuffer.viewport(), {ColorFormat::RGBA, ColorType::UnsignedByte});
* @endcode
*/
Image2D read(const Range2Di& rectangle, Image2D&& image);
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief read(const Range2Di&, Image2D&)
* @deprecated Use @ref read(const Range2Di&, Image2D&) instead.
*/
CORRADE_DEPRECATED("use read(const Range2Di&, Image2D& instead) instead") void read(const Vector2i& offset, const Vector2i& size, Image2D& image) {
read({offset, size}, image);
}
#endif
#ifndef MAGNUM_TARGET_GLES2
/**
* @brief Read block of pixels from framebuffer to buffer image
* @param offset Offset in the framebuffer
* @param size %Image size
* @param image %Buffer image where to put the data
* @param usage %Buffer usage
* @param rectangle Framebuffer rectangle to read
* @param image Buffer image where to put the data
* @param usage Buffer usage
*
* See @ref read(const Vector2i&, const Vector2i&, Image2D&) for more
* information.
@ -323,7 +361,27 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @todo Make it more flexible (usable with
* @extension{ARB,buffer_storage}, avoiding relocations...)
*/
void read(const Vector2i& offset, const Vector2i& size, BufferImage2D& image, BufferUsage usage);
void read(const Range2Di& rectangle, BufferImage2D& image, BufferUsage usage);
/** @overload
*
* Convenience alternative to the above, example usage:
* @code
* BufferImage2D image = framebuffer.read(framebuffer.viewport(), {ColorFormat::RGBA, ColorType::UnsignedByte}, BufferUsage::StaticRead);
* @endcode
*/
BufferImage2D read(const Range2Di& rectangle, BufferImage2D&& image, BufferUsage usage);
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief read(const Range2Di&, BufferImage2D&, BufferUsage)
* @deprecated Use @ref read(const Range2Di&, BufferImage2D&, BufferUsage)
* instead.
*/
CORRADE_DEPRECATED("use read(const Range2Di&, BufferImage2D&, BufferUsage) instead") void read(const Vector2i& offset, const Vector2i& size, BufferImage2D& image, BufferUsage usage) {
read({offset, size}, image, usage);
}
#endif
#endif
#ifdef DOXYGEN_GENERATING_OUTPUT
@ -345,40 +403,65 @@ class MAGNUM_EXPORT AbstractFramebuffer {
Range2Di _viewport;
private:
#ifndef MAGNUM_TARGET_GLES2
static void MAGNUM_LOCAL blitImplementationDefault(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);
#ifndef MAGNUM_TARGET_GLES
static void MAGNUM_LOCAL blitImplementationDSA(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);
#endif
#else
static void MAGNUM_LOCAL blitImplementationANGLE(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);
static void MAGNUM_LOCAL blitImplementationNV(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);
#endif
void MAGNUM_LOCAL bindImplementationDefault(FramebufferTarget target);
FramebufferTarget MAGNUM_LOCAL bindImplementationDefault();
#ifdef MAGNUM_TARGET_GLES2
static void MAGNUM_LOCAL blitImplementationANGLE(const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);
static void MAGNUM_LOCAL blitImplementationNV(const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter);
void MAGNUM_LOCAL bindImplementationSingle(FramebufferTarget);
FramebufferTarget MAGNUM_LOCAL bindImplementationSingle();
#endif
GLenum MAGNUM_LOCAL checkStatusImplementationDefault(FramebufferTarget target);
#ifdef MAGNUM_TARGET_GLES2
GLenum MAGNUM_LOCAL checkStatusImplementationSingle(FramebufferTarget);
#endif
#ifndef MAGNUM_TARGET_GLES
GLenum MAGNUM_LOCAL checkStatusImplementationDSA(FramebufferTarget target);
GLenum MAGNUM_LOCAL checkStatusImplementationDSAEXT(FramebufferTarget target);
#endif
void MAGNUM_LOCAL drawBuffersImplementationDefault(GLsizei count, const GLenum* buffers);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL drawBuffersImplementationDSA(GLsizei count, const GLenum* buffers);
void MAGNUM_LOCAL drawBuffersImplementationDSAEXT(GLsizei count, const GLenum* buffers);
#endif
void MAGNUM_LOCAL drawBufferImplementationDefault(GLenum buffer);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL drawBufferImplementationDSA(GLenum buffer);
void MAGNUM_LOCAL drawBufferImplementationDSAEXT(GLenum buffer);
#endif
void MAGNUM_LOCAL readBufferImplementationDefault(GLenum buffer);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer);
void MAGNUM_LOCAL readBufferImplementationDSAEXT(GLenum buffer);
#endif
static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
static void MAGNUM_LOCAL readImplementationRobustness(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
static void MAGNUM_LOCAL readImplementationDefault(const Range2Di& rectangle, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
static void MAGNUM_LOCAL readImplementationRobustness(const Range2Di& rectangle, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*);
void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL invalidateImplementationDSA(GLsizei count, const GLenum* attachments);
#endif
#ifndef MAGNUM_TARGET_GLES2
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&);
void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments, const Range2Di& rectangle);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL invalidateImplementationDSA(GLsizei count, const GLenum* attachments, const Range2Di& rectangle);
#endif
#endif
};

2
src/Magnum/AbstractImage.cpp

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a

2
src/Magnum/AbstractImage.h

@ -3,7 +3,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a

2
src/Magnum/AbstractObject.cpp

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a

4
src/Magnum/AbstractObject.h

@ -3,7 +3,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -44,7 +44,7 @@ namespace Implementation { struct DebugState; }
@brief Base for all OpenGL objects
*/
class MAGNUM_EXPORT AbstractObject {
friend struct Implementation::DebugState;
friend Implementation::DebugState;
public:
/**

2
src/Magnum/AbstractQuery.cpp

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a

17
src/Magnum/AbstractQuery.h

@ -3,7 +3,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -47,7 +47,7 @@ more information.
@todo `QUERY_COUNTER_BITS` (not sure since when this is supported)
*/
class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
friend class Implementation::QueryState;
friend Implementation::QueryState;
public:
/** @brief Copying is not allowed */
@ -66,7 +66,7 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
GLuint id() const { return _id; }
/**
* @brief %Query label
* @brief Query label
*
* The result is *not* cached, repeated queries will result in repeated
* OpenGL calls. If OpenGL 4.3 is not supported and neither
@ -95,7 +95,7 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
/** @overload */
template<std::size_t size> AbstractQuery& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
return setLabelInternal({label, size - 1});
}
/**
@ -115,10 +115,10 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject {
* @attention @ref Magnum::UnsignedLong "UnsignedLong" and @ref Magnum::Long "Long"
* result type is not available in @ref MAGNUM_TARGET_WEBGL "WebGL".
* @see @fn_gl{GetQueryObject} with @def_gl{QUERY_RESULT}
* @requires_gl33 %Extension @extension{ARB,timer_query} for result
* @requires_gl33 Extension @extension{ARB,timer_query} for result
* type @ref Magnum::UnsignedInt "UnsignedInt" and @ref Magnum::Long
* "Long"
* @requires_es_extension %Extension @es_extension{EXT,disjoint_timer_query}
* @requires_es_extension Extension @es_extension{EXT,disjoint_timer_query}
* for result types @ref Magnum::Int "Int", @ref Magnum::UnsignedLong "UnsignedLong"
* @ref Magnum::Long "Long".
*/
@ -186,8 +186,9 @@ inline AbstractQuery::AbstractQuery(AbstractQuery&& other) noexcept: _id(other._
}
inline AbstractQuery& AbstractQuery::operator=(AbstractQuery&& other) noexcept {
std::swap(_id, other._id);
std::swap(_target, other._target);
using std::swap;
swap(_id, other._id);
swap(_target, other._target);
return *this;
}

6
src/Magnum/AbstractResourceLoader.h

@ -3,7 +3,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -101,7 +101,7 @@ Resource<Mesh> myMesh = manager->get<Mesh>("my-mesh");
buffers), should that be allowed?
*/
template<class T> class AbstractResourceLoader {
friend class Implementation::ResourceManagerData<T>;
friend Implementation::ResourceManagerData<T>;
public:
explicit AbstractResourceLoader(): manager(nullptr), _requestedCount(0), _loadedCount(0), _notFoundCount(0) {}
@ -132,7 +132,7 @@ template<class T> class AbstractResourceLoader {
std::size_t loadedCount() const { return _loadedCount; }
/**
* @brief %Resource name corresponding to given key
* @brief Resource name corresponding to given key
*
* If no such resource exists or the resource name is not available,
* returns empty string.

317
src/Magnum/AbstractShaderProgram.cpp

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -247,7 +247,8 @@ AbstractShaderProgram::~AbstractShaderProgram() {
}
AbstractShaderProgram& AbstractShaderProgram::operator=(AbstractShaderProgram&& other) noexcept {
std::swap(_id, other._id);
using std::swap;
swap(_id, other._id);
return *this;
}
@ -313,6 +314,17 @@ void AbstractShaderProgram::bindFragmentDataLocationIndexedInternal(const Unsign
}
#endif
#ifndef MAGNUM_TARGET_GLES2
void AbstractShaderProgram::setTransformFeedbackOutputs(const std::initializer_list<std::string> outputs, const TransformFeedbackBufferMode bufferMode) {
Containers::Array<const char*> names{outputs.size()};
Int i = 0;
for(const std::string& output: outputs) names[i++] = output.data();
glTransformFeedbackVaryings(_id, outputs.size(), names, GLenum(bufferMode));
}
#endif
bool AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<AbstractShaderProgram>> shaders) {
bool allSuccess = true;
@ -1083,305 +1095,4 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
}
#endif
namespace Implementation {
UnsignedInt FloatAttribute::size(GLint components, DataType dataType) {
switch(dataType) {
case DataType::UnsignedByte:
case DataType::Byte:
return components;
case DataType::UnsignedShort:
case DataType::Short:
case DataType::HalfFloat:
return 2*components;
case DataType::UnsignedInt:
case DataType::Int:
case DataType::Float:
return 4*components;
#ifndef MAGNUM_TARGET_GLES
case DataType::Double:
return 8*components;
#endif
}
CORRADE_ASSERT_UNREACHABLE();
}
#ifndef MAGNUM_TARGET_GLES2
UnsignedInt IntAttribute::size(GLint components, DataType dataType) {
switch(dataType) {
case DataType::UnsignedByte:
case DataType::Byte:
return components;
case DataType::UnsignedShort:
case DataType::Short:
return 2*components;
case DataType::UnsignedInt:
case DataType::Int:
return 4*components;
}
CORRADE_ASSERT_UNREACHABLE();
}
#endif
#ifndef MAGNUM_TARGET_GLES
UnsignedInt DoubleAttribute::size(GLint components, DataType dataType) {
switch(dataType) {
case DataType::Double:
return 8*components;
}
CORRADE_ASSERT_UNREACHABLE();
}
#endif
UnsignedInt Attribute<Math::Vector<3, Float>>::size(GLint components, DataType dataType) {
switch(dataType) {
case DataType::UnsignedByte:
case DataType::Byte:
return components;
case DataType::UnsignedShort:
case DataType::Short:
case DataType::HalfFloat:
return 2*components;
case DataType::UnsignedInt:
case DataType::Int:
case DataType::Float:
return 4*components;
#ifndef MAGNUM_TARGET_GLES
case DataType::Double:
return 8*components;
case DataType::UnsignedInt10f11f11fRev:
CORRADE_INTERNAL_ASSERT(components == 3);
return 4;
#endif
}
CORRADE_ASSERT_UNREACHABLE();
}
UnsignedInt Attribute<Math::Vector<4, Float>>::size(GLint components, DataType dataType) {
#ifndef MAGNUM_TARGET_GLES
if(components == GL_BGRA) components = 4;
#endif
switch(dataType) {
case DataType::UnsignedByte:
case DataType::Byte:
return components;
case DataType::UnsignedShort:
case DataType::Short:
case DataType::HalfFloat:
return 2*components;
case DataType::UnsignedInt:
case DataType::Int:
case DataType::Float:
return 4*components;
#ifndef MAGNUM_TARGET_GLES
case DataType::Double:
return 8*components;
#endif
#ifndef MAGNUM_TARGET_GLES2
case DataType::UnsignedInt2101010Rev:
case DataType::Int2101010Rev:
CORRADE_INTERNAL_ASSERT(components == 4);
return 4;
#endif
}
CORRADE_ASSERT_UNREACHABLE();
}
Debug operator<<(Debug debug, SizedAttribute<1, 1>::Components value) {
switch(value) {
case SizedAttribute<1, 1>::Components::One:
return debug << "AbstractShaderProgram::Attribute::Components::One";
}
return debug << "AbstractShaderProgram::Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedAttribute<1, 2>::Components value) {
switch(value) {
case SizedAttribute<1, 2>::Components::One:
return debug << "AbstractShaderProgram::Attribute::Components::One";
case SizedAttribute<1, 2>::Components::Two:
return debug << "AbstractShaderProgram::Attribute::Components::Two";
}
return debug << "AbstractShaderProgram::Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedAttribute<1, 3>::Components value) {
switch(value) {
case SizedAttribute<1, 3>::Components::One:
return debug << "AbstractShaderProgram::Attribute::Components::One";
case SizedAttribute<1, 3>::Components::Two:
return debug << "AbstractShaderProgram::Attribute::Components::Two";
case SizedAttribute<1, 3>::Components::Three:
return debug << "AbstractShaderProgram::Attribute::Components::Three";
}
return debug << "AbstractShaderProgram::Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedAttribute<1, 4>::Components value) {
switch(value) {
case SizedAttribute<1, 4>::Components::One:
return debug << "AbstractShaderProgram::Attribute::Components::One";
case SizedAttribute<1, 4>::Components::Two:
return debug << "AbstractShaderProgram::Attribute::Components::Two";
case SizedAttribute<1, 4>::Components::Three:
return debug << "AbstractShaderProgram::Attribute::Components::Three";
case SizedAttribute<1, 4>::Components::Four:
return debug << "AbstractShaderProgram::Attribute::Components::Four";
}
return debug << "AbstractShaderProgram::Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedMatrixAttribute<2>::Components value) {
switch(value) {
case SizedMatrixAttribute<2>::Components::Two:
return debug << "AbstractShaderProgram::Attribute::Components::Two";
}
return debug << "AbstractShaderProgram::Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedMatrixAttribute<3>::Components value) {
switch(value) {
case SizedMatrixAttribute<3>::Components::Three:
return debug << "AbstractShaderProgram::Attribute::Components::Three";
}
return debug << "AbstractShaderProgram::Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedMatrixAttribute<4>::Components value) {
switch(value) {
case SizedMatrixAttribute<4>::Components::Four:
return debug << "AbstractShaderProgram::Attribute::Components::Four";
}
return debug << "AbstractShaderProgram::Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, Attribute<Math::Vector<4, Float>>::Components value) {
switch(value) {
case Attribute<Math::Vector<4, Float>>::Components::One:
return debug << "AbstractShaderProgram::Attribute::Components::One";
case Attribute<Math::Vector<4, Float>>::Components::Two:
return debug << "AbstractShaderProgram::Attribute::Components::Two";
case Attribute<Math::Vector<4, Float>>::Components::Three:
return debug << "AbstractShaderProgram::Attribute::Components::Three";
case Attribute<Math::Vector<4, Float>>::Components::Four:
return debug << "AbstractShaderProgram::Attribute::Components::Four";
#ifndef MAGNUM_TARGET_GLES
case Attribute<Math::Vector<4, Float>>::Components::BGRA:
return debug << "AbstractShaderProgram::Attribute::Components::BGRA";
#endif
}
return debug << "AbstractShaderProgram::Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, FloatAttribute::DataType value) {
switch(value) {
#define _c(value) case FloatAttribute::DataType::value: return debug << "AbstractShaderProgram::Attribute::DataType::" #value;
_c(UnsignedByte)
_c(Byte)
_c(UnsignedShort)
_c(Short)
_c(UnsignedInt)
_c(Int)
_c(HalfFloat)
_c(Float)
#ifndef MAGNUM_TARGET_GLES
_c(Double)
#endif
#undef _c
}
return debug << "AbstractShaderProgram::Attribute::DataType::(invalid)";
}
#ifndef MAGNUM_TARGET_GLES2
Debug operator<<(Debug debug, IntAttribute::DataType value) {
switch(value) {
#define _c(value) case IntAttribute::DataType::value: return debug << "AbstractShaderProgram::Attribute::DataType::" #value;
_c(UnsignedByte)
_c(Byte)
_c(UnsignedShort)
_c(Short)
_c(UnsignedInt)
_c(Int)
#undef _c
}
return debug << "AbstractShaderProgram::Attribute::DataType::(invalid)";
}
#endif
#ifndef MAGNUM_TARGET_GLES
Debug operator<<(Debug debug, DoubleAttribute::DataType value) {
switch(value) {
#define _c(value) case DoubleAttribute::DataType::value: return debug << "AbstractShaderProgram::Attribute::DataType::" #value;
_c(Double)
#undef _c
}
return debug << "AbstractShaderProgram::Attribute::DataType::(invalid)";
}
#endif
Debug operator<<(Debug debug, Attribute<Math::Vector<3, Float>>::DataType value) {
switch(value) {
#define _c(value) case Attribute<Math::Vector<3, Float>>::DataType::value: return debug << "AbstractShaderProgram::Attribute::DataType::" #value;
_c(UnsignedByte)
_c(Byte)
_c(UnsignedShort)
_c(Short)
_c(UnsignedInt)
_c(Int)
_c(HalfFloat)
_c(Float)
#ifndef MAGNUM_TARGET_GLES
_c(Double)
_c(UnsignedInt10f11f11fRev)
#endif
#undef _c
}
return debug << "AbstractShaderProgram::Attribute::DataType::(invalid)";
}
Debug operator<<(Debug debug, Attribute<Math::Vector<4, Float>>::DataType value) {
switch(value) {
#define _c(value) case Attribute<Math::Vector<4, Float>>::DataType::value: return debug << "AbstractShaderProgram::Attribute::DataType::" #value;
_c(UnsignedByte)
_c(Byte)
_c(UnsignedShort)
_c(Short)
_c(UnsignedInt)
_c(Int)
_c(HalfFloat)
_c(Float)
#ifndef MAGNUM_TARGET_GLES
_c(Double)
#endif
#ifndef MAGNUM_TARGET_GLES2
_c(UnsignedInt2101010Rev)
_c(Int2101010Rev)
#endif
#undef _c
}
return debug << "AbstractShaderProgram::Attribute::DataType::(invalid)";
}
}
}

800
src/Magnum/AbstractShaderProgram.h

File diff suppressed because it is too large Load Diff

505
src/Magnum/AbstractTexture.cpp

@ -1,7 +1,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -35,6 +35,7 @@
#include "Magnum/Extensions.h"
#include "Magnum/Image.h"
#include "Magnum/TextureFormat.h"
#include "Magnum/Math/Range.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include "Magnum/Shader.h"
@ -116,25 +117,25 @@ Int AbstractTexture::maxIntegerSamples() {
#endif
void AbstractTexture::unbind(const Int textureUnit) {
Implementation::TextureState* const textureState = Context::current()->state().texture;
Implementation::TextureState& textureState = *Context::current()->state().texture;
/* If given texture unit is already unbound, nothing to do */
if(textureState->bindings[textureUnit].second == 0) return;
if(textureState.bindings[textureUnit].second == 0) return;
/* Unbind the texture, reset state tracker */
Context::current()->state().texture->unbindImplementation(textureUnit);
textureState->bindings[textureUnit] = {};
textureState.bindings[textureUnit] = {};
}
void AbstractTexture::unbindImplementationDefault(const GLint textureUnit) {
Implementation::TextureState* const textureState = Context::current()->state().texture;
Implementation::TextureState& textureState = *Context::current()->state().texture;
/* Activate given texture unit if not already active, update state tracker */
if(textureState->currentTextureUnit != textureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = textureUnit));
if(textureState.currentTextureUnit != textureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = textureUnit));
CORRADE_INTERNAL_ASSERT(textureState->bindings[textureUnit].first != 0);
glBindTexture(textureState->bindings[textureUnit].first, 0);
CORRADE_INTERNAL_ASSERT(textureState.bindings[textureUnit].first != 0);
glBindTexture(textureState.bindings[textureUnit].first, 0);
}
#ifndef MAGNUM_TARGET_GLES
@ -143,11 +144,18 @@ void AbstractTexture::unbindImplementationMulti(const GLint textureUnit) {
glBindTextures(textureUnit, 1, &zero);
}
void AbstractTexture::unbindImplementationDSA(const GLint textureUnit) {
Implementation::TextureState& textureState = *Context::current()->state().texture;
CORRADE_INTERNAL_ASSERT(textureState.bindings[textureUnit].first != 0);
glBindTextureUnit(textureUnit, 0);
}
void AbstractTexture::unbindImplementationDSAEXT(const GLint textureUnit) {
Implementation::TextureState* const textureState = Context::current()->state().texture;
Implementation::TextureState& textureState = *Context::current()->state().texture;
CORRADE_INTERNAL_ASSERT(textureState->bindings[textureUnit].first != 0);
glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, textureState->bindings[textureUnit].first, 0);
CORRADE_INTERNAL_ASSERT(textureState.bindings[textureUnit].first != 0);
glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, textureState.bindings[textureUnit].first, 0);
}
#endif
@ -168,8 +176,9 @@ void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, c
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, const Containers::ArrayReference<AbstractTexture* const> textures) {
Implementation::TextureState* const textureState = Context::current()->state().texture;
/** @todoc const Containers::ArrayReference makes Doxygen grumpy */
void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Containers::ArrayReference<AbstractTexture* const> textures) {
Implementation::TextureState& textureState = *Context::current()->state().texture;
/* Create array of IDs and also update bindings in state tracker */
Containers::Array<GLuint> ids{textures ? textures.size() : 0};
@ -182,9 +191,9 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, cons
ids[i] = id;
}
if(textureState->bindings[firstTextureUnit + i].second != id) {
if(textureState.bindings[firstTextureUnit + i].second != id) {
different = true;
textureState->bindings[firstTextureUnit + i].second = id;
textureState.bindings[firstTextureUnit + i].second = id;
}
}
@ -246,22 +255,22 @@ AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayRefere
}
void AbstractTexture::bind(Int textureUnit) {
Implementation::TextureState* const textureState = Context::current()->state().texture;
Implementation::TextureState& textureState = *Context::current()->state().texture;
/* If already bound in given texture unit, nothing to do */
if(textureState->bindings[textureUnit].second == _id) return;
if(textureState.bindings[textureUnit].second == _id) return;
/* Update state tracker, bind the texture to the unit */
textureState->bindings[textureUnit] = {_target, _id};
(this->*Context::current()->state().texture->bindImplementation)(textureUnit);
textureState.bindings[textureUnit] = {_target, _id};
(this->*textureState.bindImplementation)(textureUnit);
}
void AbstractTexture::bindImplementationDefault(GLint textureUnit) {
Implementation::TextureState* const textureState = Context::current()->state().texture;
Implementation::TextureState& textureState = *Context::current()->state().texture;
/* Activate given texture unit if not already active, update state tracker */
if(textureState->currentTextureUnit != textureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = textureUnit));
if(textureState.currentTextureUnit != textureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = textureUnit));
/* Binding the texture finally creates it */
_created = true;
@ -274,6 +283,10 @@ void AbstractTexture::bindImplementationMulti(GLint textureUnit) {
glBindTextures(textureUnit, 1, &_id);
}
void AbstractTexture::bindImplementationDSA(const GLint textureUnit) {
glBindTextureUnit(textureUnit, _id);
}
void AbstractTexture::bindImplementationDSAEXT(GLint textureUnit) {
_created = true;
glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, _target, _id);
@ -401,6 +414,10 @@ void AbstractTexture::mipmapImplementationDefault() {
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::mipmapImplementationDSA() {
glGenerateTextureMipmap(_id);
}
void AbstractTexture::mipmapImplementationDSAEXT() {
_created = true;
glGenerateTextureMipmapEXT(_id, _target);
@ -412,21 +429,21 @@ void AbstractTexture::bindInternal() {
functions need to have the texture bound in *currently active* unit,
so we would need to call glActiveTexture() afterwards anyway. */
Implementation::TextureState* const textureState = Context::current()->state().texture;
Implementation::TextureState& textureState = *Context::current()->state().texture;
/* If the texture is already bound in current unit, nothing to do */
if(textureState->bindings[textureState->currentTextureUnit].second == _id)
if(textureState.bindings[textureState.currentTextureUnit].second == _id)
return;
/* Set internal unit as active if not already, update state tracker */
CORRADE_INTERNAL_ASSERT(textureState->maxTextureUnits > 1);
const GLint internalTextureUnit = textureState->maxTextureUnits-1;
if(textureState->currentTextureUnit != internalTextureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = internalTextureUnit));
CORRADE_INTERNAL_ASSERT(textureState.maxTextureUnits > 1);
const GLint internalTextureUnit = textureState.maxTextureUnits-1;
if(textureState.currentTextureUnit != internalTextureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = internalTextureUnit));
/* Bind the texture to internal unit if not already, update state tracker */
if(textureState->bindings[internalTextureUnit].second == _id) return;
textureState->bindings[internalTextureUnit] = {_target, _id};
if(textureState.bindings[internalTextureUnit].second == _id) return;
textureState.bindings[internalTextureUnit] = {_target, _id};
/* Binding the texture finally creates it */
_created = true;
@ -810,6 +827,10 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLint val
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLint value) {
glTextureParameteri(_id, parameter, value);
}
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLint value) {
_created = true;
glTextureParameteriEXT(_id, _target, parameter, value);
@ -822,6 +843,10 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLfloat v
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLfloat value) {
glTextureParameterf(_id, parameter, value);
}
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLfloat value) {
_created = true;
glTextureParameterfEXT(_id, _target, parameter, value);
@ -835,6 +860,10 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLi
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLint* const values) {
glTextureParameteriv(_id, parameter, values);
}
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, const GLint* values) {
_created = true;
glTextureParameterivEXT(_id, _target, parameter, values);
@ -848,6 +877,10 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLf
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLfloat* const values) {
glTextureParameterfv(_id, parameter, values);
}
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, const GLfloat* values) {
_created = true;
glTextureParameterfvEXT(_id, _target, parameter, values);
@ -860,6 +893,10 @@ void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GL
glTexParameterIuiv(_target, parameter, values);
}
void AbstractTexture::parameterIImplementationDSA(const GLenum parameter, const GLuint* const values) {
glTextureParameterIuiv(_id, parameter, values);
}
void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLuint* values) {
_created = true;
glTextureParameterIuivEXT(_id, _target, parameter, values);
@ -870,6 +907,10 @@ void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GL
glTexParameterIiv(_target, parameter, values);
}
void AbstractTexture::parameterIImplementationDSA(const GLenum parameter, const GLint* const values) {
glTextureParameterIiv(_id, parameter, values);
}
void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLint* values) {
_created = true;
glTextureParameterIivEXT(_id, _target, parameter, values);
@ -883,59 +924,65 @@ void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) {
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values) {
void AbstractTexture::getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values) {
bindInternal();
glGetTexLevelParameteriv(target, level, parameter, values);
glGetTexLevelParameteriv(_target, level, parameter, values);
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::getLevelParameterImplementationDSAEXT(GLenum target, GLint level, GLenum parameter, GLint* values) {
void AbstractTexture::getLevelParameterImplementationDSA(const GLint level, const GLenum parameter, GLint* const values) {
glGetTextureLevelParameteriv(_id, level, parameter, values);
}
void AbstractTexture::getLevelParameterImplementationDSAEXT(GLint level, GLenum parameter, GLint* values) {
_created = true;
glGetTextureLevelParameterivEXT(_id, target, level, parameter, values);
glGetTextureLevelParameterivEXT(_id, _target, level, parameter, values);
}
#endif
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
CORRADE_INTERNAL_ASSERT(target == GL_TEXTURE_1D);
void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat);
for(GLsizei level = 0; level != levels; ++level) {
(this->*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, Math::max(Math::Vector<1, GLsizei>(1), size >> level), format, type, nullptr);
}
for(GLsizei level = 0; level != levels; ++level)
DataHelper<1>::setImage(*this, level, internalFormat,
ImageReference1D{format, type, Math::max(Math::Vector<1, GLsizei>(1), size >> level)});
}
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
bindInternal();
glTexStorage1D(target, levels, GLenum(internalFormat), size[0]);
glTexStorage1D(_target, levels, GLenum(internalFormat), size[0]);
}
void AbstractTexture::storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
glTextureStorage1D(_id, levels, GLenum(internalFormat), size[0]);
}
void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
_created = true;
glTextureStorage1DEXT(_id, target, levels, GLenum(internalFormat), size[0]);
glTextureStorage1DEXT(_id, _target, levels, GLenum(internalFormat), size[0]);
}
#endif
void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat);
/* Common code for classic types */
#ifndef MAGNUM_TARGET_GLES
if(target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE)
if(_target == GL_TEXTURE_2D || _target == GL_TEXTURE_RECTANGLE)
#else
if(target == GL_TEXTURE_2D)
if(_target == GL_TEXTURE_2D)
#endif
{
for(GLsizei level = 0; level != levels; ++level) {
(this->*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, Math::max(Vector2i(1), size >> level), format, type, nullptr);
}
for(GLsizei level = 0; level != levels; ++level)
DataHelper<2>::setImage(*this, level, internalFormat,
ImageReference2D{format, type, Math::max(Vector2i(1), size >> level)});
/* Cube map additionally needs to specify all faces */
} else if(target == GL_TEXTURE_CUBE_MAP) {
} else if(_target == GL_TEXTURE_CUBE_MAP) {
for(GLsizei level = 0; level != levels; ++level) {
const std::initializer_list<GLenum> faces = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
@ -946,29 +993,29 @@ void AbstractTexture::storageImplementationFallback(const GLenum target, const G
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
};
for(auto it = faces.begin(); it != faces.end(); ++it)
(this->*Context::current()->state().texture->image2DImplementation)(*it, level, internalFormat, Math::max(Vector2i(1), size >> level), format, type, nullptr);
DataHelper<2>::setImage(*this, *it, level, internalFormat,
ImageReference2D{format, type, Math::max(Vector2i(1), size >> level)});
}
#ifndef MAGNUM_TARGET_GLES
/* Array texture is not scaled in "layer" dimension */
} else if(target == GL_TEXTURE_1D_ARRAY) {
for(GLsizei level = 0; level != levels; ++level) {
(this->*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, Math::max(Vector2i(1), size >> level), format, type, nullptr);
}
} else if(_target == GL_TEXTURE_1D_ARRAY) {
for(GLsizei level = 0; level != levels; ++level)
DataHelper<2>::setImage(*this, level, internalFormat,
ImageReference2D{format, type, Vector2i{Math::max(1, size.x() >> level), size.y()}});
#endif
/* No other targets are available */
} else CORRADE_ASSERT_UNREACHABLE();
}
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
bindInternal();
#ifndef MAGNUM_TARGET_GLES2
glTexStorage2D(target, levels, GLenum(internalFormat), size.x(), size.y());
glTexStorage2D(_target, levels, GLenum(internalFormat), size.x(), size.y());
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
glTexStorage2DEXT(target, levels, GLenum(internalFormat), size.x(), size.y());
glTexStorage2DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y());
#else
static_cast<void>(target);
static_cast<void>(levels);
static_cast<void>(internalFormat);
static_cast<void>(size);
@ -977,53 +1024,53 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
glTextureStorage2D(_id, levels, GLenum(internalFormat), size.x(), size.y());
}
void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Vector2i& size) {
_created = true;
glTextureStorage2DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y());
glTextureStorage2DEXT(_id, _target, levels, GLenum(internalFormat), size.x(), size.y());
}
#endif
void AbstractTexture::storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
void AbstractTexture::storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat);
/* Common code for classic type */
#ifndef MAGNUM_TARGET_GLES2
if(target == GL_TEXTURE_3D)
if(_target == GL_TEXTURE_3D)
#else
if(target == GL_TEXTURE_3D_OES)
if(_target == GL_TEXTURE_3D_OES)
#endif
{
for(GLsizei level = 0; level != levels; ++level) {
(this->*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, Math::max(Vector3i(1), size >> level), format, type, nullptr);
}
for(GLsizei level = 0; level != levels; ++level)
DataHelper<3>::setImage(*this, level, internalFormat,
ImageReference3D{format, type, Math::max(Vector3i(1), size >> level)});
#ifndef MAGNUM_TARGET_GLES2
/* Array texture is not scaled in "layer" dimension */
}
#ifndef MAGNUM_TARGET_GLES
else if(target == GL_TEXTURE_2D_ARRAY || target == GL_TEXTURE_CUBE_MAP_ARRAY)
else if(_target == GL_TEXTURE_2D_ARRAY || _target == GL_TEXTURE_CUBE_MAP_ARRAY)
#else
else if(target == GL_TEXTURE_2D_ARRAY)
else if(_target == GL_TEXTURE_2D_ARRAY)
#endif
{
for(GLsizei level = 0; level != levels; ++level) {
(this->*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, Math::max(Vector3i(1), size >> level), format, type, nullptr);
}
for(GLsizei level = 0; level != levels; ++level)
DataHelper<3>::setImage(*this, level, internalFormat,
ImageReference3D{format, type, Vector3i{Math::max(Vector2i{1}, size.xy() >> level), size.z()}});
#endif
/* No other targets are available */
} else CORRADE_ASSERT_UNREACHABLE();
else CORRADE_ASSERT_UNREACHABLE();
}
void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
void AbstractTexture::storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
bindInternal();
#ifndef MAGNUM_TARGET_GLES2
glTexStorage3D(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
glTexStorage3D(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
glTexStorage3DEXT(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
glTexStorage3DEXT(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
#else
static_cast<void>(target);
static_cast<void>(levels);
static_cast<void>(internalFormat);
static_cast<void>(size);
@ -1032,146 +1079,120 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
void AbstractTexture::storageImplementationDSA(const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) {
glTextureStorage3D(_id, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
}
void AbstractTexture::storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Vector3i& size) {
_created = true;
glTextureStorage3DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
glTextureStorage3DEXT(_id, _target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageMultisampleImplementationFallback(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
void AbstractTexture::storageMultisampleImplementationFallback(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
bindInternal();
glTexImage2DMultisample(target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
glTexImage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
}
#endif
#ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::storageMultisampleImplementationDefault(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
void AbstractTexture::storageMultisampleImplementationDefault(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
bindInternal();
glTexStorage2DMultisample(target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
glTexStorage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
_created = true;
glTextureStorage2DMultisampleEXT(_id, target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
glTextureStorage2DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
}
void AbstractTexture::storageMultisampleImplementationFallback(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
bindInternal();
glTexImage3DMultisample(target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
_created = true;
glTextureStorage2DMultisampleEXT(_id, _target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
}
void AbstractTexture::storageMultisampleImplementationDefault(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
void AbstractTexture::storageMultisampleImplementationFallback(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
bindInternal();
glTexStorage3DMultisample(target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
glTexImage3DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
}
void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
_created = true;
glTextureStorage3DMultisampleEXT(_id, target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::getImageImplementationDefault(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
void AbstractTexture::storageMultisampleImplementationDefault(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
bindInternal();
glGetTexImage(target, level, GLenum(format), GLenum(type), data);
glTexStorage3DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
}
void AbstractTexture::getImageImplementationDSAEXT(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
_created = true;
glGetTextureImageEXT(_id, target, level, GLenum(format), GLenum(type), data);
void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
glTextureStorage3DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
}
void AbstractTexture::getImageImplementationRobustness(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
bindInternal();
glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data);
void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
_created = true;
glTextureStorage3DMultisampleEXT(_id, _target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::getImageImplementationDefault(const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
bindInternal();
glTexImage1D(target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data);
glGetTexImage(_target, level, GLenum(format), GLenum(type), data);
}
void AbstractTexture::imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
_created = true;
glTextureImage1DEXT(_id, target, level, GLint(internalFormat), size[0], 0, GLenum(format), GLenum(type), data);
}
#endif
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
glTexImage2D(target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data);
void AbstractTexture::getImageImplementationDSA(const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
glGetTextureImage(_id, level, GLenum(format), GLenum(type), dataSize, data);
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::getImageImplementationDSAEXT(const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
_created = true;
glTextureImage2DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), 0, GLenum(format), GLenum(type), data);
glGetTextureImageEXT(_id, _target, level, GLenum(format), GLenum(type), data);
}
#endif
void AbstractTexture::imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::getImageImplementationRobustness(const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
bindInternal();
#ifndef MAGNUM_TARGET_GLES2
glTexImage3D(target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
glTexImage3DOES(target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
#else
static_cast<void>(target);
static_cast<void>(level);
static_cast<void>(internalFormat);
static_cast<void>(size);
static_cast<void>(format);
static_cast<void>(type);
static_cast<void>(data);
CORRADE_ASSERT_UNREACHABLE();
#endif
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
_created = true;
glTextureImage3DEXT(_id, target, level, GLint(internalFormat), size.x(), size.y(), size.z(), 0, GLenum(format), GLenum(type), data);
glGetnTexImageARB(_target, level, GLenum(format), GLenum(type), dataSize, data);
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
glTexSubImage1D(target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
glTexSubImage1D(_target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
}
void AbstractTexture::subImageImplementationDSAEXT(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDSA(const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
glTextureSubImage1D(_id, level, offset[0], size[0], GLenum(format), GLenum(type), data);
}
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data) {
_created = true;
glTextureSubImage1DEXT(_id, target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
glTextureSubImage1DEXT(_id, _target, level, offset[0], size[0], GLenum(format), GLenum(type), data);
}
#endif
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
glTexSubImage2D(target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
glTexSubImage2D(_target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSAEXT(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDSA(const GLint level, const Vector2i& offset, const Vector2i& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
glTextureSubImage2D(_id, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
_created = true;
glTextureSubImage2DEXT(_id, target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
glTextureSubImage2DEXT(_id, _target, level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data);
}
#endif
void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
bindInternal();
#ifndef MAGNUM_TARGET_GLES2
glTexSubImage3D(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
glTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
glTexSubImage3DOES(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
glTexSubImage3DOES(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
#else
static_cast<void>(target);
static_cast<void>(level);
static_cast<void>(offset);
static_cast<void>(size);
@ -1183,9 +1204,13 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level,
}
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::subImageImplementationDSAEXT(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
void AbstractTexture::subImageImplementationDSA(const GLint level, const Vector3i& offset, const Vector3i& size, const ColorFormat format, const ColorType type, const GLvoid* const data) {
glTextureSubImage3D(_id, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
}
void AbstractTexture::subImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data) {
_created = true;
glTextureSubImage3DEXT(_id, target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
glTextureSubImage3DEXT(_id, _target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
}
#endif
@ -1209,109 +1234,148 @@ void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vec
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, Image<dimensions>& image) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, target, level);
template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Image<dimensions>& image) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
const std::size_t dataSize = image.dataSize(size);
char* data = new char[dataSize];
(this->*Context::current()->state().texture->getImageImplementation)(target, level, image.format(), image.type(), dataSize, data);
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
(this->*Context::current()->state().texture->getImageImplementation)(level, image.format(), image.type(), dataSize, data);
image.setData(image.format(), image.type(), size, data);
}
template void MAGNUM_EXPORT AbstractTexture::image<1>(GLenum, GLint, Image<1>&);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, Image<2>&);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, Image<3>&);
template void MAGNUM_EXPORT AbstractTexture::image<1>(GLint, Image<1>&);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLint, Image<2>&);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, Image<3>&);
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, BufferImage<dimensions>& image, BufferUsage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, target, level);
template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, BufferImage<dimensions>& image, BufferUsage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
const std::size_t dataSize = image.dataSize(size);
if(image.size() != size)
image.setData(image.format(), image.type(), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
(this->*Context::current()->state().texture->getImageImplementation)(target, level, image.format(), image.type(), dataSize, nullptr);
(this->*Context::current()->state().texture->getImageImplementation)(level, image.format(), image.type(), dataSize, nullptr);
}
template void MAGNUM_EXPORT AbstractTexture::image<1>(GLenum, GLint, BufferImage<1>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, BufferImage<2>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, BufferImage<3>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<1>(GLint, BufferImage<1>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLint, BufferImage<2>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, BufferImage<3>&, BufferUsage);
template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image) {
createIfNotAlready();
const Math::Vector<dimensions, Int> size = range.size();
const Vector3i paddedOffset = Vector3i::pad(range.min());
const Vector3i paddedSize = Vector3i::pad(size, 1);
const std::size_t dataSize = image.dataSize(size);
char* data = new char[dataSize];
Buffer::unbindInternal(Buffer::TargetHint::PixelPack);
glGetTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), GLenum(image.format()), GLenum(image.type()), dataSize, data);
image.setData(image.format(), image.type(), size, data);
}
template void MAGNUM_EXPORT AbstractTexture::subImage<1>(GLint, const Range1Di&, Image<1>&);
template void MAGNUM_EXPORT AbstractTexture::subImage<2>(GLint, const Range2Di&, Image<2>&);
template void MAGNUM_EXPORT AbstractTexture::subImage<3>(GLint, const Range3Di&, Image<3>&);
template<UnsignedInt dimensions> void AbstractTexture::subImage(const GLint level, const RangeTypeFor<dimensions, Int>& range, BufferImage<dimensions>& image, const BufferUsage usage) {
createIfNotAlready();
const Math::Vector<dimensions, Int> size = range.size();
const std::size_t dataSize = image.dataSize(size);
const Vector3i paddedOffset = Vector3i::pad(range.min());
const Vector3i paddedSize = Vector3i::pad(size, 1);
if(image.size() != size)
image.setData(image.format(), image.type(), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack);
glGetTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), GLenum(image.format()), GLenum(image.type()), dataSize, nullptr);
}
template void MAGNUM_EXPORT AbstractTexture::subImage<1>(GLint, const Range1Di&, BufferImage<1>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::subImage<2>(GLint, const Range2Di&, BufferImage<2>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::subImage<3>(GLint, const Range3Di&, BufferImage<3>&, BufferUsage);
#endif
#endif
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES
Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) {
Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, const GLint level) {
Math::Vector<1, GLint> value;
(texture.*Context::current()->state().texture->getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*Context::current()->state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
return value;
}
#endif
#ifndef MAGNUM_TARGET_GLES2
Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) {
Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLint level) {
const Implementation::TextureState& state = *Context::current()->state().texture;
Vector2i value;
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]);
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
return value;
}
Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) {
Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, const GLint level) {
const Implementation::TextureState& state = *Context::current()->state().texture;
Vector3i value;
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]);
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_DEPTH, &value[2]);
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
(texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_DEPTH, &value[2]);
return value;
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture& texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) {
(texture.*Context::current()->state().texture->storage1DImplementation)(target, levels, internalFormat, size);
void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) {
(texture.*Context::current()->state().texture->storage1DImplementation)(levels, internalFormat, size);
}
#endif
void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
(texture.*Context::current()->state().texture->storage2DImplementation)(target, levels, internalFormat, size);
void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
(texture.*Context::current()->state().texture->storage2DImplementation)(levels, internalFormat, size);
}
void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) {
(texture.*Context::current()->state().texture->storage3DImplementation)(target, levels, internalFormat, size);
void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) {
(texture.*Context::current()->state().texture->storage3DImplementation)(levels, internalFormat, size);
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
(texture.*Context::current()->state().texture->storage2DMultisampleImplementation)(target, samples, internalFormat, size, fixedSampleLocations);
void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
(texture.*Context::current()->state().texture->storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations);
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& texture, const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
(texture.*Context::current()->state().texture->storage3DMultisampleImplementation)(target, samples, internalFormat, size, fixedSampleLocations);
void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
(texture.*Context::current()->state().texture->storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations);
}
#endif
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference1D& image) {
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageReference1D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
(texture.*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data());
texture.bindInternal();
glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(image.format()), GLenum(image.type()), image.data());
}
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) {
void AbstractTexture::DataHelper<1>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage1D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
(texture.*Context::current()->state().texture->image1DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
texture.bindInternal();
glTexImage1D(texture._target, level, GLint(internalFormat), image.size()[0], 0, GLenum(image.format()), GLenum(image.type()), nullptr);
}
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image) {
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image) {
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
(texture.*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data());
(texture.*Context::current()->state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), image.data());
}
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) {
void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
(texture.*Context::current()->state().texture->subImage1DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
(texture.*Context::current()->state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr);
}
#endif
@ -1319,55 +1383,68 @@ void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GL
#ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif
(texture.*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data());
texture.bindInternal();
glTexImage2D(target, level, GLint(internalFormat), image.size().x(), image.size().y(), 0, GLenum(image.format()), GLenum(image.type()), image.data());
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
(texture.*Context::current()->state().texture->image2DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
texture.bindInternal();
glTexImage2D(target, level, GLint(internalFormat), image.size().x(), image.size().y(), 0, GLenum(image.format()), GLenum(image.type()), nullptr);
}
#endif
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector2i& offset, const ImageReference2D& image) {
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const ImageReference2D& image) {
#ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif
(texture.*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data());
(texture.*Context::current()->state().texture->subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), image.data());
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector2i& offset, BufferImage2D& image) {
void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, BufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
(texture.*Context::current()->state().texture->subImage2DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
(texture.*Context::current()->state().texture->subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr);
}
#endif
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) {
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, const ImageReference3D& image) {
#ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif
(texture.*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), image.data());
texture.bindInternal();
#ifndef MAGNUM_TARGET_GLES2
glTexImage3D(texture._target, level, GLint(internalFormat), image.size().x(), image.size().y(), image.size().z(), 0, GLenum(image.format()), GLenum(image.type()), image.data());
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL)
glTexImage3DOES(texture._target, level, GLint(internalFormat), image.size().x(), image.size().y(), image.size().z(), 0, GLenum(image.format()), GLenum(image.type()), image.data());
#else
static_cast<void>(level);
static_cast<void>(internalFormat);
static_cast<void>(image);
CORRADE_ASSERT_UNREACHABLE();
#endif
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) {
void AbstractTexture::DataHelper<3>::setImage(AbstractTexture& texture, const GLint level, const TextureFormat internalFormat, BufferImage3D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
(texture.*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, image.size(), image.format(), image.type(), nullptr);
texture.bindInternal();
glTexImage3D(texture._target, level, GLint(internalFormat), image.size().x(), image.size().y(), image.size().z(), 0, GLenum(image.format()), GLenum(image.type()), nullptr);
}
#endif
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector3i& offset, const ImageReference3D& image) {
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const ImageReference3D& image) {
#ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif
(texture.*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), image.data());
(texture.*Context::current()->state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), image.data());
}
#ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLenum target, const GLint level, const Vector3i& offset, BufferImage3D& image) {
void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, BufferImage3D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack);
(texture.*Context::current()->state().texture->subImage3DImplementation)(target, level, offset, image.size(), image.format(), image.type(), nullptr);
(texture.*Context::current()->state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr);
}
#endif

238
src/Magnum/AbstractTexture.h

@ -3,7 +3,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -31,8 +31,13 @@
#include <Corrade/Containers/Array.h>
#include "Magnum/Sampler.h"
#include "Magnum/AbstractObject.h"
#include "Magnum/DimensionTraits.h"
#include "Magnum/Sampler.h"
#ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Utility/Macros.h>
#endif
#ifdef CORRADE_GCC45_COMPATIBILITY
#include "Buffer.h"
@ -75,27 +80,36 @@ documentation for details.
The engine tracks currently bound textures in all available texture units to
avoid unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}.
%Texture configuration functions use dedicated highest available texture unit
to not affect active bindings in user units. %Texture limits and
Texture configuration functions use dedicated highest available texture unit
to not affect active bindings in user units. Texture limits and
implementation-defined values (such as @ref maxColorSamples()) are cached, so
repeated queries don't result in repeated @fn_gl{Get} calls.
If extension @extension{ARB,multi_bind} is available, @ref bind() uses
@fn_gl{BindTextures} to avoid unnecessary calls to @fn_gl{ActiveTexture}.
Otherwise, if extension @extension{EXT,direct_state_access} is available,
@ref bind() uses @fn_gl_extension{BindMultiTexture,EXT,direct_state_access}
function.
In addition, if extension @extension{EXT,direct_state_access} is available,
also all texture configuration and data updating functions use DSA functions
to avoid unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}.
See respective function documentation for more information.
If on desktop GL and @extension{ARB,direct_state_access} (part of OpenGL 4.5)
is available, @ref bind(Int) and @ref unbind(Int) use @fn_gl{BindTextureUnit}.
Otherwise, if @extension{ARB,multi_bind} (part of OpenGL 4.4) is available,
@ref bind(Int) and @ref unbind() uses @fn_gl{BindTextures}. Lastly, if
@extension{EXT,direct_state_access} is available, @fn_gl_extension{BindNamedTexture,EXT,direct_state_access}
function is used to avoid unnecessary calls to @fn_gl{ActiveTexture}.
In addition, if either @extension{ARB,direct_state_access} (part of OpenGL 4.5)
or @extension{EXT,direct_state_access} is available, also all texture
configuration and data updating functions use DSA functions to avoid
unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. See
respective function documentation for more information.
If @extension{ARB,multi_bind} (part of OpenGL 4.5) is available,
@ref bind(Int, std::initializer_list<AbstractTexture*>) and @ref unbind(Int, std::size_t)
use @fn_gl{BindTextures} to avoid unnecessary calls to @fn_gl{ActiveTexture}.
Otherwise the feature is emulated with sequence of @ref bind(Int)/@ref unbind(Int)
calls.
If extension @extension{ARB,robustness} is available, image reading operations
(such as @ref Texture::image()) are protected from buffer overflow. However, if
both @extension{EXT,direct_state_access} and @extension{ARB,robustness} are
available, the DSA version is used, because it is better for performance and
there isn't any function combining both features.
If either @extension{ARB,direct_state_access} or @extension{ARB,robustness} is
available, image reading operations (such as @ref Texture::image()) are
protected from buffer overflow. However, if @extension{ARB,direct_state_access}
is not available and both @extension{EXT,direct_state_access} and
@extension{ARB,robustness} are available, the robust version is preferred over
DSA.
To achieve least state changes, fully configure each texture in one run --
method chaining comes in handy -- and try to have often used textures in
@ -128,13 +142,10 @@ functions do nothing.
@todo `GL_NUM_COMPRESSED_TEXTURE_FORMATS` when compressed textures are implemented
@todo `GL_MAX_SAMPLE_MASK_WORDS` when @extension{ARB,texture_multisample} is done
@todo Query for immutable levels (@extension{ARB,ES3_compatibility})
@bug If using @extension{ARB,multi_bind} and the texture is bound right after
construction, the @fn_gl{BindTextures} call will fail with
Renderer::Error::InvalidOperation, because the texture doesn't yet have
associated target
*/
class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
friend struct Implementation::TextureState;
friend Implementation::TextureState;
friend CubeMapTexture;
public:
#ifdef MAGNUM_BUILD_DEPRECATED
@ -153,7 +164,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
* The result is cached, repeated queries don't result in repeated
* OpenGL calls.
* @see @fn_gl{Get} with @def_gl{MAX_TEXTURE_LOD_BIAS}
* @requires_gles30 %Texture LOD bias doesn't have
* @requires_gles30 Texture LOD bias doesn't have
* implementation-defined range in OpenGL ES 2.0.
*/
static Float maxLodBias();
@ -197,15 +208,17 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
/**
* @brief Unbind any texture from given texture unit
*
* If @extension{ARB,multi_bind} (part of OpenGL 4.4) or
* @extension{EXT,direct_state_access} is not available, the texture
* unit is made active before binding the texture.
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part
* of OpenGL 4.5), @extension{ARB,multi_bind} (part of OpenGL 4.4) nor
* @extension{EXT,direct_state_access} is available, the texture unit
* is made active before unbinding the texture.
* @note This function is meant to be used only internally from
* @ref AbstractShaderProgram subclasses. See its documentation
* for more information.
* @see @ref bind(), @ref Shader::maxCombinedTextureImageUnits(),
* @fn_gl{ActiveTexture}, @fn_gl{BindTexture}, @fn_gl{BindTextures}
* or @fn_gl_extension{BindMultiTexture,EXT,direct_state_access}
* @fn_gl{BindTextureUnit}, @fn_gl{BindTextures},
* @fn_gl_extension{BindMultiTexture,EXT,direct_state_access},
* eventually @fn_gl{ActiveTexture} and @fn_gl{BindTexture}
*/
static void unbind(Int textureUnit);
@ -218,9 +231,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
* @note This function is meant to be used only internally from
* @ref AbstractShaderProgram subclasses. See its documentation
* for more information.
* @see @ref Shader::maxCombinedTextureImageUnits(), @fn_gl{BindTextures},
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} or
* @fn_gl_extension{BindMultiTexture,EXT,direct_state_access}
* @see @ref Shader::maxCombinedTextureImageUnits(), @fn_gl{BindTextures}
*/
static void unbind(Int firstTextureUnit, std::size_t count);
@ -235,9 +246,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
* @note This function is meant to be used only internally from
* @ref AbstractShaderProgram subclasses. See its documentation
* for more information.
* @see @ref Shader::maxCombinedTextureImageUnits(), @fn_gl{BindTextures},
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} or
* @fn_gl_extension{BindMultiTexture,EXT,direct_state_access}
* @see @ref Shader::maxCombinedTextureImageUnits(), @fn_gl{BindTextures}
*/
static void bind(Int firstTextureUnit, std::initializer_list<AbstractTexture*> textures);
@ -262,7 +271,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
AbstractTexture& operator=(AbstractTexture&& other) noexcept;
/**
* @brief %Texture label
* @brief Texture label
*
* The result is *not* cached, repeated queries will result in repeated
* OpenGL calls. If OpenGL 4.3 is not supported and neither
@ -291,7 +300,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
/** @overload */
template<std::size_t size> AbstractTexture& setLabel(const char(&label)[size]) {
return setLabelInternal(label);
return setLabelInternal({label, size - 1});
}
/** @brief OpenGL texture ID */
@ -300,16 +309,18 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
/**
* @brief Bind texture to given texture unit
*
* If @extension{ARB,multi_bind} (part of OpenGL 4.4) or
* @extension{EXT,direct_state_access} is not available, the texture
* unit is made active before binding the texture.
* If on OpenGL ES or neither @extension{ARB,direct_state_access} (part
* of OpenGL 4.5), @extension{ARB,multi_bind} (part of OpenGL 4.4) nor
* @extension{EXT,direct_state_access} is available, the texture unit
* is made active before binding the texture.
* @note This function is meant to be used only internally from
* @ref AbstractShaderProgram subclasses. See its documentation
* for more information.
* @see @ref bind(Int, std::initializer_list<AbstractTexture*>),
* @ref unbind(), @ref Shader::maxCombinedTextureImageUnits(),
* @fn_gl{ActiveTexture}, @fn_gl{BindTexture}, @fn_gl{BindTextures}
* or @fn_gl_extension{BindMultiTexture,EXT,direct_state_access}
* @fn_gl{BindTextureUnit}, @fn_gl{BindTextures},
* @fn_gl_extension{BindMultiTexture,EXT,direct_state_access},
* eventually @fn_gl{ActiveTexture} and @fn_gl{BindTexture}
*/
void bind(Int textureUnit);
@ -367,8 +378,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
void generateMipmap();
#ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void image(GLenum target, GLint level, Image<dimensions>& image);
template<UnsignedInt dimensions> void image(GLenum target, GLint level, BufferImage<dimensions>& image, BufferUsage usage);
template<UnsignedInt dimensions> void image(GLint level, Image<dimensions>& image);
template<UnsignedInt dimensions> void image(GLint level, BufferImage<dimensions>& image, BufferUsage usage);
template<UnsignedInt dimensions> void subImage(GLint level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image);
template<UnsignedInt dimensions> void subImage(GLint level, const RangeTypeFor<dimensions, Int>& range, BufferImage<dimensions>& image, BufferUsage usage);
#endif
GLenum _target;
@ -377,6 +390,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
static void MAGNUM_LOCAL unbindImplementationDefault(GLint textureUnit);
#ifndef MAGNUM_TARGET_GLES
static void MAGNUM_LOCAL unbindImplementationMulti(GLint textureUnit);
static void MAGNUM_LOCAL unbindImplementationDSA(GLint textureUnit);
static void MAGNUM_LOCAL unbindImplementationDSAEXT(GLint textureUnit);
#endif
@ -395,6 +409,7 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
void MAGNUM_LOCAL bindImplementationDefault(GLint textureUnit);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL bindImplementationMulti(GLint textureUnit);
void MAGNUM_LOCAL bindImplementationDSA(GLint textureUnit);
void MAGNUM_LOCAL bindImplementationDSAEXT(GLint textureUnit);
#endif
@ -409,11 +424,17 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
void MAGNUM_LOCAL parameterIImplementationDefault(GLenum parameter, const GLint* values);
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, GLint value);
void MAGNUM_LOCAL parameterImplementationDSAEXT(GLenum parameter, GLint value);
void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, GLfloat value);
void MAGNUM_LOCAL parameterImplementationDSAEXT(GLenum parameter, GLfloat value);
void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLint* values);
void MAGNUM_LOCAL parameterImplementationDSAEXT(GLenum parameter, const GLint* values);
void MAGNUM_LOCAL parameterImplementationDSA(GLenum parameter, const GLfloat* values);
void MAGNUM_LOCAL parameterImplementationDSAEXT(GLenum parameter, const GLfloat* values);
void MAGNUM_LOCAL parameterIImplementationDSA(GLenum parameter, const GLuint* values);
void MAGNUM_LOCAL parameterIImplementationDSAEXT(GLenum parameter, const GLuint* values);
void MAGNUM_LOCAL parameterIImplementationDSA(GLenum parameter, const GLint* values);
void MAGNUM_LOCAL parameterIImplementationDSAEXT(GLenum parameter, const GLint* values);
#endif
@ -421,85 +442,81 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
void MAGNUM_LOCAL setMaxAnisotropyImplementationExt(GLfloat anisotropy);
#ifndef MAGNUM_TARGET_GLES2
void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values);
void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL getLevelParameterImplementationDSAEXT(GLenum target, GLint level, GLenum parameter, GLint* values);
void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLint level, GLenum parameter, GLint* values);
void MAGNUM_LOCAL getLevelParameterImplementationDSAEXT(GLint level, GLenum parameter, GLint* values);
#endif
#endif
void MAGNUM_LOCAL mipmapImplementationDefault();
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL mipmapImplementationDSA();
void MAGNUM_LOCAL mipmapImplementationDSAEXT();
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
void MAGNUM_LOCAL storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
void MAGNUM_LOCAL storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
void MAGNUM_LOCAL storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
void MAGNUM_LOCAL storageImplementationDSA(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
void MAGNUM_LOCAL storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
#endif
void MAGNUM_LOCAL storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
void MAGNUM_LOCAL storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
void MAGNUM_LOCAL storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
void MAGNUM_LOCAL storageImplementationDSA(GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
void MAGNUM_LOCAL storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
#endif
void MAGNUM_LOCAL storageImplementationFallback(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
void MAGNUM_LOCAL storageImplementationDefault(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
void MAGNUM_LOCAL storageImplementationFallback(GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
void MAGNUM_LOCAL storageImplementationDefault(GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL storageImplementationDSAEXT(GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
void MAGNUM_LOCAL storageImplementationDSA(GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
void MAGNUM_LOCAL storageImplementationDSAEXT(GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations);
#endif
#ifndef MAGNUM_TARGET_GLES2
void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations);
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations);
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationDSA(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedsamplelocations);
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL getImageImplementationDefault(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSAEXT(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationRobustness(GLenum target, GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL storageMultisampleImplementationFallback(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationDefault(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationDSA(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations);
void MAGNUM_LOCAL storageMultisampleImplementationDSAEXT(GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedsamplelocations);
#endif
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDefault(GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSA(GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationDSAEXT(GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL getImageImplementationRobustness(GLint level, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
#endif
void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
#endif
void MAGNUM_LOCAL imageImplementationDefault(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
#endif
void MAGNUM_LOCAL subImageImplementationDefault(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLsizei>& size, ColorFormat format, ColorType type, const GLvoid* data);
#endif
void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLenum target, GLint level, const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data);
#endif
void MAGNUM_LOCAL subImageImplementationDefault(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLenum target, GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSA(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
void MAGNUM_LOCAL subImageImplementationDSAEXT(GLint level, const Vector3i& offset, const Vector3i& size, ColorFormat format, ColorType type, const GLvoid* data);
#endif
void MAGNUM_LOCAL invalidateImageImplementationNoOp(GLint level);
@ -528,17 +545,17 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> {
};
#endif
static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLenum target, GLint level);
static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLint level);
static void setWrapping(AbstractTexture& texture, const Array1D<Sampler::Wrapping>& wrapping);
static void setStorage(AbstractTexture& texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size);
static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference1D& image);
static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage1D& image);
static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageReference1D& image);
static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, BufferImage1D& image);
static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image);
static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image);
static void setSubImage(AbstractTexture& texture, GLint level, const Math::Vector<1, GLint>& offset, const ImageReference1D& image);
static void setSubImage(AbstractTexture& texture, GLint level, const Math::Vector<1, GLint>& offset, BufferImage1D& image);
static void invalidateSubImage(AbstractTexture& texture, GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size);
};
@ -556,25 +573,31 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> {
#endif
#ifndef MAGNUM_TARGET_GLES2
static Vector2i imageSize(AbstractTexture& texture, GLenum target, GLint level);
static Vector2i imageSize(AbstractTexture& texture, GLint level);
#endif
static void setWrapping(AbstractTexture& texture, const Array2D<Sampler::Wrapping>& wrapping);
static void setStorage(AbstractTexture& texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector2i& size);
#ifndef MAGNUM_TARGET_GLES2
static void setStorageMultisample(AbstractTexture& texture, GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedSampleLocations);
static void setStorageMultisample(AbstractTexture& texture, GLsizei samples, TextureFormat internalFormat, const Vector2i& size, GLboolean fixedSampleLocations);
#endif
static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageReference2D& image) {
setImage(texture, texture._target, level, internalFormat, image);
}
static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference2D& image);
#ifndef MAGNUM_TARGET_GLES2
static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, BufferImage2D& image) {
setImage(texture, texture._target, level, internalFormat, image);
}
static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage2D& image);
#endif
static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Vector2i& offset, const ImageReference2D& image);
static void setSubImage(AbstractTexture& texture, GLint level, const Vector2i& offset, const ImageReference2D& image);
#ifndef MAGNUM_TARGET_GLES2
static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Vector2i& offset, BufferImage2D& image);
static void setSubImage(AbstractTexture& texture, GLint level, const Vector2i& offset, BufferImage2D& image);
#endif
static void invalidateSubImage(AbstractTexture& texture, GLint level, const Vector2i& offset, const Vector2i& size);
@ -595,25 +618,25 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> {
#endif
#ifndef MAGNUM_TARGET_GLES2
static Vector3i imageSize(AbstractTexture& texture, GLenum target, GLint level);
static Vector3i imageSize(AbstractTexture& texture, GLint level);
#endif
static void setWrapping(AbstractTexture& texture, const Array3D<Sampler::Wrapping>& wrapping);
static void setStorage(AbstractTexture& texture, GLenum target, GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
static void setStorage(AbstractTexture& texture, GLsizei levels, TextureFormat internalFormat, const Vector3i& size);
#ifndef MAGNUM_TARGET_GLES
static void setStorageMultisample(AbstractTexture& texture, GLenum target, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedSampleLocations);
static void setStorageMultisample(AbstractTexture& texture, GLsizei samples, TextureFormat internalFormat, const Vector3i& size, GLboolean fixedSampleLocations);
#endif
static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, const ImageReference3D& image);
static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, const ImageReference3D& image);
#ifndef MAGNUM_TARGET_GLES2
static void setImage(AbstractTexture& texture, GLenum target, GLint level, TextureFormat internalFormat, BufferImage3D& image);
static void setImage(AbstractTexture& texture, GLint level, TextureFormat internalFormat, BufferImage3D& image);
#endif
static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Vector3i& offset, const ImageReference3D& image);
static void setSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, const ImageReference3D& image);
#ifndef MAGNUM_TARGET_GLES2
static void setSubImage(AbstractTexture& texture, GLenum target, GLint level, const Vector3i& offset, BufferImage3D& image);
static void setSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, BufferImage3D& image);
#endif
static void invalidateSubImage(AbstractTexture& texture, GLint level, const Vector3i& offset, const Vector3i& size);
@ -625,9 +648,10 @@ inline AbstractTexture::AbstractTexture(AbstractTexture&& other) noexcept: _targ
}
inline AbstractTexture& AbstractTexture::operator=(AbstractTexture&& other) noexcept {
std::swap(_target, other._target);
std::swap(_id, other._id);
std::swap(_created, other._created);
using std::swap;
swap(_target, other._target);
swap(_id, other._id);
swap(_created, other._created);
return *this;
}

8
src/Magnum/Array.h

@ -3,7 +3,7 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
@ -41,7 +41,7 @@
namespace Magnum {
/**
@brief %Array
@brief Array
@tparam dimensions Dimension count
@tparam T Data type
@ -169,7 +169,7 @@ template<class T> class Array2D: public Array<2, T> {
*/
constexpr /*implicit*/ Array2D(T x, T y): Array<2, T>(x, y) {}
/** @copydoc Array::Array(U) */
/** @brief Initializer-list constructor */
constexpr /*implicit*/ Array2D(T value): Array<2, T>(value, value) {}
/** @brief Copy constructor */
@ -198,7 +198,7 @@ template<class T> class Array3D: public Array<3, T> {
*/
constexpr /*implicit*/ Array3D(T x, T y, T z): Array<3, T>(x, y, z) {}
/** @copydoc Array::Array(U) */
/** @brief Initializer-list constructor */
constexpr /*implicit*/ Array3D(T value): Array<3, T>(value, value, value) {}
/** @brief Copy constructor */

329
src/Magnum/Attribute.cpp

@ -0,0 +1,329 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "Attribute.h"
#include <Corrade/Utility/Assert.h>
namespace Magnum { namespace Implementation {
UnsignedInt FloatAttribute::size(GLint components, DataType dataType) {
switch(dataType) {
case DataType::UnsignedByte:
case DataType::Byte:
return components;
case DataType::UnsignedShort:
case DataType::Short:
case DataType::HalfFloat:
return 2*components;
case DataType::UnsignedInt:
case DataType::Int:
case DataType::Float:
return 4*components;
#ifndef MAGNUM_TARGET_GLES
case DataType::Double:
return 8*components;
#endif
}
CORRADE_ASSERT_UNREACHABLE();
}
#ifndef MAGNUM_TARGET_GLES2
UnsignedInt IntAttribute::size(GLint components, DataType dataType) {
switch(dataType) {
case DataType::UnsignedByte:
case DataType::Byte:
return components;
case DataType::UnsignedShort:
case DataType::Short:
return 2*components;
case DataType::UnsignedInt:
case DataType::Int:
return 4*components;
}
CORRADE_ASSERT_UNREACHABLE();
}
#endif
#ifndef MAGNUM_TARGET_GLES
UnsignedInt DoubleAttribute::size(GLint components, DataType dataType) {
switch(dataType) {
case DataType::Double:
return 8*components;
}
CORRADE_ASSERT_UNREACHABLE();
}
#endif
UnsignedInt Attribute<Math::Vector<3, Float>>::size(GLint components, DataType dataType) {
switch(dataType) {
case DataType::UnsignedByte:
case DataType::Byte:
return components;
case DataType::UnsignedShort:
case DataType::Short:
case DataType::HalfFloat:
return 2*components;
case DataType::UnsignedInt:
case DataType::Int:
case DataType::Float:
return 4*components;
#ifndef MAGNUM_TARGET_GLES
case DataType::Double:
return 8*components;
case DataType::UnsignedInt10f11f11fRev:
CORRADE_INTERNAL_ASSERT(components == 3);
return 4;
#endif
}
CORRADE_ASSERT_UNREACHABLE();
}
UnsignedInt Attribute<Math::Vector<4, Float>>::size(GLint components, DataType dataType) {
#ifndef MAGNUM_TARGET_GLES
if(components == GL_BGRA) components = 4;
#endif
switch(dataType) {
case DataType::UnsignedByte:
case DataType::Byte:
return components;
case DataType::UnsignedShort:
case DataType::Short:
case DataType::HalfFloat:
return 2*components;
case DataType::UnsignedInt:
case DataType::Int:
case DataType::Float:
return 4*components;
#ifndef MAGNUM_TARGET_GLES
case DataType::Double:
return 8*components;
#endif
#ifndef MAGNUM_TARGET_GLES2
case DataType::UnsignedInt2101010Rev:
case DataType::Int2101010Rev:
CORRADE_INTERNAL_ASSERT(components == 4);
return 4;
#endif
}
CORRADE_ASSERT_UNREACHABLE();
}
Debug operator<<(Debug debug, SizedAttribute<1, 1>::Components value) {
switch(value) {
case SizedAttribute<1, 1>::Components::One:
return debug << "Attribute::Components::One";
}
return debug << "Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedAttribute<1, 2>::Components value) {
switch(value) {
case SizedAttribute<1, 2>::Components::One:
return debug << "Attribute::Components::One";
case SizedAttribute<1, 2>::Components::Two:
return debug << "Attribute::Components::Two";
}
return debug << "Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedAttribute<1, 3>::Components value) {
switch(value) {
case SizedAttribute<1, 3>::Components::One:
return debug << "Attribute::Components::One";
case SizedAttribute<1, 3>::Components::Two:
return debug << "Attribute::Components::Two";
case SizedAttribute<1, 3>::Components::Three:
return debug << "Attribute::Components::Three";
}
return debug << "Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedAttribute<1, 4>::Components value) {
switch(value) {
case SizedAttribute<1, 4>::Components::One:
return debug << "Attribute::Components::One";
case SizedAttribute<1, 4>::Components::Two:
return debug << "Attribute::Components::Two";
case SizedAttribute<1, 4>::Components::Three:
return debug << "Attribute::Components::Three";
case SizedAttribute<1, 4>::Components::Four:
return debug << "Attribute::Components::Four";
}
return debug << "Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedMatrixAttribute<2>::Components value) {
switch(value) {
case SizedMatrixAttribute<2>::Components::Two:
return debug << "Attribute::Components::Two";
}
return debug << "Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedMatrixAttribute<3>::Components value) {
switch(value) {
case SizedMatrixAttribute<3>::Components::Three:
return debug << "Attribute::Components::Three";
}
return debug << "Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, SizedMatrixAttribute<4>::Components value) {
switch(value) {
case SizedMatrixAttribute<4>::Components::Four:
return debug << "Attribute::Components::Four";
}
return debug << "Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, Attribute<Math::Vector<4, Float>>::Components value) {
switch(value) {
case Attribute<Math::Vector<4, Float>>::Components::One:
return debug << "Attribute::Components::One";
case Attribute<Math::Vector<4, Float>>::Components::Two:
return debug << "Attribute::Components::Two";
case Attribute<Math::Vector<4, Float>>::Components::Three:
return debug << "Attribute::Components::Three";
case Attribute<Math::Vector<4, Float>>::Components::Four:
return debug << "Attribute::Components::Four";
#ifndef MAGNUM_TARGET_GLES
case Attribute<Math::Vector<4, Float>>::Components::BGRA:
return debug << "Attribute::Components::BGRA";
#endif
}
return debug << "Attribute::Components::(invalid)";
}
Debug operator<<(Debug debug, FloatAttribute::DataType value) {
switch(value) {
#define _c(value) case FloatAttribute::DataType::value: return debug << "Attribute::DataType::" #value;
_c(UnsignedByte)
_c(Byte)
_c(UnsignedShort)
_c(Short)
_c(UnsignedInt)
_c(Int)
_c(HalfFloat)
_c(Float)
#ifndef MAGNUM_TARGET_GLES
_c(Double)
#endif
#undef _c
}
return debug << "Attribute::DataType::(invalid)";
}
#ifndef MAGNUM_TARGET_GLES2
Debug operator<<(Debug debug, IntAttribute::DataType value) {
switch(value) {
#define _c(value) case IntAttribute::DataType::value: return debug << "Attribute::DataType::" #value;
_c(UnsignedByte)
_c(Byte)
_c(UnsignedShort)
_c(Short)
_c(UnsignedInt)
_c(Int)
#undef _c
}
return debug << "Attribute::DataType::(invalid)";
}
#endif
#ifndef MAGNUM_TARGET_GLES
Debug operator<<(Debug debug, DoubleAttribute::DataType value) {
switch(value) {
#define _c(value) case DoubleAttribute::DataType::value: return debug << "Attribute::DataType::" #value;
_c(Double)
#undef _c
}
return debug << "Attribute::DataType::(invalid)";
}
#endif
Debug operator<<(Debug debug, Attribute<Math::Vector<3, Float>>::DataType value) {
switch(value) {
#define _c(value) case Attribute<Math::Vector<3, Float>>::DataType::value: return debug << "Attribute::DataType::" #value;
_c(UnsignedByte)
_c(Byte)
_c(UnsignedShort)
_c(Short)
_c(UnsignedInt)
_c(Int)
_c(HalfFloat)
_c(Float)
#ifndef MAGNUM_TARGET_GLES
_c(Double)
_c(UnsignedInt10f11f11fRev)
#endif
#undef _c
}
return debug << "Attribute::DataType::(invalid)";
}
Debug operator<<(Debug debug, Attribute<Math::Vector<4, Float>>::DataType value) {
switch(value) {
#define _c(value) case Attribute<Math::Vector<4, Float>>::DataType::value: return debug << "Attribute::DataType::" #value;
_c(UnsignedByte)
_c(Byte)
_c(UnsignedShort)
_c(Short)
_c(UnsignedInt)
_c(Int)
_c(HalfFloat)
_c(Float)
#ifndef MAGNUM_TARGET_GLES
_c(Double)
#endif
#ifndef MAGNUM_TARGET_GLES2
_c(UnsignedInt2101010Rev)
_c(Int2101010Rev)
#endif
#undef _c
}
return debug << "Attribute::DataType::(invalid)";
}
}}

657
src/Magnum/Attribute.h

@ -0,0 +1,657 @@
#ifndef Magnum_Attribute_h
#define Magnum_Attribute_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Class @ref Magnum::Attribute
*/
#include <Corrade/Containers/EnumSet.h>
#include "Magnum/Magnum.h"
#include "Magnum/OpenGL.h"
#include "Magnum/visibility.h"
namespace Magnum {
namespace Implementation { template<class> struct Attribute; }
/**
@brief Base class for attribute location and type
For use in @ref AbstractShaderProgram subclasses. Template parameter @p location
is vertex attribute location, number between `0` and
@ref AbstractShaderProgram::maxVertexAttributes(). To ensure compatibility, you
should always have vertex attribute with location `0`.
Template parameter @p T is the type which is used for shader attribute, e.g.
@ref Vector4i for `ivec4`. DataType is type of passed data when adding vertex
buffers to mesh. By default it is the same as type used in shader (e.g.
@ref DataType::Int for @ref Vector4i). It's also possible to pass integer data
to floating-point shader inputs. In this case you may want to normalize the
values (e.g. color components from 0-255 to 0.0f - 1.0f) -- see
@ref DataOption::Normalized.
Only some types are allowed as attribute types, see @ref AbstractShaderProgram-types
for more information.
See @ref AbstractShaderProgram-subclassing for example usage in shaders and
@ref Mesh-configuration for example usage when adding vertex buffers to mesh.
*/
template<UnsignedInt location, class T> class Attribute {
public:
enum: UnsignedInt {
/**
* Location to which the attribute is bound
*
* @see @ref AbstractShaderProgram::maxVertexAttributes()
*/
Location = location,
/**
* Count of vectors in this type
*
* @see @ref vectorSize()
*/
VectorCount = Implementation::Attribute<T>::VectorCount
};
/**
* @brief Type
*
* Type used in shader code.
* @see @ref ScalarType, @ref DataType
*/
typedef T Type;
/**
* @brief Scalar type
*
* The underlying scalar type of the attribute.
* @see @ref Type, @ref DataType
*/
typedef typename Implementation::Attribute<T>::ScalarType ScalarType;
/**
* @brief Component count
*
* Count of components passed to the shader. If passing smaller count
* of components than corresponding type has, unspecified components
* are set to default values (second and third to `0`, fourth to `1`).
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
enum class Components: GLint {
/**
* Only first component is specified. Second, third and fourth
* component are set to `0`, `0`, `1`, respectively. Only for
* scalar and vector types, not matrices.
*/
One = 1,
/**
* First two components are specified. Third and fourth component
* are set to `0`, `1`, respectively. Only for two, three and
* four-component vector types and 2x2, 3x2 and 4x2 matrix types.
*/
Two = 2,
/**
* First three components are specified. Fourth component is set to
* `1`. Only for three and four-component vector types, 2x3, 3x3
* and 4x3 matrix types.
*/
Three = 3,
/**
* All four components are specified. Only for four-component
* vector types and 2x4, 3x4 and 4x4 matrix types.
*/
Four = 4,
#ifndef MAGNUM_TARGET_GLES
/**
* Four components with BGRA ordering. Only for four-component
* float vector type. Must be used along with @ref DataType::UnsignedByte
* and @ref DataOption::Normalized.
* @requires_gl32 Extension @extension{ARB,vertex_array_bgra}
* @requires_gl Only RGBA component ordering is supported in OpenGL
* ES.
*/
BGRA = GL_BGRA
#endif
};
#else
typedef typename Implementation::Attribute<T>::Components Components;
#endif
/**
* @brief Data type
*
* Type of data passed to shader.
* @see @ref Type, @ref DataOptions, @ref Attribute()
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
enum class DataType: GLenum {
UnsignedByte = GL_UNSIGNED_BYTE, /**< Unsigned byte */
Byte = GL_BYTE, /**< Byte */
UnsignedShort = GL_UNSIGNED_SHORT, /**< Unsigned short */
Short = GL_SHORT, /**< Short */
UnsignedInt = GL_UNSIGNED_INT, /**< Unsigned int */
Int = GL_INT, /**< Int */
/**
* Half float. Only for float attribute types.
* @requires_gl30 Extension @extension{ARB,half_float_vertex}
* @requires_gles30 Extension @es_extension{OES,vertex_half_float}
* in OpenGL ES 2.0
*/
HalfFloat = GL_HALF_FLOAT,
/** Float. Only for float attribute types. */
Float = GL_FLOAT,
#ifndef MAGNUM_TARGET_GLES
/**
* Double. Only for float and double attribute types.
* @requires_gl Only floats are available in OpenGL ES.
*/
Double = GL_DOUBLE,
/**
* Unsigned 10.11.11 packed float. Only for three-component float
* vector attribute type.
* @requires_gl44 Extension @extension{ARB,vertex_type_10f_11f_11f_rev}
* @requires_gl Packed float attributes are not available in OpenGL
* ES.
*/
UnsignedInt10f11f11fRev = GL_UNSIGNED_INT_10F_11F_11F_REV,
#endif
/* GL_FIXED not supported */
#ifndef MAGNUM_TARGET_GLES2
/**
* Unsigned 2.10.10.10 packed integer. Only for four-component
* float vector attribute type.
* @todo How about (incompatible) @es_extension{OES,vertex_type_10_10_10_2}?
* @requires_gl33 Extension @extension{ARB,vertex_type_2_10_10_10_rev}
* @requires_gles30 Packed attributes are not available in OpenGL
* ES 2.0
*/
UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV,
/**
* Signed 2.10.10.10 packed integer. Only for four-component float
* vector attribute type.
* @requires_gl33 Extension @extension{ARB,vertex_type_2_10_10_10_rev}
* @requires_gles30 Packed attributes are not available in OpenGL
* ES 2.0
*/
Int2101010Rev = GL_INT_2_10_10_10_REV
#endif
};
#else
typedef typename Implementation::Attribute<T>::DataType DataType;
#endif
/**
* @brief Data option
* @see @ref DataOptions, @ref Attribute()
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
enum class DataOption: UnsignedByte {
/**
* Normalize integer components. Only for float attribute types.
* Default is to not normalize.
*/
Normalized = 1 << 0
};
#else
typedef typename Implementation::Attribute<T>::DataOption DataOption;
#endif
/**
* @brief Data options
* @see @ref Attribute()
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
typedef typename Containers::EnumSet<DataOption> DataOptions;
#else
typedef typename Implementation::Attribute<T>::DataOptions DataOptions;
#endif
/**
* @brief Constructor
* @param components Component count
* @param dataType Type of passed data. Default is the same as
* type used in shader (e.g. @ref DataType::Int for @ref Vector4i).
* @param dataOptions Data options. Default is no options.
*/
constexpr Attribute(Components components, DataType dataType = Implementation::Attribute<T>::DefaultDataType, DataOptions dataOptions = DataOptions()): _components(components), _dataType(dataType), _dataOptions(dataOptions) {}
/**
* @brief Constructor
* @param dataType Type of passed data. Default is the same as
* type used in shader (e.g. @ref DataType::Int for @ref Vector4i).
* @param dataOptions Data options. Default is no options.
*
* Component count is set to the same value as in type used in shader
* (e.g. @ref Components::Three for @ref Vector3).
*/
constexpr Attribute(DataType dataType = Implementation::Attribute<T>::DefaultDataType, DataOptions dataOptions = DataOptions()): _components(Implementation::Attribute<T>::DefaultComponents), _dataType(dataType), _dataOptions(dataOptions) {}
/** @brief Component count of passed data */
constexpr Components components() const { return _components; }
/** @brief Type of passed data */
constexpr DataType dataType() const { return _dataType; }
/**
* @brief Size of each vector in passed data
*
* @see @ref VectorCount
*/
UnsignedInt vectorSize() const {
return Implementation::Attribute<T>::size(GLint(_components), _dataType);
}
/** @brief Data options */
constexpr DataOptions dataOptions() const { return _dataOptions; }
private:
Components _components;
DataType _dataType;
DataOptions _dataOptions;
};
#ifdef DOXYGEN_GENERATING_OUTPUT
/** @debugoperatorclassenum{Magnum::Attribute,Magnum::Attribute::Components} */
template<class T> Debug operator<<(Debug debug, Attribute<T>::Components);
/** @debugoperatorclassenum{Magnum::Attribute,Magnum::Attribute::DataType} */
template<class T> Debug operator<<(Debug debug, Attribute<T>::DataType);
#endif
namespace Implementation {
/* Base for sized attributes */
template<std::size_t cols, std::size_t rows> struct SizedAttribute;
/* Vector attribute sizes */
template<std::size_t cols> struct SizedVectorAttribute {
enum: UnsignedInt { VectorCount = UnsignedInt(cols) };
};
template<> struct SizedAttribute<1, 1>: SizedVectorAttribute<1> {
enum class Components: GLint { One = 1 };
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
Components DefaultComponents = Components::One;
};
template<> struct SizedAttribute<1, 2>: SizedVectorAttribute<1> {
enum class Components: GLint { One = 1, Two = 2 };
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
Components DefaultComponents = Components::Two;
};
template<> struct SizedAttribute<1, 3>: SizedVectorAttribute<1> {
enum class Components: GLint { One = 1, Two = 2, Three = 3 };
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
Components DefaultComponents = Components::Three;
};
template<> struct SizedAttribute<1, 4>: SizedVectorAttribute<1> {
enum class Components: GLint { One = 1, Two = 2, Three = 3, Four = 4 };
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
Components DefaultComponents = Components::Four;
};
Debug MAGNUM_EXPORT operator<<(Debug debug, SizedAttribute<1, 1>::Components value);
Debug MAGNUM_EXPORT operator<<(Debug debug, SizedAttribute<1, 2>::Components value);
Debug MAGNUM_EXPORT operator<<(Debug debug, SizedAttribute<1, 3>::Components value);
Debug MAGNUM_EXPORT operator<<(Debug debug, SizedAttribute<1, 4>::Components value);
/* Matrix attribute sizes */
template<std::size_t rows> struct SizedMatrixAttribute;
template<> struct SizedMatrixAttribute<2> {
enum class Components: GLint { Two = 2 };
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
Components DefaultComponents = Components::Two;
};
template<> struct SizedMatrixAttribute<3> {
enum class Components: GLint { Three = 3 };
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
Components DefaultComponents = Components::Three;
};
template<> struct SizedMatrixAttribute<4> {
enum class Components: GLint { Four = 4 };
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
Components DefaultComponents = Components::Four;
};
Debug MAGNUM_EXPORT operator<<(Debug debug, SizedMatrixAttribute<2>::Components value);
Debug MAGNUM_EXPORT operator<<(Debug debug, SizedMatrixAttribute<3>::Components value);
Debug MAGNUM_EXPORT operator<<(Debug debug, SizedMatrixAttribute<4>::Components value);
template<> struct SizedAttribute<2, 2>: SizedVectorAttribute<2>, SizedMatrixAttribute<2> {};
template<> struct SizedAttribute<3, 3>: SizedVectorAttribute<3>, SizedMatrixAttribute<3> {};
template<> struct SizedAttribute<4, 4>: SizedVectorAttribute<4>, SizedMatrixAttribute<4> {};
#ifndef MAGNUM_TARGET_GLES2
template<> struct SizedAttribute<2, 3>: SizedVectorAttribute<2>, SizedMatrixAttribute<3> {};
template<> struct SizedAttribute<3, 2>: SizedVectorAttribute<3>, SizedMatrixAttribute<2> {};
template<> struct SizedAttribute<2, 4>: SizedVectorAttribute<2>, SizedMatrixAttribute<4> {};
template<> struct SizedAttribute<4, 2>: SizedVectorAttribute<4>, SizedMatrixAttribute<2> {};
template<> struct SizedAttribute<3, 4>: SizedVectorAttribute<3>, SizedMatrixAttribute<4> {};
template<> struct SizedAttribute<4, 3>: SizedVectorAttribute<4>, SizedMatrixAttribute<3> {};
#endif
/* Base for attributes */
template<class> struct Attribute;
/* Base for float attributes */
struct FloatAttribute {
typedef Float ScalarType;
enum class DataType: GLenum {
UnsignedByte = GL_UNSIGNED_BYTE,
Byte = GL_BYTE,
UnsignedShort = GL_UNSIGNED_SHORT,
Short = GL_SHORT,
UnsignedInt = GL_UNSIGNED_INT,
Int = GL_INT,
#ifndef MAGNUM_TARGET_GLES2
HalfFloat = GL_HALF_FLOAT,
#else
HalfFloat = GL_HALF_FLOAT_OES,
#endif
Float = GL_FLOAT
#ifndef MAGNUM_TARGET_GLES
,
Double = GL_DOUBLE
#endif
};
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
DataType DefaultDataType = DataType::Float;
enum class DataOption: UnsignedByte {
Normalized = 1 << 0
};
typedef Containers::EnumSet<DataOption, UnsignedByte> DataOptions;
static UnsignedInt MAGNUM_EXPORT size(GLint components, DataType dataType);
};
CORRADE_ENUMSET_OPERATORS(FloatAttribute::DataOptions)
Debug MAGNUM_EXPORT operator<<(Debug debug, FloatAttribute::DataType value);
#ifndef MAGNUM_TARGET_GLES2
/* Base for int attributes */
struct IntAttribute {
typedef Int ScalarType;
enum class DataType: GLenum {
UnsignedByte = GL_UNSIGNED_BYTE,
Byte = GL_BYTE,
UnsignedShort = GL_UNSIGNED_SHORT,
Short = GL_SHORT,
UnsignedInt = GL_UNSIGNED_INT,
Int = GL_INT
};
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
DataType DefaultDataType = DataType::Int;
enum class DataOption: UnsignedByte {};
typedef Containers::EnumSet<DataOption, UnsignedByte> DataOptions;
static UnsignedInt MAGNUM_EXPORT size(GLint components, DataType dataType);
};
CORRADE_ENUMSET_OPERATORS(IntAttribute::DataOptions)
Debug MAGNUM_EXPORT operator<<(Debug debug, IntAttribute::DataType value);
/* Base for unsigned int attributes */
struct UnsignedIntAttribute {
typedef UnsignedInt ScalarType;
typedef IntAttribute::DataType DataType;
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
DataType DefaultDataType = DataType::UnsignedInt;
typedef IntAttribute::DataOption DataOption;
typedef IntAttribute::DataOptions DataOptions;
static UnsignedInt size(GLint components, DataType dataType) {
return IntAttribute::size(components, dataType);
}
};
#endif
#ifndef MAGNUM_TARGET_GLES
/* Base for double attributes */
struct DoubleAttribute {
typedef Double ScalarType;
enum class DataType: GLenum {
Double = GL_DOUBLE
};
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
DataType DefaultDataType = DataType::Double;
typedef IntAttribute::DataOption DataOption;
typedef IntAttribute::DataOptions DataOptions;
static UnsignedInt MAGNUM_EXPORT size(GLint components, DataType dataType);
};
Debug MAGNUM_EXPORT operator<<(Debug debug, DoubleAttribute::DataType value);
#endif
/* Floating-point three-component vector has additional data type compared to
classic floats */
template<> struct Attribute<Math::Vector<3, Float>>: SizedAttribute<1, 3> {
typedef Float ScalarType;
enum class DataType: GLenum {
UnsignedByte = GL_UNSIGNED_BYTE,
Byte = GL_BYTE,
UnsignedShort = GL_UNSIGNED_SHORT,
Short = GL_SHORT,
UnsignedInt = GL_UNSIGNED_INT,
Int = GL_INT,
#ifndef MAGNUM_TARGET_GLES2
HalfFloat = GL_HALF_FLOAT,
#else
HalfFloat = GL_HALF_FLOAT_OES,
#endif
Float = GL_FLOAT
#ifndef MAGNUM_TARGET_GLES
,
Double = GL_DOUBLE,
UnsignedInt10f11f11fRev = GL_UNSIGNED_INT_10F_11F_11F_REV
#endif
};
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
DataType DefaultDataType = DataType::Float;
typedef FloatAttribute::DataOption DataOption;
typedef FloatAttribute::DataOptions DataOptions;
static UnsignedInt MAGNUM_EXPORT size(GLint components, DataType dataType);
};
Debug MAGNUM_EXPORT operator<<(Debug debug, Attribute<Math::Vector<3, Float>>::DataType value);
/* Floating-point four-component vector is absolutely special case */
template<> struct Attribute<Math::Vector<4, Float>> {
typedef Float ScalarType;
enum class Components: GLint {
One = 1,
Two = 2,
Three = 3,
Four = 4
#ifndef MAGNUM_TARGET_GLES
,
BGRA = GL_BGRA
#endif
};
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
Components DefaultComponents = Components::Four;
enum class DataType: GLenum {
UnsignedByte = GL_UNSIGNED_BYTE,
Byte = GL_BYTE,
UnsignedShort = GL_UNSIGNED_SHORT,
Short = GL_SHORT,
UnsignedInt = GL_UNSIGNED_INT,
Int = GL_INT,
#ifndef MAGNUM_TARGET_GLES2
HalfFloat = GL_HALF_FLOAT,
#else
HalfFloat = GL_HALF_FLOAT_OES,
#endif
Float = GL_FLOAT
#ifndef MAGNUM_TARGET_GLES
,
Double = GL_DOUBLE
#endif
#ifndef MAGNUM_TARGET_GLES2
,
UnsignedInt2101010Rev = GL_UNSIGNED_INT_2_10_10_10_REV,
Int2101010Rev = GL_INT_2_10_10_10_REV
#endif
};
#if !defined(CORRADE_GCC45_COMPATIBILITY) && !defined(CORRADE_MSVC2013_COMPATIBILITY)
constexpr static
#else
static const
#endif
DataType DefaultDataType = DataType::Float;
typedef FloatAttribute::DataOption DataOption;
typedef FloatAttribute::DataOptions DataOptions;
enum: UnsignedInt { VectorCount = 1 };
static UnsignedInt MAGNUM_EXPORT size(GLint components, DataType dataType);
};
Debug MAGNUM_EXPORT operator<<(Debug debug, Attribute<Math::Vector<4, Float>>::Components value);
Debug MAGNUM_EXPORT operator<<(Debug debug, Attribute<Math::Vector<4, Float>>::DataType value);
/* Common float, int, unsigned int and double scalar attributes */
template<> struct Attribute<Float>: FloatAttribute, SizedAttribute<1, 1> {};
#ifndef MAGNUM_TARGET_GLES2
template<> struct Attribute<Int>: IntAttribute, SizedAttribute<1, 1> {};
template<> struct Attribute<UnsignedInt>: UnsignedIntAttribute, SizedAttribute<1, 1> {};
#ifndef MAGNUM_TARGET_GLES
template<> struct Attribute<Double>: DoubleAttribute, SizedAttribute<1, 1> {};
#endif
#endif
/* Common float, int, unsigned int and double vector attributes */
template<std::size_t size_> struct Attribute<Math::Vector<size_, Float>>: FloatAttribute, SizedAttribute<1, size_> {};
#ifndef MAGNUM_TARGET_GLES2
template<std::size_t size_> struct Attribute<Math::Vector<size_, Int>>: IntAttribute, SizedAttribute<1, size_> {};
template<std::size_t size_> struct Attribute<Math::Vector<size_, UnsignedInt>>: UnsignedIntAttribute, SizedAttribute<1, size_> {};
#ifndef MAGNUM_TARGET_GLES
template<std::size_t size_> struct Attribute<Math::Vector<size_, Double>>: DoubleAttribute, SizedAttribute<1, size_> {};
#endif
#endif
template<class T> struct Attribute<Math::Vector2<T>>: Attribute<Math::Vector<2, T>> {};
template<class T> struct Attribute<Math::Vector3<T>>: Attribute<Math::Vector<3, T>> {};
template<class T> struct Attribute<Math::Vector4<T>>: Attribute<Math::Vector<4, T>> {};
template<class T> struct Attribute<BasicColor3<T>>: Attribute<Math::Vector3<T>> {};
template<class T> struct Attribute<BasicColor4<T>>: Attribute<Math::Vector4<T>> {};
/* Common float and double rectangular matrix attributes */
template<std::size_t cols, std::size_t rows> struct Attribute<Math::RectangularMatrix<cols, rows, Float>>: FloatAttribute, SizedAttribute<cols, rows> {};
#ifndef MAGNUM_TARGET_GLES
template<std::size_t cols, std::size_t rows> struct Attribute<Math::RectangularMatrix<cols, rows, Double>>: DoubleAttribute, SizedAttribute<cols, rows> {};
#endif
/* Common float and double square matrix attributes */
template<std::size_t size_> struct Attribute<Math::Matrix<size_, Float>>: Attribute<Math::RectangularMatrix<size_, size_, Float>> {};
#ifndef MAGNUM_TARGET_GLES
template<std::size_t size_> struct Attribute<Math::Matrix<size_, Double>>: Attribute<Math::RectangularMatrix<size_, size_, Double>> {};
#endif
template<class T> struct Attribute<Math::Matrix3<T>>: Attribute<Math::Matrix<3, T>> {};
template<class T> struct Attribute<Math::Matrix4<T>>: Attribute<Math::Matrix<4, T>> {};
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save