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. # 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> # Vladimír Vondruš <mosra@centrum.cz>
# #
# Permission is hereby granted, free of charge, to any person obtaining a # Permission is hereby granted, free of charge, to any person obtaining a
@ -23,7 +23,7 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
cmake_minimum_required(VERSION 2.8.8) cmake_minimum_required(VERSION 2.8.9)
project(Magnum) project(Magnum)
# Find Corrade first so we can check on the target # 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_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) 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 # Parts of the library
option(WITH_AUDIO "Build Audio library" OFF) option(WITH_AUDIO "Build Audio library" OFF)
option(WITH_DEBUGTOOLS "Build DebugTools library" ON) option(WITH_DEBUGTOOLS "Build DebugTools library" ON)
@ -72,7 +70,7 @@ elseif(CORRADE_TARGET_APPLE)
elseif(CORRADE_TARGET_UNIX) elseif(CORRADE_TARGET_UNIX)
option(WITH_GLXAPPLICATION "Build GlxApplication library" OFF) 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_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) option(WITH_GLXCONTEXT "Build GlxContext library" OFF)
# Windows-specific application libraries # Windows-specific application libraries
@ -112,7 +110,8 @@ if(BUILD_DEPRECATED)
endif() endif()
option(BUILD_STATIC "Build static libraries (default are shared)" OFF) 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) option(BUILD_TESTS "Build unit tests." OFF)
cmake_dependent_option(BUILD_GL_TESTS "Build unit tests for OpenGL code." OFF "BUILD_TESTS" OFF) cmake_dependent_option(BUILD_GL_TESTS "Build unit tests for OpenGL code." OFF "BUILD_TESTS" OFF)
if(BUILD_TESTS) if(BUILD_TESTS)
@ -135,6 +134,7 @@ endif()
# meaningless on Emscripten and too inconvenient on Android # meaningless on Emscripten and too inconvenient on Android
if(CORRADE_TARGET_NACL_NEWLIB OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) if(CORRADE_TARGET_NACL_NEWLIB OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
set(BUILD_STATIC ON) set(BUILD_STATIC ON)
set(BUILD_PLUGINS_STATIC ON)
endif() endif()
if(BUILD_STATIC) if(BUILD_STATIC)
@ -182,11 +182,11 @@ else()
endif() endif()
# Installation paths # Installation paths
include(CorradeLibSuffix) include(${CORRADE_LIB_SUFFIX_MODULE})
set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin) set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(MAGNUM_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/magnum) 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_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum)
set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumExternal) set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumExternal)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumPlugins) 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Copyright © YEAR YOUR_NAME <your@mail.com> 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a

16
CREDITS.md

@ -1,9 +1,15 @@
Third-party components Third-party components
---------------------- ----------------------
* **flextGL** extension loader generator -- https://github.com/ginkgo/flextGL, Not mentioning OpenGL API and platform-specific toolkits.
Copyright © 2011 Thomas Weber, licensed under
[MIT license](https://raw.githubusercontent.com/ginkgo/flextGL/master/COPYING) * 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 Contributors to Magnum library
------------------------------ ------------------------------
@ -21,5 +27,9 @@ Contributors to Magnum library
Debian package Debian package
* Olga Turanksaya ([@olga-python](https://github.com/olga-python)) -- Gentoo * Olga Turanksaya ([@olga-python](https://github.com/olga-python)) -- Gentoo
ebuild 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! Big thanks to everyone involved!

15
Doxyfile

@ -233,13 +233,13 @@ TAB_SIZE = 8
# newlines. # newlines.
ALIASES = \ 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." \ "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>\"" \ "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." \ "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" \ "collisionoccurenceoperator{2}=@relatesalso \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" \ "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\"" \ "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_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>" \ "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. # or globally by setting AUTOLINK_SUPPORT to NO.
# The default value is: YES. # 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 # 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 # 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. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED = DOXYGEN_GENERATING_OUTPUT \ PREDEFINED = DOXYGEN_GENERATING_OUTPUT \
MAGNUM_BUILD_DEPRECATED CORRADE_DEPRECATED(message)= \ CORRADE_DEPRECATED(message)= CORRADE_DEPRECATED_ENUM(message)= \
MAGNUM_BUILD_DEPRECATED \
MAGNUM_EXPORT= \ MAGNUM_EXPORT= \
MAGNUM_AUDIO_EXPORT= \ MAGNUM_AUDIO_EXPORT= \
MAGNUM_DEBUGTOOLS_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 Magnum is 2D/3D graphics engine written in C++11/C++14 and modern OpenGL. Its
to simplify low-level graphics development and interaction with OpenGL using goal is to simplify low-level graphics development and interaction with OpenGL
recent C++11 features and to abstract away platform-specific issues. using recent C++11/C++14 features and to abstract away platform-specific
issues.
DESIGN GOALS DESIGN GOALS
============ ============
@ -89,7 +90,7 @@ Minimal dependencies
>= 3.1. On Windows you can use **MinGW**. GCC 4.5, 4.4 and **MSVC** 2013 >= 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 support involves some ugly workarounds and thus is available only in
`compatibility` branch. `compatibility` branch.
* **CMake** >= 2.8.8 * **CMake** >= 2.8.9
* **Corrade** - Plugin management and utility library. You can get it at * **Corrade** - Plugin management and utility library. You can get it at
https://github.com/mosra/corrade. https://github.com/mosra/corrade.
@ -161,6 +162,8 @@ separate repositories.
* **libRocket integration** -- integrates Magnum as rendering backend into * **libRocket integration** -- integrates Magnum as rendering backend into
[libRocket](https://github.com/libRocket/libRocket) GUI library: [libRocket](https://github.com/libRocket/libRocket) GUI library:
https://github.com/miguelmartin75/Magnum-libRocket https://github.com/miguelmartin75/Magnum-libRocket
* **Magnum Inspector** -- Gtk-based inspector window running alongside Magnum
https://github.com/wivlaro/magnum-inspector
CONTACT CONTACT
======= =======
@ -170,6 +173,7 @@ idea? Feel free to visit my website or contact me at:
* Website -- http://mosra.cz/blog/magnum.php * Website -- http://mosra.cz/blog/magnum.php
* GitHub -- https://github.com/mosra/magnum * GitHub -- https://github.com/mosra/magnum
* IRC -- join `#magnum-engine` channel on freenode
* Google Groups -- https://groups.google.com/forum/#!forum/magnum-engine * Google Groups -- https://groups.google.com/forum/#!forum/magnum-engine
* Twitter -- https://twitter.com/czmosra * Twitter -- https://twitter.com/czmosra
* E-mail -- mosra@centrum.cz * E-mail -- mosra@centrum.cz

2
doc/best-practices.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -26,7 +26,7 @@
namespace Magnum { namespace Magnum {
/** @page building Downloading and building /** @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 @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 >= 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 support involves some ugly workarounds and thus is available only in
`compatibility` branch. `compatibility` branch.
- **CMake** >= 2.8.8 - **CMake** >= 2.8.9
- **Corrade** - Plugin management and utility library. See - **Corrade** - Plugin management and utility library. See
@ref building-corrade "Corrade download and installation guide" for more @ref building-corrade "Corrade download and installation guide" for more
information. 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 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 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 them statically, enable `BUILD_STATIC` to build the libraries as static.
plan to use them with shared libraries later, enable also position-independent Building of static plugins is controlled with separate `BUILD_PLUGINS_STATIC`
code with `BUILD_STATIC_PIC`. If you want to build with another compiler (e.g. variable. If you plan to use the static libraries and plugins with shared
Clang), pass `-DCMAKE_CXX_COMPILER=clang++` to CMake. 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 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 `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* both debug and release libraries installed alongside each other. *Dynamic*
plugins in `Debug` configuration are installed to `magnum-d` subdirectory plugins in `Debug` configuration are installed to `magnum-d` subdirectory
instead of `magnum`. Headers and other files are the same for both. The library 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. 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 The library is constantly evolving and thus some APIs are deprecated and then
later removed in favor of better ones. To preserve backwards compatibility, 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 code more robust and future-proof, it's recommended to build the library with
`BUILD_DEPRECATED` disabled. `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 - `WITH_AUDIO` - @ref Audio library. Depends on **OpenAL** library, not built
by default. by default.
- `WITH_DEBUGTOOLS` - @ref DebugTools library. Enables also building of - `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_MESHTOOLS` - @ref MeshTools library. Enabled automatically if
`WITH_DEBUGTOOLS` is enabled. `WITH_DEBUGTOOLS` is enabled.
- `WITH_PRIMITIVES` - @ref Primitives library. Enabled automatically if - `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_DEBUGTOOLS` or `WITH_SHAPES` is enabled.
- `WITH_SHADERS` - @ref Shaders library. Enabled automatically if - `WITH_SHADERS` - @ref Shaders library. Enabled automatically if
`WITH_DEBUGTOOLS` is enabled. `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. 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. library.
- `WITH_TEXTURETOOLS` - @ref TextureTools library. Enabled automatically if - `WITH_TEXTURETOOLS` - @ref TextureTools library. Enabled automatically if
`WITH_TEXT` or `WITH_DISTANCEFIELDCONVERTER` is enabled. `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. information about the engine and OpenGL capabilities.
- `WITH_DISTANCEFIELDCONVERTER` - @ref magnum-distancefieldconverter "magnum-distancefieldconverter" - `WITH_DISTANCEFIELDCONVERTER` - @ref magnum-distancefieldconverter "magnum-distancefieldconverter"
executable for converting black&white images to distance field textures. 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" - `WITH_FONTCONVERTER` - @ref magnum-fontconverter "magnum-fontconverter"
executable for converting fonts to raster ones. Enables also building of 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, file formats. Additional plugins are provided in separate plugin repository,
see @ref building-plugins for more information. None of the plugins is built by see @ref building-plugins for more information. None of the plugins is built by
default. default.
@ -285,9 +283,9 @@ be build by running
in root directory (i.e. where `Doxyfile` is). Resulting HTML documentation in root directory (i.e. where `Doxyfile` is). Resulting HTML documentation
will be in `build/doc/` directory. You might need to create `build/` directory 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 `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 and `magnum-examples`, see below) are places along these, their documentation
will be also included in generated output. 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 There are also a few development PKGBUILDs in `package/archlinux`, which allow
you to build and install the package directly from source tree without you to build and install the package directly from source tree without
downloading anything. The native PKGBUILDs also contain `check()` function downloading anything. The native PKGBUILDs also contain `check()` function
which will run all unit tests before packaging. You need to build them from which will run all unit tests before packaging.
project root:
makepkg -p package/archlinux/<file>
@subsection building-packages-gentoo Gentoo ebuilds @subsection building-packages-gentoo Gentoo ebuilds
@ -336,7 +331,7 @@ features, for example), modify the last entry in `debian/rules`.
@section building-crosscompiling Crosscompiling @section building-crosscompiling Crosscompiling
For crosscompiling you need to have *both* target and native version of 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 host system as part of the build process. If native version of `corrade-rc` is
not found on the system, crosscompilation will fail. 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 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 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 mkdir build-win && cd build-win
cmake .. \ cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../toolchains/archlinux/basic-mingw32.cmake \ -DCMAKE_TOOLCHAIN_FILE=../toolchains/archlinux/basic-mingw32.cmake \
-DCMAKE_PREFIX_PATH=/usr/i486-mingw32 \
-DCMAKE_INSTALL_PREFIX=/usr/i486-mingw32 -DCMAKE_INSTALL_PREFIX=/usr/i486-mingw32
cmake --build . 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 command in them. The toolchains need access to the platform file, so be sure to
properly set **absolute** path to `modules/` directory containing properly set **absolute** path to `modules/` directory containing
`Platform/NaCl.cmake`. Also adapt `CMAKE_INSTALL_PREFIX` to the same value as `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 mkdir build-nacl-x86-32 && cd build-nacl-x86-32
cmake .. \ cmake .. \
-DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-32.cmake" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-32.cmake" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/usr/nacl \
-DCMAKE_INSTALL_PREFIX=/usr/nacl \ -DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_NACLAPPLICATION=ON \ -DWITH_NACLAPPLICATION=ON \
-DLIB_SUFFIX=/32 -DLIB_SUFFIX=/32
@ -409,6 +408,7 @@ in `NACL_PREFIX` in toolchain file.
-DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-64.cmake" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-64.cmake" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/usr/nacl \
-DCMAKE_INSTALL_PREFIX=/usr/nacl \ -DCMAKE_INSTALL_PREFIX=/usr/nacl \
-DWITH_NACLAPPLICATION=ON -DWITH_NACLAPPLICATION=ON
cmake --build . cmake --build .
@ -427,9 +427,9 @@ You will need [Emscripten](https://github.com/kripken/emscripten/wiki/Tutorial)
installed and configured. installed and configured.
Don't forget to adapt `EMSCRIPTEN_PREFIX` variable in `generic/Emscripten.cmake` Don't forget to adapt `EMSCRIPTEN_PREFIX` variable in `generic/Emscripten.cmake`
to path where Emscripten is installed. Default is `/usr/emscripten`. Emscripten to path where Emscripten is installed. Default is `/usr/lib/emscripten`.
supports dynamic libraries only to simplify porting and they are generally Emscripten supports dynamic libraries only to simplify porting and they are
slower, thus `BUILD_STATIC` is implicitly enabled. generally slower, thus `BUILD_STATIC` is implicitly enabled.
Then create build directory and run cmake and build command in it. The 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 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_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten.cmake" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten.cmake" \
-DCMAKE_BUILD_TYPE=Release \ -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 -DWITH_SDL2APPLICATION=ON
cmake --build . 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 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** toolchain needs access to its platform file, so be sure to properly set **absolute**
path to `modules/` directory containing `Platform/Android.cmake`. Also set 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 Note that `BUILD_STATIC` is implicitly enabled, because manually loading all
depending shared libraries using JNI would be too inconvenient. Decision 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_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-ARM.cmake" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-ARM.cmake" \
-DCMAKE_BUILD_TYPE=Release \ -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 \ -DCMAKE_INSTALL_PREFIX=/opt/android-ndk/platforms/android-19/arch-arm/usr \
-DTARGET_GLES=ON -DTARGET_GLES2=ON -DTARGET_GLES=ON -DTARGET_GLES2=ON
cmake --build . 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_MODULE_PATH="/absolute/path/to/toolchains/modules" \
-DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-x86.cmake" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-x86.cmake" \
-DCMAKE_BUILD_TYPE=Release \ -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 \ -DCMAKE_INSTALL_PREFIX=/opt/android-ndk/platforms/android-19/arch-x86/usr \
-DTARGET_GLES=ON -DTARGET_GLES2=ON -DTARGET_GLES=ON -DTARGET_GLES2=ON
cmake --build . 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 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 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** GL tests only. Setup your Jenkins server, enable the **Git** and
plugin and download the CLI application from here: **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` Then add new jobs or update existing ones (update path to the `*.jar` file,
or `update-job`). 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://localhost:8080 update-job Magnum-Compatibility < package/ci/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-GLTests < package/ci/jenkins-gltests.xml
Build is done using **Ninja** build system and everything possible is enabled, Build is done using **Ninja** build system and everything possible is enabled,
thus you need also **SDL2**, **GLUT** and **OpenAL** libraries. It expects that 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 Magnum-Compatibility-GLTests depend on active X11 session, thus they should be
run from Jenkins instance running on graphical user session. 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 There is also MinGW-w64, Emscripten, NaCl and Android configuration, add or
update them with the commands below. See @ref building-crosscompiling for more update them with the commands below. See @ref building-crosscompiling for more
information about setting up the crosscompilers and `toolchains/` submodule. information about setting up the crosscompilers and `toolchains/` submodule.
For Emscripten you need also **Node.js** installed to run the tests. 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://localhost:8080 update-job Magnum-MinGW-w64 < package/ci/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://localhost:8080 update-job Magnum-Emscripten < package/ci/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://localhost:8080 update-job Magnum-NaCl < package/ci/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-Android < package/ci/jenkins-android.xml
*/ */
} }

73
doc/cmake.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -25,14 +25,14 @@
namespace Magnum { namespace Magnum {
/** @page cmake Usage with CMake /** @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 projects. The logic is in module `FindMagnum.cmake` distributed with the engine
in `modules/` directory, you are encouraged to copy it along with in `modules/` directory, you are encouraged to copy it along with
`FindCorrade.cmake` into your project and add path to the files to `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 `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 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 `FindOpenGLES2.cmake` or `FindOpenGLES3.cmake` and in some cases also
`FindEGL.cmake`. `FindEGL.cmake`.
@ -50,17 +50,17 @@ Basic usage is:
find_package(Magnum REQUIRED) 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: variables:
- `MAGNUM_FOUND` -- Whether the library was found - `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_INCLUDE_DIRS` -- Root include dir and include dirs of dependencies
- `MAGNUM_PLUGINS_DEBUG_DIR` -- Base directory with dynamic plugins for debug - `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 was found
- `MAGNUM_PLUGINS_RELEASE_DIR` -- Base directory with dynamic plugins for - `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 library was found
- `MAGNUM_PLUGINS_DIR` -- Base directory with dynamic plugins, defaults to - `MAGNUM_PLUGINS_DIR` -- Base directory with dynamic plugins, defaults to
`MAGNUM_PLUGINS_RELEASE_DIR` in release builds and multi-configuration `MAGNUM_PLUGINS_RELEASE_DIR` in release builds and multi-configuration
@ -80,32 +80,31 @@ variables:
dynamic audio importer plugins dynamic audio importer plugins
However, this command will try to find only the base library, not the optional 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. OpenGL ES libraries). Additional dependencies are specified by the components.
The optional components are: The optional components are:
- `%Audio` -- @ref Audio library - `Audio` -- @ref Audio library
- `%DebugTools` -- @ref DebugTools library (depends on `%MeshTools`, - `DebugTools` -- @ref DebugTools library
`%Primitives`, `%SceneGraph`, `%Shaders` and `%Shapes` components) - `MeshTools` -- @ref MeshTools library
- `%MeshTools` -- @ref MeshTools library - `Primitives` -- @ref Primitives library
- `%Primitives` -- @ref Primitives library - `SceneGraph` -- @ref SceneGraph library
- `%SceneGraph` -- @ref SceneGraph library - `Shaders` -- @ref Shaders library
- `%Shaders` -- @ref Shaders library - `Shapes` -- @ref Shapes library
- `%Shapes` -- @ref Shapes library (depends on `%SceneGraph` component) - `Text` -- @ref Text library
- `%Text` -- @ref Text library (depends on `%TextureTools` component) - `TextureTools` -- @ref TextureTools library
- `%TextureTools` -- @ref TextureTools library
Platform namespace is split into more components: Platform namespace is split into more components:
- `%GlutApplication` -- @ref Platform::GlutApplication "GlutApplication" - `GlutApplication` -- @ref Platform::GlutApplication "GlutApplication"
- `%GlxApplication` -- @ref Platform::GlxApplication "GlxApplication" - `GlxApplication` -- @ref Platform::GlxApplication "GlxApplication"
- `%NaClApplication` -- @ref Platform::NaClApplication "NaClApplication" - `NaClApplication` -- @ref Platform::NaClApplication "NaClApplication"
- `%Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application" - `Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application"
- `%XEglApplication` -- @ref Platform::XEglApplication "XEglApplication" - `XEglApplication` -- @ref Platform::XEglApplication "XEglApplication"
- `%WindowlessCglApplication` -- @ref Platform::WindowlessCglApplication "WindowlessCglApplication" - `WindowlessCglApplication` -- @ref Platform::WindowlessCglApplication "WindowlessCglApplication"
- `%WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication" - `WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication"
- `%WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication" - `WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication"
- `%WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication" - `WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication"
For manual context creation (without application wrappers) there are also For manual context creation (without application wrappers) there are also
platform-specific context libraries (see @ref platform-custom for more 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 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. dependencies, you need to find the dependency and then link to it.
- `MagnumFont` -- @ref Text::MagnumFont "MagnumFont" plugin (depends on - `MagnumFont` -- @ref Text::MagnumFont "MagnumFont" plugin
`%Text` component and `TgaImporter` plugin)
- `MagnumFontConverter` -- @ref Text::MagnumFontConverter "MagnumFontConverter" - `MagnumFontConverter` -- @ref Text::MagnumFontConverter "MagnumFontConverter"
plugin (depends on `%Text` component and `%TgaImageConverter` plugin) plugin
- `ObjImporter` -- @ref Trade::ObjImporter "ObjImporter" plugin (depends on - `ObjImporter` -- @ref Trade::ObjImporter "ObjImporter" plugin
`%MeshTools` component)
- `TgaImageConverter` -- @ref Trade::TgaImageConverter "TgaImageConverter" - `TgaImageConverter` -- @ref Trade::TgaImageConverter "TgaImageConverter"
plugin plugin
- `TgaImporter` -- @ref Trade::TgaImporter "TgaImporter" plugin - `TgaImporter` -- @ref Trade::TgaImporter "TgaImporter" plugin
- `WavAudioImporter` -- @ref Audio::WavImporter "WavAudioImporter" plugin - `WavAudioImporter` -- @ref Audio::WavImporter "WavAudioImporter" plugin
(depends on `%Audio` component)
Note that [each namespace](namespaces.html), all @ref Platform libraries and Note that [each namespace](namespaces.html), all @ref Platform libraries and
each plugin class contain more detailed information about dependencies, 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` variable along with `MAGNUM_PLUGINS_*_DEBUG_DIR` / `MAGNUM_PLUGINS_*_RELEASE_DIR`
variables to decide in preprocessing step. 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 are also available as preprocessor variables if including
@ref Magnum/Magnum.h "Magnum/Magnum.h": @ref Magnum/Magnum.h "Magnum/Magnum.h":
@ -187,12 +183,7 @@ are also available as preprocessor variables if including
emulation on desktop OpenGL emulation on desktop OpenGL
- `MAGNUM_TARGET_WEBGL` --- Defined if compiled for WebGL - `MAGNUM_TARGET_WEBGL` --- Defined if compiled for WebGL
If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable also Corrade library provides also its own set of CMake macros and variables, see
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
@ref corrade-cmake "its documentation" for more information. @ref corrade-cmake "its documentation" for more information.
@ref cmake-plugins "Plugins repository" and @ref cmake-integration "Integration library" @ref cmake-plugins "Plugins repository" and @ref cmake-integration "Integration library"
have also their own CMake modules. have also their own CMake modules.

10
doc/coding-style.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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 @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 @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 third party libraries and OpenGL (e.g. `GLuint`) and rely only on implicit
conversions when converting between them. This helps avoiding sign, truncation 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`. @ref Vector2i if and only if @ref Int is the same type as `GLsizei`.
@subsubsection coding-style-cpp-naming Naming @subsubsection coding-style-cpp-naming Naming
@ -100,7 +100,7 @@ void setPolygonMode(PolygonMode mode);
Additionally to @c \@todoc, @c \@debugoperator, @c \@debugoperatorenum, Additionally to @c \@todoc, @c \@debugoperator, @c \@debugoperatorenum,
@c \@debugoperatorclassenum, @c \@configurationvalue and @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 @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 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 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 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 related GL API last, then various support information such as
@c \@requires_glXX, @c \@requires_es_extension etc. (first desktop GL, then ES, @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 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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 @section compilation-forward-declarations Forward declarations instead of includes
Essential thing when speeding up compilation is reducing number of `#``include` 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 policy in all header files, so all types which are not directly used in the
header have only forward declarations. header have only forward declarations.
@ -55,19 +55,19 @@ available, each namespace has its own:
@section compilation-speedup-templates Templates @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 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 or @ref Double data type. However, having templated classes and function
usually means that the compiler compiles the whole templated code again in each 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 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 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 @subsection compilation-speedup-hpp Template headers and implementation files
When templated code is too large, it is not stored in header file, but in 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 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 Template implementation files have `*.hpp` extension, hinting that they are
something between `*.h` and `*.cpp` files. 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 Keyword `extern template` is a new thing in C++11, attempting to solve
compilation time problems related to templated code. However, on some compilers 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. it's used only for specific functions.
This is completely transparent to end user, so no special care is needed. 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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 @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 @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 shaders. They are implemented as object features, so you can attach any number
of them to any object. of them to any object.
Basic usage involves instancing DebugTools::ResourceManager and keeping it for Basic usage involves instancing @ref DebugTools::ResourceManager and keeping it
for the whole lifetime of debug renderers. Next you need some SceneGraph::DrawableGroup for the whole lifetime of debug renderers. Next you need some
instance. You can use the same group as for the rest of your scene, but @ref SceneGraph::DrawableGroup instance. You can use the same group as for the
preferrably use dedicated one for debug renderers, so you can easily enable or rest of your scene, but preferrably use dedicated one for debug renderers, so
disable debug rendering. you can easily enable or disable debug rendering.
Next step is to create configuration for your debug renderers and create Next step is to create configuration for your debug renderers and create
particular debug renderer. The configuration is managed using the resource 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. given key doesn't exist, default fallback is used.
Example usage: visualizing object position, rotation and scaling using Example usage: visualizing object position, rotation and scaling using
DebugTools::ObjectRenderer: @link DebugTools::ObjectRenderer @endlink:
@code @code
// Global instance of debug resource manager, drawable group for the renderers // Global instance of debug resource manager, drawable group for the renderers
DebugTools::ResourceManager manager; DebugTools::ResourceManager manager;
@ -75,7 +75,7 @@ Object3D* object;
new DebugTools::ObjectRenderer2D(*object, "my", debugDrawables); new DebugTools::ObjectRenderer2D(*object, "my", debugDrawables);
@endcode @endcode
See DebugTools::ObjectRenderer and DebugTools::ShapeRenderer for more See @ref DebugTools::ObjectRenderer and @ref DebugTools::ShapeRenderer for more
information. information.
- Previous page: @ref shapes - Previous page: @ref shapes

3
doc/features.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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 matrix-vector -- @copybrief matrix-vector
- @subpage transformations -- @copybrief transformations - @subpage transformations -- @copybrief transformations
- @subpage plugins -- @copybrief plugins - @subpage plugins -- @copybrief plugins
- @subpage shaders -- @copybrief shaders
- @subpage scenegraph -- @copybrief scenegraph - @subpage scenegraph -- @copybrief scenegraph
- @subpage shapes -- @copybrief shapes - @subpage shapes -- @copybrief shapes
- @subpage debug-tools -- @copybrief debug-tools - @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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -25,16 +23,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include "Magnum/configure.h" #ifdef CORRADE_IS_DEBUG_BUILD
#define MAGNUM_PLUGINS_IMAGECONVERTER_DIR "${MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR}"
#ifdef MAGNUM_BUILD_STATIC #define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}"
#ifdef MAGNUM_BUILD_DEPRECATED
#include "Magnum/Shaders/resourceImport.hpp"
#else
#error use Magnum/Shaders/resourceImport.hpp instead
#endif
#else #else
#error this header is available only in static build #define MAGNUM_PLUGINS_IMAGECONVERTER_DIR "${MAGNUM_PLUGINS_IMAGECONVERTER_DIR}"
#endif #define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DIR}"
#endif #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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -25,7 +25,7 @@
namespace Magnum { namespace Magnum {
/** @page getting-started Getting started /** @page getting-started Getting started
@brief Get started with %Magnum in matter of minutes. @brief Get started with Magnum in matter of minutes.
@tableofcontents @tableofcontents
@ -42,7 +42,7 @@ parameter.
@section getting-started-bootstrap Download bootstrap project @section getting-started-bootstrap Download bootstrap project
Setting up a new project can be pretty gruesome and nobody likes repeating the 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. many use cases, helping you get up and running in no time.
The [bootstrap repository](https://github.com/mosra/magnum-bootstrap) is 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 @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. CMake build system, see @ref cmake for more information.
modules/FindCorrade.cmake 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/` directory and delegates everything important to `CMakeLists.txt` in `src/`
subdirectory. subdirectory.
@code @code
cmake_minimum_required(VERSION 2.8.8) cmake_minimum_required(VERSION 2.8.9)
project(MyApplication) project(MyApplication)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules/") 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 Directory `modules/` contains CMake modules for finding the needed
dependencies. Unlike modules for finding e.g. OpenGL, which are part of 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 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. repository.
Directory `src/` contains the actual project. To keep things simple, the 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 The application essentially does nothing, just clears screen framebuffer to
default (dark gray) color and then does buffer swap to actually display it on 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: executable and links it to all needed libraries:
@code @code
find_package(Magnum REQUIRED Sdl2Application) 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 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, 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". @ref getting-started-download "go back and fix it".
@image html getting-started.png @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 And in the constructor (which is currently empty) change the clear color and
print something to debug output: print something to debug output:
@code @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() Debug() << "Hello! This application is running on" << Context::current()->version()
<< "using" << Context::current()->rendererString(); << "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 After rebuilding and starting the application, the clear color changes to
blueish one and something like this would be printed to the console: 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 html getting-started-blue.png
@image latex getting-started-blue.png @image latex getting-started-blue.png
@ -223,6 +223,7 @@ experimenting on your own!
- @subpage building - @subpage building
- @subpage building-plugins - @subpage building-plugins
- @subpage building-integration - @subpage building-integration
- @subpage building-examples
- @subpage cmake - @subpage cmake
- @subpage cmake-plugins - @subpage cmake-plugins
- @subpage cmake-integration - @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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -26,9 +26,10 @@
namespace Magnum { namespace Magnum {
/** @mainpage /** @mainpage
%Magnum is 2D/3D graphics engine written in C++11 and modern OpenGL. Its goal Magnum is 2D/3D graphics engine written in C++11/C++14 and modern OpenGL. Its
is to simplify low-level graphics development and interaction with OpenGL using goal is to simplify low-level graphics development and interaction with OpenGL
recent C++11 features and to abstract away platform-specific issues. using recent C++11/C++14 features and to abstract away platform-specific
issues.
@section mainpage-design-goals Design goals @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 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 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. 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. learned for 3D and even combine 2D and 3D in one project.
- **Forward compatibility** - **Forward compatibility**
If newer technology makes things faster, simpler or more intuitive, it is 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 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 using older functionality. However, you are not restricted to use the older
functionality directly, if you really want to. functionality directly, if you really want to.
- **Intuitive, but not restrictive API** - **Intuitive, but not restrictive API**
Scripting languages are often preferred to C/C++ because they are designed 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 designed with intuitivity in mind, but also with speed and static checks
that strongly-typed native code offers. It wraps OpenGL into less verbose 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 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 - Website -- http://mosra.cz/blog/magnum.php
- GitHub -- https://github.com/mosra/magnum - GitHub -- https://github.com/mosra/magnum
- IRC -- join `#magnum-engine` channel on freenode
- Google Groups -- https://groups.google.com/forum/#!forum/magnum-engine - Google Groups -- https://groups.google.com/forum/#!forum/magnum-engine
- Twitter -- https://twitter.com/czmosra - Twitter -- https://twitter.com/czmosra
- E-mail -- mosra@centrum.cz - E-mail -- mosra@centrum.cz
@ -121,10 +123,10 @@ Feel free to get more information or contact the author at:
@section mainpage-license License @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; > Vladimír Vondruš &lt;mosra@centrum.cz&gt;
> >
> Permission is hereby granted, free of charge, to any person obtaining a > 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -31,7 +31,7 @@ namespace Magnum {
- Next page: @ref transformations - Next page: @ref transformations
Matrices and vectors are the most important part of graphics programming and 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 are contained in @ref Math namespace and common variants also have aliases in
root @ref Magnum namespace. See documentation of these namespaces for more root @ref Magnum namespace. See documentation of these namespaces for more
information about usage with CMake. information about usage with CMake.
@ -40,10 +40,10 @@ information about usage with CMake.
@section matrix-vector-hierarchy Matrix and vector classes @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 (square) @ref Math::Matrix and @ref Math::Vector. To achieve greatest code
reuse, %Matrix is internally square %RectangularMatrix and %RectangularMatrix reuse, Matrix is internally square RectangularMatrix and RectangularMatrix
is internally array of one or more %Vector instances. Both vectors and matrices 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 can have arbitrary size (known at compile time) and can store any arithmetic
type. 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 @ref Math::Vector2, @ref Math::Vector3 and @ref Math::Vector4, implementing
direct access to named components. Functions of each class try to return the direct access to named components. Functions of each class try to return the
most specialized type known to make subsequent operations more convenient -- most specialized type known to make subsequent operations more convenient --
columns of %RectangularMatrix are returned as %Vector, but when accessing columns of RectangularMatrix are returned as Vector, but when accessing
columns of e.g. %Matrix3, they are returned as %Vector3. columns of e.g. Matrix3, they are returned as Vector3.
There are also even more specialized subclasses, e.g. @ref Color3 and There are also even more specialized subclasses, e.g. @ref Color3 and
@ref Color4 for color handling and conversion. @ref Color4 for color handling and conversion.
Commonly used types have convenience aliases in @ref Magnum namespace, so you 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. namespace documentation for more information.
@section matrix-vector-construction Constructing matrices and vectors @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 @section matrix-vector-operations Operations with matrices and vectors
Vectors can be added, subtracted, negated and multiplied or divided with 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: scalar with vector:
@code @code
Vector3 a(1.0f, 2.0f, 3.0f); 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 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. 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 will have integral result, you need to convert both arguments to the same
floating-point type to have floating-point result. floating-point type to have floating-point result.
@code @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 @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 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: implications and it may differ from what is common in mathematics:
- Order of template arguments in specification of @ref Math::RectangularMatrix - 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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 repeatedly specifying variable the method is called on. Its primary goal is to
reduce unnecessary repeated names, improving code readability. 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 various mesh and framebuffer options, shader uniforms etc.). Because OpenGL was
designed with "bind-to-modify" approach, most configuration calls internally designed with "bind-to-modify" approach, most configuration calls internally
need to bind the object first and only after that change the parameters (unless 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 @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 bound somewhere. Method chaining encourages you to configure whole object in
one run, effectively reducing the number of needed bindings. Consider the one run, effectively reducing the number of needed bindings. Consider the
following example: following example:
@ -74,13 +74,14 @@ carBumpTexture.setStorage(5, TextureFormat::RGB8)
.generateMipmap(); .generateMipmap();
@endcode @endcode
Method chaining is not used on non-configuring functions, such as Framebuffer::clear() Method chaining is not used on non-configuring functions, such as
or Mesh::draw(), as these won't be commonly used in conjunction with other @ref Framebuffer::clear() or @ref Mesh::draw(), as these won't be commonly used
functions anyway. in conjunction with other functions anyway.
Method chaining is also used in SceneGraph and other libraries and in some cases Method chaining is also used in @ref SceneGraph and other libraries and in some
it allows you to just "configure and forget" without even saving the created cases it allows you to just "configure and forget" without even saving the
object to some variable, for example when adding static object to an scene: created object to some variable, for example when adding static object to an
scene:
@code @code
Scene3D scene; Scene3D scene;

119
doc/namespaces.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -24,21 +24,21 @@
*/ */
/** @dir magnum/src/Magnum /** @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 /** @namespace Magnum
@brief Root namespace @brief Root namespace
Contains classes for interacting with OpenGL. Contains classes for interacting with OpenGL.
This library is built as part of %Magnum by default. To use it, you need to 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 find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more
information. information.
*/ */
/** @dir Magnum/Platform /** @dir Magnum/Platform
* @brief Namespace Magnum::Platform * @brief Namespace @ref Magnum::Platform
*/ */
/** @namespace Magnum::Platform /** @namespace Magnum::Platform
@brief Platform-specific application and context creation @brief Platform-specific application and context creation
@ -46,9 +46,9 @@ information.
Base classes for creating applications with various toolkits. Base classes for creating applications with various toolkits.
Parts of this namespace are built if `WITH_*APPLICATION` is enabled when 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 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_INCLUDE_DIRS}` to include path and link to
`${MAGNUM_*APPLICATION_LIBRARIES}`. See particular `*Application` class `${MAGNUM_*APPLICATION_LIBRARIES}`. See particular `*Application` class
documentation, @ref building, @ref cmake and @ref platform for more documentation, @ref building, @ref cmake and @ref platform for more
@ -56,58 +56,58 @@ information.
*/ */
/** @dir Magnum/Math /** @dir Magnum/Math
* @brief Namespace Magnum::Math * @brief Namespace @ref Magnum::Math
*/ */
/** @namespace Magnum::Math /** @namespace Magnum::Math
@brief %Math library @brief Math library
Template classes for matrix and vector calculations. Template classes for matrix and vector calculations.
This library is built as part of %Magnum by default. To use it, you need to 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 find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building, @ref cmake, @ref matrix-vector and to `${MAGNUM_LIBRARIES}`. See @ref building, @ref cmake, @ref matrix-vector and
@ref transformations for more information. @ref transformations for more information.
*/ */
/** @dir Magnum/Math/Algorithms /** @dir Magnum/Math/Algorithms
* @brief Namespace Magnum::Math::Algorithms * @brief Namespace @ref Magnum::Math::Algorithms
*/ */
/** @namespace Magnum::Math::Algorithms /** @namespace Magnum::Math::Algorithms
@brief %Algorithms @brief Algorithms
Various matrix and vector algorithms. Various matrix and vector algorithms.
This library is built as part of %Magnum by default. To use it, you need to 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 find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more
information. information.
*/ */
/** @dir Magnum/Math/Geometry /** @dir Magnum/Math/Geometry
* @brief Namespace Magnum::Math::Geometry * @brief Namespace @ref Magnum::Math::Geometry
*/ */
/** @namespace Magnum::Math::Geometry /** @namespace Magnum::Math::Geometry
@brief %Geometry library @brief Geometry library
Functions for computing intersections, distances, areas and volumes. Functions for computing intersections, distances, areas and volumes.
This library is built as part of %Magnum by default. To use it, you need to 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 find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more
information. information.
*/ */
/** @dir Magnum/Audio /** @dir Magnum/Audio
* @brief Namespace Magnum::Audio * @brief Namespace @ref Magnum::Audio
*/ */
/** @namespace Magnum::Audio /** @namespace Magnum::Audio
@brief %Audio playback @brief Audio playback
Audio import, playback and integration with @ref SceneGraph. Audio import, playback and integration with @ref SceneGraph.
This library depends on **OpenAL** library. It is built if `WITH_AUDIO` is 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 enabled when building Magnum. To use this library, you need to request
`%Audio` component of `%Magnum` package in CMake, add `${MAGNUM_AUDIO_INCLUDE_DIRS}` `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 to include path and link to `${MAGNUM_AUDIO_LIBRARIES}`. See @ref building and
@ref cmake for more information. Additional plugins are enabled separately, see @ref cmake for more information. Additional plugins are enabled separately, see
particular `*Importer` class documentation, @ref building-plugins, particular `*Importer` class documentation, @ref building-plugins,
@ -115,100 +115,99 @@ particular `*Importer` class documentation, @ref building-plugins,
*/ */
/** @dir Magnum/DebugTools /** @dir Magnum/DebugTools
* @brief Namespace Magnum::DebugTools * @brief Namespace @ref Magnum::DebugTools
*/ */
/** @namespace Magnum::DebugTools /** @namespace Magnum::DebugTools
@brief %Debug tools @brief Debug tools
Debugging helpers, renderers and profilers. Debugging helpers, renderers and profilers.
This library is built if `WITH_DEBUGTOOLS` is enabled when building %Magnum. To This library is built if `WITH_DEBUGTOOLS` is enabled when building Magnum. To
use this library, you need to request `%DebugTools` component of `%Magnum` use this library, you need to request `DebugTools` component of `Magnum`
package in CMake and link to `${MAGNUM_DEBUGTOOLS_LIBRARIES}`. See package in CMake and link to `${MAGNUM_DEBUGTOOLS_LIBRARIES}`. See
@ref building, @ref cmake and @ref debug-tools for more information. @ref building, @ref cmake and @ref debug-tools for more information.
*/ */
/** @dir Magnum/MeshTools /** @dir Magnum/MeshTools
* @brief Namespace Magnum::MeshTools * @brief Namespace @ref Magnum::MeshTools
*/ */
/** @namespace Magnum::MeshTools /** @namespace Magnum::MeshTools
@brief %Mesh tools @brief Mesh tools
Tools for generating, optimizing and cleaning meshes. Tools for generating, optimizing and cleaning meshes.
This library is built if `WITH_MESHTOOLS` is enabled when building %Magnum. To This library is built if `WITH_MESHTOOLS` is enabled when building Magnum. To
use this library, you need to request `%MeshTools` component of `%Magnum` use this library, you need to request `MeshTools` component of `Magnum`
package in CMake and link to `${MAGNUM_MESHTOOLS_LIBRARIES}`. See @ref building package in CMake and link to `${MAGNUM_MESHTOOLS_LIBRARIES}`. See @ref building
and @ref cmake for more information. and @ref cmake for more information.
*/ */
/** @dir Magnum/Primitives /** @dir Magnum/Primitives
* @brief Namespace Magnum::Primitives * @brief Namespace @ref Magnum::Primitives
*/ */
/** @namespace Magnum::Primitives /** @namespace Magnum::Primitives
@brief Primitive library @brief Primitive library
Basic primitives for testing purposes. Basic primitives for testing purposes.
This library is built if `WITH_PRIMITIVES` is enabled when building %Magnum. To This library is built if `WITH_PRIMITIVES` is enabled when building Magnum. To
use this library, you need to request `%Primitives` component of `%Magnum` use this library, you need to request `Primitives` component of `Magnum`
package in CMake and link to `${MAGNUM_PRIMITIVES_LIBRARIES}`. See package in CMake and link to `${MAGNUM_PRIMITIVES_LIBRARIES}`. See
@ref building and @ref cmake for more information. @ref building and @ref cmake for more information.
*/ */
/** @dir Magnum/SceneGraph /** @dir Magnum/SceneGraph
* @brief Namespace Magnum::SceneGraph * @brief Namespace @ref Magnum::SceneGraph
*/ */
/** /** @namespace Magnum::SceneGraph
@namespace Magnum::SceneGraph @brief Scene graph library
@brief %Scene graph library
Managing object hierarchy, transformations and interactions. Managing object hierarchy, transformations and interactions.
This library is built if `WITH_SCENEGRAPH` is enabled when building %Magnum. To This library is built if `WITH_SCENEGRAPH` is enabled when building Magnum. To
use this library, you need to request `%SceneGraph` component of `%Magnum` use this library, you need to request `SceneGraph` component of `Magnum`
package in CMake and link to `${MAGNUM_SCENEGRAPH_LIBRARIES}`. See package in CMake and link to `${MAGNUM_SCENEGRAPH_LIBRARIES}`. See
@ref building, @ref cmake and @ref scenegraph for more information. @ref building, @ref cmake and @ref scenegraph for more information.
*/ */
/** @dir Magnum/Shaders /** @dir Magnum/Shaders
* @brief Namespace Magnum::Shaders * @brief Namespace @ref Magnum::Shaders
*/ */
/** @namespace Magnum::Shaders /** @namespace Magnum::Shaders
@brief Builtin shaders @brief Builtin shaders
Collection of shaders for easy prototyping and basic usage. Collection of shaders for easy prototyping and basic usage.
This library is built if `WITH_SHADERS` is enabled when building %Magnum. To 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 use this library, you need to request `Shaders` component of `Magnum` package
in CMake and link to `${MAGNUM_MESHTOOLS_SHADERS}`. See @ref building and 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 /** @dir Magnum/Shapes
* @brief Namespace Magnum::Shapes * @brief Namespace @ref Magnum::Shapes
*/ */
/** @namespace Magnum::Shapes /** @namespace Magnum::Shapes
@brief %Shape library @brief Shape library
Collision detection system. Collision detection system.
This library is built if `WITH_SHAPES` is enabled when building %Magnum. To use 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, you need to request `Shapes` component of `Magnum` package in
CMake and link to `${MAGNUM_SHAPES_LIBRARIES}`. See @ref building, @ref cmake CMake and link to `${MAGNUM_SHAPES_LIBRARIES}`. See @ref building, @ref cmake
and @ref shapes for more information. and @ref shapes for more information.
*/ */
/** @dir Magnum/Text /** @dir Magnum/Text
* @brief Namespace Magnum::Text * @brief Namespace @ref Magnum::Text
*/ */
/** @namespace Magnum::Text /** @namespace Magnum::Text
@brief %Text rendering @brief Text rendering
Font texture creation and text layouting. Font texture creation and text layouting.
This library is built if `WITH_TEXT` is enabled when building %Magnum. To use 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, you need to request `Text` component of `Magnum` package in
CMake and link to `${MAGNUM_TEXT_LIBRARIES}`. See @ref building and @ref cmake CMake and link to `${MAGNUM_TEXT_LIBRARIES}`. See @ref building and @ref cmake
for more information. Additional plugins are enabled separately, see particular for more information. Additional plugins are enabled separately, see particular
`*Font` and `*FontConverter` class documentation, @ref building-plugins, `*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 /** @dir Magnum/TextureTools
* @brief Namespace Magnum::TextureTools * @brief Namespace @ref Magnum::TextureTools
*/ */
/** @namespace Magnum::TextureTools /** @namespace Magnum::TextureTools
@brief %Texture tools @brief Texture tools
Tools for generating, compressing and optimizing textures. Tools for generating, compressing and optimizing textures.
This library is built if `WITH_TEXTURETOOLS` is enabled when building %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` To use this library, you need to request `TextureTools` component of `Magnum`
package in CMake and link to `${MAGNUM_TEXTURETOOLS_LIBRARIES}`. See package in CMake and link to `${MAGNUM_TEXTURETOOLS_LIBRARIES}`. See
@ref building and @ref cmake for more information. @ref building and @ref cmake for more information.
*/ */
/** @dir Magnum/Trade /** @dir Magnum/Trade
* @brief Namespace Magnum::Trade * @brief Namespace @ref Magnum::Trade
*/ */
/** @namespace Magnum::Trade /** @namespace Magnum::Trade
@brief Data format exchange @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 Contains plugin interfaces for importing data of various formats and classes
for direct access to the data. for direct access to the data.
This library is built as part of %Magnum by default. To use it, you need to 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 find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link
to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more
information. Additional plugins are enabled separately, see particular information. Additional plugins are enabled separately, see particular
`*Importer` and `*ImageConverter` class documentation, @ref building-plugins, `*Importer` and `*ImageConverter` class documentation, @ref building-plugins,
@ -247,5 +246,5 @@ information. Additional plugins are enabled separately, see particular
*/ */
/** @dir magnum/src/MagnumPlugins /** @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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -26,7 +26,7 @@
namespace Magnum { namespace Magnum {
/** @page opengl-mapping OpenGL command mapping /** @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 @tableofcontents
@ -53,10 +53,10 @@ OpenGL function | Matching API
@fn_gl{BeginConditionalRender}, `glEndConditionalRender()` | @ref SampleQuery::beginConditionalRender(), \n @ref SampleQuery::endConditionalRender() @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{BeginQuery}, `glEndQuery()` | @ref PrimitiveQuery::begin(), \n @ref SampleQuery::begin(), \n @ref TimeQuery::begin(), \n @ref AbstractQuery::end()
@fn_gl{BeginQueryIndexed}, `glEndQueryIndexed()` | | @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{BindAttribLocation} | @ref AbstractShaderProgram::bindAttributeLocation()
@fn_gl{BindBuffer} | not needed, handled internally in @ref Buffer and elsewhere @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{BindFragDataLocation} | @ref AbstractShaderProgram::bindFragmentDataLocation()
@fn_gl{BindFragDataLocationIndexed} | @ref AbstractShaderProgram::bindFragmentDataLocationIndexed() @fn_gl{BindFragDataLocationIndexed} | @ref AbstractShaderProgram::bindFragmentDataLocationIndexed()
@fn_gl{BindFramebuffer} | @ref Framebuffer::bind() @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{BindRenderbuffer} | not needed, handled internally in @ref Renderbuffer
@fn_gl{BindSampler}, \n @fn_gl{BindSamplers} | | @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{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{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{BindVertexBuffer}, \n `glVertexArrayVertexBuffer()`, \n @fn_gl_extension{VertexArrayBindVertexBuffer,EXT,direct_state_access} \n @fn_gl{BindVertexBuffers}, \n `glVertexArrayVertexBuffers()` | |
@fn_gl{BlendColor} | @ref Renderer::setBlendColor() @fn_gl{BlendColor} | @ref Renderer::setBlendColor()
@ -110,8 +110,8 @@ OpenGL function | Matching API
OpenGL function | Matching API OpenGL function | Matching API
--------------------------------------- | ------------ --------------------------------------- | ------------
@fn_gl{DebugMessageCallback} | @ref DebugMessage::setCallback() @fn_gl{DebugMessageCallback} | @ref DebugOutput::setCallback()
@fn_gl{DebugMessageControl} | @ref DebugMessage::setEnabled() @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{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{DepthFunc} | @ref Renderer::setDepthFunction()
@fn_gl{DepthMask} | @ref Renderer::setDepthMask() @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{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{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{GetTexParameter}, \n `glGetTextureParameter()`, \n @fn_gl_extension{GetTextureParameter,EXT,direct_state_access} | |
@fn_gl{GetTextureSubImage} | | @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} | | @fn_gl{GetTransformFeedback} | not queryable, @ref TransformFeedback::attachBuffer() and @ref TransformFeedback::attachBuffers() setters only
@fn_gl{GetTransformFeedbackVarying} | | @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{GetUniform}, \n `glGetnUniform()`, \n @fn_gl_extension{GetnUniform,ARB,robustness} | not queryable, @ref AbstractShaderProgram::setUniform() setter only
@fn_gl{GetUniformBlockIndex} | | @fn_gl{GetUniformBlockIndex} | |
@fn_gl{GetUniformIndices} | | @fn_gl{GetUniformIndices} | |
@ -267,7 +267,7 @@ OpenGL function | Matching API
OpenGL function | Matching API OpenGL function | Matching API
--------------------------------------- | ------------ --------------------------------------- | ------------
@fn_gl{PatchParameter} | | @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{PixelStore} | |
@fn_gl{PointParameter} | | @fn_gl{PointParameter} | |
@fn_gl{PointSize} | @ref Renderer::setPointSize() @fn_gl{PointSize} | @ref Renderer::setPointSize()
@ -277,7 +277,8 @@ OpenGL function | Matching API
@fn_gl{ProgramBinary} | | @fn_gl{ProgramBinary} | |
@fn_gl{ProgramParameter} | @ref AbstractShaderProgram::setRetrievableBinary(), \n @ref AbstractShaderProgram::setSeparable() @fn_gl{ProgramParameter} | @ref AbstractShaderProgram::setRetrievableBinary(), \n @ref AbstractShaderProgram::setSeparable()
@fn_gl{ProvokingVertex} | @ref Renderer::setProvokingVertex() @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 @subsection opengl-mapping-functions-q Q
@ -317,7 +318,7 @@ OpenGL function | Matching API
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{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{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{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() @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{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{TextureBarrier} | |
@fn_gl{TextureView} | | @fn_gl{TextureView} | |
@fn_gl{TransformFeedbackBufferBase}, \n @fn_gl{TransformFeedbackBufferRange} | | @fn_gl{TransformFeedbackBufferBase}, \n @fn_gl{TransformFeedbackBufferRange} | @ref TransformFeedback::attachBuffer(), \n @ref TransformFeedback::attachBuffers()
@fn_gl{TransformFeedbackVaryings} | | @fn_gl{TransformFeedbackVaryings} | @ref AbstractShaderProgram::setTransformFeedbackOutputs()
@subsection opengl-mapping-functions-u U @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_COUNT} | |
@def_gl{MAX_COMPUTE_WORK_GROUP_INVOCATIONS} | @ref AbstractShaderProgram::maxComputeWorkGroupInvocations() @def_gl{MAX_COMPUTE_WORK_GROUP_INVOCATIONS} | @ref AbstractShaderProgram::maxComputeWorkGroupInvocations()
@def_gl{MAX_COMPUTE_WORK_GROUP_SIZE} | | @def_gl{MAX_COMPUTE_WORK_GROUP_SIZE} | |
@def_gl{MAX_DEBUG_LOGGED_MESSAGES} | @ref DebugMessage::maxLoggedMessages() @def_gl{MAX_DEBUG_LOGGED_MESSAGES} | @ref DebugOutput::maxLoggedMessages()
@def_gl{MAX_DEBUG_MESSAGE_LENGTH} | @ref DebugMessage::maxMessageLength() @def_gl{MAX_DEBUG_MESSAGE_LENGTH} | @ref DebugOutput::maxMessageLength()
@def_gl{MAX_DEBUG_GROUP_STACK_DEPTH} | | @def_gl{MAX_DEBUG_GROUP_STACK_DEPTH} | @ref DebugGroup::maxStackDepth()
@def_gl{MAX_CLIP_DISTANCES} | | @def_gl{MAX_CLIP_DISTANCES} | |
@def_gl{MAX_CULL_DISTANCES} | | @def_gl{MAX_CULL_DISTANCES} | |
@def_gl{MAX_COMBINED_CLIP_AND_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{MAX_TEXTURE_BUFFER_SIZE} | @ref BufferTexture::maxSize()
@def_gl_extension{MAX_TEXTURE_MAX_ANISOTROPY,EXT,texture_filter_anisotropic} | @ref Sampler::maxMaxAnisotropy() @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_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_BLOCK_SIZE} | @ref AbstractShaderProgram::maxUniformBlockSize()
@def_gl{MAX_UNIFORM_BUFFER_BINDINGS} | @ref Buffer::maxUniformBindings() @def_gl{MAX_UNIFORM_BUFFER_BINDINGS} | @ref Buffer::maxUniformBindings()
@def_gl{MAX_UNIFORM_LOCATIONS} | @ref AbstractShaderProgram::maxUniformLocations() @def_gl{MAX_UNIFORM_LOCATIONS} | @ref AbstractShaderProgram::maxUniformLocations()

51
doc/opengl-support.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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 @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 @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 GLSL 1.30 | done
@extension{ARB,map_buffer_range} | done @extension{ARB,map_buffer_range} | done
@ -70,13 +70,13 @@ GLSL 1.30 | done
@extension{EXT,texture_shared_exponent} | done @extension{EXT,texture_shared_exponent} | done
@extension{EXT,draw_buffers2} | | @extension{EXT,draw_buffers2} | |
@extension{EXT,texture_integer} | done (GL 3.0 subset) @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,depth_buffer_float} | |
@extension{NV,conditional_render} | done @extension{NV,conditional_render} | done
@subsection opengl-support-31 OpenGL 3.1 @subsection opengl-support-31 OpenGL 3.1
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 1.40 | done GLSL 1.40 | done
@extension{ARB,texture_rectangle} | done @extension{ARB,texture_rectangle} | done
@ -89,7 +89,7 @@ GLSL 1.40 | done
@subsection opengl-support-32 OpenGL 3.2 @subsection opengl-support-32 OpenGL 3.2
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 1.50 | done GLSL 1.50 | done
@extension{ARB,geometry_shader4} | missing layered attachments @extension{ARB,geometry_shader4} | missing layered attachments
@ -104,7 +104,7 @@ GLSL 1.50 | done
@subsection opengl-support-33 OpenGL 3.3 @subsection opengl-support-33 OpenGL 3.3
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 3.30 | done GLSL 3.30 | done
@extension{ARB,instanced_arrays} | done @extension{ARB,instanced_arrays} | done
@ -120,7 +120,7 @@ GLSL 3.30 | done
@subsection opengl-support-40 OpenGL 4.0 @subsection opengl-support-40 OpenGL 4.0
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 4.00 | done GLSL 4.00 | done
@extension{ARB,draw_buffers_blend} | | @extension{ARB,draw_buffers_blend} | |
@ -134,12 +134,12 @@ GLSL 4.00 | done
@extension{ARB,shader_subroutine} | | @extension{ARB,shader_subroutine} | |
@extension{ARB,tessellation_shader} | missing some limit queries and patch parameter specification function @extension{ARB,tessellation_shader} | missing some limit queries and patch parameter specification function
@extension{ARB,texture_buffer_object_rgb32} | done @extension{ARB,texture_buffer_object_rgb32} | done
@extension{ARB,transform_feedback2} | | @extension{ARB,transform_feedback2} | missing transform feedback draw
@extension{ARB,transform_feedback3} | | @extension{ARB,transform_feedback3} | only advanced interleaving
@subsection opengl-support-41 OpenGL 4.1 @subsection opengl-support-41 OpenGL 4.1
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 4.10 | done GLSL 4.10 | done
@extension{ARB,ES2_compatibility} | only float depth clear @extension{ARB,ES2_compatibility} | only float depth clear
@ -151,7 +151,7 @@ GLSL 4.10 | done
@subsection opengl-support-42 OpenGL 4.2 @subsection opengl-support-42 OpenGL 4.2
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 4.20 | done GLSL 4.20 | done
@extension{ARB,texture_compression_bptc} | done @extension{ARB,texture_compression_bptc} | done
@ -169,7 +169,7 @@ GLSL 4.20 | done
@subsection opengl-support-43 OpenGL 4.3 @subsection opengl-support-43 OpenGL 4.3
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 4.30 | done GLSL 4.30 | done
@extension{ARB,arrays_of_arrays} | done (shading language only) @extension{ARB,arrays_of_arrays} | done (shading language only)
@ -177,7 +177,7 @@ GLSL 4.30 | done
@extension{ARB,clear_buffer_object} | | @extension{ARB,clear_buffer_object} | |
@extension{ARB,compute_shader} | | @extension{ARB,compute_shader} | |
@extension{ARB,copy_image} | | @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,explicit_uniform_location} | done
@extension{ARB,fragment_layer_viewport} | done (shading language only) @extension{ARB,fragment_layer_viewport} | done (shading language only)
@extension{ARB,framebuffer_no_attachments} | | @extension{ARB,framebuffer_no_attachments} | |
@ -200,7 +200,7 @@ GLSL 4.30 | done
@todo Also fallback to @extension{AMD,query_buffer_object} @todo Also fallback to @extension{AMD,query_buffer_object}
@todo @extension{AMD,pinned_memory} "fallback" for @extension{ARB,buffer_storage} @todo @extension{AMD,pinned_memory} "fallback" for @extension{ARB,buffer_storage}
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 4.40 | done GLSL 4.40 | done
@def_gl{MAX_VERTEX_ATTRIB_STRIDE} | | @def_gl{MAX_VERTEX_ATTRIB_STRIDE} | |
@ -215,7 +215,7 @@ GLSL 4.40 | done
@subsection opengl-support-45 OpenGL 4.5 @subsection opengl-support-45 OpenGL 4.5
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
GLSL 4.50 | done GLSL 4.50 | done
@extension{ARB,ES3_1_compatibility} | | @extension{ARB,ES3_1_compatibility} | |
@ -223,8 +223,8 @@ GLSL 4.50 | done
@extension{ARB,conditional_render_inverted} | done @extension{ARB,conditional_render_inverted} | done
@extension{ARB,cull_distance} | | @extension{ARB,cull_distance} | |
@extension{ARB,derivative_control} | done (shading language only) @extension{ARB,derivative_control} | done (shading language only)
@extension{ARB,direct_state_access} | object creation subset only @extension{ARB,direct_state_access} | done for implemented functionality (except VAOs)
@extension{ARB,get_texture_sub_image} | | @extension{ARB,get_texture_sub_image} | missing compressed texture queries
@extension{ARB,shader_texture_image_samples} | done (shading language only) @extension{ARB,shader_texture_image_samples} | done (shading language only)
@extension{ARB,texture_barrier} | | @extension{ARB,texture_barrier} | |
@extension{KHR,context_flush_control} (also in ES) | | @extension{KHR,context_flush_control} (also in ES) | |
@ -232,7 +232,7 @@ GLSL 4.50 | done
@subsection opengl-support-extensions ARB / Khronos OpenGL extensions @subsection opengl-support-extensions ARB / Khronos OpenGL extensions
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
@extension{ARB,robustness} | done @extension{ARB,robustness} | done
@extension3{KHR,texture_compression_astc_ldr,texture_compression_astc_hdr} (also in ES) | | @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{ATI,meminfo}, @extension{NVX,gpu_memory_info}, GPU temperature
@todo @extension{AMD,performance_monitor}, @extension{INTEL,performance_query} @todo @extension{AMD,performance_monitor}, @extension{INTEL,performance_query}
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
@extension{AMD,vertex_shader_layer} | done (shading language only) @extension{AMD,vertex_shader_layer} | done (shading language only)
@extension{AMD,shader_trinary_minmax} | 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,direct_state_access} | done for implemented functionality
@extension{EXT,texture_sRGB_decode} (also in ES) | done @extension{EXT,texture_sRGB_decode} (also in ES) | done
@extension{EXT,shader_integer_mix} (also in ES) | done (shading language only) @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_label} (also in ES) | missing pipeline and sampler label
@extension2{EXT,debug_marker} (also in ES) | missing marker groups @extension2{EXT,debug_marker} (also in ES) | done
@extension{GREMEDY,string_marker} | done @extension{GREMEDY,string_marker} | done
@subsection opengl-support-es20 OpenGL ES 2.0 @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 @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_blit} | done
@es_extension{ANGLE,framebuffer_multisample} | 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_extension{OES,texture_float_linear} | done
@es_extension2{OES,texture_half_float,OES_texture_float} | done @es_extension2{OES,texture_half_float,OES_texture_float} | done
@es_extension{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,vertex_half_float} | done
@es_extension{OES,packed_depth_stencil} | done @es_extension{OES,packed_depth_stencil} | done
@es_extension{OES,depth_texture} | 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 @todo Support also IMG_multisampled_render_to_texture? It has different enum
values (!) values (!)
%Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------
@es_extension{APPLE,texture_format_BGRA8888} | done @es_extension{APPLE,texture_format_BGRA8888} | done
@es_extension{CHROMIUM,map_sub} | only buffer mapping @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 @section opengl-unsupported Unsupported OpenGL features
Some functionality, which is either soon-to-be deprecated or isn't proven to 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. @ref opengl-deprecated.
@subsection opengl-unsupported-features Unsupported features @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 not supported. The only exception are features that are needed for some
OpenGL ES 2.0 implementations (such as luminance texture formats). OpenGL ES 2.0 implementations (such as luminance texture formats).
- State queries (various `glIs*()`, `glGet*()` functions) are not supported. - 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 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 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 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -26,7 +26,7 @@
/** @page opengl OpenGL /** @page opengl OpenGL
@brief State of OpenGL support, version and extension requirements. @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 developers with existing OpenGL background. Note that, as reverse mapping, each
function documentation also contains list of OpenGL functions used. 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 functionality has greater requirements. Following are lists of features
requiring specific OpenGL version. In most cases it is also specified which requiring specific OpenGL version. In most cases it is also specified which
extension is required, so if given hardware supports required extension, it 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). is supported on older Intel GPUs even if they are capable of OpenGL 2.1 only).
- @subpage requires-gl30 - @subpage requires-gl30

50
doc/platform.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -23,13 +23,13 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
namespace Magnum { namespace Platform { namespace Magnum {
/** @page platform Platform support /** @page platform Platform support
@brief Integration into windowing toolkits and creation of windowless contexts. @brief Integration into windowing toolkits and creation of windowless contexts.
- Next page: @ref types - 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 various toolkits, both windowed and windowless. Each class has slightly
different dependencies and platform requirements, see documentation of different dependencies and platform requirements, see documentation of
@ref Platform namespace and particular `*Application` classes for more @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 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 @ref Platform::Sdl2Application. As said above, the usage is similar for all
toolkits, you must provide one-argument constructor and implement at least toolkits, you must provide one-argument constructor and implement at least
@ref Sdl2Application::drawEvent() "drawEvent()" function. The class can be then @ref Platform::Sdl2Application::drawEvent() "drawEvent()" function. The class
used directly in `main()`, but for convenience and portability it's better to can be then used directly in `main()`, but for convenience and portability it's
use @ref MAGNUM_SDL2APPLICATION_MAIN() macro. better to use @ref MAGNUM_SDL2APPLICATION_MAIN() macro.
To simplify the porting, the library provides `Platform::Application` typedef To simplify the porting, the library provides `Platform::Application` typedef
and `MAGNUM_APPLICATION_MAIN()` macro (but only if only one application header 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 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). one line in CMake build script, as you see later).
Barebone application implementation which will just clear the window to dark 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, 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 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 example by resizing the default framebuffer, you need to reimplement
@ref Sdl2Application::viewportEvent() "viewportEvent()" function and pass the @ref Platform::Sdl2Application::viewportEvent() "viewportEvent()" function and
new size to the framebuffer: pass the new size to the framebuffer:
@code @code
class MyApplication: public Platform::Application { 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 Windowless applications provide just a context for ofscreen rendering or
performing tasks on GPU. There is not yet any platform-independent toolkit 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 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 Windows. To make things simple, as an example we will use only
@ref Platform::WindowlessGlxApplication, see link for bootstrap application @ref Platform::WindowlessGlxApplication, see link for bootstrap application
below for fully portable example. 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 function. The class can be then used directly in `main()`, but again, for
convenience and portability it's better to use convenience and portability it's better to use
@ref MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN() macro. @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()` provides `Platform::WindowlessApplication` typedef and `MAGNUM_WINDOWLESSAPPLICATION_MAIN()`
macro, but only if just one windowless application header is included. Changing 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 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 separated from aliases for windowed applications, because projects commonly
contain both graphics application and command-line tools (for data preparation contain both graphics application and command-line tools (for data preparation
etc.). etc.).
@ -182,8 +182,8 @@ MAGNUM_WINDOWLESSAPPLICATION_MAIN(MyApplication)
@section platform-compilation Compilation with CMake @section platform-compilation Compilation with CMake
Barebone compilation consists just of finding %Magnum library with required Barebone compilation consists just of finding Magnum library with required
`*Application` component, adding %Magnum's `${MAGNUM_INCLUDE_DIRS}` and `*Application` component, adding Magnum's `${MAGNUM_INCLUDE_DIRS}` and
application-specific `${MAGNUM_SDL2APPLICATION_INCLUDE_DIRS}` to include path, application-specific `${MAGNUM_SDL2APPLICATION_INCLUDE_DIRS}` to include path,
compilation of the executable and linking `${MAGNUM_LIBRARIES}` and compilation of the executable and linking `${MAGNUM_LIBRARIES}` and
`${MAGNUM_SDL2APPLICATION_LIBRARIES}` to it. `${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 only if only one application (windowless application) component is requested to
avoid ambiguity. Changing the build script to use different toolkit is then avoid ambiguity. Changing the build script to use different toolkit is then
matter of replacing only the requested `*Application` component (and one 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 @code
find_package(Magnum REQUIRED Sdl2Application) 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. By default the application is created with some reasonable defaults (e.g.
window size 800x600 pixels). If you want something else, you can pass window size 800x600 pixels). If you want something else, you can pass
@ref Sdl2Application::Configuration "Configuration" instance to application @ref Platform::Sdl2Application::Configuration "Configuration" instance to
constructor. Using method chaining it can be done conveniently like this: application constructor. Using method chaining it can be done conveniently like
this:
@code @code
MyApplication::MyApplication(int& argc, char** argv): MyApplication::MyApplication(int& argc, char** argv):
Platform::Application(argc, argv, Configuration() 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 However, sometimes you would need to configure the application based on some
configuration file or system introspection. In that case you can pass `nullptr` configuration file or system introspection. In that case you can pass `nullptr`
instead of @ref Sdl2Application::Configuration "Configuration" instance and instead of @ref Platform::Sdl2Application::Configuration "Configuration"
then specify it later with @ref Sdl2Application::createContext() "createContext()": instance and then specify it later with @ref Platform::Sdl2Application::createContext() "createContext()":
@code @code
MyApplication::MyApplication(int& argc, char** argv): Platform::Application(argc, argv, nullptr) { 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 @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 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. 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 You can for example try enabling MSAA and if the context creation fails, fall
back to no-AA rendering: 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 @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 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 manually. First create OpenGL context and then create instance of
@ref Platform::Context class, which will take care of proper initialization and @ref Platform::Context class, which will take care of proper initialization and
feature detection. The instance must be alive for whole application lifetime. feature detection. The instance must be alive for whole application lifetime.
@ -287,6 +288,9 @@ int main(int argc, char** argv) {
} }
@endcode @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 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 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. 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 - Next page: @ref types
*/ */
}} }

38
doc/plugins.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -25,12 +25,12 @@
namespace Magnum { namespace Magnum {
/** @page plugins Loading and using plugins /** @page plugins Loading and using plugins
@brief Extending %Magnum with additional functionality @brief Extending Magnum with additional functionality
- Previous page: @ref transformations - 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 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 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. 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 @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, - @ref Trade::AbstractImporter -- importers for general 2D and 3D scene,
mesh, material, texture and image data. See `*Importer` classes in 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 set particular plugin directory, from which the manager will load and
instantiate the plugins. To save you from hardcoding the value into your instantiate the plugins. To save you from hardcoding the value into your
application source, the plugin directory is provided as `MAGNUM_PLUGINS_DIR` 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`, change it through CMake to anything else. The `MAGNUM_PLUGINS_IMPORTER_DIR`,
`MAGNUM_PLUGINS_IMAGECONVERTER_DIR`, `MAGNUM_PLUGINS_FONT_DIR`, `MAGNUM_PLUGINS_IMAGECONVERTER_DIR`, `MAGNUM_PLUGINS_FONT_DIR`,
`MAGNUM_PLUGINS_FONTCONVERTER_DIR`, `MAGNUM_PLUGINS_AUDIOIMPORTER_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 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 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 build and you have to select between `MAGNUM_PLUGINS_*_DIR` and
@ref corrade-cmake "CORRADE_IS_DEBUG_BUILD" variable. This will ensure that you `MAGNUM_PLUGINS_*_DEBUG_DIR` based on @ref corrade-cmake "CORRADE_IS_DEBUG_BUILD"
use debug plugin directory for debug build on multi-configuration build sytems preprocessor variable. This will ensure that you use debug plugin directory for
and fall back to autodetection for the rest: debug build on multi-configuration build sytems and fall back to autodetection
for the rest:
@code @code
#ifdef CORRADE_IS_DEBUG_BUILD #ifdef CORRADE_IS_DEBUG_BUILD
#define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}" #define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}"
@ -110,6 +111,11 @@ and fall back to autodetection for the rest:
#endif #endif
@endcode @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 Then process the file in your `CMakeLists.txt`. The result
(`${MAGNUM_PLUGINS_IMPORTER_DIR}` / `${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}` gets (`${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 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); PluginManager::Manager<Trade::AbstractImporter> manager{MAGNUM_PLUGINS_IMPORTER_DIR};
if(!(manager.load("TgaImporter") & PluginManager::LoadState::Loaded)) { std::unique_ptr<Trade::AbstractImporter> tgaImporter = manager.loadAndInstantiate("TgaImporter");
Error() << "Cannot load TgaImporter plugin from" << manager.pluginDirectory(); if(!tgaImporter) {
Error() << "Cannot load importer plugin from" << manager.pluginDirectory();
std::exit(1); std::exit(1);
} }
std::unique_ptr<Trade::AbstractImporter> tgaImporter = manager.instance("TgaImporter");
// Use the plugin... // Use the plugin...
@ -202,7 +208,7 @@ int main(int argc, char** argv) {
@section plugins-develop Developing your own plugins @section plugins-develop Developing your own plugins
See class documentation of particular plugin interfaces for more information 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. contains more information about plugin compilation and registering.
If you want to develop a plugin which depends on another, you need to find the 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. for more information.
- Previous page: @ref transformations - 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -31,7 +31,7 @@ namespace Magnum {
@section portability-target Target-specific code @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 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 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 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 @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 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 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 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 compilers is also available and handled by Corrade library. See @ref Corrade.h
for more information. for more information.
@ -108,7 +108,7 @@ MAGNUM_ASSERT_EXTENSION_SUPPORTED(GL::ARB::geometry_shader4);
@endcode @endcode
Each class, function or enum value is marked accordingly if it needs specific 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 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 available, but also have proper fallback when it's not, see for example
@ref AbstractShaderProgram-performance-optimization "AbstractShaderProgram", @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 @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` address - different shader syntax (`in`/`out` vs. `attribute` and `varying`
etc.), explicit vs. implicit methods to specify vertex attribute, uniform and etc.), explicit vs. implicit methods to specify vertex attribute, uniform and
texture uniform locations, required precision qualifiers in OpenGL ES etc. texture uniform locations, required precision qualifiers in OpenGL ES etc.

314
doc/scenegraph.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -23,14 +23,14 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
namespace Magnum { namespace SceneGraph { namespace Magnum {
/** @page scenegraph Using scene graph /** @page scenegraph Using scene graph
@brief Overview of scene management capabilities. @brief Overview of scene management capabilities.
- Previous page: @ref plugins - Previous page: @ref shaders
- Next page: @ref shapes - 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 transformation, physics interaction, animation and rendering. The library is
contained in @ref SceneGraph namespace, see its documentation for more contained in @ref SceneGraph namespace, see its documentation for more
information about building and usage with CMake. 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 transformation representations, animated vs. static, object can have collision
shape, participate in physics events, have forward vs. deferred rendering...) shape, participate in physics events, have forward vs. deferred rendering...)
and to make everything possible without combinatiorial explosion and allow the 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: three main components:
- objects, providing parent/children hierarchy - objects, providing parent/children hierarchy
@ -56,114 +56,154 @@ three main components:
@section scenegraph-transformation Transformations @section scenegraph-transformation Transformations
Transformation handles object position, rotation etc. and its basic property Transformation handles object position, rotation etc. and its basic property
is dimension count (2D or 3D) and underlying floating-point type. 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
@note All classes in @ref SceneGraph are templated on underlying type. However, @ref Float "Float" is used and thus nearly all classes have convenience aliases
in most cases @ref Magnum::Float "Float" is used and thus nearly all so you don't have to explicitly specify it.
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
%Scene graph has implementation of transformations in both 2D and 3D, using using matrices you can have nearly arbitrary transformations, but composing
either matrices or combination of position and rotation. Each implementation transformations, computing their inverse and accounting for floating-point
has its own advantages and disadvantages -- for example when using matrices drift is rather costly operation. On the other hand quaternions won't allow you
you can have nearly arbitrary transformations, but composing transformations to scale or shear objects, but have far better performance characteristics.
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.
It's also possible to implement your own transformation class for specific It's also possible to implement your own transformation class for specific
needs, see source of other transformation classes for more information. needs, see source of builtin transformation classes for more information.
@section scenegraph-hierarchy Scene hierarchy Magnum provides the following transformation classes. See documentation of each
class for more detailed information:
%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 - @ref SceneGraph::BasicMatrixTransformation2D "SceneGraph::MatrixTransformation2D" --
transformation type, identical for all objects (because for example having part arbitrary 2D transformations but with slow inverse transformations and no
of the tree in 2D and part in 3D just wouldn't make sense). Common usage is to floating-point drift reduction
typedef %Scene and %Object with desired transformation type to save unnecessary - @ref SceneGraph::BasicMatrixTransformation3D "SceneGraph::MatrixTransformation3D" --
typing later: 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 @code
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D> Scene3D; typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D> Scene3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> Object3D; typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> Object3D;
@endcode @endcode
Then you can start building the hierarchy by *parenting* one object to another. @attention Note that you have to include both @ref Magnum/SceneGraph/Object.h
Parent object can be either passed in constructor or using @ref Object::setParent(). and desired transformation class (e.g. @ref Magnum/SceneGraph/MatrixTransformation3D.h)
%Scene is always root object, so it naturally cannot have parent object. 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 @code
Scene3D scene; Scene3D scene;
auto first = new Object3D(&scene); Object3D object;
auto second = new Object3D(first); object.setParent(&scene)
.rotateY(15.0_degf)
.translate(Vector3::xAxis(5.0f));
@endcode @endcode
%Object children can be accessed using @ref Object::firstChild() and @section scenegraph-hierarchy Scene hierarchy
@ref Object::lastChild(), then you can traverse siblings (objects with the same
parent) with @ref Object::previousSibling() and @ref Object::nextSibling(). For Scene hierarchy is skeleton part of scene graph. In the root there is
example all children of an object can be traversed the following way: @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 @code
Object3D* o; Scene3D scene;
for(Object3D* child = o->firstChild(); child; child = child->nextSibling()) {
// ... Object3D* first = new Object3D{&scene};
} Object3D* second = new Object3D{first};
@endcode @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 all its children are destroyed too. See detailed explanation of
@ref scenegraph-object-construction-order "construction and destruction order" @ref scenegraph-object-construction-order "construction and destruction order"
for information about possible issues. below for information about possible issues. To reflect the implicit memory
management in the code better, you can use @ref SceneGraph::Object::addChild()
The object is derived from the transformation you specified earlier in the instead of the naked `new` call in the code above:
`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:
@code @code
auto next = new Object3D; Scene3D scene;
next->setParent(another)
.translate(Vector3::yAxis(3.0f)) Object3D& first = scene.addChild<Object3D>();
.rotateY(35.0_degf); Object3D& second = first.addChild<Object3D>();
@endcode @endcode
@section scenegraph-features Object features @section scenegraph-features Object features
The object itself handles only parent/child relationship and transformation. 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. have to add a *feature* to it.
Each feature takes reference to holder object in constructor, so adding a Magnum provides the following builtin features. See documentation of each class
feature to an object might look just like this, as in some cases you don't even for more detailed information and usage examples:
need to keep the pointer to it:
@code - @ref SceneGraph::AbstractCamera "SceneGraph::Camera*D" -- Handles
Object3D* o; projection matrix, aspect ratio correction etc.. Used for rendering parts
new MyFeature(o); of the scene.
@endcode - @ref SceneGraph::Drawable "SceneGraph::Drawable*D" -- Adds drawing
functionality to given object. Group of drawables can be then rendered
Features of an object can be accessed using @ref Object::firstFeature() and using the camera feature.
@ref Object::lastFeature(), then you can traverse the features using - @ref SceneGraph::Animable "SceneGraph::Animable*D" -- Adds animation
@ref AbstractFeature::previousFeature() and @ref AbstractFeature::nextFeature(), functionality to given object. Group of animables can be then controlled
similarly to traversing object children: 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 @code
Object3D* o; Object3D& o;
for(Object3D::FeatureType feature = o->firstFeature(); feature; feature = feature->nextFeature()) { new MyFeature{o, ...};
// ...
}
@endcode @endcode
Some features are passive, some active. Passive features can be just added to 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). an object, with no additional work except for possible configuration (for
Active features require the user to implement some virtual function (for example collision shape). Active features require the user to implement some
example to draw the object on screen or perform animation step). To make things virtual function (for example to draw the object on screen or perform animation
convenient, features can be added directly to object itself using multiple step). To make things convenient, features can be added directly to object
inheritance, so you can conveniently add all the active features you want and itself using multiple inheritance, so you can conveniently add all the active
implement needed functions in your own @ref Object subclass without having to features you want and implement needed functions in your own @ref SceneGraph::Object
subclass each feature individually (and making the code overly verbose). subclass without having to subclass each feature individually (and making the
Simplified example: code overly verbose). Simplified example:
@code @code
class Bomb: public Object3D, SceneGraph::Drawable3D, SceneGraph::Animable3D { class BouncingBall: public Object3D, SceneGraph::Drawable3D, SceneGraph::Animable3D {
public: 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 // drawing implementation for Drawable feature
void draw(...) override; void draw(...) override;
@ -179,55 +219,111 @@ feature list.
Similarly to object hierarchy, when destroying object, all its features (both Similarly to object hierarchy, when destroying object, all its features (both
member and inherited) are destroyed. See detailed explanation of member and inherited) are destroyed. See detailed explanation of
@ref scenegraph-feature-construction-order "construction and destruction order" @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 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 scene, collision detection needs to know about positions of surrounding
objects etc. To avoid computing the transformations from scratch every time, objects etc. To avoid computing the transformations from scratch every time,
the feature can cache them. the feature can cache them.
The cached data stay until the object is marked as dirty - that is by changing The cached data stay until the object is marked as dirty -- that is by changing
transformation, changing parent or explicitly calling @ref Object::setDirty(). 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 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 SceneGraph::AbstractFeature::markDirty() is called on every feature.
@ref Object::setClean() cleans the dirty object and all its dirty parents. Calling @ref SceneGraph::Object::setClean() cleans the dirty object and all its
The function goes through all object features and calls @ref AbstractFeature::clean() dirty parents. The function goes through all object features and calls
or @ref AbstractFeature::cleanInverted() depending on which caching is enabled @ref SceneGraph::AbstractFeature::clean() or
on given feature. If the object is already clean, @ref Object::setClean() does @ref SceneGraph::AbstractFeature::cleanInverted() depending on which caching is
nothing. enabled on given feature. If the object is already clean,
@ref SceneGraph::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 Most probably you will need caching in @ref SceneGraph::Object itself -- which
and implement it using @ref AbstractFeature. In order to have caching, you must doesn't support it on its own -- however you can take advantage of multiple
enable it first, because by default the caching is disabled. You can enable it inheritance and implement it using @ref SceneGraph::AbstractFeature. In order
using @ref AbstractFeature::setCachedTransformations() and then implement to have caching, you must enable it first, because by default the caching is
corresponding cleaning function(s): disabled. You can enable it using @ref SceneGraph::AbstractFeature::setCachedTransformations()
and then implement corresponding cleaning function(s):
@code @code
class CachingObject: public Object3D, SceneGraph::AbstractFeature3D { class CachingObject: public Object3D, SceneGraph::AbstractFeature3D {
public: public:
CachingObject(Object3D* parent): SceneGraph::AbstractFeature3D(*this) { explicit CachingObject(Object3D* parent): Object3D{parent}, SceneGraph::AbstractFeature3D{*this} {
setCachedTransformations(SceneGraph::CachedTransformation::Absolute); setCachedTransformations(SceneGraph::CachedTransformation::Absolute);
} }
protected: protected:
void clean(const Matrix4& absoluteTransformation) override { void clean(const Matrix4& absoluteTransformation) override {
absolutePosition = absoluteTransformation.translation(); _absolutePosition = absoluteTransformation.translation();
} }
private: private:
Vector3 absolutePosition; Vector3 _absolutePosition;
}; };
@endcode @endcode
When you need to use the cached value, you can explicitly request the cleanup 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 by calling @ref SceneGraph::Object::setClean(). @ref SceneGraph::Camera3D "Camera",
it automatically before it starts rendering, as it needs its own inverse for example, calls it automatically before it starts rendering, as it needs its
transformation to properly draw the objects. 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 @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 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 as member it's no issue, features added using multiple inheritance must be
inherited after the %Object class: inherited after the Object class:
@code @code
class MyObject: public Object3D, MyFeature { class MyObject: public Object3D, MyFeature {
public: 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 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). program didn't already crash) destructor of MyFeature is called (again).
- Previous page: @ref plugins - Previous page: @ref shaders
- Next page: @ref shapes - 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
namespace Magnum { namespace Shapes { namespace Magnum {
/** @page shapes Collision detection /** @page shapes Collision detection
@brief Collection of simple shapes for high performance 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 @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 what is found in many other collision detection libraries. Additionally some
shapes are provided in inverted form -- e.g. inverted box detects collisions on 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 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 - @ref Shapes::LineSegment "Shapes::LineSegment*D" -- @copybrief Shapes::LineSegment
Because of numerical instability it's not possible to detect collisions of 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 @subsection shapes-2D Two-dimensional shapes
@ -76,7 +76,7 @@ is least efficient.
@section shapes-composition Creating shape compositions @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 `!` operations: AND, OR and NOT. These operations are mapped to `&&`, `||` and `!`
operators, so for example creating negation of logical OR of line segment and operators, so for example creating negation of logical OR of line segment and
point is simple as this: point is simple as this:
@ -110,7 +110,7 @@ Shapes::Composition3D composition = simplified && (sphere || box);
@section shapes-collisions Detecting shape collisions @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 for collision using the `%` operator. The operator returns boolean describing
whether the collision happened or not. Example: whether the collision happened or not. Example:
@code @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 serious physics you often need more information like contact point, separation
normal and penetration depth. For shape pairs which have implemented this normal and penetration depth. For shape pairs which have implemented this
detailed collision detection you can use the `/` operator, which returns detailed collision detection you can use the `/` operator, which returns
@ref Collision object. Note that unlike with the `%` operator mentioned above, @ref Shapes::Collision object. Note that unlike with the `%` operator mentioned
this operation is not commutative. See @ref Collision class documentation for above, this operation is not commutative. See @ref Shapes::Collision class
more information about the returned data. Example: documentation for more information about the returned data. Example:
@code @code
const Shapes::Collision3D c = point/sphere; const Shapes::Collision3D c = point/sphere;
if(c) { if(c) {
@ -137,7 +137,7 @@ if(c) {
@section shapes-scenegraph Integration with scene graph @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 In conjunction with @ref Shapes::ShapeGroup you can use
@ref Shapes::Shape::collides() and @ref Shapes::Shape::collision() similarly to @ref Shapes::Shape::collides() and @ref Shapes::Shape::collision() similarly to
the `%` and `/` operators above. Please note that the shape group caches the 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 - Next page: @ref debug-tools
*/ */
}}} }

2
doc/tips.dox

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

6
doc/troubleshooting.dox

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -30,13 +30,13 @@ namespace Magnum {
@section troubleshooting-building Building issues @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: things:
- If the building fails on CMake step, be sure that you have up-to-date - 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 `FindCorrade.cmake`, `FindMagnum.cmake` and other CMake modules in your
project (`FindSDL2.cmake`). They are contained in `modules/` directory of 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`. `share/cmake/Magnum`.
- In some cases when the changes done to build system are too drastic, - 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 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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 @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 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 consistency and reduce confusion (e.g. `std::int32_t`, `int` and `GLint` all
refer to the same type). refer to the same type).
| %Magnum type | Size | Equivalent GLSL type | | Magnum type | Size | Equivalent GLSL type |
| ------------------ | -------------- | -------------------- | | ------------------ | -------------- | -------------------- |
| @ref UnsignedByte | 8bit unsigned | | | @ref UnsignedByte | 8bit unsigned | |
| @ref Byte | 8bit signed | | | @ref Byte | 8bit signed | |
@ -65,14 +65,14 @@ underlying type.
@section types-matrix Matrix/vector types @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 Vector2, @ref Vector3, @ref Vector4 | `vec2`, `vec3`, `vec4` |
| @ref Vector2ui, @ref Vector3ui, @ref Vector4ui | `uvec2`, `uvec3`, `uvec4` | | @ref Vector2ui, @ref Vector3ui, @ref Vector4ui | `uvec2`, `uvec3`, `uvec4` |
| @ref Vector2i, @ref Vector3i, @ref Vector4i | `ivec2`, `ivec3`, `ivec4` | | @ref Vector2i, @ref Vector3i, @ref Vector4i | `ivec2`, `ivec3`, `ivec4` |
| @ref Vector2d, @ref Vector3d, @ref Vector4d | `dvec2`, `dvec3`, `dvec4` | | @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 Matrix2x2 or @ref Matrix2x2d | `mat2`/`mat2x2` or `dmat2`/`dmat2x2` |
| @ref Matrix3 / @ref Matrix3x3 or @ref Matrix3d / @ref Matrix3x3d | `mat3`/`mat3x3` or `dmat3`/`dmat3x3` | | @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 @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 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 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 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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. # 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> # Vladimír Vondruš <mosra@centrum.cz>
# #
# Permission is hereby granted, free of charge, to any person obtaining a # Permission is hereby granted, free of charge, to any person obtaining a
@ -23,6 +23,8 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
if(WITH_FIND_MODULE) set(Magnum_MODULES
install(FILES FindMagnum.cmake DESTINATION ${MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR}) FindMagnum.cmake
endif() 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 # CORRADE_TESTSUITE_LIBRARIES - TestSuite library and dependent
# libraries # libraries
# CORRADE_RC_EXECUTABLE - Resource compiler executable # 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 # 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 # 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 # 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 # single-configuration build systems (such as Makefiles) this information is
# not needed and thus the variable is not defined in any case. # not needed and thus the variable is not defined in any case.
# #
# Corrade configures the compiler to use C++11 standard. Additionally you can # Corrade configures the compiler to use C++11 standard (if it is not already
# use CORRADE_CXX_FLAGS to enable additional pedantic set of warnings and # configured to do so). Additionally you can use CORRADE_CXX_FLAGS to enable
# enable hidden visibility by default. # additional pedantic set of warnings and enable hidden visibility by default.
# #
# Features of found Corrade library are exposed in these variables: # Features of found Corrade library are exposed in these variables:
# CORRADE_GCC47_COMPATIBILITY - Defined if compiled with compatibility # CORRADE_GCC47_COMPATIBILITY - Defined if compiled with compatibility
@ -57,10 +58,6 @@
# CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten # CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten
# CORRADE_TARGET_ANDROID - Defined if compiled for Android # CORRADE_TARGET_ANDROID - Defined if compiled for Android
# #
# 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: # Corrade provides these macros and functions:
# #
# #
@ -119,12 +116,14 @@
# CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found # CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found
# CORRADE_*_LIBRARY_RELEASE - Release version of given library, if # CORRADE_*_LIBRARY_RELEASE - Release version of given library, if
# found # found
# CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included
# automatically)
# #
# #
# This file is part of Corrade. # 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> # Vladimír Vondruš <mosra@centrum.cz>
# #
# Permission is hereby granted, free of charge, to any person obtaining a # Permission is hereby granted, free of charge, to any person obtaining a
@ -174,7 +173,7 @@ endforeach()
find_program(CORRADE_RC_EXECUTABLE corrade-rc) find_program(CORRADE_RC_EXECUTABLE corrade-rc)
# Include dir # Include dir
find_path(_CORRADE_INCLUDE_DIR find_path(CORRADE_INCLUDE_DIR
NAMES Corrade/PluginManager Corrade/Utility) NAMES Corrade/PluginManager Corrade/Utility)
# CMake module dir # CMake module dir
@ -182,19 +181,13 @@ find_path(_CORRADE_MODULE_DIR
NAMES UseCorrade.cmake CorradeLibSuffix.cmake NAMES UseCorrade.cmake CorradeLibSuffix.cmake
PATH_SUFFIXES share/cmake/Corrade) 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) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Corrade DEFAULT_MSG find_package_handle_standard_args(Corrade DEFAULT_MSG
CORRADE_UTILITY_LIBRARY CORRADE_UTILITY_LIBRARY
CORRADE_INTERCONNECT_LIBRARY CORRADE_INTERCONNECT_LIBRARY
CORRADE_PLUGINMANAGER_LIBRARY CORRADE_PLUGINMANAGER_LIBRARY
CORRADE_TESTSUITE_LIBRARY CORRADE_TESTSUITE_LIBRARY
_CORRADE_INCLUDE_DIR CORRADE_INCLUDE_DIR
CORRADE_RC_EXECUTABLE CORRADE_RC_EXECUTABLE
_CORRADE_MODULE_DIR) _CORRADE_MODULE_DIR)
@ -202,75 +195,37 @@ if(NOT CORRADE_FOUND)
return() return()
endif() endif()
# Configuration # Read flags from fonfiguration
file(READ ${_CORRADE_INCLUDE_DIR}/Corrade/configure.h _corradeConfigure) file(READ ${CORRADE_INCLUDE_DIR}/Corrade/configure.h _corradeConfigure)
set(_corradeFlags
# Compatibility? GCC47_COMPATIBILITY
string(FIND "${_corradeConfigure}" "#define CORRADE_GCC47_COMPATIBILITY" _GCC47_COMPATIBILITY) GCC46_COMPATIBILITY
if(NOT _GCC47_COMPATIBILITY EQUAL -1) GCC45_COMPATIBILITY
set(CORRADE_GCC47_COMPATIBILITY 1) GCC44_COMPATIBILITY
endif() MSVC2013_COMPATIBILITY
string(FIND "${_corradeConfigure}" "#define CORRADE_GCC46_COMPATIBILITY" _GCC46_COMPATIBILITY) BUILD_DEPRECATED
if(NOT _GCC46_COMPATIBILITY EQUAL -1) BUILD_STATIC
set(CORRADE_GCC46_COMPATIBILITY 1) TARGET_UNIX
endif() TARGET_APPLE
string(FIND "${_corradeConfigure}" "#define CORRADE_GCC45_COMPATIBILITY" _GCC45_COMPATIBILITY) TARGET_WINDOWS
if(NOT _GCC45_COMPATIBILITY EQUAL -1) TARGET_NACL
set(CORRADE_GCC45_COMPATIBILITY 1) TARGET_NACL_NEWLIB
endif() TARGET_NACL_GLIBC
string(FIND "${_corradeConfigure}" "#define CORRADE_GCC44_COMPATIBILITY" _GCC44_COMPATIBILITY) TARGET_EMSCRIPTEN
if(NOT _GCC44_COMPATIBILITY EQUAL -1) TARGET_ANDROID)
set(CORRADE_GCC44_COMPATIBILITY 1) foreach(_corradeFlag ${_corradeFlags})
endif() string(FIND "${_corradeConfigure}" "#define CORRADE_${_corradeFlag}" _corrade_${_corradeFlag})
string(FIND "${_corradeConfigure}" "#define CORRADE_MSVC2013_COMPATIBILITY" _MSVC2013_COMPATIBILITY) if(NOT _corrade_${_corradeFlag} EQUAL -1)
if(NOT _MSVC2013_COMPATIBILITY EQUAL -1) set(CORRADE_${_corradeFlag} 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)
endif() endif()
endforeach()
set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARY}) set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARY})
set(CORRADE_INTERCONNECT_LIBRARIES ${CORRADE_INTERCONNECT_LIBRARY} ${CORRADE_UTILITY_LIBRARIES}) set(CORRADE_INTERCONNECT_LIBRARIES ${CORRADE_INTERCONNECT_LIBRARY} ${CORRADE_UTILITY_LIBRARIES})
set(CORRADE_PLUGINMANAGER_LIBRARIES ${CORRADE_PLUGINMANAGER_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_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 # At least static build needs this
if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL_GLIBC) 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) set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARIES} log)
endif() endif()
mark_as_advanced(_CORRADE_INCLUDE_DIR mark_as_advanced(_CORRADE_MODULE_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()
# Finalize the finding process # Finalize the finding process
include(UseCorrade) include(${CORRADE_USE_MODULE})

9
modules/FindEGL.cmake

@ -10,7 +10,7 @@
# #
# This file is part of Magnum. # 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> # Vladimír Vondruš <mosra@centrum.cz>
# #
# Permission is hereby granted, free of charge, to any person obtaining a # Permission is hereby granted, free of charge, to any person obtaining a
@ -37,12 +37,9 @@ find_library(EGL_LIBRARY EGL)
# Include dir # Include dir
find_path(EGL_INCLUDE_DIR find_path(EGL_INCLUDE_DIR
NAMES egl.h NAMES EGL/egl.h)
PATH_SUFFIXES EGL
)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("EGL" DEFAULT_MSG find_package_handle_standard_args("EGL" DEFAULT_MSG
EGL_LIBRARY 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 # OpenGL ES libraries). Additional dependencies are specified by the
# components. The optional components are: # components. The optional components are:
# Audio - Audio library # Audio - Audio library
# DebugTools - DebugTools library (depends on MeshTools, Primitives, # DebugTools - DebugTools library
# SceneGraph, Shaders and Shapes components)
# MeshTools - MeshTools library # MeshTools - MeshTools library
# Primitives - Primitives library # Primitives - Primitives library
# SceneGraph - SceneGraph library # SceneGraph - SceneGraph library
# Shaders - Shaders library # Shaders - Shaders library
# Shapes - Shapes library (depends on SceneGraph component) # Shapes - Shapes library
# Text - Text library (depends on TextureTools component) # Text - Text library
# TextureTools - TextureTools library # TextureTools - TextureTools library
# MagnumFont - Magnum bitmap font plugin (depends on Text component # MagnumFont - Magnum bitmap font plugin
# and TgaImporter plugin) # MagnumFontConverter - Magnum bitmap font converter plugin
# MagnumFontConverter - Magnum bitmap font converter plugin (depends on Text
# component and TgaImageConverter plugin)
# ObjImporter - OBJ importer plugin # ObjImporter - OBJ importer plugin
# TgaImageConverter - TGA image converter plugin # TgaImageConverter - TGA image converter plugin
# TgaImporter - TGA importer plugin # TgaImporter - TGA importer plugin
# WavAudioImporter - WAV audio importer plugin (depends on Audio component) # WavAudioImporter - WAV audio importer plugin
# GlutApplication - GLUT application # GlutApplication - GLUT application
# GlxApplication - GLX application # GlxApplication - GLX application
# NaClApplication - NaCl application # NaClApplication - NaCl application
@ -101,11 +98,6 @@
# emulation on desktop OpenGL # emulation on desktop OpenGL
# MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL # 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: # Additionally these variables are defined for internal usage:
# MAGNUM_INCLUDE_DIR - Root include dir (w/o dependencies) # MAGNUM_INCLUDE_DIR - Root include dir (w/o dependencies)
# MAGNUM_LIBRARY - Magnum library (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_*_LIBRARY_RELEASE - Release version of given library, if found
# MAGNUM_BINARY_INSTALL_DIR - Binary installation directory # MAGNUM_BINARY_INSTALL_DIR - Binary installation directory
# MAGNUM_LIBRARY_INSTALL_DIR - Library 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_[DEBUG|RELEASE]_INSTALL_DIR - Plugin installation directory
# MAGNUM_PLUGINS_FONT_[DEBUG|RELEASE]_INSTALL_DIR - Font plugin installation # MAGNUM_PLUGINS_FONT_[DEBUG|RELEASE]_INSTALL_DIR - Font plugin installation
# directory # directory
@ -127,8 +120,6 @@
# installation directory # installation directory
# MAGNUM_PLUGINS_AUDIOIMPORTER_[DEBUG|RELEASE]_INSTALL_DIR - Audio importer # MAGNUM_PLUGINS_AUDIOIMPORTER_[DEBUG|RELEASE]_INSTALL_DIR - Audio importer
# plugin installation directory # plugin installation directory
# MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR - Installation dir for CMake Find*
# modules
# MAGNUM_INCLUDE_INSTALL_DIR - Header installation directory # MAGNUM_INCLUDE_INSTALL_DIR - Header installation directory
# MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR - Plugin header installation directory # MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR - Plugin header installation directory
# #
@ -136,7 +127,7 @@
# #
# This file is part of Magnum. # 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> # Vladimír Vondruš <mosra@centrum.cz>
# #
# Permission is hereby granted, free of charge, to any person obtaining a # Permission is hereby granted, free of charge, to any person obtaining a
@ -199,35 +190,20 @@ endif()
# Configuration # Configuration
file(READ ${MAGNUM_INCLUDE_DIR}/Magnum/configure.h _magnumConfigure) file(READ ${MAGNUM_INCLUDE_DIR}/Magnum/configure.h _magnumConfigure)
set(_magnumFlags
string(FIND "${_magnumConfigure}" "#define MAGNUM_BUILD_DEPRECATED" _BUILD_DEPRECATED) BUILD_DEPRECATED
if(NOT _BUILD_DEPRECATED EQUAL -1) BUILD_STATIC
set(MAGNUM_BUILD_DEPRECATED 1) TARGET_GLES
endif() TARGET_GLES2
string(FIND "${_magnumConfigure}" "#define MAGNUM_BUILD_STATIC" _BUILD_STATIC) TARGET_GLES3
if(NOT _BUILD_STATIC EQUAL -1) TARGET_DESKTOP_GLES
set(MAGNUM_BUILD_STATIC 1) TARGET_WEBGL)
endif() foreach(_magnumFlag ${_magnumFlags})
string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_GLES" _TARGET_GLES) string(FIND "${_magnumConfigure}" "#define MAGNUM_${_magnumFlag}" _magnum_${_magnumFlag})
if(NOT _TARGET_GLES EQUAL -1) if(NOT _magnum_${_magnumFlag} EQUAL -1)
set(MAGNUM_TARGET_GLES 1) set(MAGNUM_${_magnumFlag} 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)
endif() endif()
endforeach()
# Dependent libraries and includes # Dependent libraries and includes
set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR} set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR}
@ -247,15 +223,44 @@ elseif(MAGNUM_TARGET_GLES3)
set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGLES3_LIBRARY}) set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGLES3_LIBRARY})
endif() endif()
# On Windows and in static builds, *Application libraries need to have # Ensure that all inter-component dependencies are specified as well
# ${MAGNUM_LIBRARIES} listed in dependencies also after all other library names set(_MAGNUM_ADDITIONAL_COMPONENTS )
# to avoid linker errors. Applicaiton libraries are often last thus it is foreach(component ${Magnum_FIND_COMPONENTS})
# +- sufficient to add it there only. string(TOUPPER ${component} _COMPONENT)
if(CORRADE_TARGET_WINDOWS OR MAGNUM_BUILD_STATIC)
set(_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY ${MAGNUM_LIBRARIES}) # 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() endif()
# Additional components # Find all components
foreach(component ${Magnum_FIND_COMPONENTS}) foreach(component ${Magnum_FIND_COMPONENTS})
string(TOUPPER ${component} _COMPONENT) string(TOUPPER ${component} _COMPONENT)
@ -352,7 +357,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
endif() endif()
# Applications # Applications
if(${component} MATCHES .+Application) if(${component} MATCHES ".+Application")
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform)
# Android application dependencies # Android application dependencies
@ -411,13 +416,8 @@ foreach(component ${Magnum_FIND_COMPONENTS})
endif() endif()
endif() endif()
# Common application dependencies
set(_MAGNUM_${_COMPONENT}_LIBRARIES
${_MAGNUM_${_COMPONENT}_LIBRARIES}
${_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY})
# Context libraries # Context libraries
elseif(${component} MATCHES .+Context) elseif(${component} MATCHES ".+Context")
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Context.h) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Context.h)
@ -454,6 +454,8 @@ foreach(component ${Magnum_FIND_COMPONENTS})
unset(MAGNUM_${_COMPONENT}_LIBRARY) unset(MAGNUM_${_COMPONENT}_LIBRARY)
endif() endif()
# No special setup for DebugTools library
# Mesh tools library # Mesh tools library
elseif(${component} STREQUAL MeshTools) elseif(${component} STREQUAL MeshTools)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h)
@ -462,13 +464,17 @@ foreach(component ${Magnum_FIND_COMPONENTS})
elseif(${component} STREQUAL Primitives) elseif(${component} STREQUAL Primitives)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Cube.h) 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 # TextureTools library
elseif(${component} STREQUAL TextureTools) elseif(${component} STREQUAL TextureTools)
set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Atlas.h) set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Atlas.h)
endif() endif()
# The plugins don't have any dependencies, nothing additional to do for # No special setup for plugins
# them
# Try to find the includes # Try to find the includes
if(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES) if(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES)
@ -477,10 +483,30 @@ foreach(component ${Magnum_FIND_COMPONENTS})
PATHS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) PATHS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX})
endif() 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 # Decide if the library was found
if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR) if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR)
set(MAGNUM_${_COMPONENT}_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARY} ${_MAGNUM_${_COMPONENT}_LIBRARIES}) set(MAGNUM_${_COMPONENT}_LIBRARIES
set(MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${_MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) ${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) set(Magnum_${component}_FOUND TRUE)
@ -493,7 +519,7 @@ foreach(component ${Magnum_FIND_COMPONENTS})
# Global aliases for Windowless*Application and *Application # Global aliases for Windowless*Application and *Application
# components. If already set, unset them to avoid ambiguity. # 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) if(NOT DEFINED MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES AND NOT DEFINED MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS)
set(MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES}) set(MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES})
set(MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) 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_LIBRARIES)
unset(MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS) unset(MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS)
endif() endif()
elseif(${component} MATCHES .+Application) elseif(${component} MATCHES ".+Application")
if(NOT DEFINED MAGNUM_APPLICATION_LIBRARIES AND NOT DEFINED MAGNUM_APPLICATION_INCLUDE_DIRS) if(NOT DEFINED MAGNUM_APPLICATION_LIBRARIES AND NOT DEFINED MAGNUM_APPLICATION_INCLUDE_DIRS)
set(MAGNUM_APPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES}) set(MAGNUM_APPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES})
set(MAGNUM_APPLICATION_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) 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 # Global aliases for *Context components. If already set, unset them to
# avoid ambiguity. # avoid ambiguity.
if(${component} MATCHES .+Context) if(${component} MATCHES ".+Context")
if(NOT DEFINED MAGNUM_CONTEXT_LIBRARIES AND NOT DEFINED MAGNUM_CONTEXT_INCLUDE_DIRS) if(NOT DEFINED MAGNUM_CONTEXT_LIBRARIES AND NOT DEFINED MAGNUM_CONTEXT_INCLUDE_DIRS)
set(MAGNUM_CONTEXT_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES}) set(MAGNUM_CONTEXT_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES})
set(MAGNUM_CONTEXT_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) set(MAGNUM_CONTEXT_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS})
@ -533,9 +559,10 @@ find_package_handle_standard_args(Magnum
HANDLE_COMPONENTS) HANDLE_COMPONENTS)
# Installation dirs # Installation dirs
include(CorradeLibSuffix) include(${CORRADE_LIB_SUFFIX_MODULE})
set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin) set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) 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_DEBUG_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum-d)
set(MAGNUM_PLUGINS_RELEASE_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum) set(MAGNUM_PLUGINS_RELEASE_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum)
set(MAGNUM_PLUGINS_FONT_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}/fonts) 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_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_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}/audioimporters)
set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_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_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumPlugins) set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumPlugins)
mark_as_advanced(FORCE mark_as_advanced(FORCE
@ -574,15 +600,6 @@ mark_as_advanced(FORCE
MAGNUM_INCLUDE_INSTALL_DIR MAGNUM_INCLUDE_INSTALL_DIR
MAGNUM_PLUGINS_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 # Get base plugin directory from main library location
set(MAGNUM_PLUGINS_DEBUG_DIR ${_MAGNUM_LIBRARY_PATH}/magnum-d set(MAGNUM_PLUGINS_DEBUG_DIR ${_MAGNUM_LIBRARY_PATH}/magnum-d
CACHE PATH "Base directory where to look for Magnum plugins for debug builds") 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. # 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> # Vladimír Vondruš <mosra@centrum.cz>
# #
# Permission is hereby granted, free of charge, to any person obtaining a # Permission is hereby granted, free of charge, to any person obtaining a
@ -43,12 +43,9 @@ endif()
# Include dir # Include dir
find_path(OPENGLES2_INCLUDE_DIR find_path(OPENGLES2_INCLUDE_DIR
NAMES gl2.h NAMES GLES2/gl2.h)
PATH_SUFFIXES GLES2
)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("OpenGLES2" DEFAULT_MSG find_package_handle_standard_args("OpenGLES2" DEFAULT_MSG
${OPENGLES2_LIBRARY_NEEDED} ${OPENGLES2_LIBRARY_NEEDED}
OPENGLES2_INCLUDE_DIR OPENGLES2_INCLUDE_DIR)
)

9
modules/FindOpenGLES3.cmake

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

2
modules/FindSDL2.cmake

@ -10,7 +10,7 @@
# #
# This file is part of Magnum. # 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> # Vladimír Vondruš <mosra@centrum.cz>
# #
# Permission is hereby granted, free of charge, to any person obtaining a # 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 pkgname=magnum
pkgver=dev pkgver=dev
pkgrel=1 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') arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php" url="http://mosra.cz/blog/magnum.php"
license=('MIT') license=('MIT')
depends=('corrade' 'openal' 'freeglut' 'sdl2') depends=('corrade' 'openal' 'freeglut' 'sdl2')
makedepends=('cmake' 'ninja') makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs') options=('!strip')
provides=('magnum-git') provides=('magnum-git')
_rootdir=$startdir/../../
build() { build() {
mkdir -p "$startdir/build" mkdir -p "$_rootdir/build"
cd "$startdir/build" cd "$_rootdir/build"
# Disable optimization (saves A LOT of compilation time) # Disable optimization (saves A LOT of compilation time)
newcxxflags=$(echo $CXXFLAGS | sed s/-O.//g | sed s/-D_FORTIFY_SOURCE=.//g) newcxxflags=$(echo $CXXFLAGS | sed s/-O.//g | sed s/-D_FORTIFY_SOURCE=.//g)
@ -26,6 +28,7 @@ build() {
-DWITH_GLUTAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \ -DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \ -DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \ -DWITH_GLXCONTEXT=ON \
@ -45,11 +48,11 @@ build() {
} }
check() { check() {
cd "$startdir/build" cd "$_rootdir/build"
ctest --output-on-failure -j5 ctest --output-on-failure -j5
} }
package() { package() {
cd "$startdir/build" cd "$_rootdir/build"
DESTDIR="$pkgdir/" ninja install DESTDIR="$pkgdir/" ninja install
} }

22
package/archlinux/PKGBUILD-android-arm

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

22
package/archlinux/PKGBUILD-android-x86

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

18
package/archlinux/PKGBUILD-clang

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

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

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

22
package/archlinux/PKGBUILD-emscripten

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

14
package/archlinux/PKGBUILD-es2

@ -2,18 +2,20 @@
pkgname=magnum pkgname=magnum
pkgver=dev.es2 pkgver=dev.es2
pkgrel=1 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') arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php" url="http://mosra.cz/blog/magnum.php"
license=('MIT') license=('MIT')
depends=('corrade' 'openal') depends=('corrade' 'openal')
makedepends=('cmake' 'ninja') makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs') options=('!strip')
provides=('magnum-git') provides=('magnum-git')
_rootdir=$startdir/../../
build() { build() {
mkdir -p "$startdir/build-es2" mkdir -p "$_rootdir/build-es2"
cd "$startdir/build-es2" cd "$_rootdir/build-es2"
cmake .. \ cmake .. \
-DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_BUILD_TYPE=Debug \
@ -34,11 +36,11 @@ build() {
} }
check() { check() {
cd "$startdir/build-es2" cd "$_rootdir/build-es2"
ctest --output-on-failure -j5 ctest --output-on-failure -j5
} }
package() { package() {
cd "$startdir/build-es2" cd "$_rootdir/build-es2"
DESTDIR="$pkgdir/" ninja install DESTDIR="$pkgdir/" ninja install
} }

17
package/archlinux/PKGBUILD-es2desktop

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

14
package/archlinux/PKGBUILD-es3

@ -2,18 +2,20 @@
pkgname=magnum pkgname=magnum
pkgver=dev.es3 pkgver=dev.es3
pkgrel=1 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') arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php" url="http://mosra.cz/blog/magnum.php"
license=('MIT') license=('MIT')
depends=('corrade' 'openal') depends=('corrade' 'openal')
makedepends=('cmake' 'ninja') makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs') options=('!strip')
provides=('magnum-git') provides=('magnum-git')
_rootdir=$startdir/../../
build() { build() {
mkdir -p "$startdir/build-es3" mkdir -p "$_rootdir/build-es3"
cd "$startdir/build-es3" cd "$_rootdir/build-es3"
cmake .. \ cmake .. \
-DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_BUILD_TYPE=Debug \
@ -34,11 +36,11 @@ build() {
} }
check() { check() {
cd "$startdir/build-es3" cd "$_rootdir/build-es3"
ctest --output-on-failure -j5 ctest --output-on-failure -j5
} }
package() { package() {
cd "$startdir/build-es3" cd "$_rootdir/build-es3"
DESTDIR="$pkgdir/" ninja install DESTDIR="$pkgdir/" ninja install
} }

17
package/archlinux/PKGBUILD-es3desktop

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

19
package/archlinux/PKGBUILD-gcc47

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

18
package/archlinux/PKGBUILD-mingw-w64

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

26
package/archlinux/PKGBUILD-nacl-glibc

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

26
package/archlinux/PKGBUILD-nacl-newlib

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

24
package/archlinux/PKGBUILD-release

@ -2,18 +2,20 @@
pkgname=magnum pkgname=magnum
pkgver=dev.release pkgver=dev.release
pkgrel=1 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') arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php" url="http://mosra.cz/blog/magnum.php"
license=('MIT') license=('MIT')
depends=('corrade' 'openal' 'sdl2' 'freeglut') depends=('corrade' 'openal' 'sdl2' 'freeglut')
makedepends=('cmake' 'ninja') makedepends=('cmake' 'ninja')
options=('!strip' 'staticlibs') options=('!strip')
provides=('magnum-git') provides=('magnum-git')
_rootdir=$startdir/../../
build() { build() {
mkdir -p "$startdir/build" mkdir -p "$_rootdir/build"
cd "$startdir/build" cd "$_rootdir/build"
cmake .. \ cmake .. \
-DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_BUILD_TYPE=Debug \
@ -22,6 +24,7 @@ build() {
-DWITH_GLUTAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \ -DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \ -DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \ -DWITH_GLXCONTEXT=ON \
@ -39,8 +42,8 @@ build() {
-G Ninja -G Ninja
ninja ninja
mkdir -p "$startdir/build-release" mkdir -p "$_rootdir/build-release"
cd "$startdir/build-release" cd "$_rootdir/build-release"
cmake .. \ cmake .. \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
@ -49,6 +52,7 @@ build() {
-DWITH_GLUTAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \ -DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_MAGNUMFONT=ON \ -DWITH_MAGNUMFONT=ON \
-DWITH_MAGNUMFONTCONVERTER=ON \ -DWITH_MAGNUMFONTCONVERTER=ON \
@ -66,17 +70,17 @@ build() {
} }
check() { check() {
cd "$startdir/build" cd "$_rootdir/build"
ctest --output-on-failure -j5 ctest --output-on-failure -j5
cd "$startdir/build-release" cd "$_rootdir/build-release"
ctest --output-on-failure -j5 ctest --output-on-failure -j5
} }
package() { package() {
cd "$startdir/build" cd "$_rootdir/build"
DESTDIR="$pkgdir/" ninja install DESTDIR="$pkgdir/" ninja install
cd "$startdir/build-release" cd "$_rootdir/build-release"
DESTDIR="$pkgdir/" ninja install/strip 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> # Author: mosra <mosra@centrum.cz>
pkgname=magnum-git pkgname=magnum-git
pkgver=20140427 pkgver=snapshot.2014.06.r380.gd0a85ee
pkgrel=1 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') arch=('i686' 'x86_64')
url="http://mosra.cz/blog/magnum.php" url="http://mosra.cz/blog/magnum.php"
license=('MIT') license=('MIT')
@ -10,33 +10,19 @@ depends=('corrade-git' 'openal' 'sdl2')
makedepends=('cmake' 'git') makedepends=('cmake' 'git')
provides=('magnum') provides=('magnum')
conflicts=('magnum') conflicts=('magnum')
options=('staticlibs') source=("git+git://github.com/mosra/magnum.git")
sha1sums=('SKIP')
_gitroot="git://github.com/mosra/magnum.git"
_gitname="magnum"
pkgver() { pkgver() {
date +%Y%m%d cd "$srcdir/${pkgname%-git}"
git describe --long | sed -r 's/([^-]*-g)/r\1/;s/-/./g'
} }
build() { 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" mkdir -p "$srcdir/build"
cd "$srcdir/build" cd "$srcdir/build"
cmake ../$_gitname \ cmake "$srcdir/${pkgname%-git}" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_PREFIX=/usr \
-DWITH_AUDIO=ON \ -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 git submodule update
if [ ${libraries} = "static" ] ; then 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 fi
if [ "${compatibility}" = "deprecated" ] ; then if [ "${compatibility}" = "deprecated" ] ; then

4
package/ci/jenkins.xml

@ -88,7 +88,7 @@ else
fi fi
if [ ${libraries} = "static" ] ; then 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 fi
if [ "${compatibility}" = "deprecated" ] ; then if [ "${compatibility}" = "deprecated" ] ; then
@ -142,7 +142,7 @@ cmake .. \
-DWITH_GLUTAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \
-DWITH_XEGLAPPLICATION=${es_flag} \ -DWITH_XEGLAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \ -DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=ON \ -DWITH_GLXCONTEXT=ON \
-DWITH_MAGNUMFONT=ON \ -DWITH_MAGNUMFONT=ON \

8
package/debian/control vendored

@ -1,7 +1,7 @@
Source: magnum Source: magnum
Priority: optional Priority: optional
Maintainer: Vladimír Vondruš <mosra@centrum.cz> 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 Standards-Version: 3.9.2
Section: libs Section: libs
Homepage: http://mosra.cz/blog/magnum.php Homepage: http://mosra.cz/blog/magnum.php
@ -11,15 +11,15 @@ Vcs-Browser: https://github.com/mosra/magnum
Package: magnum-dev Package: magnum-dev
Section: libdevel Section: libdevel
Architecture: any 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 Description: Magnum development files
Headers and tools needed for developing with Magnum. Headers and tools needed for developing with Magnum.
Package: magnum Package: magnum
Section: libs Section: libs
Architecture: any Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, corrade, libgl1, freeglut3, libopenal1 Depends: ${shlibs:Depends}, ${misc:Depends}, corrade, libgl1, freeglut3, libopenal1, libsdl2
Description: C++11 and OpenGL 2D/3D graphics engine 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 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 is to simplify low-level graphics development and interaction with OpenGL
using recent C++11 features and to abstract away platform-specific issues. 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 Source: https://github.com/mosra/magnum
Files: * Files: *
Copyright: 2010-2014 Vladimír Vondruš <mosra@centrum.cz> Copyright: 2010-2015 Vladimír Vondruš <mosra@centrum.cz>
License: Expat License: Expat
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), 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_AUDIO=ON \
-DWITH_GLUTAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \
-DWITH_GLXAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \
-DWITH_SDL2APPLICATION=ON \
-DWITH_WINDOWLESSGLXAPPLICATION=ON \ -DWITH_WINDOWLESSGLXAPPLICATION=ON \
-DWITH_EGLCONTEXT=ON \ -DWITH_EGLCONTEXT=ON \
-DWITH_GLXCONTEXT=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 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" HOMEPAGE="http://mosra.cz/blog/magnum.php"
LICENSE="MIT" LICENSE="MIT"
@ -27,26 +27,25 @@ DEPEND="${RDEPEND}"
src_configure() { src_configure() {
local mycmakeargs=( local mycmakeargs=(
-DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
-DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_BUILD_TYPE=Release
-DWITH_AUDIO=ON \ -DWITH_AUDIO=ON
-DWITH_GLUTAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON
-DWITH_GLXAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON
-DWITH_SDL2APPLICATION=ON \ -DWITH_SDL2APPLICATION=ON
-DWITH_WINDOWLESSGLXAPPLICATION=ON \ -DWITH_WINDOWLESSGLXAPPLICATION=ON
-DWITH_EGLCONTEXT=ON \ -DWITH_EGLCONTEXT=ON
-DWITH_GLXCONTEXT=ON \ -DWITH_GLXCONTEXT=ON
-DWITH_MAGNUMFONT=ON \ -DWITH_MAGNUMFONT=ON
-DWITH_MAGNUMFONTCONVERTER=ON \ -DWITH_MAGNUMFONTCONVERTER=ON
-DWITH_OBJIMPORTER=ON \ -DWITH_OBJIMPORTER=ON
-DWITH_TGAIMAGECONVERTER=ON \ -DWITH_TGAIMAGECONVERTER=ON
-DWITH_TGAIMPORTER=ON \ -DWITH_TGAIMPORTER=ON
-DWITH_WAVAUDIOIMPORTER=ON \ -DWITH_WAVAUDIOIMPORTER=ON
-DWITH_DISTANCEFIELDCONVERTER=ON \ -DWITH_DISTANCEFIELDCONVERTER=ON
-DWITH_FONTCONVERTER=ON \ -DWITH_FONTCONVERTER=ON
-DWITH_MAGNUMINFO=ON \ -DWITH_MAGNUMINFO=ON
-DBUILD_TESTS=ON \
-DBUILD_GL_TESTS=ON
) )
cmake-utils_src_configure cmake-utils_src_configure
} }
# kate: replace-tabs off;

2
src/CMakeLists.txt

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

211
src/Magnum/AbstractFramebuffer.h

@ -3,7 +3,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -30,6 +30,7 @@
*/ */
#include <Corrade/Containers/EnumSet.h> #include <Corrade/Containers/EnumSet.h>
#include <Corrade/Utility/Macros.h>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/OpenGL.h" #include "Magnum/OpenGL.h"
@ -58,15 +59,19 @@ enum class FramebufferClear: GLbitfield {
@see @ref AbstractFramebuffer::clear() @see @ref AbstractFramebuffer::clear()
*/ */
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef Containers::EnumSet<FramebufferClear, GLbitfield, typedef Containers::EnumSet<FramebufferClear, GLbitfield,
GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT> FramebufferClearMask; 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 @brief Mask for framebuffer blitting
@see @ref AbstractFramebuffer, @ref FramebufferBlitMask @see @ref AbstractFramebuffer, @ref FramebufferBlitMask
@requires_gl30 %Extension @extension{ARB,framebuffer_object} @requires_gl30 Extension @extension{ARB,framebuffer_object}
@requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or @requires_gles30 Extension @es_extension{ANGLE,framebuffer_blit} or
@es_extension{NV,framebuffer_blit} in OpenGL ES 2.0 @es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
*/ */
enum class FramebufferBlit: GLbitfield { enum class FramebufferBlit: GLbitfield {
@ -96,19 +101,23 @@ enum class FramebufferBlit: GLbitfield {
@brief Mask for framebuffer blitting @brief Mask for framebuffer blitting
@see @ref AbstractFramebuffer::blit() @see @ref AbstractFramebuffer::blit()
@requires_gl30 %Extension @extension{ARB,framebuffer_object} @requires_gl30 Extension @extension{ARB,framebuffer_object}
@requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or @requires_gles30 Extension @es_extension{ANGLE,framebuffer_blit} or
@es_extension{NV,framebuffer_blit} in OpenGL ES 2.0 @es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
*/ */
#ifndef DOXYGEN_GENERATING_OUTPUT
typedef Containers::EnumSet<FramebufferBlit, GLbitfield, typedef Containers::EnumSet<FramebufferBlit, GLbitfield,
GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT> FramebufferBlitMask; 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() @see @ref AbstractFramebuffer::blit()
@requires_gl30 %Extension @extension{ARB,framebuffer_object} @requires_gl30 Extension @extension{ARB,framebuffer_object}
@requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or @requires_gles30 Extension @es_extension{ANGLE,framebuffer_blit} or
@es_extension{NV,framebuffer_blit} in OpenGL ES 2.0 @es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
*/ */
enum class FramebufferBlitFilter: GLenum { 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() @see @ref DefaultFramebuffer::checkStatus(), @ref Framebuffer::checkStatus()
@requires_gl30 %Extension @extension{ARB,framebuffer_object} @requires_gl30 Extension @extension{ARB,framebuffer_object}
*/ */
enum class FramebufferTarget: GLenum { enum class FramebufferTarget: GLenum {
/** /** Frambebuffer reading target */
* 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
*/
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Read = GL_READ_FRAMEBUFFER, Read = GL_READ_FRAMEBUFFER,
#else #else
Read = GL_READ_FRAMEBUFFER_APPLE, Read = GL_READ_FRAMEBUFFER_APPLE,
#endif #endif
/** /** Framebuffer drawing target */
* 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
*/
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Draw = GL_DRAW_FRAMEBUFFER, Draw = GL_DRAW_FRAMEBUFFER,
#else #else
Draw = GL_DRAW_FRAMEBUFFER_APPLE, Draw = GL_DRAW_FRAMEBUFFER_APPLE,
#endif #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; } 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 The engine tracks currently bound framebuffer and current viewport to avoid
unnecessary calls to @fn_gl{BindFramebuffer} and @fn_gl{Viewport} when 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 (such as @ref maxViewportSize()) are cached, so repeated queries don't result
in repeated @fn_gl{Get} calls. 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 If @extension{ARB,robustness} is available, @ref read() operations are
protected from buffer overflow. protected from buffer overflow.
*/ */
class MAGNUM_EXPORT AbstractFramebuffer { class MAGNUM_EXPORT AbstractFramebuffer {
friend struct Implementation::FramebufferState; friend Implementation::FramebufferState;
public: 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}). */ /** @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 mask Which buffers to perform blit operation on
* @param filter Interpolation filter * @param filter Interpolation filter
* *
* Binds @p source framebuffer to @ref FramebufferTarget::Read and * See @ref DefaultFramebuffer::mapForRead(), @ref Framebuffer::mapForRead(),
* @p destination framebuffer to @ref FramebufferTarget::Draw and * @ref DefaultFramebuffer::mapForDraw() and @ref Framebuffer::mapForDraw()
* performs blitting operation. See @ref DefaultFramebuffer::mapForRead(), * for specifying particular buffers for blitting operation. If
* @ref Framebuffer::mapForRead(), @ref DefaultFramebuffer::mapForDraw() * @extension{ARB,direct_state_access} (part of OpenGL 4.5) is not
* and @ref Framebuffer::mapForDraw() for specifying particular buffers * available, @p source framebuffer is bound to @ref FramebufferTarget::Read
* for blitting operation. * and @p destination framebuffer to @ref FramebufferTarget::Draw
* @see @fn_gl{BlitFramebuffer} * before the operation (if not already).
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or * @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 * @es_extension{NV,framebuffer_blit} in OpenGL ES 2.0
* @todo NaCl exports `BlitFramebufferEXT` (although no such extension * @todo NaCl exports `BlitFramebufferEXT` (although no such extension
* exists for ES) * exists for ES)
@ -235,35 +251,37 @@ class MAGNUM_EXPORT AbstractFramebuffer {
/** /**
* @brief Copy block of pixels * @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 * Convenience alternative to the above function when source rectangle
* the same as destination rectangle. As the image is copied * is the same as destination rectangle. As the image is copied
* pixel-by-pixel, no interpolation is needed and thus * pixel-by-pixel, no interpolation is needed and thus
* @ref FramebufferBlitFilter::Nearest filtering is used by default. * @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) { static void blit(AbstractFramebuffer& source, AbstractFramebuffer& destination, const Range2Di& rectangle, FramebufferBlitMask mask) {
blit(source, destination, rectangle, rectangle, mask, FramebufferBlitFilter::Nearest); 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(), * @see @ref setViewport(), @ref DefaultFramebuffer::mapForRead(),
* @ref Framebuffer::mapForRead(), @ref DefaultFramebuffer::mapForDraw(), * @ref Framebuffer::mapForRead(), @ref DefaultFramebuffer::mapForDraw(),
* @ref Framebuffer::mapForDraw(), @fn_gl{BindFramebuffer}, * @ref Framebuffer::mapForDraw(), @fn_gl{BindFramebuffer},
* @fn_gl{Viewport} * @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 */ /** @brief Viewport rectangle */
Range2Di viewport() const { return _viewport; } 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 * Saves the viewport to be used at later time in @ref bind(). If the
* framebuffer is currently bound, updates the viewport to given * 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} * @see @ref maxViewportSize(), @fn_gl{Viewport}
*/ */
AbstractFramebuffer& setViewport(const Range2Di& rectangle); AbstractFramebuffer& setViewport(const Range2Di& rectangle);
@ -282,6 +302,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
/** /**
* @brief Clear specified buffers in framebuffer * @brief Clear specified buffers in framebuffer
* @param mask Which buffers to clear * @param mask Which buffers to clear
* @return Reference to self (for method chaining)
* *
* To improve performance you can also use * To improve performance you can also use
* @ref DefaultFramebuffer::invalidate() / @ref Framebuffer::invalidate() * @ref DefaultFramebuffer::invalidate() / @ref Framebuffer::invalidate()
@ -291,15 +312,14 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @ref Renderer::setClearStencil(), @fn_gl{BindFramebuffer}, * @ref Renderer::setClearStencil(), @fn_gl{BindFramebuffer},
* @fn_gl{Clear} * @fn_gl{Clear}
*/ */
void clear(FramebufferClearMask mask); AbstractFramebuffer& clear(FramebufferClearMask mask);
/** /**
* @brief Read block of pixels from framebuffer to image * @brief Read block of pixels from framebuffer to image
* @param offset Offset in the framebuffer * @param rectangle Framebuffer rectangle to read
* @param size %Image size * @param image Image where to put the data
* @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. * given image.
* *
* If @extension{ARB,robustness} is available, the operation is * 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 * @see @fn_gl{BindFramebuffer}, @fn_gl{ReadPixels} or
* @fn_gl_extension{ReadnPixels,ARB,robustness} * @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 #ifndef MAGNUM_TARGET_GLES2
/** /**
* @brief Read block of pixels from framebuffer to buffer image * @brief Read block of pixels from framebuffer to buffer image
* @param offset Offset in the framebuffer * @param rectangle Framebuffer rectangle to read
* @param size %Image size * @param image Buffer image where to put the data
* @param image %Buffer image where to put the data * @param usage Buffer usage
* @param usage %Buffer usage
* *
* See @ref read(const Vector2i&, const Vector2i&, Image2D&) for more * See @ref read(const Vector2i&, const Vector2i&, Image2D&) for more
* information. * information.
@ -323,7 +361,27 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @todo Make it more flexible (usable with * @todo Make it more flexible (usable with
* @extension{ARB,buffer_storage}, avoiding relocations...) * @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 #endif
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
@ -345,40 +403,65 @@ class MAGNUM_EXPORT AbstractFramebuffer {
Range2Di _viewport; Range2Di _viewport;
private: 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 #ifdef MAGNUM_TARGET_GLES2
static void MAGNUM_LOCAL blitImplementationANGLE(const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter); void MAGNUM_LOCAL bindImplementationSingle(FramebufferTarget);
static void MAGNUM_LOCAL blitImplementationNV(const Range2Di& sourceRectangle, const Range2Di& destinationRectangle, FramebufferBlitMask mask, FramebufferBlitFilter filter); FramebufferTarget MAGNUM_LOCAL bindImplementationSingle();
#endif #endif
GLenum MAGNUM_LOCAL checkStatusImplementationDefault(FramebufferTarget target); GLenum MAGNUM_LOCAL checkStatusImplementationDefault(FramebufferTarget target);
#ifdef MAGNUM_TARGET_GLES2
GLenum MAGNUM_LOCAL checkStatusImplementationSingle(FramebufferTarget);
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
GLenum MAGNUM_LOCAL checkStatusImplementationDSA(FramebufferTarget target);
GLenum MAGNUM_LOCAL checkStatusImplementationDSAEXT(FramebufferTarget target); GLenum MAGNUM_LOCAL checkStatusImplementationDSAEXT(FramebufferTarget target);
#endif #endif
void MAGNUM_LOCAL drawBuffersImplementationDefault(GLsizei count, const GLenum* buffers); void MAGNUM_LOCAL drawBuffersImplementationDefault(GLsizei count, const GLenum* buffers);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL drawBuffersImplementationDSA(GLsizei count, const GLenum* buffers);
void MAGNUM_LOCAL drawBuffersImplementationDSAEXT(GLsizei count, const GLenum* buffers); void MAGNUM_LOCAL drawBuffersImplementationDSAEXT(GLsizei count, const GLenum* buffers);
#endif #endif
void MAGNUM_LOCAL drawBufferImplementationDefault(GLenum buffer); void MAGNUM_LOCAL drawBufferImplementationDefault(GLenum buffer);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL drawBufferImplementationDSA(GLenum buffer);
void MAGNUM_LOCAL drawBufferImplementationDSAEXT(GLenum buffer); void MAGNUM_LOCAL drawBufferImplementationDSAEXT(GLenum buffer);
#endif #endif
void MAGNUM_LOCAL readBufferImplementationDefault(GLenum buffer); void MAGNUM_LOCAL readBufferImplementationDefault(GLenum buffer);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL readBufferImplementationDSA(GLenum buffer);
void MAGNUM_LOCAL readBufferImplementationDSAEXT(GLenum buffer); void MAGNUM_LOCAL readBufferImplementationDSAEXT(GLenum buffer);
#endif #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 readImplementationDefault(const Range2Di& rectangle, 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 readImplementationRobustness(const Range2Di& rectangle, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data);
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*); void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*);
void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments); 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 #ifndef MAGNUM_TARGET_GLES2
void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&); void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&);
void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments, const Range2Di& rectangle); 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 #endif
}; };

2
src/Magnum/AbstractImage.cpp

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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 @brief Base for all OpenGL objects
*/ */
class MAGNUM_EXPORT AbstractObject { class MAGNUM_EXPORT AbstractObject {
friend struct Implementation::DebugState; friend Implementation::DebugState;
public: public:
/** /**

2
src/Magnum/AbstractQuery.cpp

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

6
src/Magnum/AbstractResourceLoader.h

@ -3,7 +3,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a 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? buffers), should that be allowed?
*/ */
template<class T> class AbstractResourceLoader { template<class T> class AbstractResourceLoader {
friend class Implementation::ResourceManagerData<T>; friend Implementation::ResourceManagerData<T>;
public: public:
explicit AbstractResourceLoader(): manager(nullptr), _requestedCount(0), _loadedCount(0), _notFoundCount(0) {} 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; } 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, * If no such resource exists or the resource name is not available,
* returns empty string. * returns empty string.

317
src/Magnum/AbstractShaderProgram.cpp

@ -1,7 +1,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -247,7 +247,8 @@ AbstractShaderProgram::~AbstractShaderProgram() {
} }
AbstractShaderProgram& AbstractShaderProgram::operator=(AbstractShaderProgram&& other) noexcept { AbstractShaderProgram& AbstractShaderProgram::operator=(AbstractShaderProgram&& other) noexcept {
std::swap(_id, other._id); using std::swap;
swap(_id, other._id);
return *this; return *this;
} }
@ -313,6 +314,17 @@ void AbstractShaderProgram::bindFragmentDataLocationIndexedInternal(const Unsign
} }
#endif #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 AbstractShaderProgram::link(std::initializer_list<std::reference_wrapper<AbstractShaderProgram>> shaders) {
bool allSuccess = true; bool allSuccess = true;
@ -1083,305 +1095,4 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co
} }
#endif #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. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -35,6 +35,7 @@
#include "Magnum/Extensions.h" #include "Magnum/Extensions.h"
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/TextureFormat.h" #include "Magnum/TextureFormat.h"
#include "Magnum/Math/Range.h"
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#include "Magnum/Shader.h" #include "Magnum/Shader.h"
@ -116,25 +117,25 @@ Int AbstractTexture::maxIntegerSamples() {
#endif #endif
void AbstractTexture::unbind(const Int textureUnit) { 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 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 */ /* Unbind the texture, reset state tracker */
Context::current()->state().texture->unbindImplementation(textureUnit); Context::current()->state().texture->unbindImplementation(textureUnit);
textureState->bindings[textureUnit] = {}; textureState.bindings[textureUnit] = {};
} }
void AbstractTexture::unbindImplementationDefault(const GLint 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 */ /* Activate given texture unit if not already active, update state tracker */
if(textureState->currentTextureUnit != textureUnit) if(textureState.currentTextureUnit != textureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = textureUnit)); glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = textureUnit));
CORRADE_INTERNAL_ASSERT(textureState->bindings[textureUnit].first != 0); CORRADE_INTERNAL_ASSERT(textureState.bindings[textureUnit].first != 0);
glBindTexture(textureState->bindings[textureUnit].first, 0); glBindTexture(textureState.bindings[textureUnit].first, 0);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -143,11 +144,18 @@ void AbstractTexture::unbindImplementationMulti(const GLint textureUnit) {
glBindTextures(textureUnit, 1, &zero); 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) { 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); CORRADE_INTERNAL_ASSERT(textureState.bindings[textureUnit].first != 0);
glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, textureState->bindings[textureUnit].first, 0); glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, textureState.bindings[textureUnit].first, 0);
} }
#endif #endif
@ -168,8 +176,9 @@ void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, c
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, const Containers::ArrayReference<AbstractTexture* const> textures) { /** @todoc const Containers::ArrayReference makes Doxygen grumpy */
Implementation::TextureState* const textureState = Context::current()->state().texture; 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 */ /* Create array of IDs and also update bindings in state tracker */
Containers::Array<GLuint> ids{textures ? textures.size() : 0}; Containers::Array<GLuint> ids{textures ? textures.size() : 0};
@ -182,9 +191,9 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, cons
ids[i] = id; ids[i] = id;
} }
if(textureState->bindings[firstTextureUnit + i].second != id) { if(textureState.bindings[firstTextureUnit + i].second != id) {
different = true; 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) { 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 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 */ /* Update state tracker, bind the texture to the unit */
textureState->bindings[textureUnit] = {_target, _id}; textureState.bindings[textureUnit] = {_target, _id};
(this->*Context::current()->state().texture->bindImplementation)(textureUnit); (this->*textureState.bindImplementation)(textureUnit);
} }
void AbstractTexture::bindImplementationDefault(GLint 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 */ /* Activate given texture unit if not already active, update state tracker */
if(textureState->currentTextureUnit != textureUnit) if(textureState.currentTextureUnit != textureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = textureUnit)); glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = textureUnit));
/* Binding the texture finally creates it */ /* Binding the texture finally creates it */
_created = true; _created = true;
@ -274,6 +283,10 @@ void AbstractTexture::bindImplementationMulti(GLint textureUnit) {
glBindTextures(textureUnit, 1, &_id); glBindTextures(textureUnit, 1, &_id);
} }
void AbstractTexture::bindImplementationDSA(const GLint textureUnit) {
glBindTextureUnit(textureUnit, _id);
}
void AbstractTexture::bindImplementationDSAEXT(GLint textureUnit) { void AbstractTexture::bindImplementationDSAEXT(GLint textureUnit) {
_created = true; _created = true;
glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, _target, _id); glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, _target, _id);
@ -401,6 +414,10 @@ void AbstractTexture::mipmapImplementationDefault() {
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::mipmapImplementationDSA() {
glGenerateTextureMipmap(_id);
}
void AbstractTexture::mipmapImplementationDSAEXT() { void AbstractTexture::mipmapImplementationDSAEXT() {
_created = true; _created = true;
glGenerateTextureMipmapEXT(_id, _target); glGenerateTextureMipmapEXT(_id, _target);
@ -412,21 +429,21 @@ void AbstractTexture::bindInternal() {
functions need to have the texture bound in *currently active* unit, functions need to have the texture bound in *currently active* unit,
so we would need to call glActiveTexture() afterwards anyway. */ 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 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; return;
/* Set internal unit as active if not already, update state tracker */ /* Set internal unit as active if not already, update state tracker */
CORRADE_INTERNAL_ASSERT(textureState->maxTextureUnits > 1); CORRADE_INTERNAL_ASSERT(textureState.maxTextureUnits > 1);
const GLint internalTextureUnit = textureState->maxTextureUnits-1; const GLint internalTextureUnit = textureState.maxTextureUnits-1;
if(textureState->currentTextureUnit != internalTextureUnit) if(textureState.currentTextureUnit != internalTextureUnit)
glActiveTexture(GL_TEXTURE0 + (textureState->currentTextureUnit = internalTextureUnit)); glActiveTexture(GL_TEXTURE0 + (textureState.currentTextureUnit = internalTextureUnit));
/* Bind the texture to internal unit if not already, update state tracker */ /* Bind the texture to internal unit if not already, update state tracker */
if(textureState->bindings[internalTextureUnit].second == _id) return; if(textureState.bindings[internalTextureUnit].second == _id) return;
textureState->bindings[internalTextureUnit] = {_target, _id}; textureState.bindings[internalTextureUnit] = {_target, _id};
/* Binding the texture finally creates it */ /* Binding the texture finally creates it */
_created = true; _created = true;
@ -810,6 +827,10 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLint val
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLint value) {
glTextureParameteri(_id, parameter, value);
}
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLint value) { void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLint value) {
_created = true; _created = true;
glTextureParameteriEXT(_id, _target, parameter, value); glTextureParameteriEXT(_id, _target, parameter, value);
@ -822,6 +843,10 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, GLfloat v
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::parameterImplementationDSA(const GLenum parameter, const GLfloat value) {
glTextureParameterf(_id, parameter, value);
}
void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLfloat value) { void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, GLfloat value) {
_created = true; _created = true;
glTextureParameterfEXT(_id, _target, parameter, value); glTextureParameterfEXT(_id, _target, parameter, value);
@ -835,6 +860,10 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLi
} }
#ifndef MAGNUM_TARGET_GLES #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) { void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, const GLint* values) {
_created = true; _created = true;
glTextureParameterivEXT(_id, _target, parameter, values); glTextureParameterivEXT(_id, _target, parameter, values);
@ -848,6 +877,10 @@ void AbstractTexture::parameterImplementationDefault(GLenum parameter, const GLf
} }
#ifndef MAGNUM_TARGET_GLES #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) { void AbstractTexture::parameterImplementationDSAEXT(GLenum parameter, const GLfloat* values) {
_created = true; _created = true;
glTextureParameterfvEXT(_id, _target, parameter, values); glTextureParameterfvEXT(_id, _target, parameter, values);
@ -860,6 +893,10 @@ void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GL
glTexParameterIuiv(_target, parameter, values); 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) { void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLuint* values) {
_created = true; _created = true;
glTextureParameterIuivEXT(_id, _target, parameter, values); glTextureParameterIuivEXT(_id, _target, parameter, values);
@ -870,6 +907,10 @@ void AbstractTexture::parameterIImplementationDefault(GLenum parameter, const GL
glTexParameterIiv(_target, parameter, values); 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) { void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLint* values) {
_created = true; _created = true;
glTextureParameterIivEXT(_id, _target, parameter, values); glTextureParameterIivEXT(_id, _target, parameter, values);
@ -883,59 +924,65 @@ void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) {
} }
#ifndef MAGNUM_TARGET_GLES2 #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(); bindInternal();
glGetTexLevelParameteriv(target, level, parameter, values); glGetTexLevelParameteriv(_target, level, parameter, values);
} }
#ifndef MAGNUM_TARGET_GLES #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; _created = true;
glGetTextureLevelParameterivEXT(_id, target, level, parameter, values); glGetTextureLevelParameterivEXT(_id, _target, level, parameter, values);
} }
#endif #endif
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { void AbstractTexture::storageImplementationFallback(const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
CORRADE_INTERNAL_ASSERT(target == GL_TEXTURE_1D);
const ColorFormat format = imageFormatForInternalFormat(internalFormat); const ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat); const ColorType type = imageTypeForInternalFormat(internalFormat);
for(GLsizei level = 0; level != levels; ++level) { 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); 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(); 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; _created = true;
glTextureStorage1DEXT(_id, target, levels, GLenum(internalFormat), size[0]); glTextureStorage1DEXT(_id, _target, levels, GLenum(internalFormat), size[0]);
} }
#endif #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 ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat); const ColorType type = imageTypeForInternalFormat(internalFormat);
/* Common code for classic types */ /* Common code for classic types */
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE) if(_target == GL_TEXTURE_2D || _target == GL_TEXTURE_RECTANGLE)
#else #else
if(target == GL_TEXTURE_2D) if(_target == GL_TEXTURE_2D)
#endif #endif
{ {
for(GLsizei level = 0; level != levels; ++level) { 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); DataHelper<2>::setImage(*this, level, internalFormat,
} ImageReference2D{format, type, Math::max(Vector2i(1), size >> level)});
/* Cube map additionally needs to specify all faces */ /* 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) { for(GLsizei level = 0; level != levels; ++level) {
const std::initializer_list<GLenum> faces = { const std::initializer_list<GLenum> faces = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_X,
@ -946,29 +993,29 @@ void AbstractTexture::storageImplementationFallback(const GLenum target, const G
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
}; };
for(auto it = faces.begin(); it != faces.end(); ++it) 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 #ifndef MAGNUM_TARGET_GLES
/* Array texture is not scaled in "layer" dimension */ /* Array texture is not scaled in "layer" dimension */
} else if(target == GL_TEXTURE_1D_ARRAY) { } else if(_target == GL_TEXTURE_1D_ARRAY) {
for(GLsizei level = 0; level != levels; ++level) { 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); DataHelper<2>::setImage(*this, level, internalFormat,
} ImageReference2D{format, type, Vector2i{Math::max(1, size.x() >> level), size.y()}});
#endif #endif
/* No other targets are available */ /* No other targets are available */
} else CORRADE_ASSERT_UNREACHABLE(); } 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(); bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glTexStorage2D(target, levels, GLenum(internalFormat), size.x(), size.y()); glTexStorage2D(_target, levels, GLenum(internalFormat), size.x(), size.y());
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #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 #else
static_cast<void>(target);
static_cast<void>(levels); static_cast<void>(levels);
static_cast<void>(internalFormat); static_cast<void>(internalFormat);
static_cast<void>(size); static_cast<void>(size);
@ -977,53 +1024,53 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels
} }
#ifndef MAGNUM_TARGET_GLES #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; _created = true;
glTextureStorage2DEXT(_id, target, levels, GLenum(internalFormat), size.x(), size.y()); glTextureStorage2DEXT(_id, _target, levels, GLenum(internalFormat), size.x(), size.y());
} }
#endif #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 ColorFormat format = imageFormatForInternalFormat(internalFormat);
const ColorType type = imageTypeForInternalFormat(internalFormat); const ColorType type = imageTypeForInternalFormat(internalFormat);
/* Common code for classic type */ /* Common code for classic type */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
if(target == GL_TEXTURE_3D) if(_target == GL_TEXTURE_3D)
#else #else
if(target == GL_TEXTURE_3D_OES) if(_target == GL_TEXTURE_3D_OES)
#endif #endif
{ for(GLsizei level = 0; level != levels; ++level)
for(GLsizei level = 0; level != levels; ++level) { DataHelper<3>::setImage(*this, level, internalFormat,
(this->*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, Math::max(Vector3i(1), size >> level), format, type, nullptr); ImageReference3D{format, type, Math::max(Vector3i(1), size >> level)});
}
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/* Array texture is not scaled in "layer" dimension */ /* Array texture is not scaled in "layer" dimension */
}
#ifndef MAGNUM_TARGET_GLES #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
else if(target == GL_TEXTURE_2D_ARRAY) else if(_target == GL_TEXTURE_2D_ARRAY)
#endif #endif
{ for(GLsizei level = 0; level != levels; ++level)
for(GLsizei level = 0; level != levels; ++level) { DataHelper<3>::setImage(*this, level, internalFormat,
(this->*Context::current()->state().texture->image3DImplementation)(target, level, internalFormat, Math::max(Vector3i(1), size >> level), format, type, nullptr); ImageReference3D{format, type, Vector3i{Math::max(Vector2i{1}, size.xy() >> level), size.z()}});
}
#endif #endif
/* No other targets are available */ /* 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(); bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glTexStorage3D(target, levels, GLenum(internalFormat), size.x(), size.y(), size.z()); glTexStorage3D(_target, levels, GLenum(internalFormat), size.x(), size.y(), size.z());
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #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 #else
static_cast<void>(target);
static_cast<void>(levels); static_cast<void>(levels);
static_cast<void>(internalFormat); static_cast<void>(internalFormat);
static_cast<void>(size); static_cast<void>(size);
@ -1032,146 +1079,120 @@ void AbstractTexture::storageImplementationDefault(GLenum target, GLsizei levels
} }
#ifndef MAGNUM_TARGET_GLES #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; _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 #endif
#ifndef MAGNUM_TARGET_GLES #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(); bindInternal();
glTexImage2DMultisample(target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); glTexImage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #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(); bindInternal();
glTexStorage2DMultisample(target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations); glTexStorage2DMultisample(_target, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLenum target, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
_created = true; glTextureStorage2DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), fixedSampleLocations);
glTextureStorage2DMultisampleEXT(_id, target, 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) { void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) {
bindInternal(); _created = true;
glTexImage3DMultisample(target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations); 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(); 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) { void AbstractTexture::storageMultisampleImplementationDefault(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) {
bindInternal(); 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) { void AbstractTexture::storageMultisampleImplementationDSA(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
_created = true; glTextureStorage3DMultisample(_id, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
glGetTextureImageEXT(_id, target, level, GLenum(format), GLenum(type), data);
} }
void AbstractTexture::getImageImplementationRobustness(const GLenum target, const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) { void AbstractTexture::storageMultisampleImplementationDSAEXT(const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) {
bindInternal(); _created = true;
glGetnTexImageARB(target, level, GLenum(format), GLenum(type), dataSize, data); glTextureStorage3DMultisampleEXT(_id, _target, samples, GLenum(internalFormat), size.x(), size.y(), size.z(), fixedSampleLocations);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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(); 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) { void AbstractTexture::getImageImplementationDSA(const GLint level, const ColorFormat format, const ColorType type, const std::size_t dataSize, GLvoid* const data) {
_created = true; glGetTextureImage(_id, level, GLenum(format), GLenum(type), dataSize, data);
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);
} }
#ifndef MAGNUM_TARGET_GLES void AbstractTexture::getImageImplementationDSAEXT(const GLint level, const ColorFormat format, const ColorType type, const std::size_t, GLvoid* const data) {
void AbstractTexture::imageImplementationDSAEXT(GLenum target, GLint level, TextureFormat internalFormat, const Vector2i& size, ColorFormat format, ColorType type, const GLvoid* data) {
_created = true; _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(); bindInternal();
#ifndef MAGNUM_TARGET_GLES2 glGetnTexImageARB(_target, level, GLenum(format), GLenum(type), dataSize, data);
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);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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(); 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; _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 #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(); 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 #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; _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 #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(); bindInternal();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
glTexSubImage3D(target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data); glTexSubImage3D(_target, level, offset.x(), offset.y(), offset.z(), size.x(), size.y(), size.z(), GLenum(format), GLenum(type), data);
#elif !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_NACL) #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 #else
static_cast<void>(target);
static_cast<void>(level); static_cast<void>(level);
static_cast<void>(offset); static_cast<void>(offset);
static_cast<void>(size); static_cast<void>(size);
@ -1183,9 +1204,13 @@ void AbstractTexture::subImageImplementationDefault(GLenum target, GLint level,
} }
#ifndef MAGNUM_TARGET_GLES #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; _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 #endif
@ -1209,109 +1234,148 @@ void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vec
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions> void AbstractTexture::image(GLenum target, GLint level, Image<dimensions>& image) { template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, Image<dimensions>& image) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, target, level); const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
const std::size_t dataSize = image.dataSize(size); const std::size_t dataSize = image.dataSize(size);
char* data = new char[dataSize]; 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); 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<1>(GLint, Image<1>&);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, Image<2>&); template void MAGNUM_EXPORT AbstractTexture::image<2>(GLint, Image<2>&);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, Image<3>&); 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) { template<UnsignedInt dimensions> void AbstractTexture::image(GLint level, BufferImage<dimensions>& image, BufferUsage usage) {
const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, target, level); const Math::Vector<dimensions, Int> size = DataHelper<dimensions>::imageSize(*this, level);
const std::size_t dataSize = image.dataSize(size); const std::size_t dataSize = image.dataSize(size);
if(image.size() != size) if(image.size() != size)
image.setData(image.format(), image.type(), size, nullptr, usage); image.setData(image.format(), image.type(), size, nullptr, usage);
image.buffer().bindInternal(Buffer::TargetHint::PixelPack); 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<1>(GLint, BufferImage<1>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<2>(GLenum, GLint, BufferImage<2>&, BufferUsage); template void MAGNUM_EXPORT AbstractTexture::image<2>(GLint, BufferImage<2>&, BufferUsage);
template void MAGNUM_EXPORT AbstractTexture::image<3>(GLenum, GLint, BufferImage<3>&, 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
#endif #endif
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_TARGET_GLES #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; 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; return value;
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #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; const Implementation::TextureState& state = *Context::current()->state().texture;
Vector2i value; Vector2i value;
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
return value; 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; const Implementation::TextureState& state = *Context::current()->state().texture;
Vector3i value; Vector3i value;
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]);
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]);
(texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_DEPTH, &value[2]); (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_DEPTH, &value[2]);
return value; return value;
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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) { 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)(target, levels, internalFormat, size); (texture.*Context::current()->state().texture->storage1DImplementation)(levels, internalFormat, size);
} }
#endif #endif
void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) {
(texture.*Context::current()->state().texture->storage2DImplementation)(target, levels, internalFormat, 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) { void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) {
(texture.*Context::current()->state().texture->storage3DImplementation)(target, levels, internalFormat, size); (texture.*Context::current()->state().texture->storage3DImplementation)(levels, internalFormat, size);
} }
#ifndef MAGNUM_TARGET_GLES2 #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) { 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)(target, samples, internalFormat, size, fixedSampleLocations); (texture.*Context::current()->state().texture->storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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) { 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)(target, samples, internalFormat, size, fixedSampleLocations); (texture.*Context::current()->state().texture->storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations);
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #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); 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); 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); 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); 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 #endif
@ -1319,55 +1383,68 @@ void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GL
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #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 #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) { void AbstractTexture::DataHelper<2>::setImage(AbstractTexture& texture, const GLenum target, const GLint level, const TextureFormat internalFormat, BufferImage2D& image) {
image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); 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 #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 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #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 #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); 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 #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 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #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 #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); 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 #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 #ifndef MAGNUM_TARGET_GLES2
Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack);
#endif #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 #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); 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 #endif

238
src/Magnum/AbstractTexture.h

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

8
src/Magnum/Array.h

@ -3,7 +3,7 @@
/* /*
This file is part of Magnum. 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> Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a Permission is hereby granted, free of charge, to any person obtaining a
@ -41,7 +41,7 @@
namespace Magnum { namespace Magnum {
/** /**
@brief %Array @brief Array
@tparam dimensions Dimension count @tparam dimensions Dimension count
@tparam T Data type @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) {} 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) {} constexpr /*implicit*/ Array2D(T value): Array<2, T>(value, value) {}
/** @brief Copy constructor */ /** @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) {} 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) {} constexpr /*implicit*/ Array3D(T value): Array<3, T>(value, value, value) {}
/** @brief Copy constructor */ /** @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