diff --git a/CMakeLists.txt b/CMakeLists.txt index 09f32734f..76873776f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -23,18 +23,28 @@ # DEALINGS IN THE SOFTWARE. # -cmake_minimum_required(VERSION 2.8.9) +cmake_minimum_required(VERSION 2.8.12) project(Magnum) -# Find Corrade first so we can check on the target +# CMake policies: enable MACOSX_RPATH by default +if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif() +# Don't treat imported targets with :: as files +if(POLICY CMP0028) + cmake_policy(SET CMP0028 NEW) +endif() + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/modules/") -find_package(Corrade REQUIRED) + +# Find Corrade first so we can check on the target +find_package(Corrade REQUIRED PluginManager Utility) include(CMakeDependentOption) -# If targeting Android, NaCl, Emscripten or Windows RT, set explicit OpenGL ES -# support -if(NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_WINDOWS_RT) +# If targeting iOS, Android, NaCl, Emscripten or Windows RT, set explicit +# OpenGL ES support +if(NOT CORRADE_TARGET_IOS AND NOT CORRADE_TARGET_ANDROID AND NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_WINDOWS_RT) option(TARGET_GLES "Build for OpenGL ES / WebGL" OFF) else() set(TARGET_GLES ON) @@ -42,21 +52,43 @@ endif() cmake_dependent_option(TARGET_GLES2 "Build for OpenGL ES 2 / WebGL 1.0" ON "TARGET_GLES" OFF) cmake_dependent_option(TARGET_DESKTOP_GLES "Build for OpenGL ES on desktop" OFF "TARGET_GLES" OFF) +option(TARGET_HEADLESS "Build command-line utilities for use on a headless machines" OFF) + +# Magnum Info (currently only using GLX, CGL, WGL/EGL on Windows or on NaCl) +if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL OR CORRADE_TARGET_WINDOWS) + option(WITH_MAGNUMINFO "Build magnum-info utility" OFF) +endif() + +# Utilities (currently only using GLX, CGL or WGL) +if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS) + cmake_dependent_option(WITH_FONTCONVERTER "Build magnum-fontconverter utility" OFF "NOT TARGET_GLES" OFF) + cmake_dependent_option(WITH_DISTANCEFIELDCONVERTER "Build magnum-distancefieldconverter utility" OFF "NOT TARGET_GLES" OFF) +endif() + +# Plugins +option(WITH_WAVAUDIOIMPORTER "Build WavAudioImporter plugin" OFF) +option(WITH_MAGNUMFONT "Build MagnumFont plugin" OFF) +cmake_dependent_option(WITH_MAGNUMFONTCONVERTER "Build MagnumFontConverter plugin" OFF "NOT TARGET_GLES" OFF) +option(WITH_OBJIMPORTER "Build ObjImporter plugin" OFF) +cmake_dependent_option(WITH_TGAIMAGECONVERTER "Build TgaImageConverter plugin" OFF "NOT WITH_MAGNUMFONTCONVERTER" ON) +cmake_dependent_option(WITH_TGAIMPORTER "Build TgaImporter plugin" OFF "NOT WITH_MAGNUMFONT" ON) # Parts of the library -option(WITH_AUDIO "Build Audio library" OFF) +cmake_dependent_option(WITH_AUDIO "Build Audio library" OFF "NOT WITH_WAVAUDIOIMPORTER" ON) option(WITH_DEBUGTOOLS "Build DebugTools library" ON) cmake_dependent_option(WITH_MESHTOOLS "Build MeshTools library" ON "NOT WITH_DEBUGTOOLS;NOT WITH_OBJIMPORTER" ON) cmake_dependent_option(WITH_PRIMITIVES "Builf Primitives library" ON "NOT WITH_DEBUGTOOLS" ON) -cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" ON "NOT WITH_DEBUGTOOLS;NOT WITH_SHAPES" ON) +option(WITH_SHAPES "Build Shapes library" ON) +cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" ON "NOT WITH_SHAPES" ON) cmake_dependent_option(WITH_SHADERS "Build Shaders library" ON "NOT WITH_DEBUGTOOLS" ON) -cmake_dependent_option(WITH_SHAPES "Build Shapes library" ON "NOT WITH_DEBUGTOOLS" ON) -option(WITH_TEXT "Build Text library" ON) +cmake_dependent_option(WITH_TEXT "Build Text library" ON "NOT WITH_MAGNUMFONT;NOT WITH_MAGNUMFONTCONVERTER" ON) cmake_dependent_option(WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT WITH_TEXT;NOT WITH_DISTANCEFIELDCONVERTER" ON) -# EGL context, available everywhere except on platforms which don't support extension loading +# EGL context and windowless EGL application, available everywhere except on +# platforms which don't support extension loading if(NOT CORRADE_TARGET_EMSCRIPTEN AND NOT CORRADE_TARGET_NACL) option(WITH_EGLCONTEXT "Build EglContext library" OFF) + option(WITH_WINDOWLESSEGLAPPLICATION "Build WindowlessEglApplication library" OFF) endif() # NaCl-specific application libraries @@ -68,6 +100,10 @@ if(CORRADE_TARGET_NACL) elseif(CORRADE_TARGET_ANDROID) option(WITH_ANDROIDAPPLICATION "Build AndroidApplication library" OFF) +# iOS-specific application libraries +elseif(CORRADE_TARGET_IOS) + option(WITH_WINDOWLESSIOSAPPLICATION "Build WindowlessIosApplication library" OFF) + # OS X-specific application libraries elseif(CORRADE_TARGET_APPLE) cmake_dependent_option(WITH_WINDOWLESSCGLAPPLICATION "Build WindowlessCglApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_FONTCONVERTER;NOT WITH_DISTANCEFIELDCONVERTER" ON) @@ -92,29 +128,11 @@ endif() # Platform-independent (almost) application libraries if(NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_ANDROID) + option(WITH_GLFWAPPLICATION "Build GlfwApplication library") cmake_dependent_option(WITH_GLUTAPPLICATION "Build GlutApplication library" OFF "NOT TARGET_GLES" OFF) option(WITH_SDL2APPLICATION "Build Sdl2Application library" OFF) endif() -# Magnum Info (currently only using GLX, CGL, WGL/EGL on Windows or on NaCl) -if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL OR CORRADE_TARGET_WINDOWS) - option(WITH_MAGNUMINFO "Build magnum-info utility" OFF) -endif() - -# Utilities (currently only using GLX, CGL or WGL) -if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS) - cmake_dependent_option(WITH_FONTCONVERTER "Build magnum-fontconverter utility" OFF "NOT TARGET_GLES" OFF) - cmake_dependent_option(WITH_DISTANCEFIELDCONVERTER "Build magnum-distancefieldconverter utility" OFF "NOT TARGET_GLES" OFF) -endif() - -# Plugins -cmake_dependent_option(WITH_MAGNUMFONT "Build MagnumFont plugin" OFF "WITH_TEXT" OFF) -cmake_dependent_option(WITH_MAGNUMFONTCONVERTER "Build MagnumFontConverter plugin" OFF "NOT MAGNUM_TARGET_GLES;WITH_TEXT" OFF) -option(WITH_OBJIMPORTER "Build ObjImporter plugin" OFF) -cmake_dependent_option(WITH_TGAIMAGECONVERTER "Build TgaImageConverter plugin" OFF "NOT WITH_MAGNUMFONTCONVERTER" ON) -cmake_dependent_option(WITH_TGAIMPORTER "Build TgaImporter plugin" OFF "NOT WITH_MAGNUMFONT" ON) -cmake_dependent_option(WITH_WAVAUDIOIMPORTER "Build WavAudioImporter plugin" OFF "WITH_AUDIO" OFF) - option(BUILD_DEPRECATED "Include deprecated API in the build" ON) if(BUILD_DEPRECATED) set(MAGNUM_BUILD_DEPRECATED 1) @@ -126,6 +144,7 @@ option(BUILD_PLUGINS_STATIC "Build static plugins (default are dynamic)" OFF) option(BUILD_TESTS "Build unit tests" OFF) cmake_dependent_option(BUILD_GL_TESTS "Build unit tests for OpenGL code" OFF "BUILD_TESTS" OFF) if(BUILD_TESTS) + find_package(Corrade REQUIRED TestSuite) enable_testing() endif() @@ -181,9 +200,18 @@ endif() if(TARGET_DESKTOP_GLES) set(MAGNUM_TARGET_DESKTOP_GLES 1) endif() +if(TARGET_HEADLESS) + set(MAGNUM_TARGET_HEADLESS 1) +endif() if(BUILD_GL_TESTS) - if(CORRADE_TARGET_APPLE) + if(MAGNUM_TARGET_HEADLESS) + set(WITH_WINDOWLESSEGLAPPLICATION ON) + set(GL_TEST_LIBRARIES Magnum MagnumWindowlessEglApplication) + elseif(CORRADE_TARGET_IOS) + set(WITH_WINDOWLESSIOSAPPLICATION ON) + set(GL_TEST_LIBRARIES Magnum MagnumWindowlessIosApplication) + elseif(CORRADE_TARGET_APPLE) set(WITH_WINDOWLESSCGLAPPLICATION ON) set(GL_TEST_LIBRARIES Magnum MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 221290ecf..7861d6f08 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ Code contribution /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © YEAR YOUR_NAME diff --git a/COPYING b/COPYING index 0d92ab1b3..dc67b8130 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/CREDITS.md b/CREDITS.md index 03ba78a5a..4cf4d5fb1 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -32,7 +32,8 @@ Contributors to Magnum library * [@wivlaro](https://github.com/wivlaro) -- numerous bug reports, Mac OS X fixes, feature improvements * Jonathan Hale ([@Squareys](https://github.com/Squareys)) -- Audio library - enhancements, bug reports, documentation improvements + enhancements, GlfwApplication implementation, bug reports, documentation + improvements * Gerhard de Clercq -- Windows RT (Store/Phone) port Big thanks to everyone involved! diff --git a/Doxyfile b/Doxyfile index 2a9f9a10d..3b466f962 100644 --- a/Doxyfile +++ b/Doxyfile @@ -266,7 +266,7 @@ ALIASES = \ "extension{2}=\1_\2" \ "extension2{2}=\1_\2" \ "extension3{3}=\1_\2" \ - "requires_gles20=@xrefitem requires-gles20 \"Requires OpenGL ES 2.0 / WebGL 1.%\" \"Functionality requiring OpenGL ES 2.0 or WebGL 1.0\"" \ + "requires_gles20=@xrefitem requires-gles20 \"Requires OpenGL ES 2.0 / WebGL 1.0\" \"Functionality requiring OpenGL ES 2.0 or WebGL 1.0\"" \ "requires_gles30=@xrefitem requires-gles30 \"Requires OpenGL ES 3.0\" \"Functionality requiring OpenGL ES 3.0\"" \ "requires_gles31=@xrefitem requires-gles31 \"Requires OpenGL ES 3.1\" \"Functionality requiring OpenGL ES 3.1\"" \ "requires_es_extension=@xrefitem requires-es-extension \"Requires OpenGL ES extension\" \"Functionality requiring specific OpenGL ES extension\"" \ @@ -282,7 +282,8 @@ ALIASES = \ "def_alc{1}=`ALC_\1`" \ "requires_al_extension=@xrefitem requires-al-extension \"Requires OpenAL extension\" \"Functionality requiring specific OpenAL extension\"" \ "al_extension{2}=AL_\1_\2" \ - "alc_extension{2}=ALC_\1_\2" + "alc_extension{2}=ALC_\1_\2" \ + "experimental=@note This functionality is still experimental and may change in the future without keeping full backwards compatibility." # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding "class=itcl::class" diff --git a/README.md b/README.md index 5cf9212e6..a65735174 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Platforms: SDL2 or GLUT toolkit) [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum) * **Windows** natively or using ANGLE (through SDL2 or GLUT toolkit) [![Build status](https://ci.appveyor.com/api/projects/status/5b477m034cfaskse/branch/master?svg=true)](https://ci.appveyor.com/project/mosra/magnum/branch/master) * **OS X** (through SDL2 toolkit) [![Build Status](https://travis-ci.org/mosra/magnum.svg?branch=master)](https://travis-ci.org/mosra/magnum) +* **iOS** (through SDL2 toolkit) * **Android** 2.3 (API Level 9) and higher * **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit) * **Google Chrome** (through [Native Client](https://developers.google.com/native-client/), @@ -93,7 +94,7 @@ Minimal dependencies On Windows you can also use **MinGW-w64**. GCC 4.6, 4.5, 4.4 and MSVC 2013 support involves some ugly workarounds and thus is available only in `compatibility` branch. -* **CMake** >= 2.8.9 +* **CMake** >= 2.8.12 * **Corrade** - Plugin management and utility library. You can get it at https://github.com/mosra/corrade. diff --git a/doc/best-practices.dox b/doc/best-practices.dox index 13793a807..bb705af92 100644 --- a/doc/best-practices.dox +++ b/doc/best-practices.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/building.dox b/doc/building.dox index 3259f5b34..fc853a21e 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -37,7 +37,7 @@ Minimal set of tools and libraries required for building is: On Windows you can also use **MinGW-w64**. GCC 4.6, 4.5, 4.4 and MSVC 2013 support involves some ugly workarounds and thus is available only in `compatibility` branch. -- **CMake** >= 2.8.9 +- **CMake** >= 2.8.12 - **Corrade** - Plugin management and utility library. See @ref building-corrade "Corrade download and installation guide" for more information. @@ -162,11 +162,16 @@ By default the engine is built for desktop OpenGL. Using `TARGET_*` CMake parameters you can target other platforms. Note that some features are available for desktop OpenGL only, see @ref requires-gl. - - `TARGET_GLES` - Target OpenGL ES. - - `TARGET_GLES2` - Target OpenGL ES 2.0. Currently enabled by default when - `TARGET_GLES` is set. - - `TARGET_DESKTOP_GLES` - Target OpenGL ES on desktop, i.e. use OpenGL ES - emulation in desktop OpenGL library. Might not be supported in all drivers. +- `TARGET_GLES` -- Target OpenGL ES. +- `TARGET_GLES2` -- Target OpenGL ES 2.0. Currently enabled by default when + `TARGET_GLES` is set. +- `TARGET_DESKTOP_GLES` -- Target OpenGL ES on desktop, i.e. use OpenGL ES + emulation in desktop OpenGL library. Might not be supported in all drivers. +- `TARGET_HEADLESS` -- Build command-line utilities for use on a headless + machine. Basically it means that EGL with no display attachment is being + used everywhere instead of platform-specific toolkits like CGL, GLX or WGL. + Supported mainly on OpenGL ES drivers, for desktop OpenGL the only driver + that supports this configuration is NVidia >= 355. The features used can be conveniently detected in depending projects both in CMake and C++ sources, see @ref cmake and @ref Magnum/Magnum.h for more @@ -201,13 +206,16 @@ need at least one). Choose the one which suits your requirements and your platform best: - `WITH_ANDROIDAPPLICATION` - @ref Platform::AndroidApplication "AndroidApplication" +- `WITH_GLFWAPPLICATION` - @ref Platform::GlfwApplication "GlfwApplication" - `WITH_GLUTAPPLICATION` - @ref Platform::GlutApplication "GlutApplication" - `WITH_GLXAPPLICATION` - @ref Platform::GlxApplication "GlxApplication" - `WITH_NACLAPPLICATION` - @ref Platform::NaClApplication "NaClApplication" - `WITH_SDL2APPLICATION` - @ref Platform::Sdl2Application "Sdl2Application" - `WITH_XEGLAPPLICATION` - @ref Platform::XEglApplication "XEglApplication" - `WITH_WINDOWLESSCGLAPPLICATION` - @ref Platform::WindowlessCglApplication "WindowlessCglApplication" +- `WITH_WINDOWLESSEGLAPPLICATION` - @ref Platform::WindowlessEglApplication "WindowlessEglApplication" - `WITH_WINDOWLESSGLXAPPLICATION` - @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication" +- `WITH_WINDOWLESSIOSAPPLICATION` - @ref Platform::WindowlessIosApplication "WindowlessIosApplication" - `WITH_WINDOWLESSNACLAPPLICATION` - @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication" - `WITH_WINDOWLESSWGLAPPLICATION` - @ref Platform::WindowlessWglApplication "WindowlessWglApplication" - `WITH_WINDOWLESSWINDOWSEGLAPPLICATION` - @ref Platform::WindowlessWindowsEglApplication "WindowlessWindowsEglApplication" @@ -330,6 +338,13 @@ This will compile binary and development packages, which will then appear in parent directory. If you need to modify CMake flags (enabling/disabling some features, for example), modify the last entry in `debian/rules`. +@subsection building-packages-brew Homebrew formulas + +OS X Homebrew formulas are in `package/homebrew` directory. Either use the +`*.rb` files directly or use the tap at https://github.com/mosra/homebrew-magnum: + + brew install --HEAD mosra/magnum/magnum + @section building-windows-angle Building for ANGLE on Windows Magnum is able to run on ANGLE OpenGL-to-D3D translator. Download the code from @@ -362,6 +377,10 @@ contents in `toolchains/` subdirectory. git submodule init git submodule update +Note that CMake for some reason treats `CMAKE_PREFIX_PATH` and +`CMAKE_INSTALL_PREFIX` differently while crosscompiling and you may need to set +also `CMAKE_FIND_ROOT_PATH` to make it able to find the dependencies. + @subsection building-cross-winrt Crosscompiling for Windows RT As said above, you need native build of `corrade-rc` executable. The below @@ -444,7 +463,6 @@ in `CMAKE_PREFIX_PATH`. mkdir build-nacl-x86-32 && cd build-nacl-x86-32 cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-32.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH=/usr/nacl \ @@ -455,7 +473,6 @@ in `CMAKE_PREFIX_PATH`. mkdir build-nacl-x86-64 && cd build-nacl-x86-64 cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-64.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH=/usr/nacl \ @@ -494,7 +511,6 @@ equivalent) by disabling `TARGET_GLES2`. mkdir build-emscripten && cd build-emscripten cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH=/usr/lib/emscripten/system \ @@ -515,6 +531,40 @@ information. See @ref Platform::Sdl2Application documentation for more information about building your projects for Emscripten. +@subsection building-cross-ios Crosscompiling for iOS + +You will need OSX and Xcode installed. + +Set `CMAKE_OSX_ROOT` to SDK you want to target and enable all desired +architectures in `CMAKE_OSX_ARCHITECTURES`. The toolchain needs access to its +platform file, so be sure to properly set **absolute** path to `modules/` +directory containing `Platform/iOS.cmake`. Set `CMAKE_INSTALL_PREFIX` to prefix +where you store other iOS dependencies such as Corrade or SDL2. + +As every application is in its own sandbox, it doesn't make sense to build +shared libraries (although it is supported). Enable `BUILD_STATIC` to build +static libraries. You might also have problems using dynamic plugins, enable +`BUILD_PLUGINS_STATIC` to build also plugins as static. OpenGL ES 2.0 is +enabled by default, switch to 3.0 by disabling `TARGET_GLES2`. + + mkdir build-ios && cd build-ios + cmake .. \ + -DCMAKE_TOOLCHAIN_FILE=../toolchains/generic/iOS.cmake \ + -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \ + -DCMAKE_OSX_ARCHITECTURES="arm64;armv7;armv7s" \ + -DCMAKE_INSTALL_PREFIX=~/ios-libs \ + -DBUILD_STATIC=ON -DBUILD_PLUGINS_STATIC=ON \ + -DTARGET_GLES2=OFF \ + -DWITH_SDL2APPLICATION=ON \ + -G Xcode + cmake --build . + +Then you can install the library using `cmake --build . --target install` to +make it available for depending projects. + +See @ref Platform::Sdl2Application documentation for more information about +building your projects for iOS. + @subsection building-cross-android Crosscompiling for Android ARM and x86 You will need [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) @@ -537,7 +587,6 @@ built for OpenGL ES 2.0 by default, switch to 3.0 by disabling `TARGET_GLES2`. mkdir build-android-arm && cd build-android-arm cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-ARM.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH=/opt/android-ndk/platforms/android-19/arch-arm/usr \ @@ -548,7 +597,6 @@ built for OpenGL ES 2.0 by default, switch to 3.0 by disabling `TARGET_GLES2`. mkdir build-android-x86 && cd build-android-x86 cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-x86.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_PREFIX_PATH=/opt/android-ndk/platforms/android-19/arch-x86/usr \ @@ -597,8 +645,8 @@ replace `localhost:8080` with your server name, replace `update-job` with java -jar ~/jenkins-cli.jar -s http://localhost:8080 update-job Magnum-GLTests < package/ci/jenkins-gltests.xml Build is done using **Ninja** build system and everything possible is enabled, -thus you need also **SDL2**, **GLUT** and **OpenAL** libraries. It expects -that **GCC** >= 4.9, 4.8, 4.7 and **Clang** are installed and there +thus you need also **SDL2**, **GLFW**, **GLUT** and **OpenAL** libraries. It +expects that **GCC** >= 4.9, 4.8, 4.7 and **Clang** are installed and there are **OpenGL**, **OpenGL ES 2.0** and **OpenGL ES 3.0** librares as it tries to compile the library with every combination of them. You can add/remove the axes in `axes/hudson.matrix.TextAxis` or via the web interface later. diff --git a/doc/cmake.dox b/doc/cmake.dox index 6253a29d0..972858b2c 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -50,12 +50,10 @@ Basic usage is: find_package(Magnum REQUIRED) -This command tries to find base Magnum library and then defines these -variables: +This module tries to find base Magnum library and then defines: -- `MAGNUM_FOUND` -- Whether the library was found -- `MAGNUM_LIBRARIES` -- Magnum library and dependent libraries -- `MAGNUM_INCLUDE_DIRS` -- Root include dir and include dirs of dependencies +- `Magnum_FOUND` -- Whether the library was found +- `Magnum::Magnum` -- Base library imported target - `MAGNUM_PLUGINS_DEBUG_DIR` -- Base directory with dynamic plugins for debug builds, defaults to `magnum-d/` subdirectory of dir where Magnum library was found @@ -96,13 +94,16 @@ The optional components are: Platform namespace is split into more components: +- `GlfwApplication` -- @ref Platform::GlfwApplication "GlfwApplication" - `GlutApplication` -- @ref Platform::GlutApplication "GlutApplication" - `GlxApplication` -- @ref Platform::GlxApplication "GlxApplication" - `NaClApplication` -- @ref Platform::NaClApplication "NaClApplication" - `Sdl2Application` -- @ref Platform::Sdl2Application "Sdl2Application" - `XEglApplication` -- @ref Platform::XEglApplication "XEglApplication" - `WindowlessCglApplication` -- @ref Platform::WindowlessCglApplication "WindowlessCglApplication" +- `WindowlessEglApplication` -- @ref Platform::WindowlessEglApplication "WindowlessEglApplication" - `WindowlessGlxApplication` -- @ref Platform::WindowlessGlxApplication "WindowlessGlxApplication" +- `WindowlessIosApplication` -- @ref Platform::WindowlessIosApplication "WindowlessIosApplication" - `WindowlessNaClApplication` -- @ref Platform::WindowlessNaClApplication "WindowlessNaClApplication" - `WindowlessWglApplication` -- @ref Platform::WindowlessWglApplication "WindowlessWglApplication" - `WindowlessWindowsEglApplication` -- @ref Platform::WindowlessWindowsEglApplication "WindowlessWindowsEglApplication" @@ -135,6 +136,12 @@ dependencies, you need to find the dependency and then link to it. - `TgaImporter` -- @ref Trade::TgaImporter "TgaImporter" plugin - `WavAudioImporter` -- @ref Audio::WavImporter "WavAudioImporter" plugin +Lastly, a few utility executables are available: + +- `distancefieldconverter` -- @ref magnum-distancefieldconverter executable +- `fontconverter` -- @ref magnum-fontconverter executable +- `info` -- @ref magnum-info executable + Note that [each namespace](namespaces.html), all @ref Platform libraries and each plugin class contain more detailed information about dependencies, availability on particular platform and also guide how to enable given library @@ -146,18 +153,14 @@ Example usage with specifying additional components is: For each component is then defined: -- `MAGNUM_*_FOUND` -- Whether the component was found -- `MAGNUM_*_LIBRARIES` -- Component library and dependent libraries -- `MAGNUM_*_INCLUDE_DIRS` -- Include dirs of module dependencies +- `Magnum_*_FOUND` -- Whether the component was found +- `Magnum::*` -- Component imported target If exactly one `*Application` or exactly one `Windowless*Application` component -is requested and found, its libraries and include dirs are available in -convenience aliases `MAGNUM_APPLICATION_LIBRARIES` / -`MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES` and `MAGNUM_APPLICATION_INCLUDE_DIRS` -/ `MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS` to simplify porting. Similarly, -if exactly one `*Context` component is requested and found, its libraries and -include dirs are available in convenience aliases `MAGNUM_CONTEXT_LIBRARIES` -and `MAGNUM_CONTEXT_INCLUDE_DIRS`. +is requested and found, its target is available in convenience alias +`Magnum::Application` / `Magnum::WindowlessApplication` to simplify porting. +Similarly, if exactly one `*Context` component is requested and found, its +target is available in convenience alias `Magnum::Context`. The package is found if either debug or release version of each requested library (or plugin) is found. If both debug and release libraries (or plugins) @@ -182,12 +185,29 @@ are also available as preprocessor variables if including - `MAGNUM_TARGET_GLES3` -- Defined if compiled for OpenGL ES 3.0 - `MAGNUM_TARGET_DESKTOP_GLES` -- Defined if compiled with OpenGL ES emulation on desktop OpenGL -- `MAGNUM_TARGET_WEBGL` --- Defined if compiled for WebGL +- `MAGNUM_TARGET_WEBGL` -- Defined if compiled for WebGL +- `MAGNUM_TARGET_HEADLESS` -- Defined if compiled for headless machines. See + @ref MAGNUM_TARGET_HEADLESS documentation for more information. + +Workflows without imported targets are deprecated and the following variables +are included just for backwards compatibility and only if +@ref MAGNUM_BUILD_DEPRECATED is enabled: + +- `MAGNUM_LIBRARIES` -- Expands to `Magnum::Magnum` target. Use `Magnum::Magnum` + target directly instead. +- `MAGNUM_*_LIBRARIES` -- Expands to `Magnum::*` target. Use `Magnum::*` + target directly instead. +- `MAGNUM_APPLICATION_LIBRARIES` / `MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES` + -- Expands to `Magnum::Application` / `Magnum::WindowlessApplication` + target. Use `Magnum::Application` / `Magnum::WindowlessApplication` target + directly instead. +- `MAGNUM_CONTEXT_LIBRARIES` -- Expands to `Magnum::Context` target. Use + `Magnum::Context` target directly instead. Corrade library provides also its own set of CMake macros and variables, see @ref corrade-cmake "its documentation" for more information. -@ref cmake-plugins "Plugins repository" and @ref cmake-integration "Integration library" -have also their own CMake modules. +@ref cmake-plugins "Plugins repository", @ref cmake-integration "Integration repository" +and @ref cmake-extras "Extras repository" have also their own CMake modules. */ } diff --git a/doc/coding-style.dox b/doc/coding-style.dox index 9f64f4bd6..c2d3892c8 100644 --- a/doc/coding-style.dox +++ b/doc/coding-style.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/compilation-speedup.dox b/doc/compilation-speedup.dox index 0b56c2e6f..c0bd06994 100644 --- a/doc/compilation-speedup.dox +++ b/doc/compilation-speedup.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/debug-tools.dox b/doc/debug-tools.dox index f079f2b93..daea2867f 100644 --- a/doc/debug-tools.dox +++ b/doc/debug-tools.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -65,7 +65,7 @@ DebugTools::ResourceManager manager; SceneGraph::DrawableGroup3D debugDrawables; // Create renderer options which will be referenced later by "my" resource key -DebugTools::ResourceManager::instance()->set("my", +DebugTools::ResourceManager::instance().set("my", DebugTools::ObjectRendererOptions().setSize(0.3f)); // Create debug renderer for given object, use "my" options for it. The diff --git a/doc/features.dox b/doc/features.dox index 5bd2c635e..4cd83cf34 100644 --- a/doc/features.dox +++ b/doc/features.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/generated/CMakeLists.txt b/doc/generated/CMakeLists.txt index a093f58c6..394584469 100644 --- a/doc/generated/CMakeLists.txt +++ b/doc/generated/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -34,6 +34,8 @@ find_package(Magnum REQUIRED Shaders Sdl2Application) +set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON) + if(CORRADE_TARGET_APPLE) find_package(Magnum REQUIRED WindowlessCglApplication) elseif(CORRADE_TARGET_UNIX) @@ -46,22 +48,17 @@ 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}) + Magnum::Magnum + Magnum::Application) add_executable(shaders shaders.cpp) +target_include_directories(shaders PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(shaders - ${MAGNUM_LIBRARIES} - ${MAGNUM_MESHTOOLS_LIBRARIES} - ${MAGNUM_PRIMITIVES_LIBRARIES} - ${MAGNUM_SHADERS_LIBRARIES} - ${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}) + Magnum::Magnum + Magnum::MeshTools + Magnum::Primitives + Magnum::Shaders + Magnum::WindowlessApplication) diff --git a/doc/generated/configure.h.cmake b/doc/generated/configure.h.cmake index fcf0164d8..0b39a4535 100644 --- a/doc/generated/configure.h.cmake +++ b/doc/generated/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/generated/hello.cpp b/doc/generated/hello.cpp index 1a21e4eb2..807f3c280 100644 --- a/doc/generated/hello.cpp +++ b/doc/generated/hello.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/generated/shaders.cpp b/doc/generated/shaders.cpp index 1515c664a..edf4cc11f 100644 --- a/doc/generated/shaders.cpp +++ b/doc/generated/shaders.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/getting-started.dox b/doc/getting-started.dox index a28852804..57e6c2634 100644 --- a/doc/getting-started.dox +++ b/doc/getting-started.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -143,18 +143,17 @@ MAGNUM_APPLICATION_MAIN(MyApplication) The application essentially does nothing, just clears screen framebuffer to default (dark gray) color and then does buffer swap to actually display it on -the screen. The `src/CMakeLists.txt` file finds Magnum, sets up compiler flags, -creates the executable and links it to all needed libraries: +the screen. The `src/CMakeLists.txt` file finds Magnum, creates the executable +and links it to all needed libraries: @code find_package(Magnum REQUIRED Sdl2Application) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CORRADE_CXX_FLAGS}") -include_directories(${MAGNUM_INCLUDE_DIRS} ${MAGNUM_APPLICATION_INCLUDE_DIRS}) +set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON) add_executable(MyApplication MyApplication.cpp) target_link_libraries(MyApplication - ${MAGNUM_LIBRARIES} - ${MAGNUM_APPLICATION_LIBRARIES}) + Magnum::Magnum + Magnum::Application) @endcode In the following tutorials the code will be explained more thoroughly. diff --git a/doc/mainpage.dox b/doc/mainpage.dox index a20ad1576..e1af78bb3 100644 --- a/doc/mainpage.dox +++ b/doc/mainpage.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -79,7 +79,7 @@ Platforms: - **Linux** and embedded Linux (natively using GLX/EGL and Xlib or through SDL2 or GLUT toolkit) - **Windows** natively or using ANGLE (through SDL2 or GLUT toolkit) -- **OS X** (through SDL2 toolkit) +- **OS X**, **iOS** (through SDL2 toolkit) - **Android** 2.3 (API Level 9) and higher - **Windows RT** (Store/Phone) using ANGLE (through SDL2 toolkit) - **Google Chrome** (through [Native Client](https://developers.google.com/native-client/), @@ -128,7 +128,7 @@ Feel free to get more information or contact the author at: Magnum is licensed under MIT/Expat license: > -> Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +> Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 > Vladimír Vondruš <mosra@centrum.cz> > > Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/matrix-vector.dox b/doc/matrix-vector.dox index baed48801..fef01297e 100644 --- a/doc/matrix-vector.dox +++ b/doc/matrix-vector.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -56,29 +56,26 @@ most specialized type known to make subsequent operations more convenient -- columns of RectangularMatrix are returned as Vector, but when accessing columns of e.g. Matrix3, they are returned as Vector3. -There are also even more specialized subclasses, e.g. @ref Color3 and -@ref Color4 for color handling and conversion. +There are also even more specialized subclasses, e.g. @ref Math::Color3 and +@ref Math::Color4 for color handling and conversion. Commonly used types have convenience aliases in @ref Magnum namespace, so you -can write e.g. `Vector3i` instead of `Math::Vector3`. See @ref types and -namespace documentation for more information. +can write e.g. @ref Vector3i instead of @ref Math::Vector3 "Math::Vector3". +See @ref types and namespace documentation for more information. @section matrix-vector-construction Constructing matrices and vectors Default constructors of @ref Math::RectangularMatrix and @ref Math::Vector (and -@ref Math::Vector2, @ref Math::Vector3, @ref Math::Vector4, @ref Color3) create -zero-filled objects. @ref Math::Matrix (and @ref Math::Matrix3, @ref Math::Matrix4) -is by default constructed as identity matrix. @ref Color4 has alpha value set -to opaque. +@ref Math::Vector2, @ref Math::Vector3, @ref Math::Vector4, @ref Math::Color3, +@ref Math::Color4) create zero-filled objects. @ref Math::Matrix (and +@ref Math::Matrix3, @ref Math::Matrix4) is by default constructed as identity +matrix. @code Matrix2x3 a; // zero-filled Vector3i b; // zero-filled Matrix3 identity; // diagonal set to 1 Matrix3 zero(Matrix::Zero); // zero-filled - -Color4 black1; // {0.0f, 0.0f, 0.0f, 1.0f} -Color4ub black2; // {0, 0, 0, 255} @endcode Most common and most efficient way to create vector is to pass all values to @@ -101,6 +98,14 @@ Vector3i fill(10); // {10, 10, 10} auto diag2 = Matrix3::fromDiagonal({3.0f, 2.0f, 1.0f}); @endcode +There are also shortcuts to create a vector with all but one component set to +zero or one, useful for transformations: +@code +auto x = Vector3::xAxis(); // {1.0f, 0.0f, 0.0f} +auto y = Vector2::yAxis(3.0f); // {0.0f, 3.0f} +auto z = Vector3::zScale(3.0f); // {1.0f, 1.0f, 3.0f} +@endcode + It is possible to create matrices from other matrices and vectors with the same row count; vectors from vector and scalar: @code @@ -124,6 +129,30 @@ Math::Matrix2x3::from(mat) *= 2; // mat == { 4, 8, 12, 2, 6, 10 } Note that, unlike constructors, this function has no way to check whether the array is long enough to contain all elements, so use with caution. +To make handling of colors easier, their behavior is a bit different with a +richer feature set. Implicit construction of @ref Color4 from @ref Color3 will +set the alpha to full value (thus `1.0f` for @ref Color4 and `255` for +@ref Color4ub): +@code +Color4 a = Color3{0.2f, 0.7f, 0.5f}; // {0.2f, 0.7f, 0.5f, 1.0f} +Color4ub b = Color3ub{0x33, 0xb2, 0x7f}; // {0x33, 0xb2, 0x7f, 0xff} +@endcode + +Similarly to axes in vectors, you can create single color shades too, or create +a RGB color from HSV representation: +@code +auto green = Color3::green(); // {0.0f, 1.0f, 0.0f} +auto cyan = Color4::cyan(0.5f, 0.95f); // {0.5f, 1.0f, 1.0f, 0.95f} +auto fadedRed = Color3::fromHSV(219.0_degf, 0.50f, 0.57f) +@endcode + +Lastly, namespace @ref Math::Literals provides convenient `_rgb`/`_rgbf` and +`_rgba`/`_rgbaf` literals for entering colors in hex representation: +@code +Color3ub a = 0x33b27f_rgb; // {0x33, 0xb2, 0x7f} +Color4 b = 0x33b27fcc_rgbaf; // {0.2f, 0.7f, 0.5f, 0.8f} +@endcode + @section matrix-vector-component-access Accessing matrix and vector components Column vectors of matrices and vector components can be accessed using square diff --git a/doc/method-chaining.dox b/doc/method-chaining.dox index e27750a0d..9f319fb3b 100644 --- a/doc/method-chaining.dox +++ b/doc/method-chaining.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/namespaces.dox b/doc/namespaces.dox index 5cc38addc..0964b018d 100644 --- a/doc/namespaces.dox +++ b/doc/namespaces.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,7 @@ */ /** @dir magnum/src/Magnum - * @brief Namespace @ref Magnum (part of @ref building "Magnum library") + * @brief Namespace @ref Magnum (part of @ref building "Magnum library"), @ref Magnum::Extensions */ /** @namespace Magnum @brief Root namespace @@ -32,9 +32,8 @@ Contains classes for interacting with OpenGL. This library is built as part of Magnum by default. To use it, you need to -find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link -to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more -information. +find `Magnum` package and link to `Magnum::Magnum` target. See @ref building +and @ref cmake for more information. */ /** @dir Magnum/Platform @@ -48,15 +47,14 @@ Base classes for creating applications with various toolkits. Parts of this namespace are built if `WITH_*APPLICATION` is enabled when building Magnum, with each library having specific toolkit dependencies and platform requirements. To use particular application library, you need to -request given `*Application` component of `Magnum` package in CMake, add -`${MAGNUM_*APPLICATION_INCLUDE_DIRS}` to include path and link to -`${MAGNUM_*APPLICATION_LIBRARIES}`. See particular `*Application` class +request given `*Application` component of `Magnum` package in CMake and link to +`Magnum::*Application` target. See particular `*Application` class documentation, @ref building, @ref cmake and @ref platform for more information. */ /** @dir Magnum/Math - * @brief Namespace @ref Magnum::Math + * @brief Namespace @ref Magnum::Math, @ref Magnum::Math::Literals */ /** @namespace Magnum::Math @brief Math library @@ -64,9 +62,17 @@ information. Template classes for matrix and vector calculations. This library is built as part of Magnum by default. To use it, you need to -find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link -to `${MAGNUM_LIBRARIES}`. See @ref building, @ref cmake, @ref matrix-vector and -@ref transformations for more information. +find `Magnum` package and link to `Magnum::Magnum` target. See @ref building, +@ref cmake, @ref matrix-vector and @ref transformations for more information. +*/ +/** @namespace Magnum::Math::Literals +@brief Math literals + +Literals for easy construction of angle and color values. + +This library is built as part of Magnum by default. To use it, you need to +find `Magnum` package and link to `Magnum::Magnum` target. See @ref building +and @ref cmake for more information. */ /** @dir Magnum/Math/Algorithms @@ -78,9 +84,8 @@ to `${MAGNUM_LIBRARIES}`. See @ref building, @ref cmake, @ref matrix-vector and Various matrix and vector algorithms. This library is built as part of Magnum by default. To use it, you need to -find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link -to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more -information. +find `Magnum` package and link to `Magnum::Magnum` target. See @ref building +and @ref cmake for more information. */ /** @dir Magnum/Math/Geometry @@ -92,9 +97,8 @@ information. Functions for computing intersections, distances, areas and volumes. This library is built as part of Magnum by default. To use it, you need to -find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link -to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more -information. +find `Magnum` package and link to `Magnum::Magnum` target. See @ref building +and @ref cmake for more information. */ /** @dir Magnum/Audio @@ -107,11 +111,11 @@ Audio import, playback and integration with @ref SceneGraph. This library depends on **OpenAL** library. It is built if `WITH_AUDIO` is enabled when building Magnum. To use this library, you need to request -`Audio` component of `Magnum` package in CMake, add `${MAGNUM_AUDIO_INCLUDE_DIRS}` -to include path and link to `${MAGNUM_AUDIO_LIBRARIES}`. See @ref building and -@ref cmake for more information. Additional plugins are enabled separately, see -particular `*Importer` class documentation, @ref building-plugins, -@ref cmake-plugins and @ref plugins for more information. +`Audio` component of `Magnum` package in CMake and link to +`Magnum::Audio` target. See @ref building and @ref cmake for more information. +Additional plugins are enabled separately, see particular `Audio::*Importer` +class documentation, @ref building-plugins, @ref cmake-plugins and @ref plugins +for more information. */ /** @dir Magnum/DebugTools @@ -124,8 +128,8 @@ Debugging helpers, renderers and profilers. This library is built if `WITH_DEBUGTOOLS` is enabled when building Magnum. To use this library, you need to request `DebugTools` component of `Magnum` -package in CMake and link to `${MAGNUM_DEBUGTOOLS_LIBRARIES}`. See -@ref building, @ref cmake and @ref debug-tools for more information. +package in CMake and link to `Magnum::DebugTools` target. See @ref building, +@ref cmake and @ref debug-tools for more information. */ /** @dir Magnum/MeshTools @@ -138,8 +142,8 @@ Tools for generating, optimizing and cleaning meshes. This library is built if `WITH_MESHTOOLS` is enabled when building Magnum. To use this library, you need to request `MeshTools` component of `Magnum` -package in CMake and link to `${MAGNUM_MESHTOOLS_LIBRARIES}`. See @ref building -and @ref cmake for more information. +package in CMake and link to `Magnum::MeshTools` target. See @ref building and +@ref cmake for more information. */ /** @dir Magnum/Primitives @@ -152,8 +156,8 @@ Basic primitives for testing purposes. This library is built if `WITH_PRIMITIVES` is enabled when building Magnum. To use this library, you need to request `Primitives` component of `Magnum` -package in CMake and link to `${MAGNUM_PRIMITIVES_LIBRARIES}`. See -@ref building and @ref cmake for more information. +package in CMake and link to `Magnum::Primitives` target. See @ref building and +@ref cmake for more information. */ /** @dir Magnum/SceneGraph @@ -166,8 +170,8 @@ Managing object hierarchy, transformations and interactions. This library is built if `WITH_SCENEGRAPH` is enabled when building Magnum. To use this library, you need to request `SceneGraph` component of `Magnum` -package in CMake and link to `${MAGNUM_SCENEGRAPH_LIBRARIES}`. See -@ref building, @ref cmake and @ref scenegraph for more information. +package in CMake and link to `Magnum::SceneGraph` target. See @ref building, +@ref cmake and @ref scenegraph for more information. */ /** @dir Magnum/Shaders @@ -180,8 +184,8 @@ Collection of shaders for easy prototyping and basic usage. This library is built if `WITH_SHADERS` is enabled when building Magnum. To use this library, you need to request `Shaders` component of `Magnum` package -in CMake and link to `${MAGNUM_MESHTOOLS_SHADERS}`. See @ref building and -@ref cmake and @ref shaders for more information. +in CMake and link to `Magnum::Shaders` target. See @ref building, @ref cmake +and @ref shaders for more information. */ /** @dir Magnum/Shapes @@ -194,8 +198,8 @@ Collision detection system. This library is built if `WITH_SHAPES` is enabled when building Magnum. To use this library, you need to request `Shapes` component of `Magnum` package in -CMake and link to `${MAGNUM_SHAPES_LIBRARIES}`. See @ref building, @ref cmake -and @ref shapes for more information. +CMake and link to `Magnum::Shapes` target. See @ref building, @ref cmake and +@ref shapes for more information. */ /** @dir Magnum/Text @@ -208,8 +212,8 @@ Font texture creation and text layouting. This library is built if `WITH_TEXT` is enabled when building Magnum. To use this library, you need to request `Text` component of `Magnum` package in -CMake and link to `${MAGNUM_TEXT_LIBRARIES}`. See @ref building and @ref cmake -for more information. Additional plugins are enabled separately, see particular +CMake and link to `Magnum::Text` target. See @ref building and @ref cmake for +more information. Additional plugins are enabled separately, see particular `*Font` and `*FontConverter` class documentation, @ref building-plugins, @ref cmake-plugins and @ref plugins for more information. */ @@ -224,8 +228,8 @@ Tools for generating, compressing and optimizing textures. This library is built if `WITH_TEXTURETOOLS` is enabled when building Magnum. To use this library, you need to request `TextureTools` component of `Magnum` -package in CMake and link to `${MAGNUM_TEXTURETOOLS_LIBRARIES}`. See -@ref building and @ref cmake for more information. +package in CMake and link to `Magnum::TextureTools`. See @ref building and +@ref cmake for more information. */ /** @dir Magnum/Trade @@ -238,11 +242,11 @@ Contains plugin interfaces for importing data of various formats and classes for direct access to the data. This library is built as part of Magnum by default. To use it, you need to -find `Magnum` package, add `${MAGNUM_INCLUDE_DIRS}` to include path and link -to `${MAGNUM_LIBRARIES}`. See @ref building and @ref cmake for more -information. Additional plugins are enabled separately, see particular -`*Importer` and `*ImageConverter` class documentation, @ref building-plugins, -@ref cmake-plugins and @ref plugins for more information. +find `Magnum` package and link to `Magnum::Magnum` target. See @ref building +and @ref cmake for more information. Additional plugins are enabled separately, +see particular `Trade::*Importer` and `*ImageConverter` class documentation, +@ref building-plugins, @ref cmake-plugins and @ref plugins for more +information. */ /** @dir magnum/src/MagnumPlugins diff --git a/doc/openal-support.dox b/doc/openal-support.dox index f99d146f3..06278b89a 100644 --- a/doc/openal-support.dox +++ b/doc/openal-support.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/doc/openal.dox b/doc/openal.dox index ab3673cb3..6a1b4635a 100644 --- a/doc/openal.dox +++ b/doc/openal.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/opengl-mapping.dox b/doc/opengl-mapping.dox index b2bbb7566..37dd149b3 100644 --- a/doc/opengl-mapping.dox +++ b/doc/opengl-mapping.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -60,7 +60,7 @@ OpenGL function | Matching API @fn_gl{BindFragDataLocation} | @ref AbstractShaderProgram::bindFragmentDataLocation() @fn_gl{BindFragDataLocationIndexed} | @ref AbstractShaderProgram::bindFragmentDataLocationIndexed() @fn_gl{BindFramebuffer} | @ref Framebuffer::bind() -@fn_gl{BindImageTexture}, \n @fn_gl{BindImageTextures} | | +@fn_gl{BindImageTexture}, \n @fn_gl{BindImageTextures} | @ref AbstractTexture::unbindImage(), \n @ref AbstractTexture::unbindImages(), \n @ref AbstractTexture::bindImages(), \n @ref Texture::bindImage(), \n @ref Texture::bindImageLayered(), \n @ref TextureArray::bindImage(), \n @ref TextureArray::bindImageLayered(), \n @ref CubeMapTexture::bindImage(), \n @ref CubeMapTexture::bindImageLayered(), \n @ref CubeMapTextureArray::bindImage(), \n @ref CubeMapTextureArray::bindImageLayered(), \n @ref MultisampleTexture::bindImage(), \n @ref MultisampleTexture::bindImageLayered(), \n @ref RectangleTexture::bindImage(), \n @ref BufferTexture::bindImage() @fn_gl{BindProgramPipeline} | | @fn_gl{BindRenderbuffer} | not needed, handled internally in @ref Renderbuffer @fn_gl{BindSampler}, \n @fn_gl{BindSamplers} | | @@ -121,7 +121,7 @@ OpenGL function | Matching API @fn_gl{DepthRangeArray} | | @fn_gl{DepthRangeIndexed} | | @fn_gl{DetachShader} | | -@fn_gl{DispatchCompute} | | +@fn_gl{DispatchCompute} | @ref AbstractShaderProgram::dispatchCompute() @fn_gl_extension{DispatchComputeGroupSize,ARB,compute_variable_group_size} | | @fn_gl{DispatchComputeIndirect} | | @fn_gl{DrawArrays}, \n @fn_gl{DrawArraysInstanced}, \n @fn_gl{DrawArraysInstancedBaseInstance}, \n @fn_gl{DrawElements}, \n @fn_gl{DrawRangeElements}, \n @fn_gl{DrawElementsBaseVertex}, \n @fn_gl{DrawRangeElementsBaseVertex}, \n @fn_gl{DrawElementsInstanced}, \n @fn_gl{DrawElementsInstancedBaseInstance}, \n @fn_gl{DrawElementsInstancedBaseVertex}, \n @fn_gl{DrawElementsInstancedBaseVertexBaseInstance} | @ref Mesh::draw(), \n @ref MeshView::draw() @@ -175,7 +175,7 @@ OpenGL function | Matching API @fn_gl2{GetBufferPointer,GetBufferPointerv}, \n `glGetNamedBufferPointer()`, \n @fn_gl_extension{GetNamedBufferPointer,EXT,direct_state_access} | not queryable, @ref Buffer::map() setter only @fn_gl{GetBufferSubData}, \n `glGetNamedBufferSubData()`, \n @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access} | @ref Buffer::data(), \n @ref Buffer::subData() @fn_gl{GetCompressedTexImage}, \n `glGetnCompressedTexImage()`, \n @fn_gl_extension{GetnCompressedTexImage,ARB,robustness}, \n `glGetCompressedTextureImage()`, \n @fn_gl_extension{GetCompressedTextureImage,EXT,direct_state_access} | @ref Texture::compressedImage(), \n @ref TextureArray::compressedImage(), \n @ref CubeMapTexture::compressedImage(), \n @ref CubeMapTextureArray::compressedImage(), \n @ref RectangleTexture::compressedImage() -@fn_gl{GetCompressedTextureSubImage} | | +@fn_gl{GetCompressedTextureSubImage} | @ref Texture::compressedSubImage(), \n @ref TextureArray::compressedSubImage(), \n @ref CubeMapTexture::compressedImage(), \n @ref CubeMapTexture::compressedSubImage(), \n @ref CubeMapTextureArray::compressedSubImage(), \n @ref RectangleTexture::compressedSubImage() @fn_gl{GetDebugMessageLog} | | @fn_gl{GetError} | @ref Renderer::error() @fn_gl{GetFragDataIndex}, @fn_gl{GetFragDataLocation} | not queryable, @ref AbstractShaderProgram::bindFragmentDataLocation() and \n @ref AbstractShaderProgram::bindFragmentDataLocationIndexed() setters only @@ -219,7 +219,7 @@ OpenGL function | Matching API @fn_gl{GetTransformFeedback} | not queryable, @ref TransformFeedback::attachBuffer() and @ref TransformFeedback::attachBuffers() setters only @fn_gl{GetTransformFeedbackVarying} | not queryable, @ref AbstractShaderProgram::setTransformFeedbackOutputs() setter only @fn_gl{GetUniform}, \n `glGetnUniform()`, \n @fn_gl_extension{GetnUniform,ARB,robustness} | not queryable, @ref AbstractShaderProgram::setUniform() setter only -@fn_gl{GetUniformBlockIndex} | | +@fn_gl{GetUniformBlockIndex} | @ref AbstractShaderProgram::uniformBlockIndex() @fn_gl{GetUniformIndices} | | @fn_gl{GetUniformLocation} | @ref AbstractShaderProgram::uniformLocation() @fn_gl{GetUniformSubroutine} | | @@ -264,7 +264,7 @@ OpenGL function | Matching API @fn_gl_extension{MakeTextureHandleNonResident,ARB,bindless_texture} | | @fn_gl{MapBuffer}, \n `glMapNamedBuffer()`, \n @fn_gl_extension{MapNamedBuffer,EXT,direct_state_access}, \n @fn_gl{MapBufferRange}, \n `glMapNamedBufferRange()`, \n @fn_gl_extension{MapNamedBufferRange,EXT,direct_state_access}, \n @fn_gl{UnmapBuffer}, \n `glUnmapNamedBuffer()`, \n @fn_gl_extension{UnmapNamedBuffer,EXT,direct_state_access} | @ref Buffer::map(), @ref Buffer::unmap() @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub}, @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub} | @ref Buffer::mapSub(), @ref Buffer::unmapSub() -@fn_gl{MemoryBarrier}, \n `glMemoryBarrierByRegion()` | | +@fn_gl{MemoryBarrier}, \n `glMemoryBarrierByRegion()` | @ref Renderer::setMemoryBarrier(), \n @ref Renderer::setMemoryBarrierByRegion() @fn_gl{MinSampleShading} | | @fn_gl{MultiDrawArrays}, \n @fn_gl{MultiDrawElements}, \n @fn_gl{MultiDrawElementsBaseVertex} | @ref MeshView::draw(AbstractShaderProgram&, std::initializer_list>) @fn_gl_extension{MultiDrawArraysIndirectCount,ARB,indirect_parameters}, \n @fn_gl_extension{MultiDrawElementsIndirectCount,ARB,indirect_parameters} | | @@ -339,7 +339,7 @@ OpenGL function | Matching API @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{TexStorage2DMultisample}, \n `glTextureStorage2DMultisample()`, \n @fn_gl_extension{TextureStorage2DMultisample,EXT,direct_state_access}, \n @fn_gl{TexStorage3DMultisample}, \n `glTextureStorage3DMultisample()`, \n @fn_gl_extension{TextureStorage3DMultisample,EXT,direct_state_access} | @ref MultisampleTexture::setStorage() @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} | @ref Renderer::setTextureBarrier() @fn_gl{TextureView} | | @fn_gl{TransformFeedbackBufferBase}, \n @fn_gl{TransformFeedbackBufferRange} | @ref TransformFeedback::attachBuffer(), \n @ref TransformFeedback::attachBuffers() @fn_gl{TransformFeedbackVaryings} | @ref AbstractShaderProgram::setTransformFeedbackOutputs() @@ -350,7 +350,7 @@ OpenGL function | Matching API --------------------------------------- | ------------ @fn_gl{Uniform}, \n @fn_gl{ProgramUniform}, \n @fn_gl_extension{ProgramUniform,EXT,direct_state_access} | @ref AbstractShaderProgram::setUniform() @fn_gl_extension{UniformHandle,ARB,bindless_texture}, \n @fn_gl_extension{ProgramUniformHandle,ARB,bindless_texture} | | -@fn_gl{UniformBlockBinding} | | +@fn_gl{UniformBlockBinding} | @ref AbstractShaderProgram::setUniformBlockBinding() @fn_gl{UniformSubroutines} | | @fn_gl{UseProgram} | @ref Mesh::draw(), @ref MeshView::draw() @fn_gl{UseProgramStages} | | @@ -431,9 +431,9 @@ OpenGL function | Matching API @def_gl{MAX_COMPUTE_SHARED_MEMORY_SIZE} | @ref AbstractShaderProgram::maxComputeSharedMemorySize() @def_gl_extension{MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS,ARB,compute_variable_group_size} | | @def_gl_extension{MAX_COMPUTE_VARIABLE_GROUP_SIZE,ARB,compute_variable_group_size} | | -@def_gl{MAX_COMPUTE_WORK_GROUP_COUNT} | | +@def_gl{MAX_COMPUTE_WORK_GROUP_COUNT} | @ref AbstractShaderProgram::maxComputeWorkGroupCount() @def_gl{MAX_COMPUTE_WORK_GROUP_INVOCATIONS} | @ref AbstractShaderProgram::maxComputeWorkGroupInvocations() -@def_gl{MAX_COMPUTE_WORK_GROUP_SIZE} | | +@def_gl{MAX_COMPUTE_WORK_GROUP_SIZE} | @ref AbstractShaderProgram::maxComputeWorkGroupSize() @def_gl{MAX_CULL_DISTANCES} | | @def_gl{MAX_DEBUG_LOGGED_MESSAGES} | @ref DebugOutput::maxLoggedMessages() @def_gl{MAX_DEBUG_MESSAGE_LENGTH} | @ref DebugOutput::maxMessageLength() @@ -463,7 +463,7 @@ OpenGL function | Matching API @def_gl_extension{MAX_SPARSE_3D_TEXTURE_SIZE,ARB,sparse_texture} | | @def_gl_extension{MAX_SPARSE_ARRAY_TEXTURE_LAYERS,ARB,sparse_texture} | | @def_gl{MAX_TESS_GEN_LEVEL} | | -@def_gl{MAX_TESS_PATCH_COMPONENTS} +@def_gl{MAX_TESS_PATCH_COMPONENTS} | | @def_gl{MAX_TEXTURE_BUFFER_SIZE} | @ref BufferTexture::maxSize() @def_gl_extension{MAX_TEXTURE_MAX_ANISOTROPY,EXT,texture_filter_anisotropic} | @ref Sampler::maxMaxAnisotropy() @def_gl{MAX_TEXTURE_LOD_BIAS} | @ref AbstractTexture::maxLodBias() @@ -483,6 +483,7 @@ OpenGL function | Matching API @def_gl{MIN_FRAGMENT_INTERPOLATION_OFFSET}, \n @def_gl{MAX_FRAGMENT_INTERPOLATION_OFFSET} | | @def_gl{MIN_MAP_BUFFER_ALIGNMENT} | @ref Buffer::minMapAlignment() @def_gl{MIN_PROGRAM_TEXEL_OFFSET}, \n @def_gl{MAX_PROGRAM_TEXEL_OFFSET} | @ref AbstractShaderProgram::minTexelOffset(), \n @ref AbstractShaderProgram::maxTexelOffset() +@def_gl{MIN_PROGRAM_TEXTURE_GATHER_OFFSET}, \n @def_gl{MAX_PROGRAM_TEXTURE_GATHER_OFFSET} | | @def_gl{MIN_SAMPLE_SHADING_VALUE} | | @def_gl{NUM_EXTENSIONS} | @ref Context::supportedExtensions() @def_gl{NUM_PROGRAM_BINARY_FORMATS}, \n @def_gl{PROGRAM_BINARY_FORMATS} | | diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 94480a052..2e90d25e8 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -80,7 +80,7 @@ GLSL 1.40 | done @extension{ARB,texture_rectangle} | done @extension{ARB,draw_instanced} | done @extension{ARB,texture_buffer_object} | done -@extension{ARB,uniform_buffer_object} | missing uniform block binding +@extension{ARB,uniform_buffer_object} | done except for data layout queries @extension{ARB,copy_buffer} | done @extension{EXT,texture_snorm} | done @extension{NV,primitive_restart} | | @@ -161,7 +161,7 @@ GLSL 4.20 | done @extension{ARB,internalformat_query} | | @extension{ARB,map_buffer_alignment} | done @extension{ARB,shader_atomic_counters} | done -@extension{ARB,shader_image_load_store} | | +@extension{ARB,shader_image_load_store} | done @extension{ARB,shading_language_packing} | done (shading language only) @extension{ARB,texture_storage} | done @@ -173,19 +173,19 @@ GLSL 4.30 | done @extension{ARB,arrays_of_arrays} | done (shading language only) @extension{ARB,ES3_compatibility} | only conservative sample query and compression formats @extension{ARB,clear_buffer_object} | | -@extension{ARB,compute_shader} | | +@extension{ARB,compute_shader} | done except for indirect dispatch @extension{ARB,copy_image} | | @extension{KHR,debug} | missing log retrieval, sync, pipeline and sampler label @extension{ARB,explicit_uniform_location} | done @extension{ARB,fragment_layer_viewport} | done (shading language only) @extension{ARB,framebuffer_no_attachments} | | -@extension{ARB,internalformat_query2} | | +@extension{ARB,internalformat_query2} | only compressed texture block queries @extension{ARB,invalidate_subdata} | done @extension{ARB,multi_draw_indirect} | | @extension{ARB,program_interface_query} | | @extension{ARB,robust_buffer_access_behavior} | done (nothing to do) @extension{ARB,shader_image_size} | done (shading language only) -@extension{ARB,shader_storage_buffer_object} | only limit queries +@extension{ARB,shader_storage_buffer_object} | missing (unneeded) block binding @extension{ARB,stencil_texturing} | done @extension{ARB,texture_buffer_range} | done @extension{ARB,texture_query_levels} | done (shading language only) @@ -205,7 +205,7 @@ GLSL 4.40 | done @extension{ARB,buffer_storage} | | @extension{ARB,clear_texture} | | @extension{ARB,enhanced_layouts} | done (shading language only) -@extension{ARB,multi_bind} | only texture and buffer binding +@extension{ARB,multi_bind} | missing sampler and vertex buffer binding @extension{ARB,query_buffer_object} | | @extension{ARB,texture_mirror_clamp_to_edge} | done @extension{ARB,texture_stencil8} | done @@ -216,15 +216,15 @@ GLSL 4.40 | done Extension | Status ------------------------------------------- | ------ GLSL 4.50 | done -@extension{ARB,ES3_1_compatibility} | | +@extension{ARB,ES3_1_compatibility} | done @extension{ARB,clip_control} | | @extension{ARB,conditional_render_inverted} | done @extension{ARB,cull_distance} | | @extension{ARB,derivative_control} | done (shading language only) @extension{ARB,direct_state_access} | done for implemented functionality (except VAOs) -@extension{ARB,get_texture_sub_image} | missing compressed texture queries +@extension{ARB,get_texture_sub_image} | done @extension{ARB,shader_texture_image_samples} | done (shading language only) -@extension{ARB,texture_barrier} | | +@extension{ARB,texture_barrier} | done @extension{KHR,context_flush_control} | | @extension{KHR,robustness} | | @@ -248,6 +248,7 @@ Extension | Status @extension{ARB,transform_feedback_overflow_query} | | @extension{KHR,blend_equation_advanced} | done @extension3{KHR,blend_equation_advanced_coherent,blend_equation_advanced} | done +@extension{KHR,no_error} | done @subsection opengl-support-extensions-vendor Vendor OpenGL extensions @@ -337,7 +338,7 @@ Extension | Status @es_extension{OES,required_internalformat} | done (desktop-compatible subset) @es_extension{OES,surfaceless_context} | done -@subsection opengl-support-es-extensions OpenGL ES extensions to match desktop functionality +@subsection opengl-support-es-extensions OpenGL ES extensions @todo @es_extension{NV,non_square_matrices} @todo Support also IMG_multisampled_render_to_texture? It has different enum @@ -347,6 +348,8 @@ Extension | Status ------------------------------------------- | ------ @es_extension{ANDROID,extension_pack_es31a} | done (nothing to do) @es_extension{APPLE,texture_format_BGRA8888} | done +@es_extension{ARM,shader_framebuffer_fetch} | missing renderer setup and limit query +@es_extension{ARM,shader_framebuffer_fetch_depth_stencil} | done (shading language only) @es_extension{CHROMIUM,map_sub} (NaCl only) | only buffer mapping @es_extension{EXT,texture_filter_anisotropic} | done @es_extension{EXT,texture_format_BGRA8888} | done @@ -357,6 +360,7 @@ Extension | Status @es_extension{EXT,separate_shader_objects} | only direct uniform binding @es_extension{EXT,multisampled_render_to_texture} | only renderbuffer storage @es_extension{EXT,robustness} | done +@es_extension{EXT,shader_framebuffer_fetch} | missing limit query @es_extension{EXT,disjoint_timer_query} | only time elapsed query @es_extension{EXT,texture_sRGB_decode} | done @es_extension{EXT,sRGB_write_control} | done @@ -380,6 +384,7 @@ Extension | Status @es_extension{KHR,robustness} | | @es_extension{KHR,robust_buffer_access_behavior} | done (nothing to do) @es_extension{KHR,context_flush_control} | | +@es_extension2{KHR,no_error,no_error} | done @es_extension2{NV,read_buffer_front,NV_read_buffer} | done @es_extension2{NV,read_depth,NV_read_depth_stencil} | done @es_extension2{NV,read_stencil,NV_read_depth_stencil} | done diff --git a/doc/opengl-wrapping.dox b/doc/opengl-wrapping.dox index 27b2b2f0b..89baca38d 100644 --- a/doc/opengl-wrapping.dox +++ b/doc/opengl-wrapping.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/opengl.dox b/doc/opengl.dox index c4feef3f7..6a8053126 100644 --- a/doc/opengl.dox +++ b/doc/opengl.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/platform.dox b/doc/platform.dox index cd5a86bd5..bc58a29b4 100644 --- a/doc/platform.dox +++ b/doc/platform.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -182,15 +182,12 @@ MAGNUM_WINDOWLESSAPPLICATION_MAIN(MyApplication) @section platform-compilation Compilation with CMake -Barebone compilation consists just of finding Magnum library with required -`*Application` component, adding Magnum's `${MAGNUM_INCLUDE_DIRS}` and -application-specific `${MAGNUM_SDL2APPLICATION_INCLUDE_DIRS}` to include path, -compilation of the executable and linking `${MAGNUM_LIBRARIES}` and -`${MAGNUM_SDL2APPLICATION_LIBRARIES}` to it. +Barebone compilation consists just of finding Magnum library with, for example, +`Sdl2Application` component, compilation of the executable and linking +`Magnum::Magnum` and `Magnum::Sdl2Application` to it. -Again, to simplify porting, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` -and `${MAGNUM_APPLICATION_LIBRARIES}` aliases (or `${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}`, -`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` for windowless applications), but +Again, to simplify porting, you can also use generic `Magnum::Application` +aliases (or `Magnum::WindowlessApplication` for windowless applications), but only if only one application (windowless application) component is requested to avoid ambiguity. Changing the build script to use different toolkit is then matter of replacing only the requested `*Application` component (and one @@ -199,12 +196,10 @@ matter of replacing only the requested `*Application` component (and one @code find_package(Magnum REQUIRED Sdl2Application) -include_directories(${MAGNUM_INCLUDE_DIRS} ${MAGNUM_APPLICATION_INCLUDE_DIRS}) - add_executable(myapplication MyApplication.cpp) target_link_libraries(myapplication - ${MAGNUM_LIBRARIES} - ${MAGNUM_APPLICATION_LIBRARIES}) + Magnum::Magnum + Magnum::Application) @endcode @section platform-configuration Specifying configuration @@ -311,20 +306,17 @@ Systems not listed here (such as Emscripten or NaCl) don't need any `Context` library, because dynamic function pointer loading is not available on these. For example, when you create the OpenGL context using GLX, you need to find -`GlxContext` component, include `${MAGNUM_GLXCONTEXT_INCLUDE_DIRS}` and link to -`${MAGNUM_GLXCONTEXT_LIBRARIES}`. Similarly to application libraries, you can -also use generic `${MAGNUM_CONTEXT_INCLUDE_DIRS}` and `${MAGNUM_CONTEXT_LIBRARIES}`, +`GlxContext` component, and link to `Magnum::GlxContext` target. Similarly to +application libraries, you can also use generic `Magnum::Context` target, providing you requested only one `*Context` component in the `find_package()` call. Complete example: @code find_package(Magnum REQUIRED GlxContext) -include_directories(${MAGNUM_INCLUDE_DIRS} ${MAGNUM_CONTEXT_INCLUDE_DIRS}) - add_executable(myapplication MyCustomApplication.cpp) target_link_libraries(myapplication - ${MAGNUM_LIBRARIES} - ${MAGNUM_CONTEXT_LIBRARIES}) + Magnum::Magnum + Magnum::Context) @endcode - Next page: @ref types diff --git a/doc/plugins.dox b/doc/plugins.dox index eeb7f8c9f..4a8432cd5 100644 --- a/doc/plugins.dox +++ b/doc/plugins.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -182,7 +182,7 @@ and @ref cmake-plugins for additional information. find_package(Magnum REQUIRED TgaImporter) add_executable(MyApp ...) -target_link_libraries(MyApp ... ${MAGNUM_TGAIMPORTER_LIBRARIES}) +target_link_libraries(MyApp ... Magnum::TgaImporter) @endcode The only user-visible behavioral change will be that diff --git a/doc/portability.dox b/doc/portability.dox index c9a2dc1a4..64abeb97b 100644 --- a/doc/portability.dox +++ b/doc/portability.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -223,12 +223,10 @@ else() find_package(Magnum REQUIRED XEglApplication) endif() -include_directories(${MAGNUM_INCLUDE_DIRS} ${MAGNUM_APPLICATION_INCLUDE_DIRS}) - add_executable(myapplication MyApplication.cpp) target_link_libraries(myapplication - ${MAGNUM_LIBRARIES} - ${MAGNUM_APPLICATION_LIBRARIES}) + Magnum::Magnum + Magnum::Application) @endcode */ diff --git a/doc/scenegraph.dox b/doc/scenegraph.dox index aa0a316ea..c667e5a3c 100644 --- a/doc/scenegraph.dox +++ b/doc/scenegraph.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/shaders.dox b/doc/shaders.dox index 5b72d3d97..6b15a310f 100644 --- a/doc/shaders.dox +++ b/doc/shaders.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/shapes.dox b/doc/shapes.dox index 4b9c79bba..ac9dc37b3 100644 --- a/doc/shapes.dox +++ b/doc/shapes.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/tips.dox b/doc/tips.dox index 0620d72f8..d8dde0d7f 100644 --- a/doc/tips.dox +++ b/doc/tips.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/transformations.dox b/doc/transformations.dox index 9a20b74c2..857e3e44b 100644 --- a/doc/transformations.dox +++ b/doc/transformations.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/troubleshooting.dox b/doc/troubleshooting.dox index b79119c9b..bb9b69b92 100644 --- a/doc/troubleshooting.dox +++ b/doc/troubleshooting.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/doc/types.dox b/doc/types.dox index e8c937491..c510c8b2c 100644 --- a/doc/types.dox +++ b/doc/types.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -87,7 +87,8 @@ underlying type. | @ref Matrix4x3 or @ref Matrix4x3d | `mat4x3` or `dmat4x3` | Any super- or sub-class of the same size and underlying type can be used -equivalently (e.g. @ref Math::Vector or @ref Color3 instead of @ref Vector3). +equivalently (e.g. @ref Math::Vector "Math::Vector" or @ref Color3 +instead of @ref Vector3). @section types-binary Binary representation @@ -116,8 +117,11 @@ usability impact in practice. These classes are *not* implicitly constructible or convertible from/to @ref Float or @ref Double, you have to either construct/convert them explicitly -or use custom `_degf`/`_deg` and `_radf`/`_rad` literals: +or use custom `_degf`/`_deg` and `_radf`/`_rad` literals that are provided in +the @ref Math::Literals namespace: @code +using namespace Math::Literals; + //Deg a = 60.0f // error, no implicit conversion from Float Deg a = 60.0_degf; // okay diff --git a/doc/utilities.dox b/doc/utilities.dox index 543adcc5a..8533fa386 100644 --- a/doc/utilities.dox +++ b/doc/utilities.dox @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 596a7fcdf..f06821645 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/modules/FindCorrade.cmake b/modules/FindCorrade.cmake index 486684230..c4af7f726 100644 --- a/modules/FindCorrade.cmake +++ b/modules/FindCorrade.cmake @@ -1,131 +1,203 @@ -# - Find Corrade -# -# Basic usage: -# find_package(Corrade [REQUIRED]) -# This module tries to find Corrade library and then defines: -# CORRADE_FOUND - True if Corrade is found -# CORRADE_INCLUDE_DIRS - Corrade include directories -# CORRADE_INTERCONNECT_LIBRARIES - Interconnect library and dependent -# libraries -# CORRADE_UTILITY_LIBRARIES - Utility library and dependent -# libraries -# CORRADE_PLUGINMANAGER_LIBRARIES - PluginManager library and dependent -# libraries -# CORRADE_TESTSUITE_LIBRARIES - TestSuite library and dependent -# libraries -# CORRADE_RC_EXECUTABLE - Resource compiler executable -# CORRADE_LIB_SUFFIX_MODULE - Path to CorradeLibSuffix.cmake module +#.rst: +# Find Corrade +# ------------ +# +# Finds the Corrade library. Basic usage:: +# +# find_package(Corrade REQUIRED) +# +# This module tries to find the base Corrade library and then defines the +# following: +# +# Corrade_FOUND - Whether the base library was found +# CORRADE_LIB_SUFFIX_MODULE - Path to CorradeLibSuffix.cmake module +# +# This command will try to find only the base library, not the optional +# components, which are: +# +# Containers - Containers library +# PluginManager - PluginManager library +# TestSuite - TestSuite library +# Utility - Utility library +# rc - corrade-rc executable +# +# Example usage with specifying additional components is:: +# +# find_package(Corrade REQUIRED Utility TestSuite) +# +# For each component is then defined: +# +# Corrade_*_FOUND - Whether the component was found +# Corrade::* - Component imported target +# # The package is found if either debug or release version of each library is # found. If both debug and release libraries are found, proper version is # chosen based on actual build configuration of the project (i.e. Debug build # is linked to debug libraries, Release build to release libraries). # -# On multi-configuration build systems (such as Visual Studio or XCode) the -# preprocessor variable CORRADE_IS_DEBUG_BUILD is defined if given build -# configuration is Debug (not Corrade itself, but build configuration of the -# project using it). Useful e.g. for selecting proper plugin directory. On -# single-configuration build systems (such as Makefiles) this information is -# not needed and thus the variable is not defined in any case. +# Corrade conditionally defines ``CORRADE_IS_DEBUG_BUILD`` preprocessor +# variable in case build configuration is ``Debug`` (not Corrade itself, but +# build configuration of the project using it). Useful e.g. for selecting +# proper plugin directory. +# +# Corrade defines the following custom target properties: # -# Corrade configures the compiler to use C++11 standard (if it is not already -# configured to do so). Additionally you can use CORRADE_CXX_FLAGS to enable -# additional pedantic set of warnings and enable hidden visibility by default. +# CORRADE_CXX_STANDARD - C++ standard to require when compiling given +# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains +# particular standard setting flag or if given target contains +# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17. +# INTERFACE_CORRADE_CXX_STANDARD - C++ standard to require when using given +# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains +# particular standard setting flag or if given target contains +# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17. +# CORRADE_USE_PEDANTIC_FLAGS - Enable additional compiler/linker flags. +# Boolean. +# +# These properties are inherited from directory properties, meaning that if you +# set them on directories, they get implicitly set on all targets in given +# directory (with a possibility to do target-specific overrides). All Corrade +# libraries have the :prop_tgt:`INTERFACE_CORRADE_CXX_STANDARD` property set to +# 11, meaning that you will always have at least C++11 enabled once you link to +# any Corrade library. # # Features of found Corrade library are exposed in these variables: -# CORRADE_GCC47_COMPATIBILITY - Defined if compiled with compatibility -# mode for GCC 4.7 -# CORRADE_MSVC2015_COMPATIBILITY - Defined if compiled with compatibility +# +# CORRADE_GCC47_COMPATIBILITY - Defined if compiled with compatibility mode +# for GCC 4.7 +# CORRADE_MSVC2015_COMPATIBILITY - Defined if compiled with compatibility # mode for MSVC 2015 # CORRADE_BUILD_DEPRECATED - Defined if compiled with deprecated APIs # included -# CORRADE_BUILD_STATIC - Defined if compiled as static libraries +# CORRADE_BUILD_STATIC - Defined if compiled as static libraries. +# Default are shared libraries. # CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor # (Linux, BSD, OS X) -# CORRADE_TARGET_APPLE - Defined if compiled for OS X +# CORRADE_TARGET_APPLE - Defined if compiled for Apple platforms +# CORRADE_TARGET_IOS - Defined if compiled for iOS # CORRADE_TARGET_WINDOWS - Defined if compiled for Windows # CORRADE_TARGET_WINDOWS_RT - Defined if compiled for Windows RT -# CORRADE_TARGET_NACL - Defined if compiled for Google Chrome -# Native Client -# CORRADE_TARGET_NACL_NEWLIB - Defined if compiled for Google Chrome -# Native Client with `newlib` toolchain -# CORRADE_TARGET_NACL_GLIBC - Defined if compiled for Google Chrome -# Native Client with `glibc` toolchain +# CORRADE_TARGET_NACL - Defined if compiled for Google Chrome Native +# Client +# CORRADE_TARGET_NACL_NEWLIB - Defined if compiled for Google Chrome Native +# Client with `newlib` toolchain +# CORRADE_TARGET_NACL_GLIBC - Defined if compiled for Google Chrome Native +# Client with `glibc` toolchain # CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten # CORRADE_TARGET_ANDROID - Defined if compiled for Android +# CORRADE_TESTSUITE_TARGET_XCTEST - Defined if TestSuite is targetting Xcode +# XCTest +# CORRADE_UTILITY_USE_ANSI_COLORS - Defined if ANSI escape sequences are used +# for colored output with Utility::Debug on Windows +# +# Additionally these variables are defined for internal usage: +# +# CORRADE_INCLUDE_DIR - Root include dir +# CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found +# CORRADE_*_LIBRARY_RELEASE - Release version of given library, if found +# CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included +# automatically) +# CORRADE_TESTSUITE_XCTEST_RUNNER - Path to XCTestRunner.mm.in file +# CORRADE_PEDANTIC_COMPILER_OPTIONS - List of pedantic compiler options used +# for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` enabled +# CORRADE_PEDANTIC_COMPILER_DEFINITIONS - List of pedantic compiler +# definitions used for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` +# enabled +# +# Workflows without :prop_tgt:`IMPORTED` targets are deprecated and the +# following variables are included just for backwards compatibility and only if +# :variable:`CORRADE_BUILD_DEPRECATED` is enabled: +# +# CORRADE_*_LIBRARIES - Expands to ``Corrade::*`` target. Use +# ``Corrade::*`` target directly instead. +# CORRADE_CXX_FLAGS - Pedantic compile flags. Use +# :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` property instead. # # Corrade provides these macros and functions: # +# .. command:: corrade_add_test +# +# Add unit test using Corrade's TestSuite:: +# +# corrade_add_test( +# ... +# [LIBRARIES ...]) # -# Add unit test using Corrade's TestSuite. -# corrade_add_test(test_name -# sources... -# [LIBRARIES libraries...]) # Test name is also executable name. You can also specify libraries to link -# with instead of using target_link_libraries(). CORRADE_TESTSUITE_LIBRARIES -# are linked automatically to each test. Note that the enable_testing() -# function must be called explicitly. +# with instead of using :command:`target_link_libraries()`. +# ``Corrade::TestSuite`` target is linked automatically to each test. Note +# that the :command:`enable_testing()` function must be called explicitly. +# +# Unless :variable:`CORRADE_TESTSUITE_TARGET_XCTEST` is set, test cases on iOS +# targets are created as bundles with bundle identifier set to CMake project +# name by default. Use the cache variable :variable:`CORRADE_TESTSUITE_BUNDLE_IDENTIFIER_PREFIX` +# to change it to something else. +# +# .. command:: corrade_add_resource # +# Compile data resources into application binary:: # -# Compile data resources into application binary. -# corrade_add_resource(name resources.conf) -# Depends on corrade-rc, which is part of Corrade utilities. This command +# corrade_add_resource( ) +# +# Depends on ``Corrade::rc``, which is part of Corrade utilities. This command # generates resource data using given configuration file in current build # directory. Argument name is name under which the resources can be explicitly -# loaded. Variable `name` contains compiled resource filename, which is then -# used for compiling library / executable. Example usage: +# loaded. Variable ```` contains compiled resource filename, which is +# then used for compiling library / executable. Example usage:: +# # corrade_add_resource(app_resources resources.conf) # add_executable(app source1 source2 ... ${app_resources}) # -# Add dynamic plugin. -# corrade_add_plugin(plugin_name debug_install_dir release_install_dir -# metadata_file sources...) -# The macro adds preprocessor directive CORRADE_DYNAMIC_PLUGIN. Additional -# libraries can be linked in via target_link_libraries(plugin_name ...). If -# debug_install_dir is set to CMAKE_CURRENT_BINARY_DIR (e.g. for testing -# purposes), the files are copied directly, without the need to perform install -# step. Note that the files are actually put into configuration-based -# subdirectory, i.e. ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}. See -# documentation of CMAKE_CFG_INTDIR variable for more information. +# .. command:: corrade_add_plugin # +# Add dynamic plugin:: # -# Add static plugin. -# corrade_add_static_plugin(plugin_name install_dir metadata_file -# sources...) -# The macro adds preprocessor directive CORRADE_STATIC_PLUGIN. Additional -# libraries can be linked in via target_link_libraries(plugin_name ...). If -# install_dir is set to CMAKE_CURRENT_BINARY_DIR (e.g. for testing purposes), -# no installation rules are added. +# corrade_add_plugin( +# +# +# ...) # -# Note that plugins built in debug configuration (e.g. with CMAKE_BUILD_TYPE -# set to Debug) have "-d" suffix to make it possible to have both debug and -# release plugins installed alongside each other. +# The macro adds preprocessor directive ``CORRADE_DYNAMIC_PLUGIN``. Additional +# libraries can be linked in via :command:`target_link_libraries(plugin_name ...) `. +# If ```` is set to :variable:`CMAKE_CURRENT_BINARY_DIR` +# (e.g. for testing purposes), the files are copied directly, without the need +# to perform install step. Note that the files are actually put into +# configuration-based subdirectory, i.e. ``${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}``. +# See documentation of :variable:`CMAKE_CFG_INTDIR` variable for more +# information. # +# .. command:: corrade_add_static_plugin # -# Find corresponding DLLs for library files. -# corrade_find_dlls_for_libs( libs...) -# Available only on Windows, for all *.lib files tries to find corresponding -# DLL file. Useful for bundling dependencies for e.g. WinRT packages. +# Add static plugin:: # +# corrade_add_static_plugin( +# +# +# ...) # -# Additionally these variables are defined for internal usage: -# CORRADE_INCLUDE_DIR - Root include dir -# CORRADE_INTERCONNECT_LIBRARY - Interconnect library (w/o -# dependencies) -# CORRADE_UTILITY_LIBRARY - Utility library (w/o dependencies) -# CORRADE_PLUGINMANAGER_LIBRARY - Plugin manager library (w/o -# dependencies) -# CORRADE_TESTSUITE_LIBRARY - TestSuite library (w/o dependencies) -# CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found -# CORRADE_*_LIBRARY_RELEASE - Release version of given library, if -# found -# CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included -# automatically) +# The macro adds preprocessor directive ``CORRADE_STATIC_PLUGIN``. Additional +# libraries can be linked in via :command:`target_link_libraries(plugin_name ...) `. +# If ```` is set to :variable:`CMAKE_CURRENT_BINARY_DIR` (e.g. for +# testing purposes), no installation rules are added. +# +# Note that plugins built in debug configuration (e.g. with :variable:`CMAKE_BUILD_TYPE` +# set to ``Debug``) have ``"-d"`` suffix to make it possible to have both debug +# and release plugins installed alongside each other. +# +# .. command:: corrade_find_dlls_for_libs +# +# Find corresponding DLLs for library files:: +# +# corrade_find_dlls_for_libs( ...) +# +# Available only on Windows, for all ``*.lib`` files tries to find +# corresponding DLL file. Useful for bundling dependencies for e.g. WinRT +# packages. # # # This file is part of Corrade. # -# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -147,62 +219,26 @@ # DEALINGS IN THE SOFTWARE. # -# Libraries -foreach(_component Interconnect Utility PluginManager TestSuite) - string(TOUPPER ${_component} _COMPONENT) - - # Try to find both debug and release version - find_library(CORRADE_${_COMPONENT}_LIBRARY_DEBUG Corrade${_component}-d) - find_library(CORRADE_${_COMPONENT}_LIBRARY_RELEASE Corrade${_component}) - - # Set the _LIBRARY variable based on what was found - if(CORRADE_${_COMPONENT}_LIBRARY_DEBUG AND CORRADE_${_COMPONENT}_LIBRARY_RELEASE) - set(CORRADE_${_COMPONENT}_LIBRARY - debug ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG} - optimized ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE}) - elseif(CORRADE_${_COMPONENT}_LIBRARY_DEBUG) - set(CORRADE_${_COMPONENT}_LIBRARY ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG}) - elseif(CORRADE_${_COMPONENT}_LIBRARY_RELEASE) - set(CORRADE_${_COMPONENT}_LIBRARY ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE}) - endif() - - mark_as_advanced(CORRADE_${_COMPONENT}_LIBRARY_DEBUG - CORRADE_${_COMPONENT}_LIBRARY_RELEASE - CORRADE_${_COMPONENT}_LIBRARY) -endforeach() - -# RC executable -find_program(CORRADE_RC_EXECUTABLE corrade-rc) - -# Include dir +# Root include dir find_path(CORRADE_INCLUDE_DIR - NAMES Corrade/PluginManager Corrade/Utility) - -# CMake module dir -find_path(_CORRADE_MODULE_DIR - NAMES UseCorrade.cmake CorradeLibSuffix.cmake - PATH_SUFFIXES share/cmake/Corrade) + NAMES Corrade/Corrade.h) +mark_as_advanced(CORRADE_INCLUDE_DIR) # Configuration file find_file(_CORRADE_CONFIGURE_FILE configure.h HINTS ${CORRADE_INCLUDE_DIR}/Corrade/) +mark_as_advanced(_CORRADE_CONFIGURE_FILE) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Corrade DEFAULT_MSG - CORRADE_UTILITY_LIBRARY - CORRADE_INTERCONNECT_LIBRARY - CORRADE_PLUGINMANAGER_LIBRARY - CORRADE_TESTSUITE_LIBRARY - CORRADE_INCLUDE_DIR - CORRADE_RC_EXECUTABLE - _CORRADE_MODULE_DIR - _CORRADE_CONFIGURE_FILE) - -if(NOT CORRADE_FOUND) - return() +# We need to open configure.h file from CORRADE_INCLUDE_DIR before we check for +# the components. Bail out with proper error message if it wasn't found. The +# complete check with all components is further below. +if(NOT CORRADE_INCLUDE_DIR) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Corrade + REQUIRED_VARS CORRADE_INCLUDE_DIR _CORRADE_CONFIGURE_FILE) endif() -# Read flags from fonfiguration +# Read flags from configuration file(READ ${_CORRADE_CONFIGURE_FILE} _corradeConfigure) set(_corradeFlags GCC47_COMPATIBILITY @@ -211,13 +247,16 @@ set(_corradeFlags BUILD_STATIC TARGET_UNIX TARGET_APPLE + TARGET_IOS TARGET_WINDOWS TARGET_WINDOWS_RT TARGET_NACL TARGET_NACL_NEWLIB TARGET_NACL_GLIBC TARGET_EMSCRIPTEN - TARGET_ANDROID) + TARGET_ANDROID + TESTSUITE_TARGET_XCTEST + UTILITY_USE_ANSI_COLORS) foreach(_corradeFlag ${_corradeFlags}) string(FIND "${_corradeConfigure}" "#define CORRADE_${_corradeFlag}" _corrade_${_corradeFlag}) if(NOT _corrade_${_corradeFlag} EQUAL -1) @@ -225,34 +264,202 @@ foreach(_corradeFlag ${_corradeFlags}) endif() endforeach() -set(CORRADE_INCLUDE_DIRS ${CORRADE_INCLUDE_DIR}) -set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARY}) -set(CORRADE_INTERCONNECT_LIBRARIES ${CORRADE_INTERCONNECT_LIBRARY} ${CORRADE_UTILITY_LIBRARIES}) -set(CORRADE_PLUGINMANAGER_LIBRARIES ${CORRADE_PLUGINMANAGER_LIBRARY} ${CORRADE_UTILITY_LIBRARIES}) -set(CORRADE_TESTSUITE_LIBRARIES ${CORRADE_TESTSUITE_LIBRARY} ${CORRADE_UTILITY_LIBRARIES}) +# XCTest runner file +if(CORRADE_TESTSUITE_TARGET_XCTEST) + find_file(CORRADE_TESTSUITE_XCTEST_RUNNER XCTestRunner.mm.in + PATH_SUFFIXES share/corrade/TestSuite) + set(CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED CORRADE_TESTSUITE_XCTEST_RUNNER) +endif() + +# CMake module dir +find_path(_CORRADE_MODULE_DIR + NAMES UseCorrade.cmake CorradeLibSuffix.cmake + PATH_SUFFIXES share/cmake/Corrade) +mark_as_advanced(_CORRADE_MODULE_DIR) + set(CORRADE_USE_MODULE ${_CORRADE_MODULE_DIR}/UseCorrade.cmake) set(CORRADE_LIB_SUFFIX_MODULE ${_CORRADE_MODULE_DIR}/CorradeLibSuffix.cmake) -# If the configure file is somewhere else than in root include dir (e.g. when -# using CMake subproject), we need to include that dir too -if(NOT ${CORRADE_INCLUDE_DIR}/Corrade/configure.h STREQUAL ${_CORRADE_CONFIGURE_FILE}) - # Go two levels up - get_filename_component(_CORRADE_CONFIGURE_FILE_INCLUDE_DIR ${_CORRADE_CONFIGURE_FILE} DIRECTORY) - get_filename_component(_CORRADE_CONFIGURE_FILE_INCLUDE_DIR ${_CORRADE_CONFIGURE_FILE_INCLUDE_DIR} DIRECTORY) - list(APPEND CORRADE_INCLUDE_DIRS ${_CORRADE_CONFIGURE_FILE_INCLUDE_DIR}) -endif() +# Ensure that all inter-component dependencies are specified as well +foreach(_component ${Corrade_FIND_COMPONENTS}) + string(TOUPPER ${_component} _COMPONENT) -# At least static build needs this -if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL_GLIBC) - set(CORRADE_PLUGINMANAGER_LIBRARIES ${CORRADE_PLUGINMANAGER_LIBRARIES} ${CMAKE_DL_LIBS}) -endif() + if(_component STREQUAL Containers) + set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility) + elseif(_component STREQUAL Interconnect) + set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility) + elseif(_component STREQUAL PluginManager) + set(_CORRADE_${_COMPONENT}_DEPENDENCIES Containers Utility rc) + elseif(_component STREQUAL TestSuite) + set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility) + elseif(_component STREQUAL Utility) + set(_CORRADE_${_COMPONENT}_DEPENDENCIES Containers rc) + endif() + + # Mark the dependencies as required if the component is also required + if(Corrade_FIND_REQUIRED_${_component}) + foreach(_dependency ${_CORRADE_${_COMPONENT}_DEPENDENCIES}) + set(Corrade_FIND_REQUIRED_${_dependency} TRUE) + endforeach() + endif() -# AndroidLogStreamBuffer class needs to be linked to log library -if(CORRADE_TARGET_ANDROID) - set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARIES} log) + list(APPEND _CORRADE_ADDITIONAL_COMPONENTS ${_CORRADE_${_COMPONENT}_DEPENDENCIES}) +endforeach() + +# Join the lists, remove duplicate components +if(_CORRADE_ADDITIONAL_COMPONENTS) + list(INSERT Corrade_FIND_COMPONENTS 0 ${_CORRADE_ADDITIONAL_COMPONENTS}) +endif() +if(Corrade_FIND_COMPONENTS) + list(REMOVE_DUPLICATES Corrade_FIND_COMPONENTS) endif() -mark_as_advanced(_CORRADE_CONFIGURE_FILE _CORRADE_MODULE_DIR) +# Component distinction +set(_CORRADE_LIBRARY_COMPONENTS "^(Containers|Interconnect|PluginManager|TestSuite|Utility)$") +set(_CORRADE_HEADER_ONLY_COMPONENTS "^(Containers)$") +set(_CORRADE_EXECUTABLE_COMPONENTS "^(rc)$") + +# Find all components +foreach(_component ${Corrade_FIND_COMPONENTS}) + string(TOUPPER ${_component} _COMPONENT) + + # Create imported target in case the library is found. If the project is + # added as subproject to CMake, the target already exists and all the + # required setup is already done from the build tree. + if(TARGET Corrade::${_component}) + set(Corrade_${_component}_FOUND TRUE) + else() + # Library components + if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND NOT _component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS}) + add_library(Corrade::${_component} UNKNOWN IMPORTED) + + # Try to find both debug and release version + find_library(CORRADE_${_COMPONENT}_LIBRARY_DEBUG Corrade${_component}-d) + find_library(CORRADE_${_COMPONENT}_LIBRARY_RELEASE Corrade${_component}) + mark_as_advanced(CORRADE_${_COMPONENT}_LIBRARY_DEBUG + CORRADE_${_COMPONENT}_LIBRARY_RELEASE) + + if(CORRADE_${_COMPONENT}_LIBRARY_RELEASE) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_property(TARGET Corrade::${_component} PROPERTY + IMPORTED_LOCATION_RELEASE ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE}) + endif() + + if(CORRADE_${_COMPONENT}_LIBRARY_DEBUG) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_property(TARGET Corrade::${_component} PROPERTY + IMPORTED_LOCATION_DEBUG ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG}) + endif() + endif() + + # Header-only library components (CMake >= 3.0) + if(_component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS} AND NOT CMAKE_VERSION VERSION_LESS 3.0.0) + add_library(Corrade::${_component} INTERFACE IMPORTED) + endif() + + # Executable components + if(_component MATCHES ${_CORRADE_EXECUTABLE_COMPONENTS}) + add_executable(Corrade::${_component} IMPORTED) + + find_program(CORRADE_${_COMPONENT}_EXECUTABLE corrade-${_component}) + mark_as_advanced(CORRADE_${_COMPONENT}_EXECUTABLE) + + if(CORRADE_${_COMPONENT}_EXECUTABLE) + set_property(TARGET Corrade::${_component} PROPERTY + IMPORTED_LOCATION ${CORRADE_${_COMPONENT}_EXECUTABLE}) + endif() + endif() + + # No special setup for Containers library + # No special setup for Interconnect library + + # PluginManager library + if(_component STREQUAL PluginManager) + # At least static build needs this + if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL_GLIBC) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS}) + endif() + + # No special setup for TestSuite library + + # Utility library (contains all setup that is used by others) + elseif(_component STREQUAL Utility) + # Top-level include directory + set_property(TARGET Corrade::${_component} APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${CORRADE_INCLUDE_DIR}) + + # Require (at least) C++11 for users + if(NOT CMAKE_VERSION VERSION_LESS 3.0.0) + set_property(TARGET Corrade::${_component} PROPERTY + INTERFACE_CORRADE_CXX_STANDARD 11) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + COMPATIBLE_INTERFACE_NUMBER_MAX CORRADE_CXX_STANDARD) + else() + # 2.8.12 is fucking buggy shit. Besides the fact that it + # doesn't know COMPATIBLE_INTERFACE_NUMBER_MAX, if I + # define_property() so I can inherit it from directory on a + # target, then I can't use it in COMPATIBLE_INTERFACE_STRING + # to inherit it from interfaces BECAUSE!! it thinks that it is + # not an user-defined property anymore. So I need to have two + # sets of properties, CORRADE_CXX_STANDARD_ used silently for + # inheritance from interfaces and CORRADE_CXX_STANDARD used + # publicly for inheritance from directories. AAAAAAAAARGH. + set_property(TARGET Corrade::${_component} PROPERTY + INTERFACE_CORRADE_CXX_STANDARD_ 11) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING CORRADE_CXX_STANDARD_) + endif() + + # AndroidLogStreamBuffer class needs to be linked to log library + if(CORRADE_TARGET_ANDROID) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "log") + endif() + endif() + + # Find library includes + if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS}) + find_path(_CORRADE_${_COMPONENT}_INCLUDE_DIR + NAMES ${_component}.h + HINTS ${CORRADE_INCLUDE_DIR}/Corrade/${_component}) + mark_as_advanced(_CORRADE_${_COMPONENT}_INCLUDE_DIR) + endif() + + # Add inter-library dependencies (except for the header-only libraries + # on 2.8.12) + if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND (NOT CMAKE_VERSION VERSION_LESS 3.0.0 OR NOT _component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS})) + foreach(_dependency ${_CORRADE_${_COMPONENT}_DEPENDENCIES}) + if(_dependency MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND (NOT CMAKE_VERSION VERSION_LESS 3.0.0 OR NOT _dependency MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS})) + set_property(TARGET Corrade::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Corrade::${_dependency}) + endif() + endforeach() + endif() + + # Decide if the component was found + if((_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND _CORRADE_${_COMPONENT}_INCLUDE_DIR AND (_component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS} OR CORRADE_${_COMPONENT}_LIBRARY_RELEASE OR CORRADE_${_COMPONENT}_LIBRARY_DEBUG)) OR (_component MATCHES ${_CORRADE_EXECUTABLE_COMPONENTS} AND CORRADE_${_COMPONENT}_EXECUTABLE)) + set(Corrade_${_component}_FOUND TRUE) + else() + set(Corrade_${_component}_FOUND FALSE) + endif() + endif() + + # Deprecated variables + if(CORRADE_BUILD_DEPRECATED AND _component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND NOT _component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS}) + set(CORRADE_${_COMPONENT}_LIBRARIES Corrade::${_component}) + endif() +endforeach() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Corrade REQUIRED_VARS + CORRADE_INCLUDE_DIR + _CORRADE_MODULE_DIR + _CORRADE_CONFIGURE_FILE + ${CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED} + HANDLE_COMPONENTS) # Finalize the finding process include(${CORRADE_USE_MODULE}) diff --git a/modules/FindEGL.cmake b/modules/FindEGL.cmake index 6f8c99916..b45a09f10 100644 --- a/modules/FindEGL.cmake +++ b/modules/FindEGL.cmake @@ -1,8 +1,14 @@ -# - Find EGL +#.rst: +# Find EGL +# -------- # -# This module defines: +# Finds the EGL library. This module defines: # # EGL_FOUND - True if EGL library is found +# EGL::EGL - EGL imported target +# +# Additionally these variables are defined for internal usage: +# # EGL_LIBRARY - EGL library # EGL_INCLUDE_DIR - Include dir # @@ -10,7 +16,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -35,13 +41,38 @@ # Library find_library(EGL_LIBRARY NAMES EGL - libEGL) # ANGLE (CMake doesn't search for lib prefix on Windows) + + # ANGLE (CMake doesn't search for lib prefix on Windows) + libEGL + + # On iOS a part of OpenGLES + OpenGLES) # Include dir -find_path(EGL_INCLUDE_DIR - NAMES EGL/egl.h) +find_path(EGL_INCLUDE_DIR NAMES + EGL/egl.h + + # iOS + EAGL.h) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args("EGL" DEFAULT_MSG +find_package_handle_standard_args(EGL DEFAULT_MSG EGL_LIBRARY EGL_INCLUDE_DIR) + +if(NOT TARGET EGL::EGL) + # Work around BUGGY framework support on OSX + # http://public.kitware.com/pipermail/cmake/2016-April/063179.html + if(APPLE AND ${EGL_LIBRARY} MATCHES "\\.framework$") + add_library(EGL::EGL INTERFACE IMPORTED) + set_property(TARGET EGL::EGL APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${EGL_LIBRARY}) + else() + add_library(EGL::EGL UNKNOWN IMPORTED) + set_property(TARGET EGL::EGL PROPERTY + IMPORTED_LOCATION ${EGL_LIBRARY}) + endif() + + set_target_properties(EGL::EGL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${EGL_INCLUDE_DIR}) +endif() diff --git a/modules/FindGLFW.cmake b/modules/FindGLFW.cmake new file mode 100644 index 000000000..c6b6d9996 --- /dev/null +++ b/modules/FindGLFW.cmake @@ -0,0 +1,67 @@ +#.rst: +# Find GLFW +# --------- +# +# Finds the GLFW library. This module defines: +# +# GLFW_FOUND - True if GLFW library is found +# GLFW::GLFW - GLFW imported target +# +# Additionally these variables are defined for internal usage: +# +# GLFW_LIBRARY - GLFW library +# GLFW_INCLUDE_DIR - Root include dir +# + +# +# This file is part of Magnum. +# +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 +# Vladimír Vondruš +# Copyright © 2016 Jonathan Hale +# +# 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. +# + +find_library(GLFW_LIBRARY NAMES glfw glfw3) + +# Include dir +find_path(GLFW_INCLUDE_DIR + NAMES glfw3.h + PATH_SUFFIXES GLFW) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args("GLFW" DEFAULT_MSG + GLFW_LIBRARY + GLFW_INCLUDE_DIR) + +if(NOT TARGET GLFW::GLFW) + add_library(GLFW::GLFW UNKNOWN IMPORTED) + + # Work around BUGGY framework support on OSX + # https://cmake.org/Bug/view.php?id=14105 + if(CORRADE_TARGET_APPLE AND ${GLFW_LIBRARY} MATCHES "\\.framework$") + set_property(TARGET GLFW::GLFW PROPERTY IMPORTED_LOCATION ${GLFW_LIBRARY}/GLFW) + else() + set_property(TARGET GLFW::GLFW PROPERTY IMPORTED_LOCATION ${GLFW_LIBRARY}) + endif() + + set_property(TARGET GLFW::GLFW PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${GLFW_INCLUDE_DIR}) +endif() diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index c3db765d6..5c88350fe 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -1,12 +1,15 @@ -# - Find Magnum +#.rst: +# Find Magnum +# ----------- # -# Basic usage: -# find_package(Magnum [REQUIRED]) -# This command tries to find base Magnum library and then defines: -# MAGNUM_FOUND - Whether the base library was found -# MAGNUM_LIBRARIES - Magnum library and dependent libraries -# MAGNUM_INCLUDE_DIRS - Root include dir and include dirs of -# dependencies +# Finds the Magnum library. Basic usage:: +# +# find_package(Magnum REQUIRED) +# +# This module tries to find the base Magnum library and then defines the +# following: +# +# Magnum_FOUND - Whether the base library was found # MAGNUM_PLUGINS_DEBUG_DIR - Base directory with dynamic plugins for # debug builds, defaults to magnum-d/ subdirectory of dir where Magnum # library was found @@ -14,11 +17,11 @@ # release builds, defaults to magnum/ subdirectory of dir where Magnum # library was found # MAGNUM_PLUGINS_DIR - Base directory with dynamic plugins, defaults -# to MAGNUM_PLUGINS_RELEASE_DIR in release builds and multi-configuration -# builds or to MAGNUM_PLUGINS_DEBUG_DIR in debug builds. You can modify all -# three variable (e.g. set them to . when deploying on Windows with plugins -# stored relatively to the executable), the following MAGNUM_PLUGINS_*_DIR -# variables depend on it. +# to :variable:`MAGNUM_PLUGINS_RELEASE_DIR` in release builds and +# multi-configuration builds or to :variable:`MAGNUM_PLUGINS_DEBUG_DIR` in +# debug builds. You can modify all three variables (e.g. set them to ``.`` +# when deploying on Windows with plugins stored relatively to the +# executable), the following ``MAGNUM_PLUGINS_*_DIR`` variables depend on it. # MAGNUM_PLUGINS_FONT[|_DEBUG|_RELEASE]_DIR - Directory with dynamic font # plugins # MAGNUM_PLUGINS_FONTCONVERTER[|_DEBUG|_RELEASE]_DIR - Directory with dynamic @@ -29,66 +32,76 @@ # importer plugins # MAGNUM_PLUGINS_AUDIOIMPORTER[|_DEBUG|_RELEASE]_DIR - Directory with dynamic # audio importer plugins +# # This command will try to find only the base library, not the optional # components. The base library depends on Corrade and OpenGL libraries (or # OpenGL ES libraries). Additional dependencies are specified by the # components. The optional components are: -# Audio - Audio library -# DebugTools - DebugTools library -# MeshTools - MeshTools library -# Primitives - Primitives library -# SceneGraph - SceneGraph library -# Shaders - Shaders library -# Shapes - Shapes library -# Text - Text library -# TextureTools - TextureTools library -# MagnumFont - Magnum bitmap font plugin -# MagnumFontConverter - Magnum bitmap font converter plugin -# ObjImporter - OBJ importer plugin -# TgaImageConverter - TGA image converter plugin -# TgaImporter - TGA importer plugin -# WavAudioImporter - WAV audio importer plugin -# GlutApplication - GLUT application -# GlxApplication - GLX application -# NaClApplication - NaCl application -# Sdl2Application - SDL2 application -# XEglApplication - X/EGL application -# WindowlessCglApplication - Windowless CGL application -# WindowlessGlxApplication - Windowless GLX application -# WindowlessNaClApplication - Windowless NaCl application -# WindowlessWglApplication - Windowless WGL application +# +# Audio - Audio library +# DebugTools - DebugTools library +# MeshTools - MeshTools library +# Primitives - Primitives library +# SceneGraph - SceneGraph library +# Shaders - Shaders library +# Shapes - Shapes library +# Text - Text library +# TextureTools - TextureTools library +# GlfwApplication - GLFW application +# GlutApplication - GLUT application +# GlxApplication - GLX application +# NaClApplication - NaCl application +# Sdl2Application - SDL2 application +# XEglApplication - X/EGL application +# WindowlessCglApplication - Windowless CGL application +# WindowlessEglApplication - Windowless EGL application +# WindowlessGlxApplication - Windowless GLX application +# WindowlessIosApplication - Windowless iOS application +# WindowlessNaClApplication - Windowless NaCl application +# WindowlessWglApplication - Windowless WGL application # WindowlessWindowsEglApplication - Windowless Windows/EGL application -# CglContext - CGL context -# EglContext - EGL context -# GlxContext - GLX context -# WglContext - WGL context -# Example usage with specifying additional components is: -# find_package(Magnum [REQUIRED|COMPONENTS] -# MeshTools Primitives GlutApplication) +# CglContext - CGL context +# EglContext - EGL context +# GlxContext - GLX context +# WglContext - WGL context +# MagnumFont - Magnum bitmap font plugin +# MagnumFontConverter - Magnum bitmap font converter plugin +# ObjImporter - OBJ importer plugin +# TgaImageConverter - TGA image converter plugin +# TgaImporter - TGA importer plugin +# WavAudioImporter - WAV audio importer plugin +# distancefieldconverter - magnum-distancefieldconverter executable +# fontconverter - magnum-fontconverter executable +# info - magnum-info executable +# +# Example usage with specifying additional components is:: +# +# find_package(Magnum REQUIRED MeshTools Primitives GlutApplication) +# # For each component is then defined: -# MAGNUM_*_FOUND - Whether the component was found -# MAGNUM_*_LIBRARIES - Component library and dependent libraries -# MAGNUM_*_INCLUDE_DIRS - Include dirs of module dependencies -# If exactly one *Application or exactly one Windowless*Application -# component is requested and found, its libraries and include dirs are -# available in convenience aliases MAGNUM_APPLICATION_LIBRARIES / -# MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES and MAGNUM_APPLICATION_INCLUDE_DIRS -# / MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS to simplify porting. Similarly, -# if exactly one *Context component is requested and found, its libraries and -# include dirs are available in convenience aliases MAGNUM_CONTEXT_LIBRARIES -# and MAGNUM_CONTEXT_INCLUDE_DIRS. +# +# Magnum_*_FOUND - Whether the component was found +# Magnum::* - Component imported target +# +# If exactly one ``*Application`` or exactly one ``Windowless*Application`` +# component is requested and found, its target is available in convenience +# alias ``Magnum::Application`` / ``Magnum::WindowlessApplication`` to simplify +# porting. Similarly, if exactly one ``*Context`` component is requested and +# found, its target is available in convenience alias ``Magnum::Context``. # # The package is found if either debug or release version of each requested # library (or plugin) is found. If both debug and release libraries (or # plugins) are found, proper version is chosen based on actual build # configuration of the project (i.e. Debug build is linked to debug libraries, # Release build to release libraries). Note that this autodetection might fail -# for the MAGNUM_PLUGINS_DIR variable, especially on multi-configuration build -# systems. You can make use of CORRADE_IS_DEBUG_BUILD preprocessor variable -# along with MAGNUM_PLUGINS_*_DEBUG_DIR / MAGNUM_PLUGINS_*_RELEASE_DIR -# variables to decide in preprocessing step. +# for the :variable:`MAGNUM_PLUGINS_DIR` variable, especially on +# multi-configuration build systems. You can make use of +# ``CORRADE_IS_DEBUG_BUILD`` preprocessor variable along with +# ``MAGNUM_PLUGINS_*_DEBUG_DIR`` / ``MAGNUM_PLUGINS_*_RELEASE_DIR`` variables +# to decide in preprocessing step. # # Features of found Magnum library are exposed in these variables: +# # MAGNUM_BUILD_DEPRECATED - Defined if compiled with deprecated APIs # included # MAGNUM_BUILD_STATIC - Defined if compiled as static libraries @@ -98,8 +111,10 @@ # MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES # emulation on desktop OpenGL # MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL +# MAGNUM_TARGET_HEADLESS - Defined if compiled for headless machines # # Additionally these variables are defined for internal usage: +# # MAGNUM_INCLUDE_DIR - Root include dir (w/o dependencies) # MAGNUM_LIBRARY - Magnum library (w/o dependencies) # MAGNUM_LIBRARY_DEBUG - Debug version of Magnum library, if found @@ -124,11 +139,26 @@ # MAGNUM_INCLUDE_INSTALL_DIR - Header installation directory # MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR - Plugin header installation directory # +# Workflows without imported targets are deprecated and the following variables +# are included just for backwards compatibility and only if +# :variable:`MAGNUM_BUILD_DEPRECATED` is enabled: +# +# MAGNUM_LIBRARIES - Expands to ``Magnum::Magnum`` target. Use +# ``Magnum::Magnum`` target directly instead. +# MAGNUM_*_LIBRARIES - Expands to ``Magnum::*`` target. Use +# ``Magnum::*`` target directly instead. +# MAGNUM_APPLICATION_LIBRARIES / MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES +# - Expands to ``Magnum::Application`` / +# ``Magnum::WindowlessApplication`` target. Use ``Magnum::Application`` / +# ``Magnum::WindowlessApplication`` target directly instead. +# MAGNUM_CONTEXT_LIBRARIES - Expands to ``Magnum::Context`` target. Use +# ``Magnum::Context`` target directly instead. +# # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -151,34 +181,12 @@ # # Dependencies -find_package(Corrade REQUIRED) - -# Base Magnum library -find_library(MAGNUM_LIBRARY_DEBUG Magnum-d) -find_library(MAGNUM_LIBRARY_RELEASE Magnum) - -# Set the MAGNUM_LIBRARY variable based on what was found, use that information -# to guess also build type of dynamic plugins -if(MAGNUM_LIBRARY_DEBUG AND MAGNUM_LIBRARY_RELEASE) - set(MAGNUM_LIBRARY - debug ${MAGNUM_LIBRARY_DEBUG} - optimized ${MAGNUM_LIBRARY_RELEASE}) - get_filename_component(_MAGNUM_LIBRARY_PATH ${MAGNUM_LIBRARY_DEBUG} PATH) - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(_MAGNUM_PLUGINS_DIR_SUFFIX "-d") - endif() -elseif(MAGNUM_LIBRARY_DEBUG) - set(MAGNUM_LIBRARY ${MAGNUM_LIBRARY_DEBUG}) - get_filename_component(_MAGNUM_LIBRARY_PATH ${MAGNUM_LIBRARY_DEBUG} PATH) - set(_MAGNUM_PLUGINS_DIR_SUFFIX "-d") -elseif(MAGNUM_LIBRARY_RELEASE) - set(MAGNUM_LIBRARY ${MAGNUM_LIBRARY_RELEASE}) - get_filename_component(_MAGNUM_LIBRARY_PATH ${MAGNUM_LIBRARY_RELEASE} PATH) -endif() +find_package(Corrade REQUIRED Utility PluginManager) # Root include dir find_path(MAGNUM_INCLUDE_DIR NAMES Magnum/Magnum.h) +mark_as_advanced(MAGNUM_INCLUDE_DIR) # Configuration file find_file(_MAGNUM_CONFIGURE_FILE configure.h @@ -190,10 +198,10 @@ find_file(_MAGNUM_CONFIGURE_FILE configure.h if(NOT MAGNUM_INCLUDE_DIR) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Magnum - REQUIRED_VARS MAGNUM_LIBRARY MAGNUM_INCLUDE_DIR _MAGNUM_CONFIGURE_FILE) + REQUIRED_VARS MAGNUM_INCLUDE_DIR _MAGNUM_CONFIGURE_FILE) endif() -# Configuration +# Read flags from configuration file(READ ${_MAGNUM_CONFIGURE_FILE} _magnumConfigure) set(_magnumFlags BUILD_DEPRECATED @@ -202,7 +210,8 @@ set(_magnumFlags TARGET_GLES2 TARGET_GLES3 TARGET_DESKTOP_GLES - TARGET_WEBGL) + TARGET_WEBGL + TARGET_HEADLESS) foreach(_magnumFlag ${_magnumFlags}) string(FIND "${_magnumConfigure}" "#define MAGNUM_${_magnumFlag}" _magnum_${_magnumFlag}) if(NOT _magnum_${_magnumFlag} EQUAL -1) @@ -210,62 +219,111 @@ foreach(_magnumFlag ${_magnumFlags}) endif() endforeach() -# Dependent libraries and includes -set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR} - ${MAGNUM_INCLUDE_DIR}/MagnumExternal/OpenGL - ${CORRADE_INCLUDE_DIRS}) -set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARY} - ${CORRADE_UTILITY_LIBRARIES} - ${CORRADE_PLUGINMANAGER_LIBRARIES}) -if(NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES) - find_package(OpenGL REQUIRED) - set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGL_gl_LIBRARY}) -elseif(MAGNUM_TARGET_GLES2) - find_package(OpenGLES2 REQUIRED) - set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGLES2_LIBRARY}) -elseif(MAGNUM_TARGET_GLES3) - find_package(OpenGLES3 REQUIRED) - set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGLES3_LIBRARY}) -endif() +# Base Magnum library +if(NOT TARGET Magnum::Magnum) + add_library(Magnum::Magnum UNKNOWN IMPORTED) + + # Try to find both debug and release version + find_library(MAGNUM_LIBRARY_DEBUG Magnum-d) + find_library(MAGNUM_LIBRARY_RELEASE Magnum) + mark_as_advanced(MAGNUM_LIBRARY_DEBUG + MAGNUM_LIBRARY_RELEASE) + + # Set the MAGNUM_LIBRARY variable based on what was found, use that + # information to guess also build type of dynamic plugins + if(MAGNUM_LIBRARY_DEBUG AND MAGNUM_LIBRARY_RELEASE) + set(MAGNUM_LIBRARY ${MAGNUM_LIBRARY_RELEASE}) + get_filename_component(_MAGNUM_LIBRARY_PATH ${MAGNUM_LIBRARY_DEBUG} PATH) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(_MAGNUM_PLUGINS_DIR_SUFFIX "-d") + endif() + elseif(MAGNUM_LIBRARY_DEBUG) + set(MAGNUM_LIBRARY ${MAGNUM_LIBRARY_DEBUG}) + get_filename_component(_MAGNUM_LIBRARY_PATH ${MAGNUM_LIBRARY_DEBUG} PATH) + set(_MAGNUM_PLUGINS_DIR_SUFFIX "-d") + elseif(MAGNUM_LIBRARY_RELEASE) + set(MAGNUM_LIBRARY ${MAGNUM_LIBRARY_RELEASE}) + get_filename_component(_MAGNUM_LIBRARY_PATH ${MAGNUM_LIBRARY_RELEASE} PATH) + endif() -# If the configure file is somewhere else than in root include dir (e.g. when -# using CMake subproject), we need to include that dir too -if(NOT ${MAGNUM_INCLUDE_DIR}/Magnum/configure.h STREQUAL ${_MAGNUM_CONFIGURE_FILE}) - # Go two levels up - get_filename_component(_MAGNUM_CONFIGURE_FILE_INCLUDE_DIR ${_MAGNUM_CONFIGURE_FILE} DIRECTORY) - get_filename_component(_MAGNUM_CONFIGURE_FILE_INCLUDE_DIR ${_MAGNUM_CONFIGURE_FILE_INCLUDE_DIR} DIRECTORY) - list(APPEND MAGNUM_INCLUDE_DIRS ${_MAGNUM_CONFIGURE_FILE_INCLUDE_DIR}) -endif() + if(MAGNUM_LIBRARY_RELEASE) + set_property(TARGET Magnum::Magnum APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_property(TARGET Magnum::Magnum PROPERTY + IMPORTED_LOCATION_RELEASE ${MAGNUM_LIBRARY_RELEASE}) + endif() + + if(MAGNUM_LIBRARY_DEBUG) + set_property(TARGET Magnum::Magnum APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_property(TARGET Magnum::Magnum PROPERTY + IMPORTED_LOCATION_DEBUG ${MAGNUM_LIBRARY_DEBUG}) + endif() -# Emscripten needs special flag to use WebGL 2 -if(CORRADE_TARGET_EMSCRIPTEN AND NOT MAGNUM_TARGET_GLES2 AND NOT CMAKE_EXE_LINKER_FLAGS MATCHES "USE_WEBGL2") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_WEBGL2=1") + # Include directories + set_property(TARGET Magnum::Magnum APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES + ${MAGNUM_INCLUDE_DIR} + ${MAGNUM_INCLUDE_DIR}/MagnumExternal/OpenGL) + + # Dependent libraries + set_property(TARGET Magnum::Magnum APPEND PROPERTY INTERFACE_LINK_LIBRARIES + Corrade::Utility + Corrade::PluginManager) + + # Dependent libraries and includes + if(NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES) + find_package(OpenGL REQUIRED) + set_property(TARGET Magnum::Magnum APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${OPENGL_gl_LIBRARY}) + elseif(MAGNUM_TARGET_GLES2) + find_package(OpenGLES2 REQUIRED) + set_property(TARGET Magnum::Magnum APPEND PROPERTY + INTERFACE_LINK_LIBRARIES OpenGLES2::OpenGLES2) + elseif(MAGNUM_TARGET_GLES3) + find_package(OpenGLES3 REQUIRED) + set_property(TARGET Magnum::Magnum APPEND PROPERTY + INTERFACE_LINK_LIBRARIES OpenGLES3::OpenGLES3) + endif() + + # Emscripten needs special flag to use WebGL 2 + if(CORRADE_TARGET_EMSCRIPTEN AND NOT MAGNUM_TARGET_GLES2) + # TODO: give me INTERFACE_LINK_OPTIONS or something, please + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_WEBGL2=1") + endif() +else() + set(MAGNUM_LIBRARY Magnum::Magnum) endif() # Ensure that all inter-component dependencies are specified as well set(_MAGNUM_ADDITIONAL_COMPONENTS ) -foreach(component ${Magnum_FIND_COMPONENTS}) - string(TOUPPER ${component} _COMPONENT) +foreach(_component ${Magnum_FIND_COMPONENTS}) + string(TOUPPER ${_component} _COMPONENT) - # The dependencies need to be sorted by their dependency order as well - if(component STREQUAL Shapes) + if(_component STREQUAL Shapes) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES SceneGraph) - elseif(component STREQUAL Text) + elseif(_component STREQUAL Text) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TextureTools) - elseif(component STREQUAL DebugTools) + elseif(_component STREQUAL DebugTools) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES MeshTools Primitives SceneGraph Shaders Shapes) - elseif(component STREQUAL MagnumFont) + elseif(_component STREQUAL MagnumFont) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TgaImporter) # and below - elseif(component STREQUAL MagnumFontConverter) + elseif(_component STREQUAL MagnumFontConverter) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TgaImageConverter) # and below - elseif(component STREQUAL ObjImporter) + elseif(_component STREQUAL ObjImporter) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES MeshTools) endif() - if(component MATCHES ".+AudioImporter") - set(_MAGNUM_${_COMPONENT}_DEPENDENCIES ${_MAGNUM_${_COMPONENT}_DEPENDENCIES} Audio) - elseif(component MATCHES ".+(Font|FontConverter)") - set(_MAGNUM_${_COMPONENT}_DEPENDENCIES ${_MAGNUM_${_COMPONENT}_DEPENDENCIES} Text TextureTools) + if(_component MATCHES ".+AudioImporter") + list(APPEND _MAGNUM_${_COMPONENT}_DEPENDENCIES Audio) + elseif(_component MATCHES ".+(Font|FontConverter)") + list(APPEND _MAGNUM_${_COMPONENT}_DEPENDENCIES Text TextureTools) + endif() + + # Mark the dependencies as required if the component is also required + if(Magnum_FIND_REQUIRED_${_component}) + foreach(_dependency ${_MAGNUM_${_COMPONENT}_DEPENDENCIES}) + set(Magnum_FIND_REQUIRED_${_dependency} TRUE) + endforeach() endif() list(APPEND _MAGNUM_ADDITIONAL_COMPONENTS ${_MAGNUM_${_COMPONENT}_DEPENDENCIES}) @@ -279,323 +337,408 @@ if(Magnum_FIND_COMPONENTS) list(REMOVE_DUPLICATES Magnum_FIND_COMPONENTS) endif() +# Component distinction (listing them explicitly to avoid mistakes with finding +# components from other repositories) +set(_MAGNUM_LIBRARY_COMPONENTS "^(Audio|DebugTools|MeshTools|Primitives|SceneGraph|Shaders|Shapes|Text|TextureTools|AndroidApplication|GlfwApplication|GlutApplication|GlxApplication|NaClApplication|Sdl2Application|XEglApplication|WindowlessCglApplication|WindowlessEglApplication|WindowlessGlxApplication|WindowlessIosApplication|WindowlessNaClApplication|WindowlessWglApplication|WindowlessWindowsEglApplication|CglContext|EglContext|GlxContext|WglContext)$") +set(_MAGNUM_PLUGIN_COMPONENTS "^(MagnumFont|MagnumFontConverter|ObjImporter|TgaImageConverter|TgaImporter|WavAudioImporter)$") +set(_MAGNUM_EXECUTABLE_COMPONENTS "^(distancefieldconverter|fontconverter|info)$") + # Find all components -foreach(component ${Magnum_FIND_COMPONENTS}) - string(TOUPPER ${component} _COMPONENT) - - # AudioImporter plugin specific name suffixes - if(${component} MATCHES ".+AudioImporter$") - set(_MAGNUM_${_COMPONENT}_IS_PLUGIN 1) - set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX audioimporters) - - # Audio importer class is Audio::*Importer, thus we need to convert - # *AudioImporter.h to *Importer.h - string(REPLACE "AudioImporter" "Importer" _MAGNUM_${_COMPONENT}_HEADER_NAME "${component}") - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_MAGNUM_${_COMPONENT}_HEADER_NAME}.h) - - # Importer plugin specific name suffixes - elseif(${component} MATCHES ".+Importer$") - set(_MAGNUM_${_COMPONENT}_IS_PLUGIN 1) - set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX importers) - - # Font plugin specific name suffixes - elseif(${component} MATCHES ".+Font$") - set(_MAGNUM_${_COMPONENT}_IS_PLUGIN 1) - set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX fonts) - - # ImageConverter plugin specific name suffixes - elseif(${component} MATCHES ".+ImageConverter$") - set(_MAGNUM_${_COMPONENT}_IS_PLUGIN 1) - set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX imageconverters) - - # FontConverter plugin specific name suffixes - elseif(${component} MATCHES ".+FontConverter$") - set(_MAGNUM_${_COMPONENT}_IS_PLUGIN 1) - set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX fontconverters) - endif() +foreach(_component ${Magnum_FIND_COMPONENTS}) + string(TOUPPER ${_component} _COMPONENT) + + # Create imported target in case the library is found. If the project is + # added as subproject to CMake, the target already exists and all the + # required setup is already done from the build tree. + if(TARGET Magnum::${_component}) + set(Magnum_${_component}_FOUND TRUE) + else() + # Library components + if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS}) + add_library(Magnum::${_component} UNKNOWN IMPORTED) + + # Set library defaults, find the library + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/${_component}) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}.h) + + # Try to find both debug and release version + find_library(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG Magnum${_component}-d) + find_library(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE Magnum${_component}) + mark_as_advanced(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG + MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) + endif() - # Set plugin defaults, find the plugin - if(_MAGNUM_${_COMPONENT}_IS_PLUGIN) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX MagnumPlugins/${component}) + # Plugin components + if(_component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + add_library(Magnum::${_component} UNKNOWN IMPORTED) - # Don't override the one for *AudioImporter plugins - if(NOT _MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${component}.h) - endif() + # AudioImporter plugin specific name suffixes + if(_component MATCHES ".+AudioImporter$") + set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX audioimporters) - # Dynamic plugins don't have any prefix (e.g. `lib` on Linux), search - # with empty prefix and then reset that back so we don't accidentaly - # break something else - set(_tmp_prefixes ${CMAKE_FIND_LIBRARY_PREFIXES}) - set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") - - find_library(MAGNUM_${_COMPONENT}_LIBRARY ${component} - PATH_SUFFIXES magnum/${_MAGNUM_${_COMPONENT}_PATH_SUFFIX}) - - # Try to find both debug and release version. Dynamic and static debug - # libraries are on different places. - find_library(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG ${component} - PATH_SUFFIXES magnum-d/${_MAGNUM_${_COMPONENT}_PATH_SUFFIX}) - find_library(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG ${component}-d - PATH_SUFFIXES magnum/${_MAGNUM_${_COMPONENT}_PATH_SUFFIX}) - find_library(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE ${component} - PATH_SUFFIXES magnum/${_MAGNUM_${_COMPONENT}_PATH_SUFFIX}) - - # Set the _LIBRARY variable based on what was found - if(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG AND MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) - set(MAGNUM_${_COMPONENT}_LIBRARY - debug ${MAGNUM_${_COMPONENT}_LIBRARY_DEBUG} - optimized ${MAGNUM_${_COMPONENT}_LIBRARY_RELEASE}) - elseif(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG) - set(MAGNUM_${_COMPONENT}_LIBRARY ${MAGNUM_${_COMPONENT}_LIBRARY_DEBUG}) - elseif(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) - set(MAGNUM_${_COMPONENT}_LIBRARY ${MAGNUM_${_COMPONENT}_LIBRARY_RELEASE}) - endif() + # Audio importer class is Audio::*Importer, thus we need to + # convert *AudioImporter.h to *Importer.h + string(REPLACE "AudioImporter" "Importer" _MAGNUM_${_COMPONENT}_HEADER_NAME "${_component}") + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_MAGNUM_${_COMPONENT}_HEADER_NAME}.h) - set(CMAKE_FIND_LIBRARY_PREFIXES ${_tmp_prefixes}) + # Importer plugin specific name suffixes + elseif(_component MATCHES ".+Importer$") + set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX importers) - # Set library defaults, find the library - else() - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/${component}) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${component}.h) - - # Try to find both debug and release version - find_library(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG Magnum${component}-d) - find_library(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE Magnum${component}) - - # Set the _LIBRARY variable based on what was found - if(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG AND MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) - set(MAGNUM_${_COMPONENT}_LIBRARY - debug ${MAGNUM_${_COMPONENT}_LIBRARY_DEBUG} - optimized ${MAGNUM_${_COMPONENT}_LIBRARY_RELEASE}) - elseif(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG) - set(MAGNUM_${_COMPONENT}_LIBRARY ${MAGNUM_${_COMPONENT}_LIBRARY_DEBUG}) - elseif(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) - set(MAGNUM_${_COMPONENT}_LIBRARY ${MAGNUM_${_COMPONENT}_LIBRARY_RELEASE}) - endif() - endif() + # Font plugin specific name suffixes + elseif(_component MATCHES ".+Font$") + set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX fonts) - # Applications - if(${component} MATCHES ".+Application") - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) - - # Android application dependencies - if(${component} STREQUAL AndroidApplication) - find_package(EGL) - if(EGL_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES android ${EGL_LIBRARY}) - set(_MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${ANDROID_NATIVE_APP_GLUE_INCLUDE_DIR}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) - endif() + # ImageConverter plugin specific name suffixes + elseif(_component MATCHES ".+ImageConverter$") + set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX imageconverters) - # GLUT application dependencies - elseif(${component} STREQUAL GlutApplication) - find_package(GLUT) - if(GLUT_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${GLUT_glut_LIBRARY}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) + # FontConverter plugin specific name suffixes + elseif(_component MATCHES ".+FontConverter$") + set(_MAGNUM_${_COMPONENT}_PATH_SUFFIX fontconverters) endif() - # SDL2 application dependencies - elseif(${component} STREQUAL Sdl2Application) - find_package(SDL2) - if(SDL2_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY}) - set(_MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) + # Don't override the exception for *AudioImporter plugins + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX MagnumPlugins/${_component}) + if(NOT _MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES ${_component}.h) endif() - # Find also EGL library, if on ES (and not on WebGL) - if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES AND NOT MAGNUM_TARGET_WEBGL) - find_package(EGL) - if(EGL_FOUND) - list(APPEND _MAGNUM_${_COMPONENT}_LIBRARIES ${EGL_LIBRARY}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) - endif() + # Dynamic plugins don't have any prefix (e.g. `lib` on Linux), + # search with empty prefix and then reset that back so we don't + # accidentaly break something else + set(_tmp_prefixes ${CMAKE_FIND_LIBRARY_PREFIXES}) + set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") + + # Try to find both debug and release version. Dynamic and static + # debug libraries are in different places. + find_library(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG ${_component} + PATH_SUFFIXES magnum-d/${_MAGNUM_${_COMPONENT}_PATH_SUFFIX}) + find_library(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG ${_component}-d + PATH_SUFFIXES magnum/${_MAGNUM_${_COMPONENT}_PATH_SUFFIX}) + find_library(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE ${_component} + PATH_SUFFIXES magnum/${_MAGNUM_${_COMPONENT}_PATH_SUFFIX}) + mark_as_advanced(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG + MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) + + # Reset back + set(CMAKE_FIND_LIBRARY_PREFIXES ${_tmp_prefixes}) + endif() + + # Library location for libraries/plugins + if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + if(MAGNUM_${_COMPONENT}_LIBRARY_RELEASE) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_property(TARGET Magnum::${_component} PROPERTY + IMPORTED_LOCATION_RELEASE ${MAGNUM_${_COMPONENT}_LIBRARY_RELEASE}) endif() - # (Windowless) NaCl application dependencies - elseif(${component} STREQUAL NaClApplication OR ${component} STREQUAL WindowlessNaClApplication) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ppapi_cpp ppapi) - - # (Windowless) GLX application dependencies - elseif(${component} STREQUAL GlxApplication OR ${component} STREQUAL WindowlessGlxApplication) - find_package(X11) - if(X11_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${X11_LIBRARIES}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) + if(MAGNUM_${_COMPONENT}_LIBRARY_DEBUG) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_property(TARGET Magnum::${_component} PROPERTY + IMPORTED_LOCATION_DEBUG ${MAGNUM_${_COMPONENT}_LIBRARY_DEBUG}) endif() + endif() - # Windowless CGL application has no additional dependencies - # Windowless WGL application has no additional dependencies + # Executables + if(_component MATCHES ${_MAGNUM_EXECUTABLE_COMPONENTS}) + add_executable(Magnum::${_component} IMPORTED) - # Windowless Windows/EGL application dependencies - elseif(${component} STREQUAL WindowlessWindowsEglApplication) - find_package(EGL) - if(EGL_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${EGL_LIBRARY}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) - endif() + find_program(MAGNUM_${_COMPONENT}_EXECUTABLE magnum-${_component}) + mark_as_advanced(MAGNUM_${_COMPONENT}_EXECUTABLE) - # X/EGL application dependencies - elseif(${component} STREQUAL XEglApplication) - find_package(EGL) - find_package(X11) - if(EGL_FOUND AND X11_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${EGL_LIBRARY} ${X11_LIBRARIES}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) + if(MAGNUM_${_COMPONENT}_EXECUTABLE) + set_property(TARGET Magnum::${_component} PROPERTY + IMPORTED_LOCATION ${MAGNUM_${_COMPONENT}_EXECUTABLE}) endif() endif() - # Context libraries - elseif(${component} MATCHES ".+Context") - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Context.h) - - # GLX context dependencies - if(${component} STREQUAL GlxContext) - find_package(X11) - if(X11_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${X11_LIBRARIES}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) + # Applications + if(_component MATCHES ".+Application") + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) + + # Android application dependencies + if(_component STREQUAL AndroidApplication) + find_package(EGL) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${ANDROID_NATIVE_APP_GLUE_INCLUDE_DIR}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES android EGL::EGL) + + # GLFW application dependencies + elseif(_component STREQUAL GlfwApplication) + find_package(GLFW) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES GLFW::GLFW) + + # GLUT application dependencies + elseif(_component STREQUAL GlutApplication) + find_package(GLUT) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${GLUT_INCLUDE_DIR}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${GLUT_glut_LIBRARY}) + + # SDL2 application dependencies + elseif(_component STREQUAL Sdl2Application) + find_package(SDL2) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES SDL2::SDL2) + + # (Windowless) NaCl application dependencies + elseif(_component STREQUAL NaClApplication OR _component STREQUAL WindowlessNaClApplication) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ppapi_cpp ppapi) + + # (Windowless) GLX application dependencies + elseif(_component STREQUAL GlxApplication OR _component STREQUAL WindowlessGlxApplication) + find_package(X11) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${X11_INCLUDE_DIR}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${X11_LIBRARIES}) + + # Windowless CGL application has no additional dependencies + + # Windowless EGL application dependencies + elseif(_component STREQUAL WindowlessEglApplication) + find_package(EGL) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES EGL::EGL) + + # Windowless iOS application dependencies + elseif(_component STREQUAL WindowlessIosApplication) + # We need to link to Foundation framework to use ObjC + find_library(_MAGNUM_IOS_FOUNDATION_FRAMEWORK_LIBRARY Foundation) + mark_as_advanced(_MAGNUM_IOS_FOUNDATION_FRAMEWORK_LIBRARY) + find_package(EGL) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES EGL::EGL ${_MAGNUM_IOS_FOUNDATION_FRAMEWORK_LIBRARY}) + + # Windowless WGL application has no additional dependencies + + # Windowless Windows/EGL application dependencies + elseif(_component STREQUAL WindowlessWindowsEglApplication) + find_package(EGL) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES EGL::EGL) + + # X/EGL application dependencies + elseif(_component STREQUAL XEglApplication) + find_package(EGL) + find_package(X11) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${X11_INCLUDE_DIR}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES EGL::EGL ${X11_LIBRARIES}) endif() - endif() - # EGL context dependencies - if(${component} STREQUAL EglContext) - find_package(EGL) - if(EGL_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${EGL_LIBRARIES}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) + # Context libraries + elseif(_component MATCHES ".+Context") + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX Magnum/Platform) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Context.h) + + # GLX context dependencies + if(_component STREQUAL GlxContext) + find_package(X11) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${X11_INCLUDE_DIR}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${X11_LIBRARIES}) + + # EGL context dependencies + elseif(_component STREQUAL EglContext) + find_package(EGL) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES EGL::EGL) endif() - endif() - # No additional dependencies for CGL context - # No additional dependencies for WGL context + # No additional dependencies for CGL context + # No additional dependencies for WGL context - # Audio library - elseif(${component} STREQUAL Audio) - find_package(OpenAL) - if(OPENAL_FOUND) - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${OPENAL_LIBRARY}) - set(_MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR}) - else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) - endif() + # Audio library + elseif(_component STREQUAL Audio) + find_package(OpenAL) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIR}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${OPENAL_LIBRARY}) - # No special setup for DebugTools library + # No special setup for DebugTools library - # Mesh tools library - elseif(${component} STREQUAL MeshTools) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h) + # Mesh tools library + elseif(_component STREQUAL MeshTools) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES CompressIndices.h) - # Primitives library - elseif(${component} STREQUAL Primitives) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Cube.h) + # Primitives library + elseif(_component STREQUAL Primitives) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Cube.h) - # No special setup for SceneGraph library - # No special setup for Shaders library - # No special setup for Shapes library - # No special setup for Text library + # No special setup for SceneGraph library + # No special setup for Shaders library + # No special setup for Shapes library + # No special setup for Text library - # TextureTools library - elseif(${component} STREQUAL TextureTools) - set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Atlas.h) - endif() + # TextureTools library + elseif(_component STREQUAL TextureTools) + set(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES Atlas.h) + endif() + + # Find library/plugin includes + if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + find_path(_MAGNUM_${_COMPONENT}_INCLUDE_DIR + NAMES ${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES} + HINTS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) + mark_as_advanced(_MAGNUM_${_COMPONENT}_INCLUDE_DIR) + endif() - # No special setup for plugins + # Link to core Magnum library, add inter-library dependencies + if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Magnum::Magnum) + foreach(_dependency ${_MAGNUM_${_COMPONENT}_DEPENDENCIES}) + set_property(TARGET Magnum::${_component} APPEND PROPERTY + INTERFACE_LINK_LIBRARIES Magnum::${_dependency}) + endforeach() + endif() - # Try to find the includes - if(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES) - find_path(_MAGNUM_${_COMPONENT}_INCLUDE_DIR - NAMES ${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES} - HINTS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) + # Decide if the library was found + if(((_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR AND (MAGNUM_${_COMPONENT}_LIBRARY_DEBUG OR MAGNUM_${_COMPONENT}_LIBRARY_RELEASE)) OR (_component MATCHES ${_MAGNUM_EXECUTABLE_COMPONENTS} AND MAGNUM_${_COMPONENT}_EXECUTABLE)) + set(Magnum_${_component}_FOUND TRUE) + else() + set(Magnum_${_component}_FOUND FALSE) + 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}) + # Global aliases for Windowless*Application, *Application and *Context + # components. If already set, unset them to avoid ambiguity. + if(_component MATCHES "Windowless.+Application") + if(NOT DEFINED _MAGNUM_WINDOWLESSAPPLICATION_ALIAS) + set(_MAGNUM_WINDOWLESSAPPLICATION_ALIAS Magnum::${_component}) else() - unset(MAGNUM_${_COMPONENT}_LIBRARY) + unset(_MAGNUM_WINDOWLESSAPPLICATION_ALIAS) endif() - endforeach() - - # Decide if the library was found - if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR) - set(MAGNUM_${_COMPONENT}_LIBRARIES - ${MAGNUM_${_COMPONENT}_LIBRARY} - ${_MAGNUM_${_COMPONENT}_LIBRARIES} - ${_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) - - # Don't expose variables w/o dependencies to end users - mark_as_advanced(FORCE - MAGNUM_${_COMPONENT}_LIBRARY_DEBUG - MAGNUM_${_COMPONENT}_LIBRARY_RELEASE - MAGNUM_${_COMPONENT}_LIBRARY - _MAGNUM_${_COMPONENT}_INCLUDE_DIR) - - # Global aliases for Windowless*Application and *Application - # components. If already set, unset them to avoid ambiguity. - if(${component} MATCHES "Windowless.+Application") - if(NOT DEFINED MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES AND NOT DEFINED MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS) - set(MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES}) - set(MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) - else() - unset(MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES) - unset(MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS) - endif() - elseif(${component} MATCHES ".+Application") - if(NOT DEFINED MAGNUM_APPLICATION_LIBRARIES AND NOT DEFINED MAGNUM_APPLICATION_INCLUDE_DIRS) - set(MAGNUM_APPLICATION_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES}) - set(MAGNUM_APPLICATION_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) - else() - unset(MAGNUM_APPLICATION_LIBRARIES) - unset(MAGNUM_APPLICATION_INCLUDE_DIRS) - endif() + elseif(_component MATCHES ".+Application") + if(NOT DEFINED _MAGNUM_APPLICATION_ALIAS) + set(_MAGNUM_APPLICATION_ALIAS Magnum::${_component}) + else() + unset(_MAGNUM_APPLICATION_ALIAS) endif() - - # Global aliases for *Context components. If already set, unset them to - # avoid ambiguity. - if(${component} MATCHES ".+Context") - if(NOT DEFINED MAGNUM_CONTEXT_LIBRARIES AND NOT DEFINED MAGNUM_CONTEXT_INCLUDE_DIRS) - set(MAGNUM_CONTEXT_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARIES}) - set(MAGNUM_CONTEXT_INCLUDE_DIRS ${MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) - else() - unset(MAGNUM_CONTEXT_LIBRARIES) - unset(MAGNUM_CONTEXT_INCLUDE_DIRS) - endif() + elseif(_component MATCHES ".+Context") + if(NOT DEFINED _MAGNUM_CONTEXT_ALIAS) + set(_MAGNUM_CONTEXT_ALIAS Magnum::${_component}) + else() + unset(_MAGNUM_CONTEXT_ALIAS) endif() - else() - set(Magnum_${component}_FOUND FALSE) + endif() + + # Deprecated variables + if(MAGNUM_BUILD_DEPRECATED AND _component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS}) + set(MAGNUM_${_COMPONENT}_LIBRARIES Magnum::${_component}) endif() endforeach() # Complete the check with also all components +include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Magnum - REQUIRED_VARS MAGNUM_LIBRARY MAGNUM_INCLUDE_DIR + REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY HANDLE_COMPONENTS) +# Create Windowless*Application, *Application and *Context aliases +# TODO: ugh why can't I make an alias of IMPORTED target? +if(_MAGNUM_WINDOWLESSAPPLICATION_ALIAS AND NOT TARGET Magnum::WindowlessApplication) + get_target_property(_MAGNUM_WINDOWLESSAPPLICATION_ALIASED_TARGET ${_MAGNUM_WINDOWLESSAPPLICATION_ALIAS} ALIASED_TARGET) + if(_MAGNUM_WINDOWLESSAPPLICATION_ALIASED_TARGET) + add_library(Magnum::WindowlessApplication ALIAS ${_MAGNUM_WINDOWLESSAPPLICATION_ALIASED_TARGET}) + else() + add_library(Magnum::WindowlessApplication UNKNOWN IMPORTED) + get_target_property(_MAGNUM_WINDOWLESSAPPLICATION_IMPORTED_CONFIGURATIONS ${_MAGNUM_WINDOWLESSAPPLICATION_ALIAS} IMPORTED_CONFIGURATIONS) + get_target_property(_MAGNUM_WINDOWLESSAPPLICATION_IMPORTED_LOCATION_RELEASE ${_MAGNUM_WINDOWLESSAPPLICATION_ALIAS} IMPORTED_LOCATION_RELEASE) + get_target_property(_MAGNUM_WINDOWLESSAPPLICATION_IMPORTED_LOCATION_DEBUG ${_MAGNUM_WINDOWLESSAPPLICATION_ALIAS} IMPORTED_LOCATION_DEBUG) + set_target_properties(Magnum::WindowlessApplication PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES $ + INTERFACE_COMPILE_DEFINITIONS $ + INTERFACE_COMPILE_OPTIONS $ + INTERFACE_LINK_LIBRARIES $ + IMPORTED_CONFIGURATIONS "${_MAGNUM_WINDOWLESSAPPLICATION_IMPORTED_CONFIGURATIONS}") + if(_MAGNUM_WINDOWLESSAPPLICATION_IMPORTED_LOCATION_RELEASE) + set_target_properties(Magnum::WindowlessApplication PROPERTIES + IMPORTED_LOCATION_RELEASE ${_MAGNUM_WINDOWLESSAPPLICATION_IMPORTED_LOCATION_RELEASE}) + endif() + if(_MAGNUM_WINDOWLESSAPPLICATION_IMPORTED_LOCATION_DEBUG) + set_target_properties(Magnum::WindowlessApplication PROPERTIES + IMPORTED_LOCATION_DEBUG ${_MAGNUM_WINDOWLESSAPPLICATION_IMPORTED_LOCATION_DEBUG}) + endif() + endif() + if(MAGNUM_BUILD_DEPRECATED) + set(MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES Magnum::WindowlessApplication) + endif() + # Prevent creating the alias again + unset(_MAGNUM_WINDOWLESSAPPLICATION_ALIAS) +endif() +if(_MAGNUM_APPLICATION_ALIAS AND NOT TARGET Magnum::Application) + get_target_property(_MAGNUM_APPLICATION_ALIASED_TARGET ${_MAGNUM_APPLICATION_ALIAS} ALIASED_TARGET) + if(_MAGNUM_APPLICATION_ALIASED_TARGET) + add_library(Magnum::Application ALIAS ${_MAGNUM_APPLICATION_ALIASED_TARGET}) + else() + add_library(Magnum::Application UNKNOWN IMPORTED) + get_target_property(_MAGNUM_APPLICATION_IMPORTED_CONFIGURATIONS ${_MAGNUM_APPLICATION_ALIAS} IMPORTED_CONFIGURATIONS) + get_target_property(_MAGNUM_APPLICATION_IMPORTED_LOCATION_RELEASE ${_MAGNUM_APPLICATION_ALIAS} IMPORTED_LOCATION_RELEASE) + get_target_property(_MAGNUM_APPLICATION_IMPORTED_LOCATION_DEBUG ${_MAGNUM_APPLICATION_ALIAS} IMPORTED_LOCATION_DEBUG) + set_target_properties(Magnum::Application PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES $ + INTERFACE_COMPILE_DEFINITIONS $ + INTERFACE_COMPILE_OPTIONS $ + INTERFACE_LINK_LIBRARIES $ + IMPORTED_CONFIGURATIONS "${_MAGNUM_APPLICATION_IMPORTED_CONFIGURATIONS}") + if(_MAGNUM_APPLICATION_IMPORTED_LOCATION_RELEASE) + set_target_properties(Magnum::Application PROPERTIES + IMPORTED_LOCATION_RELEASE ${_MAGNUM_APPLICATION_IMPORTED_LOCATION_RELEASE}) + endif() + if(_MAGNUM_APPLICATION_IMPORTED_LOCATION_DEBUG) + set_target_properties(Magnum::Application PROPERTIES + IMPORTED_LOCATION_DEBUG ${_MAGNUM_APPLICATION_IMPORTED_LOCATION_DEBUG}) + endif() + endif() + if(MAGNUM_BUILD_DEPRECATED) + set(MAGNUM_APPLICATION_LIBRARIES Magnum::Application) + endif() + # Prevent creating the alias again + unset(_MAGNUM_APPLICATION_ALIAS) +endif() +if(_MAGNUM_CONTEXT_ALIAS AND NOT TARGET Magnum::Context) + get_target_property(_MAGNUM_CONTEXT_ALIASED_TARGET ${_MAGNUM_CONTEXT_ALIAS} ALIASED_TARGET) + if(_MAGNUM_CONTEXT_ALIASED_TARGET) + add_library(Magnum::Context ALIAS ${_MAGNUM_CONTEXT_ALIASED_TARGET}) + else() + add_library(Magnum::Context UNKNOWN IMPORTED) + get_target_property(_MAGNUM_CONTEXT_IMPORTED_CONFIGURATIONS ${_MAGNUM_CONTEXT_ALIAS} IMPORTED_CONFIGURATIONS) + get_target_property(_MAGNUM_CONTEXT_IMPORTED_LOCATION_RELEASE ${_MAGNUM_CONTEXT_ALIAS} IMPORTED_LOCATION_RELEASE) + get_target_property(_MAGNUM_CONTEXT_IMPORTED_LOCATION_DEBUG ${_MAGNUM_CONTEXT_ALIAS} IMPORTED_LOCATION_DEBUG) + set_target_properties(Magnum::Context PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES $ + INTERFACE_COMPILE_DEFINITIONS $ + INTERFACE_COMPILE_OPTIONS $ + INTERFACE_LINK_LIBRARIES $ + IMPORTED_CONFIGURATIONS "${_MAGNUM_CONTEXT_IMPORTED_CONFIGURATIONS}") + if(_MAGNUM_CONTEXT_IMPORTED_LOCATION_RELEASE) + set_target_properties(Magnum::Context PROPERTIES + IMPORTED_LOCATION_RELEASE ${_MAGNUM_CONTEXT_IMPORTED_LOCATION_RELEASE}) + endif() + if(_MAGNUM_CONTEXT_IMPORTED_LOCATION_DEBUG) + set_target_properties(Magnum::Context PROPERTIES + IMPORTED_LOCATION_DEBUG ${_MAGNUM_CONTEXT_IMPORTED_LOCATION_DEBUG}) + endif() + endif() + if(MAGNUM_BUILD_DEPRECATED) + set(MAGNUM_CONTEXT_LIBRARIES Magnum::Context) + endif() + # Prevent creating the alias again + unset(_MAGNUM_CONTEXT_ALIAS) +endif() + # Installation dirs include(${CORRADE_LIB_SUFFIX_MODULE}) set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin) @@ -615,29 +758,6 @@ set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTAL set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_INSTALL_DIR}/audioimporters) set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum) set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumPlugins) -mark_as_advanced(FORCE - MAGNUM_LIBRARY_DEBUG - MAGNUM_LIBRARY_RELEASE - MAGNUM_LIBRARY - MAGNUM_INCLUDE_DIR - MAGNUM_BINARY_INSTALL_DIR - MAGNUM_LIBRARY_INSTALL_DIR - MAGNUM_PLUGINS_DEBUG_INSTALL_DIR - MAGNUM_PLUGINS_RELEASE_INSTALL_DIR - MAGNUM_PLUGINS_FONT_DEBUG_INSTALL_DIR - MAGNUM_PLUGINS_FONT_RELEASE_INSTALL_DIR - MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_INSTALL_DIR - MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_INSTALL_DIR - MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_INSTALL_DIR - MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_INSTALL_DIR - MAGNUM_PLUGINS_IMPORTER_DEBUG_INSTALL_DIR - MAGNUM_PLUGINS_IMPORTER_RELEASE_INSTALL_DIR - MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_INSTALL_DIR - MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_INSTALL_DIR - MAGNUM_CMAKE_MODULE_INSTALL_DIR - MAGNUM_INCLUDE_INSTALL_DIR - MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR - _MAGNUM_CONFIGURE_FILE) # Get base plugin directory from main library location set(MAGNUM_PLUGINS_DEBUG_DIR ${_MAGNUM_LIBRARY_PATH}/magnum-d @@ -663,3 +783,8 @@ set(MAGNUM_PLUGINS_IMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/importers) set(MAGNUM_PLUGINS_AUDIOIMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/audioimporters) set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/audioimporters) set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/audioimporters) + +# Deprecated variables +if(MAGNUM_BUILD_DEPRECATED) + set(MAGNUM_LIBRARIES Magnum::Magnum) +endif() diff --git a/modules/FindNodeJs.cmake b/modules/FindNodeJs.cmake index 90f7ebf21..fe85046b2 100644 --- a/modules/FindNodeJs.cmake +++ b/modules/FindNodeJs.cmake @@ -1,15 +1,17 @@ -# - Find Node.js +#.rst: +# Find Node.js +# ------------ # -# This module defines: +# Finds the Node.js executable. This module defines: # # NODEJS_FOUND - True if Node.js executable is found -# NODEJS_EXECUTABLE - Node.js executable +# NodeJs::NodeJs - Node.js executable imported target # # # This file is part of Corrade. # -# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013 +# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -35,3 +37,8 @@ find_program(NODEJS_EXECUTABLE node) include(FindPackageHandleStandardArgs) find_package_handle_standard_args("NodeJs" DEFAULT_MSG NODEJS_EXECUTABLE) + +if(NOT TARGET NodeJs::NodeJs) + add_executable(NodeJs::NodeJs IMPORTED) + set_property(TARGET NodeJs::NodeJs PROPERTY IMPORTED_LOCATION ${NODEJS_EXECUTABLE}) +endif() diff --git a/modules/FindOpenGLES2.cmake b/modules/FindOpenGLES2.cmake index 179a53742..c99e976fb 100644 --- a/modules/FindOpenGLES2.cmake +++ b/modules/FindOpenGLES2.cmake @@ -1,8 +1,14 @@ -# - Find OpenGL ES 2 +#.rst: +# Find OpenGL ES 2 +# ---------------- # -# This module defines: +# Finds the OpenGL ES 2 library. This module defines: +# +# OpenGLES2_FOUND - True if OpenGL ES 2 library is found +# OpenGLES2::OpenGLES2 - OpenGL ES 2 imported target +# +# Additionally these variables are defined for internal usage: # -# OPENGLES2_FOUND - True if OpenGL ES 2 library is found # OPENGLES2_LIBRARY - OpenGL ES 2 library # OPENGLES2_INCLUDE_DIR - Include dir # @@ -10,7 +16,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -37,16 +43,50 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN) find_library(OPENGLES2_LIBRARY NAMES GLESv2 - libGLESv2 # ANGLE (CMake doesn't search for lib prefix on Windows) - ppapi_gles2) # NaCl + + # ANGLE (CMake doesn't search for lib prefix on Windows) + libGLESv2 + + # iOS + OpenGLES + + # NaCl + ppapi_gles2) set(OPENGLES2_LIBRARY_NEEDED OPENGLES2_LIBRARY) endif() # Include dir -find_path(OPENGLES2_INCLUDE_DIR - NAMES GLES2/gl2.h) +find_path(OPENGLES2_INCLUDE_DIR NAMES + GLES2/gl2.h + + # iOS + ES2/gl.h) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args("OpenGLES2" DEFAULT_MSG +find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG ${OPENGLES2_LIBRARY_NEEDED} OPENGLES2_INCLUDE_DIR) + +if(NOT TARGET OpenGLES2::OpenGLES2) + if(OPENGLES2_LIBRARY_NEEDED) + # Work around BUGGY framework support on OSX + # http://public.kitware.com/pipermail/cmake/2016-April/063179.html + if(CORRADE_TARGET_APPLE AND ${OPENGLES2_LIBRARY} MATCHES "\\.framework$") + add_library(OpenGLES2::OpenGLES2 INTERFACE IMPORTED) + set_property(TARGET OpenGLES2::OpenGLES2 APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${OPENGLES2_LIBRARY}) + else() + add_library(OpenGLES2::OpenGLES2 UNKNOWN IMPORTED) + set_property(TARGET OpenGLES2::OpenGLES2 PROPERTY + IMPORTED_LOCATION ${OPENGLES2_LIBRARY}) + endif() + else() + # This won't work in CMake 2.8.12, but that affects Emscripten only so + # I assume people building for that are not on that crap old Ubuntu + # 14.04 LTS + add_library(OpenGLES2::OpenGLES2 INTERFACE IMPORTED) + endif() + + set_property(TARGET OpenGLES2::OpenGLES2 PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${OPENGLES2_INCLUDE_DIR}) +endif() diff --git a/modules/FindOpenGLES3.cmake b/modules/FindOpenGLES3.cmake index 2d07aa5b4..3ae2c4e74 100644 --- a/modules/FindOpenGLES3.cmake +++ b/modules/FindOpenGLES3.cmake @@ -1,8 +1,14 @@ -# - Find OpenGL ES 3 +#.rst: +# Find OpenGL ES 3 +# ---------------- # -# This module defines: +# Finds the OpenGL ES 3 library. This module defines: +# +# OpenGLES3_FOUND - True if OpenGL ES 3 library is found +# OpenGLES3::OpenGLES3 - OpenGL ES 3 imported target +# +# Additionally these variables are defined for internal usage: # -# OPENGLES3_FOUND - True if OpenGL ES 3 library is found # OPENGLES3_LIBRARY - OpenGL ES 3 library # OPENGLES3_INCLUDE_DIR - Include dir # @@ -10,7 +16,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -42,15 +48,46 @@ if(NOT CORRADE_TARGET_EMSCRIPTEN) # support is provided in ES2 lib GLESv2 - libGLESv2) # ANGLE (CMake doesn't search for lib prefix on Windows) + # ANGLE (CMake doesn't search for lib prefix on Windows) + libGLESv2 + + # iOS + OpenGLES) set(OPENGLES3_LIBRARY_NEEDED OPENGLES3_LIBRARY) endif() # Include dir -find_path(OPENGLES3_INCLUDE_DIR - NAMES GLES3/gl3.h) +find_path(OPENGLES3_INCLUDE_DIR NAMES + GLES3/gl3.h + + # iOS + ES3/gl.h) include(FindPackageHandleStandardArgs) find_package_handle_standard_args("OpenGLES3" DEFAULT_MSG ${OPENGLES3_LIBRARY_NEEDED} OPENGLES3_INCLUDE_DIR) + +if(NOT TARGET OpenGLES3::OpenGLES3) + if(OPENGLES3_LIBRARY_NEEDED) + # Work around BUGGY framework support on OSX + # http://public.kitware.com/pipermail/cmake/2016-April/063179.html + if(CORRADE_TARGET_APPLE AND ${OPENGLES3_LIBRARY} MATCHES "\\.framework$") + add_library(OpenGLES3::OpenGLES3 INTERFACE IMPORTED) + set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${OPENGLES3_LIBRARY}) + else() + add_library(OpenGLES3::OpenGLES3 UNKNOWN IMPORTED) + set_property(TARGET OpenGLES3::OpenGLES3 PROPERTY + IMPORTED_LOCATION ${OPENGLES3_LIBRARY}) + endif() + else() + # This won't work in CMake 2.8.12, but that affects Emscripten only so + # I assume people building for that are not on that crap old Ubuntu + # 14.04 LTS + add_library(OpenGLES3::OpenGLES3 INTERFACE IMPORTED) + endif() + + set_property(TARGET OpenGLES3::OpenGLES3 PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${OPENGLES3_INCLUDE_DIR}) +endif() diff --git a/modules/FindSDL2.cmake b/modules/FindSDL2.cmake index aa95cbf12..172965181 100644 --- a/modules/FindSDL2.cmake +++ b/modules/FindSDL2.cmake @@ -1,16 +1,22 @@ -# - Find SDL2 +#.rst: +# Find SDL2 +# --------- # -# This module defines: +# Finds the SDL2 library. This module defines: # # SDL2_FOUND - True if SDL2 library is found -# SDL2_LIBRARY - SDL2 dynamic library -# SDL2_INCLUDE_DIR - Include dir +# SDL2::SDL2 - SDL2 imported target +# +# Additionally these variables are defined for internal usage: +# +# SDL2_LIBRARY - SDL2 library +# SDL2_INCLUDE_DIR - Root include dir # # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -61,7 +67,61 @@ find_path(SDL2_INCLUDE_DIR NAMES SDL_scancode.h PATH_SUFFIXES ${_SDL2_PATH_SUFFIXES}) +# iOS dependencies +if(CORRADE_TARGET_IOS) + set(_SDL2_FRAMEWORKS + AudioToolbox + CoreGraphics + CoreMotion + Foundation + GameController + QuartzCore + UIKit) + set(_SDL2_FRAMEWORK_LIBRARIES ) + foreach(framework ${_SDL2_FRAMEWORKS}) + find_library(_SDL2_${framework}_LIBRARY ${framework}) + list(APPEND _SDL2_FRAMEWORK_LIBRARIES ${_SDL2_${framework}_LIBRARY}) + list(APPEND _SDL2_FRAMEWORK_LIBRARY_NAMES _SDL2_${framework}_LIBRARY) + endforeach() +endif() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args("SDL2" DEFAULT_MSG ${SDL2_LIBRARY_NEEDED} + ${_SDL2_FRAMEWORK_LIBRARY_NAMES} SDL2_INCLUDE_DIR) + +if(NOT TARGET SDL2::SDL2) + if(SDL2_LIBRARY_NEEDED) + add_library(SDL2::SDL2 UNKNOWN IMPORTED) + + # Work around BUGGY framework support on OSX + # https://cmake.org/Bug/view.php?id=14105 + if(CORRADE_TARGET_APPLE AND ${SDL2_LIBRARY} MATCHES "\\.framework$") + set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION ${SDL2_LIBRARY}/SDL2) + else() + set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION ${SDL2_LIBRARY}) + endif() + + # Link frameworks on iOS + if(CORRADE_TARGET_IOS) + set_property(TARGET SDL2::SDL2 APPEND PROPERTY + INTERFACE_LINK_LIBRARIES ${_SDL2_FRAMEWORK_LIBRARIES}) + endif() + + # Link also EGL library, if on ES (and not on WebGL) + if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_DESKTOP_GLES AND NOT MAGNUM_TARGET_WEBGL) + find_package(EGL REQUIRED) + set_property(TARGET SDL2::SDL2 APPEND PROPERTY + INTERFACE_LINK_LIBRARIES EGL::EGL) + endif() + else() + # This won't work in CMake 2.8.12, but that affects Emscripten only so + # I assume people building for that are not on that crap old Ubuntu + # 14.04 LTS + add_library(SDL2::SDL2 INTERFACE IMPORTED) + endif() + + set_property(TARGET SDL2::SDL2 PROPERTY + INTERFACE_INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}) +endif() diff --git a/modules/MagnumConfig.cmake b/modules/MagnumConfig.cmake index 9049be70e..1d3452ac6 100644 --- a/modules/MagnumConfig.cmake +++ b/modules/MagnumConfig.cmake @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD index 592d3029a..428e6bb08 100644 --- a/package/archlinux/PKGBUILD +++ b/package/archlinux/PKGBUILD @@ -6,7 +6,7 @@ pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine" arch=('i686' 'x86_64') url="http://mosra.cz/blog/magnum.php" license=('MIT') -depends=('corrade' 'openal' 'freeglut' 'sdl2') +depends=('corrade' 'openal' 'freeglut' 'sdl2' 'glfw') makedepends=('cmake' 'ninja') options=('!strip') provides=('magnum-git') @@ -25,6 +25,7 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ @@ -49,7 +50,7 @@ build() { check() { cd "$_rootdir/build" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/archlinux/PKGBUILD-android-arm b/package/archlinux/PKGBUILD-android-arm index 272043844..01b7a6154 100644 --- a/package/archlinux/PKGBUILD-android-arm +++ b/package/archlinux/PKGBUILD-android-arm @@ -18,7 +18,6 @@ build() { cd "$_rootdir/build-android-arm" cmake .. \ - -DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Android-ARM.cmake" \ -DTARGET_GLES=ON \ -DTARGET_GLES2=ON \ diff --git a/package/archlinux/PKGBUILD-android-x86 b/package/archlinux/PKGBUILD-android-x86 index d8225212a..5862419ef 100644 --- a/package/archlinux/PKGBUILD-android-x86 +++ b/package/archlinux/PKGBUILD-android-x86 @@ -18,7 +18,6 @@ build() { cd "$_rootdir/build-android-x86" cmake .. \ - -DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Android-x86.cmake" \ -DTARGET_GLES=ON \ -DTARGET_GLES2=ON \ diff --git a/package/archlinux/PKGBUILD-clang b/package/archlinux/PKGBUILD-clang index 57baa3023..29a127c45 100644 --- a/package/archlinux/PKGBUILD-clang +++ b/package/archlinux/PKGBUILD-clang @@ -6,7 +6,7 @@ pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (built with clang)" arch=('i686' 'x86_64') url="http://mosra.cz/blog/magnum.php" license=('MIT') -depends=('corrade' 'openal' 'freeglut' 'sdl2') +depends=('corrade' 'openal' 'freeglut' 'sdl2' 'glfw') makedepends=('cmake' 'clang' 'ninja') options=('!strip') provides=('magnum-git') @@ -30,6 +30,7 @@ build() { -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ -DWITH_GLUTAPPLICATION=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSGLXAPPLICATION=ON \ @@ -51,7 +52,7 @@ build() { check() { cd "$_rootdir/build-clang" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/archlinux/PKGBUILD-clang-libc++ b/package/archlinux/PKGBUILD-clang-libc++ index 7e1e1a9db..bcbef4df6 100644 --- a/package/archlinux/PKGBUILD-clang-libc++ +++ b/package/archlinux/PKGBUILD-clang-libc++ @@ -6,7 +6,7 @@ pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (built with clang and libc arch=('i686' 'x86_64') url="http://mosra.cz/blog/magnum.php" license=('MIT') -depends=('corrade' 'openal' 'freeglut' 'sdl2' 'libc++') +depends=('corrade' 'openal' 'freeglut' 'sdl2' 'glfw' 'libc++') makedepends=('cmake' 'clang' 'ninja') options=('!strip') provides=('magnum-git') @@ -31,6 +31,7 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ @@ -54,7 +55,7 @@ build() { check() { cd "$_rootdir/build-clang-libc++" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/archlinux/PKGBUILD-emscripten b/package/archlinux/PKGBUILD-emscripten index 1142dc9ed..12445e06c 100644 --- a/package/archlinux/PKGBUILD-emscripten +++ b/package/archlinux/PKGBUILD-emscripten @@ -18,7 +18,6 @@ build() { cd "$_rootdir/build-emscripten" cmake .. \ - -DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Emscripten.cmake" \ -DCMAKE_PREFIX_PATH=/usr/lib/emscripten/system fi @@ -32,8 +31,7 @@ build() { -DWITH_MAGNUMFONT=ON \ -DWITH_OBJIMPORTER=ON \ -DWITH_TGAIMAGECONVERTER=ON \ - -DWITH_TGAIMPORTER=ON \ - -DWITH_WAVAUDIOIMPORTER=ON + -DWITH_TGAIMPORTER=ON make } diff --git a/package/archlinux/PKGBUILD-emscripten-webgl2 b/package/archlinux/PKGBUILD-emscripten-webgl2 index 2ccc843ed..5025f842d 100644 --- a/package/archlinux/PKGBUILD-emscripten-webgl2 +++ b/package/archlinux/PKGBUILD-emscripten-webgl2 @@ -18,7 +18,6 @@ build() { cd "$_rootdir/build-emscripten-webgl2" cmake .. \ - -DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/Emscripten.cmake" \ -DCMAKE_PREFIX_PATH=/usr/lib/emscripten/system fi diff --git a/package/archlinux/PKGBUILD-es2 b/package/archlinux/PKGBUILD-es2 index 2eea4e0c4..572e3e47f 100644 --- a/package/archlinux/PKGBUILD-es2 +++ b/package/archlinux/PKGBUILD-es2 @@ -37,7 +37,7 @@ build() { check() { cd "$_rootdir/build-es2" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/archlinux/PKGBUILD-es2desktop b/package/archlinux/PKGBUILD-es2desktop index 552984b26..6642f10a1 100644 --- a/package/archlinux/PKGBUILD-es2desktop +++ b/package/archlinux/PKGBUILD-es2desktop @@ -6,7 +6,7 @@ pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (desktop OpenGL ES 2.0 ver arch=('i686' 'x86_64') url="http://mosra.cz/blog/magnum.php" license=('MIT') -depends=('corrade' 'openal') +depends=('corrade' 'openal' 'sdl2' 'glfw') makedepends=('cmake' 'ninja') options=('!strip') provides=('magnum-git') @@ -24,6 +24,7 @@ build() { -DTARGET_GLES2=ON \ -DTARGET_DESKTOP_GLES=ON \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_XEGLAPPLICATION=ON \ @@ -44,7 +45,7 @@ build() { check() { cd "$_rootdir/build-es2desktop" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/archlinux/PKGBUILD-es3 b/package/archlinux/PKGBUILD-es3 index 587a1f9a7..132ffaa72 100644 --- a/package/archlinux/PKGBUILD-es3 +++ b/package/archlinux/PKGBUILD-es3 @@ -37,7 +37,7 @@ build() { check() { cd "$_rootdir/build-es3" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/archlinux/PKGBUILD-es3desktop b/package/archlinux/PKGBUILD-es3desktop index 9855e7c3a..31e7254ff 100644 --- a/package/archlinux/PKGBUILD-es3desktop +++ b/package/archlinux/PKGBUILD-es3desktop @@ -6,7 +6,7 @@ pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (desktop OpenGL ES 3.0 ver arch=('i686' 'x86_64') url="http://mosra.cz/blog/magnum.php" license=('MIT') -depends=('corrade' 'openal') +depends=('corrade' 'openal' 'sdl2' 'glfw') makedepends=('cmake' 'ninja') options=('!strip') provides=('magnum-git') @@ -24,6 +24,7 @@ build() { -DTARGET_GLES2=OFF \ -DTARGET_DESKTOP_GLES=ON \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_XEGLAPPLICATION=ON \ @@ -44,7 +45,7 @@ build() { check() { cd "$_rootdir/build-es3desktop" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/archlinux/PKGBUILD-gcc47 b/package/archlinux/PKGBUILD-gcc47 index acda7ac47..cdb125d4c 100644 --- a/package/archlinux/PKGBUILD-gcc47 +++ b/package/archlinux/PKGBUILD-gcc47 @@ -6,7 +6,7 @@ pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (built with GCC 4.7)" arch=('i686' 'x86_64') url="http://mosra.cz/blog/magnum.php" license=('MIT') -depends=('corrade' 'openal' 'freeglut' 'sdl2') +depends=('corrade' 'openal' 'freeglut' 'sdl2' 'glfw') makedepends=('cmake' 'ninja' 'gcc47') options=('!strip') provides=('magnum-git') @@ -33,6 +33,7 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ @@ -56,7 +57,7 @@ build() { check() { cd "$_rootdir/build-gcc47" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/archlinux/PKGBUILD-nacl-glibc b/package/archlinux/PKGBUILD-nacl-glibc index 16f035e9c..045c4387d 100644 --- a/package/archlinux/PKGBUILD-nacl-glibc +++ b/package/archlinux/PKGBUILD-nacl-glibc @@ -18,7 +18,6 @@ build() { cd "$_rootdir/build-nacl-glibc-x86-32" cmake .. \ - -DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-glibc-x86-32.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/nacl \ @@ -39,7 +38,6 @@ build() { cd "$_rootdir/build-nacl-glibc-x86-64" cmake .. \ - -DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-glibc-x86-64.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/nacl \ diff --git a/package/archlinux/PKGBUILD-nacl-newlib b/package/archlinux/PKGBUILD-nacl-newlib index 1821e61f0..58acf01a3 100644 --- a/package/archlinux/PKGBUILD-nacl-newlib +++ b/package/archlinux/PKGBUILD-nacl-newlib @@ -18,7 +18,6 @@ build() { cd "$_rootdir/build-nacl-newlib-x86-32" cmake .. \ - -DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-newlib-x86-32.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/nacl \ @@ -40,7 +39,6 @@ build() { cd "$_rootdir/build-nacl-newlib-x86-64" cmake .. \ - -DCMAKE_MODULE_PATH="$_rootdir/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="$_rootdir/toolchains/generic/NaCl-newlib-x86-64.cmake" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/nacl \ diff --git a/package/archlinux/PKGBUILD-release b/package/archlinux/PKGBUILD-release index c675243a7..6886a63fe 100644 --- a/package/archlinux/PKGBUILD-release +++ b/package/archlinux/PKGBUILD-release @@ -6,7 +6,7 @@ pkgdesc="C++11/C++14 and OpenGL 2D/3D graphics engine (debug+release libs)" arch=('i686' 'x86_64') url="http://mosra.cz/blog/magnum.php" license=('MIT') -depends=('corrade' 'openal' 'sdl2' 'freeglut') +depends=('corrade' 'openal' 'freeglut' 'sdl2' 'glfw') makedepends=('cmake' 'ninja') options=('!strip') provides=('magnum-git') @@ -21,6 +21,7 @@ build() { -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_INSTALL_PREFIX=/usr \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ @@ -71,10 +72,10 @@ build() { check() { cd "$_rootdir/build" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 cd "$_rootdir/build-release" - ctest --output-on-failure -j5 + CORRADE_TEST_COLOR=ON ctest --output-on-failure -j5 } package() { diff --git a/package/ci/appveyor.yml b/package/ci/appveyor.yml index 52be3c8a4..e8efe86fc 100644 --- a/package/ci/appveyor.yml +++ b/package/ci/appveyor.yml @@ -2,9 +2,6 @@ version: '{branch}-{build}' -branches: - only: - - master skip_tags: true shallow_clone: true clone_depth: 1 @@ -30,9 +27,9 @@ install: - cinst ninja # OpenAL -- appveyor DownloadFile http://kcat.strangesoft.net/openal-binaries/openal-soft-1.17.0-bin.zip -- 7z x openal-soft-1.17.0-bin.zip -- ren openal-soft-1.17.0-bin openal +- appveyor DownloadFile http://kcat.strangesoft.net/openal-binaries/openal-soft-1.17.2-bin.zip +- 7z x openal-soft-1.17.2-bin.zip +- ren openal-soft-1.17.2-bin openal - ren openal\bin\Win32\soft_oal.dll OpenAL32.dll - echo [General] > %APPDATA%/alsoft.ini - echo drivers=null >> %APPDATA%/alsoft.ini @@ -56,7 +53,7 @@ install: build_script: - mkdir build - cd build -- cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:/Sys -DCMAKE_PREFIX_PATH="%APPVEYOR_BUILD_FOLDER%/SDL;%APPVEYOR_BUILD_FOLDER%/openal" -DWITH_AUDIO=ON -DWITH_SDL2APPLICATION=ON -DWITH_WINDOWLESSWGLAPPLICATION=ON -DWITH_WGLCONTEXT=ON -DWITH_MAGNUMFONT=ON -DWITH_MAGNUMFONTCONVERTER=ON -DWITH_OBJIMPORTER=ON -DWITH_TGAIMAGECONVERTER=ON -DWITH_TGAIMPORTER=ON -DWITH_WAVAUDIOIMPORTER=ON -DWITH_DISTANCEFIELDCONVERTER=ON -DWITH_FONTCONVERTER=ON -DWITH_MAGNUMINFO=ON -DBUILD_STATIC=%BUILD_STATIC% -DBUILD_TESTS=ON -G Ninja +- cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:/Sys -DCMAKE_PREFIX_PATH="%APPVEYOR_BUILD_FOLDER%/SDL;%APPVEYOR_BUILD_FOLDER%/openal" -DWITH_AUDIO=ON -DWITH_SDL2APPLICATION=ON -DWITH_WINDOWLESSWGLAPPLICATION=ON -DWITH_WGLCONTEXT=ON -DWITH_MAGNUMFONT=ON -DWITH_MAGNUMFONTCONVERTER=ON -DWITH_OBJIMPORTER=ON -DWITH_TGAIMAGECONVERTER=ON -DWITH_TGAIMPORTER=ON -DWITH_WAVAUDIOIMPORTER=ON -DWITH_DISTANCEFIELDCONVERTER=ON -DWITH_FONTCONVERTER=ON -DWITH_MAGNUMINFO=ON -DBUILD_STATIC=%BUILD_STATIC% -DBUILD_TESTS=ON -DBUILD_GL_TESTS=ON -G Ninja - cmake --build . - cmake --build . --target install - cmake . -DCMAKE_INSTALL_PREFIX=%APPVEYOR_BUILD_FOLDER%/Deploy -DBUILD_TESTS=OFF @@ -67,7 +64,7 @@ build_script: test_script: - cd %APPVEYOR_BUILD_FOLDER%/build - SET fail=0 -- ctest --output-on-failure || SET fail=1 & ver > nul +- ctest --output-on-failure -E GLTest || SET fail=1 & ver > nul - cd %APPVEYOR_BUILD_FOLDER% - appveyor PushArtifact magnum.zip - exit %fail% diff --git a/package/ci/jenkins-android.xml b/package/ci/jenkins-android.xml index d215debc0..845e228a4 100644 --- a/package/ci/jenkins-android.xml +++ b/package/ci/jenkins-android.xml @@ -39,6 +39,13 @@ false Magnum + + gl + + es2 + es3 + + toolchain @@ -61,22 +68,29 @@ git submodule init git submodule update +if [ ${gl} = "es2" ] ; then + gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=ON" +elif [ ${gl} = "es3" ] ; then + gl_flags="-DTARGET_GLES=ON -DTARGET_GLES2=OFF" +fi + if [ "${compatibility}" = "deprecated" ] ; then deprecated_build_flag=ON else deprecated_build_flag=OFF fi -mkdir -p build-android-${toolchain}-${compatibility} -cd build-android-${toolchain}-${compatibility} +mkdir -p build-android-${gl}-${toolchain}-${compatibility} +cd build-android-${gl}-${toolchain}-${compatibility} cmake .. \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_MODULE_PATH="${WORKSPACE}/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE=../toolchains/generic/Android-${toolchain}.cmake \ -DCMAKE_FIND_ROOT_PATH=${JENKINS_HOME}/filesystem/android-${toolchain}-${compatibility} \ - -DCMAKE_INSTALL_PREFIX=${JENKINS_HOME}/filesystem/android-${toolchain}-${compatibility} \ + -DCMAKE_PREFIX_PATH=${JENKINS_HOME}/filesystem/android-${toolchain}-${compatibility} \ + -DCMAKE_INSTALL_PREFIX=${JENKINS_HOME}/filesystem/android-${gl}-${toolchain}-${compatibility} \ -DBUILD_DEPRECATED=${deprecated_build_flag} \ + ${gl_flags} \ `#-DWITH_AUDIO=ON` \ -DWITH_ANDROIDAPPLICATION=ON \ -DWITH_EGLCONTEXT=ON \ @@ -108,7 +122,7 @@ ninja install/strip true diff --git a/package/ci/jenkins-clang-analyzer.xml b/package/ci/jenkins-clang-analyzer.xml index 09587fe85..24d4f123c 100644 --- a/package/ci/jenkins-clang-analyzer.xml +++ b/package/ci/jenkins-clang-analyzer.xml @@ -108,6 +108,7 @@ scan-build --use-c++=$(which clang++) cmake .. \ -DBUILD_DEPRECATED=${deprecated_build_flag} \ ${gl_flags} \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ diff --git a/package/ci/jenkins-clang-sanitizer.xml b/package/ci/jenkins-clang-sanitizer.xml index a13fe4343..929a225fe 100644 --- a/package/ci/jenkins-clang-sanitizer.xml +++ b/package/ci/jenkins-clang-sanitizer.xml @@ -116,6 +116,7 @@ cmake .. \ -DBUILD_DEPRECATED=${deprecated_build_flag} \ ${gl_flags} \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ diff --git a/package/ci/jenkins-emscripten.xml b/package/ci/jenkins-emscripten.xml index 916941224..aa9aa6317 100644 --- a/package/ci/jenkins-emscripten.xml +++ b/package/ci/jenkins-emscripten.xml @@ -78,7 +78,6 @@ cd build-emscripten-${compatibility}-${gl} cmake .. \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_MODULE_PATH="${WORKSPACE}/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten.cmake" \ -DCMAKE_FIND_ROOT_PATH=${JENKINS_HOME}/filesystem/emscripten-${compatibility} \ -DCMAKE_PREFIX_PATH=${JENKINS_HOME}/filesystem/emscripten-${compatibility} \ diff --git a/package/ci/jenkins-gltests.xml b/package/ci/jenkins-gltests.xml index d6794e420..9f291c445 100644 --- a/package/ci/jenkins-gltests.xml +++ b/package/ci/jenkins-gltests.xml @@ -82,6 +82,18 @@ cd build-${compiler}-${libraries}-${compatibility}-${gl} ninja ctest --output-on-failure -R GLTest -j5 || true +if [ ${gl} = "desktop" ] ; then + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access GL_ARB_get_texture_sub_image" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access GL_ARB_get_texture_sub_image GL_ARB_multi_bind" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access GL_ARB_get_texture_sub_image GL_ARB_multi_bind GL_ARB_robustness" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access GL_ARB_get_texture_sub_image GL_ARB_multi_bind GL_ARB_robustness GL_ARB_separate_shader_objects" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access GL_ARB_get_texture_sub_image GL_ARB_multi_bind GL_ARB_robustness GL_ARB_separate_shader_objects GL_ARB_texture_storage" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access GL_ARB_get_texture_sub_image GL_ARB_multi_bind GL_ARB_robustness GL_ARB_separate_shader_objects GL_ARB_texture_storage GL_ARB_texture_storage_multisample" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access GL_ARB_get_texture_sub_image GL_ARB_multi_bind GL_ARB_robustness GL_ARB_separate_shader_objects GL_ARB_texture_storage GL_ARB_texture_storage_multisample GL_KHR_debug" ctest --output-on-failure -R GLTest -j5 || true + MAGNUM_DISABLE_EXTENSIONS="GL_ARB_direct_state_access GL_EXT_direct_state_access GL_ARB_get_texture_sub_image GL_ARB_multi_bind GL_ARB_robustness GL_ARB_separate_shader_objects GL_ARB_texture_storage GL_ARB_texture_storage_multisample GL_KHR_debug GL_ARB_compressed_texture_pixel_storage" ctest --output-on-failure -R GLTest -j5 || true +fi ]]> diff --git a/package/ci/jenkins-nacl.xml b/package/ci/jenkins-nacl.xml index 2cccbe67b..16f970324 100644 --- a/package/ci/jenkins-nacl.xml +++ b/package/ci/jenkins-nacl.xml @@ -72,7 +72,6 @@ cd build-nacl-${toolchain}-${compatibility} cmake .. \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_MODULE_PATH="${WORKSPACE}/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE=../toolchains/generic/NaCl-${toolchain}.cmake \ -DCMAKE_FIND_ROOT_PATH=${JENKINS_HOME}/filesystem/nacl-${toolchain}-${compatibility} \ -DCMAKE_INSTALL_PREFIX=${JENKINS_HOME}/filesystem/nacl-${toolchain}-${compatibility} \ diff --git a/package/ci/jenkins.xml b/package/ci/jenkins.xml index d3a88cfa6..4f76bf63e 100644 --- a/package/ci/jenkins.xml +++ b/package/ci/jenkins.xml @@ -141,6 +141,7 @@ cmake .. \ ${static_build_flag} \ ${gl_flags} \ -DWITH_AUDIO=ON \ + -DWITH_GLFWAPPLICATION=ON \ -DWITH_GLUTAPPLICATION=ON \ -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ diff --git a/package/ci/travis.yml b/package/ci/travis.yml index 9e83485cb..b49d85c3b 100644 --- a/package/ci/travis.yml +++ b/package/ci/travis.yml @@ -1,9 +1,5 @@ # kate: indent-width 2; -branches: - only: - - master - os: - linux - osx @@ -12,7 +8,7 @@ addons: apt: sources: - ubuntu-toolchain-r-test - - kalakris-cmake + - kubuntu-backports packages: - g++-4.7 - cmake @@ -31,20 +27,27 @@ cache: - $HOME/sdl2 install: +- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; fi + - if [ "$TRAVIS_OS_NAME" == "linux" ]; then export CXX=g++-4.7; fi - if [ "$TRAVIS_OS_NAME" == "linux" ]; then export PLATFORM_GL_API=GLX; fi - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PLATFORM_GL_API=CGL; fi - printf "[General]\ndrivers=null" > ~/.alsoftrc # SDL (cached) -- if [ ! -e "$HOME/sdl2/include" ]; then curl -O http://www.libsdl.org/release/SDL2-2.0.3.tar.gz && tar -xzvf SDL2-2.0.3.tar.gz && cd SDL2-2.0.3 && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/sdl2 -DCMAKE_BUILD_TYPE=Release && cmake --build . --target install && cd ../..; fi +- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install sdl2; fi +- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ ! -e "$HOME/sdl2/include" ]; then curl -O http://www.libsdl.org/release/SDL2-2.0.4.tar.gz && tar -xzvf SDL2-2.0.4.tar.gz && cd SDL2-2.0.4 && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/sdl2 -DCMAKE_BUILD_TYPE=Release && cmake --build . --target install && cd ../..; fi + +# GLFW (cached) +- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install homebrew/versions/glfw3; fi +- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ ! -e "$HOME/glfw/include" ]; then wget https://github.com/glfw/glfw/releases/download/3.1.2/glfw-3.1.2.zip && unzip glfw-3.1.2.zip && cd glfw-3.1.2 && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/glfw -DCMAKE_BUILD_TYPE=Release -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF && cmake --build . --target install && cd ../..; fi # Corrade - git clone --depth 1 git://github.com/mosra/corrade.git - cd corrade - mkdir build - cd build -- cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/deps -DCMAKE_INSTALL_RPATH=$HOME/deps/lib -DCMAKE_MACOSX_RPATH=ON -DCMAKE_BUILD_TYPE=Release +- cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/deps -DCMAKE_INSTALL_RPATH=$HOME/deps/lib -DCMAKE_BUILD_TYPE=Release - cmake --build . - cmake --build . --target install - cd .. @@ -52,6 +55,6 @@ install: script: - mkdir build && cd build -- cmake .. -DCMAKE_PREFIX_PATH="$HOME/sdl2;$HOME/deps" -DCMAKE_BUILD_TYPE=Release -DWITH_AUDIO=ON -DWITH_SDL2APPLICATION=ON -DWITH_WINDOWLESS${PLATFORM_GL_API}APPLICATION=ON -DWITH_${PLATFORM_GL_API}CONTEXT=ON -DWITH_MAGNUMFONT=ON -DWITH_MAGNUMFONTCONVERTER=ON -DWITH_OBJIMPORTER=ON -DWITH_TGAIMAGECONVERTER=ON -DWITH_TGAIMPORTER=ON -DWITH_WAVAUDIOIMPORTER=ON -DWITH_DISTANCEFIELDCONVERTER=ON -DWITH_FONTCONVERTER=ON -DWITH_MAGNUMINFO=ON -DBUILD_TESTS=ON +- cmake .. -DCMAKE_PREFIX_PATH="$HOME/deps;$HOME/sdl2;$HOME/glfw" -DCMAKE_BUILD_TYPE=Release -DWITH_AUDIO=ON -DWITH_GLFWAPPLICATION=ON -DWITH_SDL2APPLICATION=ON -DWITH_WINDOWLESS${PLATFORM_GL_API}APPLICATION=ON -DWITH_${PLATFORM_GL_API}CONTEXT=ON -DWITH_MAGNUMFONT=ON -DWITH_MAGNUMFONTCONVERTER=ON -DWITH_OBJIMPORTER=ON -DWITH_TGAIMAGECONVERTER=ON -DWITH_TGAIMPORTER=ON -DWITH_WAVAUDIOIMPORTER=ON -DWITH_DISTANCEFIELDCONVERTER=ON -DWITH_FONTCONVERTER=ON -DWITH_MAGNUMINFO=ON -DBUILD_TESTS=ON -DBUILD_GL_TESTS=ON - cmake --build . -- ctest --output-on-failure +- ctest --output-on-failure -E GLTest diff --git a/package/debian/changelog b/package/debian/changelog index 796c69eba..53cbb5959 100644 --- a/package/debian/changelog +++ b/package/debian/changelog @@ -1,4 +1,4 @@ -magnum (1.0-1) UNRELEASED; urgency=low +magnum (1.0) UNRELEASED; urgency=low * Latest upstream version diff --git a/package/debian/rules b/package/debian/rules index 53e29e11f..c20a60cdc 100755 --- a/package/debian/rules +++ b/package/debian/rules @@ -9,7 +9,6 @@ override_dh_auto_configure: -DWITH_GLXAPPLICATION=ON \ -DWITH_SDL2APPLICATION=ON \ -DWITH_WINDOWLESSGLXAPPLICATION=ON \ - -DWITH_EGLCONTEXT=ON \ -DWITH_GLXCONTEXT=ON \ -DWITH_MAGNUMFONT=ON \ -DWITH_MAGNUMFONTCONVERTER=ON \ @@ -20,3 +19,9 @@ override_dh_auto_configure: -DWITH_DISTANCEFIELDCONVERTER=ON \ -DWITH_FONTCONVERTER=ON \ -DWITH_MAGNUMINFO=ON + +# Extraordinarily coarse way to suppress error about libGL not being in +# dependencies when the user has installed NVidia binary drivers which are not +# in the repositories. Can't I just IGNORE A SIGNLE FILE DAMMIT?! +override_dh_shlibdeps: + dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info diff --git a/package/homebrew/magnum.rb b/package/homebrew/magnum.rb new file mode 100644 index 000000000..e9e0095bc --- /dev/null +++ b/package/homebrew/magnum.rb @@ -0,0 +1,20 @@ +# kate: indent-width 2; + +class Magnum < Formula + desc "C++11/C++14 and OpenGL 2D/3D graphics engine" + homepage "https://github.com/mosra/magnum" + head "git://github.com/mosra/magnum.git" + + depends_on "cmake" + depends_on "corrade" + depends_on "sdl2" + + def install + system "mkdir build" + cd "build" do + system "cmake", "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_INSTALL_PREFIX=#{prefix}", "-DWITH_AUDIO=ON", "-DWITH_SDL2APPLICATION=ON", "-DWITH_WINDOWLESSCGLAPPLICATION=ON", "-DWITH_CGLCONTEXT=ON", "-DWITH_MAGNUMFONT=ON", "-DWITH_MAGNUMFONTCONVERTER=ON", "-DWITH_OBJIMPORTER=ON", "-DWITH_TGAIMAGECONVERTER=ON", "-DWITH_TGAIMPORTER=ON", "-DWITH_WAVAUDIOIMPORTER=ON", "-DWITH_DISTANCEFIELDCONVERTER=ON", "-DWITH_FONTCONVERTER=ON", "-DWITH_MAGNUMINFO=ON", ".." + system "cmake", "--build", "." + system "cmake", "--build", ".", "--target", "install" + end + end +end diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dcb11ca12..4d22dc8f2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -27,7 +27,7 @@ # without any warning, only in release build, any attempt to add debug print # results in issue disappearing. Not an issue on Clang or GCC < 4.8. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.0") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") + add_compile_options("-fno-strict-aliasing") endif() # On MSVC remove /W3, as we are replacing it with /W4 @@ -37,17 +37,13 @@ endif() # Emscripten needs special flag to use WebGL 2 if(CORRADE_TARGET_EMSCRIPTEN AND NOT TARGET_GLES2) + # TODO: give me INTERFACE_LINK_OPTIONS or something, please set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_WEBGL2=1") endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CORRADE_CXX_FLAGS}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CORRADE_INCLUDE_DIRS}) - -# We can use both implicit include path (GLES2/gl2.h) where our headers can -# be overriden with system ones or explicit (MagnumExternal/OpenGL/GLES2/gl2ext.h) -# where only our headers will be used -include_directories(${PROJECT_SOURCE_DIR}/src/MagnumExternal/OpenGL) +set_directory_properties(PROPERTIES + CORRADE_CXX_STANDARD 11 + CORRADE_USE_PEDANTIC_FLAGS ON) add_subdirectory(MagnumExternal) add_subdirectory(Magnum) diff --git a/src/Magnum/AbstractFramebuffer.cpp b/src/Magnum/AbstractFramebuffer.cpp index 25ecc43d1..d5ced3a92 100644 --- a/src/Magnum/AbstractFramebuffer.cpp +++ b/src/Magnum/AbstractFramebuffer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -38,7 +38,7 @@ namespace Magnum { Vector2i AbstractFramebuffer::maxViewportSize() { - Vector2i& value = Context::current()->state().framebuffer->maxViewportSize; + Vector2i& value = Context::current().state().framebuffer->maxViewportSize; /* Get the value, if not already cached */ if(value == Vector2i()) @@ -50,16 +50,16 @@ Vector2i AbstractFramebuffer::maxViewportSize() { Int AbstractFramebuffer::maxDrawBuffers() { #ifdef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif #endif - GLint& value = Context::current()->state().framebuffer->maxDrawBuffers; + GLint& value = Context::current().state().framebuffer->maxDrawBuffers; /* Get the value, if not already cached */ if(value == 0) { @@ -75,10 +75,10 @@ Int AbstractFramebuffer::maxDrawBuffers() { #ifndef MAGNUM_TARGET_GLES Int AbstractFramebuffer::maxDualSourceDrawBuffers() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current()->state().framebuffer->maxDualSourceDrawBuffers; + GLint& value = Context::current().state().framebuffer->maxDualSourceDrawBuffers; /* Get the value, if not already cached */ if(value == 0) @@ -105,16 +105,19 @@ void AbstractFramebuffer::bind() { } void AbstractFramebuffer::bindInternal(FramebufferTarget target) { - #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - (this->*Context::current()->state().framebuffer->bindImplementation)(target); - #else + #ifndef MAGNUM_TARGET_GLES2 bindImplementationDefault(target); + #elif defined(MAGNUM_TARGET_WEBGL) + static_cast(target); + bindImplementationSingle(); + #else + (this->*Context::current().state().framebuffer->bindImplementation)(target); #endif } #ifdef MAGNUM_TARGET_GLES2 void AbstractFramebuffer::bindImplementationSingle(FramebufferTarget) { - Implementation::FramebufferState& state = *Context::current()->state().framebuffer; + Implementation::FramebufferState& state = *Context::current().state().framebuffer; CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding); if(state.readBinding == _id) return; @@ -130,7 +133,7 @@ void AbstractFramebuffer::bindImplementationSingle(FramebufferTarget) { inline #endif void AbstractFramebuffer::bindImplementationDefault(FramebufferTarget target) { - Implementation::FramebufferState& state = *Context::current()->state().framebuffer; + Implementation::FramebufferState& state = *Context::current().state().framebuffer; if(target == FramebufferTarget::Read) { if(state.readBinding == _id) return; @@ -146,16 +149,18 @@ void AbstractFramebuffer::bindImplementationDefault(FramebufferTarget target) { } FramebufferTarget AbstractFramebuffer::bindInternal() { - #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - return (this->*Context::current()->state().framebuffer->bindInternalImplementation)(); - #else + #ifndef MAGNUM_TARGET_GLES2 return bindImplementationDefault(); + #elif defined(MAGNUM_TARGET_WEBGL) + return bindImplementationSingle(); + #else + return (this->*Context::current().state().framebuffer->bindInternalImplementation)(); #endif } #ifdef MAGNUM_TARGET_GLES2 FramebufferTarget AbstractFramebuffer::bindImplementationSingle() { - Implementation::FramebufferState& state = *Context::current()->state().framebuffer; + Implementation::FramebufferState& state = *Context::current().state().framebuffer; CORRADE_INTERNAL_ASSERT(state.readBinding == state.drawBinding); /* Bind the framebuffer, if not already */ @@ -175,7 +180,7 @@ FramebufferTarget AbstractFramebuffer::bindImplementationSingle() { inline #endif FramebufferTarget AbstractFramebuffer::bindImplementationDefault() { - Implementation::FramebufferState& state = *Context::current()->state().framebuffer; + Implementation::FramebufferState& state = *Context::current().state().framebuffer; /* Return target to which the framebuffer is already bound */ if(state.readBinding == _id) @@ -194,7 +199,7 @@ FramebufferTarget AbstractFramebuffer::bindImplementationDefault() { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) 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); + Context::current().state().framebuffer->blitImplementation(source, destination, sourceRectangle, destinationRectangle, mask, filter); } #endif @@ -250,14 +255,14 @@ AbstractFramebuffer& AbstractFramebuffer::setViewport(const Range2Di& rectangle) _viewport = rectangle; /* Update the viewport if the framebuffer is currently bound */ - if(Context::current()->state().framebuffer->drawBinding == _id) + if(Context::current().state().framebuffer->drawBinding == _id) setViewportInternal(); return *this; } void AbstractFramebuffer::setViewportInternal() { - Implementation::FramebufferState& state = *Context::current()->state().framebuffer; + Implementation::FramebufferState& state = *Context::current().state().framebuffer; CORRADE_INTERNAL_ASSERT(_viewport != Implementation::FramebufferState::DisengagedViewport); CORRADE_INTERNAL_ASSERT(state.drawBinding == _id); @@ -291,7 +296,7 @@ void AbstractFramebuffer::read(const Range2Di& rectangle, Image2D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelPack); #endif image.storage().applyPack(); - (Context::current()->state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), data.size(), data + (Context::current().state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), data.size(), data #ifdef MAGNUM_TARGET_GLES2 + Implementation::pixelStorageSkipOffsetFor(image, rectangle.size()) #endif @@ -317,7 +322,7 @@ void AbstractFramebuffer::read(const Range2Di& rectangle, BufferImage2D& image, image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (Context::current()->state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), dataSize, nullptr); + (Context::current().state().framebuffer->readImplementation)(rectangle, image.format(), image.type(), dataSize, nullptr); } BufferImage2D AbstractFramebuffer::read(const Range2Di& rectangle, BufferImage2D&& image, BufferUsage usage) { diff --git a/src/Magnum/AbstractFramebuffer.h b/src/Magnum/AbstractFramebuffer.h index e0ec07038..d8c9a61fc 100644 --- a/src/Magnum/AbstractFramebuffer.h +++ b/src/Magnum/AbstractFramebuffer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/AbstractObject.cpp b/src/Magnum/AbstractObject.cpp index a50bc0345..beaff5bca 100644 --- a/src/Magnum/AbstractObject.cpp +++ b/src/Magnum/AbstractObject.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -113,10 +113,10 @@ namespace { #endif Int AbstractObject::maxLabelLength() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current()->state().debug->maxLabelLength; + GLint& value = Context::current().state().debug->maxLabelLength; if(value == 0) { #ifndef MAGNUM_TARGET_GLES @@ -161,7 +161,7 @@ std::string AbstractObject::getLabelImplementationNoOp(GLenum, GLuint) { return std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, const GLuint name) { /* Get label size (w/o null terminator). Specifying 0 as size is not allowed, thus we pass the maximum instead. */ - GLsizei size; + GLsizei size = 0; #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(identifier, name, maxLabelLength(), &size, nullptr); #elif !defined(CORRADE_TARGET_NACL) @@ -189,7 +189,7 @@ std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, c } std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, const GLuint name) { - GLsizei size; + GLsizei size = 0; /* Get label size (w/o null terminator) */ #ifndef CORRADE_TARGET_NACL @@ -205,7 +205,7 @@ std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, c std::string label; label.resize(size+1); #ifndef CORRADE_TARGET_NACL - glGetObjectLabelEXT(identifier, name, size+1, nullptr, &label[0]); + glGetObjectLabelEXT(type, name, size+1, nullptr, &label[0]); #else CORRADE_ASSERT_UNREACHABLE(); #endif diff --git a/src/Magnum/AbstractObject.h b/src/Magnum/AbstractObject.h index 60fa9cfae..86cd1bb92 100644 --- a/src/Magnum/AbstractObject.h +++ b/src/Magnum/AbstractObject.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/AbstractQuery.cpp b/src/Magnum/AbstractQuery.cpp index 0feead69e..4f90c7fd8 100644 --- a/src/Magnum/AbstractQuery.cpp +++ b/src/Magnum/AbstractQuery.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -37,7 +37,7 @@ namespace Magnum { AbstractQuery::AbstractQuery(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current()->state().query->createImplementation)(); + (this->*Context::current().state().query->createImplementation)(); } #ifdef MAGNUM_BUILD_DEPRECATED @@ -79,17 +79,17 @@ void AbstractQuery::createImplementationDSA() { #ifndef MAGNUM_TARGET_WEBGL std::string AbstractQuery::label() const { #ifndef MAGNUM_TARGET_GLES - return Context::current()->state().debug->getLabelImplementation(GL_QUERY, _id); + return Context::current().state().debug->getLabelImplementation(GL_QUERY, _id); #else - return Context::current()->state().debug->getLabelImplementation(GL_QUERY_KHR, _id); + return Context::current().state().debug->getLabelImplementation(GL_QUERY_KHR, _id); #endif } AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayView label) { #ifndef MAGNUM_TARGET_GLES - Context::current()->state().debug->labelImplementation(GL_QUERY, _id, label); + Context::current().state().debug->labelImplementation(GL_QUERY, _id, label); #else - Context::current()->state().debug->labelImplementation(GL_QUERY_KHR, _id, label); + Context::current().state().debug->labelImplementation(GL_QUERY_KHR, _id, label); #endif return *this; } diff --git a/src/Magnum/AbstractQuery.h b/src/Magnum/AbstractQuery.h index 2f0427874..ea2b20e86 100644 --- a/src/Magnum/AbstractQuery.h +++ b/src/Magnum/AbstractQuery.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/AbstractResourceLoader.h b/src/Magnum/AbstractResourceLoader.h index c32ab37fa..2a40386b4 100644 --- a/src/Magnum/AbstractResourceLoader.h +++ b/src/Magnum/AbstractResourceLoader.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index 88f825150..fc5f2f096 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -50,7 +50,7 @@ namespace Implementation { } Int AbstractShaderProgram::maxVertexAttributes() { - GLint& value = Context::current()->state().shaderProgram->maxVertexAttributes; + GLint& value = Context::current().state().shaderProgram->maxVertexAttributes; /* Get the value, if not already cached */ if(value == 0) @@ -62,13 +62,13 @@ Int AbstractShaderProgram::maxVertexAttributes() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Int AbstractShaderProgram::maxAtomicCounterBufferSize() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shaderProgram->maxAtomicCounterBufferSize; + GLint& value = Context::current().state().shaderProgram->maxAtomicCounterBufferSize; if(value == 0) glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE, &value); @@ -78,13 +78,13 @@ Int AbstractShaderProgram::maxAtomicCounterBufferSize() { Int AbstractShaderProgram::maxComputeSharedMemorySize() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shaderProgram->maxComputeSharedMemorySize; + GLint& value = Context::current().state().shaderProgram->maxComputeSharedMemorySize; if(value == 0) glGetIntegerv(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE, &value); @@ -94,13 +94,13 @@ Int AbstractShaderProgram::maxComputeSharedMemorySize() { Int AbstractShaderProgram::maxComputeWorkGroupInvocations() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shaderProgram->maxComputeWorkGroupInvocations; + GLint& value = Context::current().state().shaderProgram->maxComputeWorkGroupInvocations; if(value == 0) glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &value); @@ -108,15 +108,53 @@ Int AbstractShaderProgram::maxComputeWorkGroupInvocations() { return value; } +Vector3i AbstractShaderProgram::maxComputeWorkGroupCount() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + #else + if(!Context::current().isVersionSupported(Version::GLES310)) + #endif + return {}; + + Vector3i& value = Context::current().state().shaderProgram->maxComputeWorkGroupCount; + + if(value.isZero()) { + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 0, &value.x()); + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 1, &value.y()); + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, 2, &value.z()); + } + + return value; +} + +Vector3i AbstractShaderProgram::maxComputeWorkGroupSize() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + #else + if(!Context::current().isVersionSupported(Version::GLES310)) + #endif + return {}; + + Vector3i& value = Context::current().state().shaderProgram->maxComputeWorkGroupSize; + + if(value.isZero()) { + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &value.x()); + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1, &value.y()); + glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 2, &value.z()); + } + + return value; +} + Int AbstractShaderProgram::maxImageUnits() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shaderProgram->maxImageUnits; + GLint& value = Context::current().state().shaderProgram->maxImageUnits; if(value == 0) glGetIntegerv(GL_MAX_IMAGE_UNITS, &value); @@ -127,10 +165,10 @@ Int AbstractShaderProgram::maxImageUnits() { #ifndef MAGNUM_TARGET_GLES Int AbstractShaderProgram::maxImageSamples() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current()->state().shaderProgram->maxImageSamples; + GLint& value = Context::current().state().shaderProgram->maxImageSamples; if(value == 0) glGetIntegerv(GL_MAX_IMAGE_SAMPLES, &value); @@ -143,13 +181,13 @@ Int AbstractShaderProgram::maxImageSamples() { #ifndef MAGNUM_TARGET_WEBGL Int AbstractShaderProgram::maxCombinedShaderOutputResources() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported() || !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() || !Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shaderProgram->maxCombinedShaderOutputResources; + GLint& value = Context::current().state().shaderProgram->maxCombinedShaderOutputResources; if(value == 0) glGetIntegerv(GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES, &value); @@ -159,13 +197,13 @@ Int AbstractShaderProgram::maxCombinedShaderOutputResources() { Long AbstractShaderProgram::maxShaderStorageBlockSize() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint64& value = Context::current()->state().shaderProgram->maxShaderStorageBlockSize; + GLint64& value = Context::current().state().shaderProgram->maxShaderStorageBlockSize; if(value == 0) glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &value); @@ -176,11 +214,11 @@ Long AbstractShaderProgram::maxShaderStorageBlockSize() { Int AbstractShaderProgram::maxUniformBlockSize() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shaderProgram->maxUniformBlockSize; + GLint& value = Context::current().state().shaderProgram->maxUniformBlockSize; if(value == 0) glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &value); @@ -191,13 +229,13 @@ Int AbstractShaderProgram::maxUniformBlockSize() { #ifndef MAGNUM_TARGET_WEBGL Int AbstractShaderProgram::maxUniformLocations() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shaderProgram->maxUniformLocations; + GLint& value = Context::current().state().shaderProgram->maxUniformLocations; if(value == 0) glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &value); @@ -208,11 +246,11 @@ Int AbstractShaderProgram::maxUniformLocations() { Int AbstractShaderProgram::minTexelOffset() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shaderProgram->minTexelOffset; + GLint& value = Context::current().state().shaderProgram->minTexelOffset; if(value == 0) glGetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, &value); @@ -222,11 +260,11 @@ Int AbstractShaderProgram::minTexelOffset() { Int AbstractShaderProgram::maxTexelOffset() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shaderProgram->maxTexelOffset; + GLint& value = Context::current().state().shaderProgram->maxTexelOffset; if(value == 0) glGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, &value); @@ -245,7 +283,7 @@ AbstractShaderProgram::AbstractShaderProgram(AbstractShaderProgram&& other) noex AbstractShaderProgram::~AbstractShaderProgram() { /* Remove current usage from the state */ - GLuint& current = Context::current()->state().shaderProgram->current; + GLuint& current = Context::current().state().shaderProgram->current; if(current == _id) current = 0; if(_id) glDeleteProgram(_id); @@ -260,17 +298,17 @@ AbstractShaderProgram& AbstractShaderProgram::operator=(AbstractShaderProgram&& #ifndef MAGNUM_TARGET_WEBGL std::string AbstractShaderProgram::label() const { #ifndef MAGNUM_TARGET_GLES - return Context::current()->state().debug->getLabelImplementation(GL_PROGRAM, _id); + return Context::current().state().debug->getLabelImplementation(GL_PROGRAM, _id); #else - return Context::current()->state().debug->getLabelImplementation(GL_PROGRAM_KHR, _id); + return Context::current().state().debug->getLabelImplementation(GL_PROGRAM_KHR, _id); #endif } AbstractShaderProgram& AbstractShaderProgram::setLabelInternal(const Containers::ArrayView label) { #ifndef MAGNUM_TARGET_GLES - Context::current()->state().debug->labelImplementation(GL_PROGRAM, _id, label); + Context::current().state().debug->labelImplementation(GL_PROGRAM, _id, label); #else - Context::current()->state().debug->labelImplementation(GL_PROGRAM_KHR, _id, label); + Context::current().state().debug->labelImplementation(GL_PROGRAM_KHR, _id, label); #endif return *this; } @@ -294,9 +332,16 @@ std::pair AbstractShaderProgram::validate() { return {success, std::move(message)}; } +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +void AbstractShaderProgram::dispatchCompute(const Vector3ui& workgroupCount) { + use(); + glDispatchCompute(workgroupCount.x(), workgroupCount.y(), workgroupCount.z()); +} +#endif + void AbstractShaderProgram::use() { /* Use only if the program isn't already in use */ - GLuint& current = Context::current()->state().shaderProgram->current; + GLuint& current = Context::current().state().shaderProgram->current; if(current != _id) glUseProgram(current = _id); } @@ -361,7 +406,7 @@ bool AbstractShaderProgram::link(std::initializer_list name) { - GLint location = glGetUniformLocation(_id, name); + const GLint location = glGetUniformLocation(_id, name); if(location == -1) - Warning() << "AbstractShaderProgram: location of uniform \'" + std::string{name, name.size()} + "\' cannot be retrieved!"; + Warning() << "AbstractShaderProgram: location of uniform \'" << Debug::nospace << std::string{name, name.size()} << Debug::nospace << "\' cannot be retrieved"; return location; } +#ifndef MAGNUM_TARGET_GLES2 +UnsignedInt AbstractShaderProgram::uniformBlockIndexInternal(const Containers::ArrayView name) { + const GLuint index = glGetUniformBlockIndex(_id, name); + if(index == GL_INVALID_INDEX) + Warning() << "AbstractShaderProgram: index of uniform block \'" << Debug::nospace << std::string{name, name.size()} << Debug::nospace << "\' cannot be retrieved"; + return index; +} +#endif + void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView values) { - (this->*Context::current()->state().shaderProgram->uniform1fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform1fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLfloat* const values) { @@ -430,7 +484,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform2fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform2fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLfloat>* const values) { @@ -458,7 +512,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform3fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform3fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLfloat>* const values) { @@ -486,7 +540,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform4fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform4fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLfloat>* const values) { @@ -514,7 +568,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView values) { - (this->*Context::current()->state().shaderProgram->uniform1ivImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform1ivImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLint* values) { @@ -542,7 +596,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform2ivImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform2ivImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLint>* const values) { @@ -570,7 +624,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform3ivImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform3ivImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLint>* const values) { @@ -598,7 +652,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform4ivImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform4ivImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLint>* const values) { @@ -627,7 +681,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView values) { - (this->*Context::current()->state().shaderProgram->uniform1uivImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform1uivImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLuint* const values) { @@ -646,7 +700,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform2uivImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform2uivImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLuint>* const values) { @@ -665,7 +719,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform3uivImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform3uivImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLuint>* const values) { @@ -684,7 +738,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform4uivImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform4uivImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLuint>* const values) { @@ -705,7 +759,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView values) { - (this->*Context::current()->state().shaderProgram->uniform1dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform1dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const GLdouble* const values) { @@ -722,7 +776,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform2dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform2dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<2, GLdouble>* const values) { @@ -739,7 +793,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform3dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform3dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<3, GLdouble>* const values) { @@ -756,7 +810,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniform4dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniform4dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::Vector<4, GLdouble>* const values) { @@ -774,7 +828,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix2fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix2fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLfloat>* const values) { @@ -802,7 +856,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix3fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix3fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLfloat>* const values) { @@ -830,7 +884,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix4fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix4fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLfloat>* const values) { @@ -859,7 +913,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix2x3fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix2x3fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLfloat>* const values) { @@ -878,7 +932,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix3x2fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix3x2fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLfloat>* const values) { @@ -897,7 +951,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix2x4fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix2x4fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLfloat>* const values) { @@ -916,7 +970,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix4x2fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix4x2fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLfloat>* const values) { @@ -935,7 +989,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix3x4fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix3x4fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLfloat>* const values) { @@ -954,7 +1008,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #endif void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix4x3fvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix4x3fvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLfloat>* const values) { @@ -975,7 +1029,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT_SSOEXT(const GLint locat #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix2dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix2dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 2, GLdouble>* const values) { @@ -992,7 +1046,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix3dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix3dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 3, GLdouble>* const values) { @@ -1009,7 +1063,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix4dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix4dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 4, GLdouble>* const values) { @@ -1026,7 +1080,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix2x3dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix2x3dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 3, GLdouble>* const values) { @@ -1043,7 +1097,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix3x2dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix3x2dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 2, GLdouble>* const values) { @@ -1060,7 +1114,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix2x4dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix2x4dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<2, 4, GLdouble>* const values) { @@ -1077,7 +1131,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix4x2dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix4x2dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 2, GLdouble>* const values) { @@ -1094,7 +1148,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix3x4dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix3x4dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<3, 4, GLdouble>* const values) { @@ -1111,7 +1165,7 @@ void AbstractShaderProgram::uniformImplementationDSAEXT(const GLint location, co } void AbstractShaderProgram::setUniform(const Int location, const Containers::ArrayView> values) { - (this->*Context::current()->state().shaderProgram->uniformMatrix4x3dvImplementation)(location, values.size(), values); + (this->*Context::current().state().shaderProgram->uniformMatrix4x3dvImplementation)(location, values.size(), values); } void AbstractShaderProgram::uniformImplementationDefault(const GLint location, const GLsizei count, const Math::RectangularMatrix<4, 3, GLdouble>* const values) { diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index 635424774..74538e0b9 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -99,9 +99,10 @@ MyShader& setNormalMatrix(const Matrix3x3& matrix) { return *this; } @endcode -- **Texture setting functions** in which you bind the textures - to particular texture units using @ref Texture::bind() "*Texture::bind()" - and equivalents, for example: +- **Texture and texture image setting functions** in which you bind the + textures/images to particular texture/image units using + @ref Texture::bind() "*Texture::bind()" / + @ref Texture::bindImage() "*Texture::bindImage()" and similar, for example: @code MyShader& setDiffuseTexture(Texture2D& texture) { texture.bind(0); @@ -136,8 +137,8 @@ The preferred workflow is to specify attribute location for vertex shader input attributes and fragment shader output attributes explicitly in the shader code, e.g.: @code -// GLSL 3.30, or -#extension GL_ARB_explicit_attrib_location: enable +// GLSL 3.30, GLSL ES 3.00 or +#extension GL_ARB_explicit_attrib_location: require layout(location = 0) in vec4 position; layout(location = 1) in vec3 normal; layout(location = 2) in vec2 textureCoordinates; @@ -151,8 +152,8 @@ layout(location = 0, index = 0) out vec4 color; layout(location = 1, index = 1) out vec3 normal; @endcode -If you don't have the required extension, declare the attributes without -`layout()` qualifier and use functions @ref bindAttributeLocation() and +If you don't have the required version/extension, declare the attributes +without `layout()` qualifier and use functions @ref bindAttributeLocation() and @ref bindFragmentDataLocation() / @ref bindFragmentDataLocationIndexed() between attaching the shaders and linking the program. Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES. @@ -178,7 +179,7 @@ bindFragmentDataLocationIndexed(NormalOutput, 1, "normal"); // Link... @endcode -@see @ref Mesh::maxVertexAttributes(), @ref AbstractFramebuffer::maxDrawBuffers() +@see @ref maxVertexAttributes(), @ref AbstractFramebuffer::maxDrawBuffers() @requires_gl30 Extension @extension{EXT,gpu_shader4} for using @ref bindFragmentDataLocation(). @requires_gl33 Extension @extension{ARB,blend_func_extended} for using @@ -208,15 +209,15 @@ bindFragmentDataLocationIndexed(NormalOutput, 1, "normal"); The preferred workflow is to specify uniform locations directly in the shader code, e.g.: @code -// GLSL 4.30, or -#extension GL_ARB_explicit_uniform_location: enable +// GLSL 4.30, GLSL ES 3.10 or +#extension GL_ARB_explicit_uniform_location: require layout(location = 0) uniform mat4 projectionMatrix; layout(location = 1) uniform mat4 transformationMatrix; layout(location = 2) uniform mat3 normalMatrix; @endcode -If you don't have the required extension, declare the uniforms without the -`layout()` qualifier, get uniform location using @ref uniformLocation() *after* +If you don't have the required version/extension, declare the uniforms without +the `layout()` qualifier, get uniform location using @ref uniformLocation() *after* linking stage and then use the queried location in uniform setting functions. Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES. @code @@ -238,22 +239,94 @@ Int normalMatrixUniform = uniformLocation("normalMatrix"); @requires_gles Explicit uniform location is not supported in WebGL. Use @ref uniformLocation() instead. +@anchor AbstractShaderProgram-uniform-block-binding +### Uniform block bindings + +The preferred workflow is to specify uniform block binding directly in the +shader code, e.g.: +@code +// GLSL 4.20, GLSL ES 3.10 or +#extension GL_ARB_shading_language_420pack: require +layout(std140, binding = 0) uniform matrices { + mat4 projectionMatrix; + mat4 transformationMatrix; +}; +layout(std140, binding = 1) uniform material { + vec4 diffuse; + vec4 specular; +}; +@endcode + +If you don't have the required version/extension, declare the uniform blocks +without the `layout()` qualifier, get uniform block index using +@ref uniformBlockIndex() and then map it to the uniform buffer binding using +@ref setUniformBlockBinding(). Note that additional syntax changes may be +needed for GLSL ES. +@code +layout(std140) uniform matrices { + mat4 projectionMatrix; + mat4 transformationMatrix; +}; +layout(std140) uniform material { + vec4 diffuse; + vec4 specular; +}; +@endcode +@code +setUniformBlockBinding(uniformBlockIndex("matrices"), 0); +setUniformBlockBinding(uniformBlockIndex("material"), 1); +@endcode + +@see @ref Buffer::maxUniformBindings() +@requires_gl31 Extension @extension{ARB,uniform_buffer_object} +@requires_gl42 Extension @extension{ARB,shading_language_420pack} for explicit + uniform block binding instead of using @ref uniformBlockIndex() and + @ref setUniformBlockBinding(). +@requires_gles30 Uniform buffers are not available in OpenGL ES 2.0. +@requires_gles31 Explicit uniform block binding is not supported in OpenGL ES + 3.0 and older. Use @ref uniformBlockIndex() and @ref setUniformBlockBinding() + instead. +@requires_webgl20 Uniform buffers are not available in WebGL 1.0. +@requires_gles Explicit uniform block binding is not supported in WebGL. Use + @ref uniformBlockIndex() and @ref setUniformBlockBinding() instead. + +@anchor AbstractShaderProgram-shader-storage-block-binding +### Shader storage block bindings + +The workflow is to specify shader storage block binding directly in the shader +code, e.g.: +@code +// GLSL 4.30 or GLSL ES 3.10 +layout(std430, binding = 0) buffer vertices { + vec3 position; + vec3 color; +}; +layout(std430, binding = 1) buffer normals { + vec3 normal; +}; +@endcode + +@see @ref Buffer::maxShaderStorageBindings() +@requires_gl43 Extension @extension{ARB,shader_storage_buffer_object} +@requires_gles31 Shader storage is not available in OpenGL ES 3.0 and older. +@requires_gles Shader storage is not available in WebGL. + @anchor AbstractShaderProgram-texture-units -### Specifying texture binding units +### Specifying texture and image binding units -The preferred workflow is to specify texture binding unit directly in the +The preferred workflow is to specify texture/image binding unit directly in the shader code, e.g.: @code -// GLSL 4.20, or -#extension GL_ARB_shading_language_420pack: enable +// GLSL 4.20, GLSL ES 3.10 or +#extension GL_ARB_shading_language_420pack: require layout(binding = 0) uniform sampler2D diffuseTexture; layout(binding = 1) uniform sampler2D specularTexture; @endcode -If you don't have the required extension, declare the uniforms without the -`binding` qualifier and set the texture binding unit using +If you don't have the required version/extension, declare the uniforms without +the `binding` qualifier and set the texture binding unit using @ref setUniform(Int, const T&) "setUniform(Int, Int)". Note that additional -syntax changes may be needed for GLSL 1.20 and GLSL ES 1.0. +syntax changes may be needed for GLSL ES. @code uniform sampler2D diffuseTexture; uniform sampler2D specularTexture; @@ -263,7 +336,7 @@ setUniform(uniformLocation("diffuseTexture"), 0); setUniform(uniformLocation("specularTexture"), 1); @endcode -@see @ref Shader::maxTextureImageUnits() +@see @ref Shader::maxTextureImageUnits(), @ref maxImageUnits() @requires_gl42 Extension @extension{ARB,shading_language_420pack} for explicit texture binding unit instead of using @ref setUniform(Int, const T&) "setUniform(Int, Int)". @@ -280,7 +353,7 @@ The preferred workflow is to specify output binding points directly in the shader code, e.g.: @code // GLSL 4.40, or -#extension GL_ARB_enhanced_layouts: enable +#extension GL_ARB_enhanced_layouts: require layout(xfb_buffer = 0, xfb_stride = 32) out block { layout(xfb_offset = 0) vec3 position; layout(xfb_offset = 16) vec3 normal; @@ -288,8 +361,8 @@ layout(xfb_buffer = 0, xfb_stride = 32) out block { layout(xfb_buffer = 1) out vec3 velocity; @endcode -If you don't have the required extension, declare the uniforms without the -`xfb_*` qualifier and set the binding points using @ref setTransformFeedbackOutputs(). +If you don't have the required version/extension, declare the uniforms without +the `xfb_*` qualifier and set the binding points using @ref setTransformFeedbackOutputs(). Equivalent setup for the previous code would be the following: @code out block { @@ -310,14 +383,17 @@ setTransformFeedbackOutputs({ @see @ref TransformFeedback::maxInterleavedComponents(), @ref TransformFeedback::maxSeparateAttributes(), @ref TransformFeedback::maxSeparateComponents() +@requires_gl40 Extension @extension{ARB,transform_feedback2} @requires_gl40 Extension @extension{ARB,transform_feedback3} for using `gl_NextBuffer` or `gl_SkipComponents#` names in @ref setTransformFeedbackOutputs() function. @requires_gl44 Extension @extension{ARB,enhanced_layouts} for explicit transform feedback output specification instead of using @ref setTransformFeedbackOutputs(). +@requires_gles30 Transform feedback is not available in OpenGL ES 2.0. @requires_gl Explicit transform feedback output specification is not available in OpenGL ES or WebGL. +@requires_webgl20 Transform feedback is not available in WebGL 1.0. @anchor AbstractShaderProgram-rendering-workflow ## Rendering workflow @@ -337,6 +413,13 @@ shader.setTransformation(transformation) mesh.draw(shader); @endcode +@anchor AbstractShaderProgram-compute-workflow +## Compute workflow + +Add just the @ref Shader::Type::Compute shader and implement uniform/texture +setting functions as needed. After setting up required parameters call +@ref dispatchCompute(). + @anchor AbstractShaderProgram-types ## Mapping between GLSL and Magnum types @@ -464,7 +547,31 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { */ static Int maxComputeWorkGroupInvocations(); - /** @todo MAX_COMPUTE_WORK_GROUP_COUNT, MAX_COMPUTE_WORK_GROUP_SIZE */ + /** + * @brief Max supported compute work group count + * + * The result is cached, repeated queries don't result in repeated + * OpenGL calls. If neither extension @extension{ARB,compute_shader} + * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns zero + * vector. + * @see @fn_gl{Get} with @def_gl{MAX_COMPUTE_WORK_GROUP_COUNT} + * @requires_gles30 Not defined in OpenGL ES 2.0. + * @requires_gles Compute shaders are not available in WebGL. + */ + static Vector3i maxComputeWorkGroupCount(); + + /** + * @brief Max supported compute work group size + * + * The result is cached, repeated queries don't result in repeated + * OpenGL calls. If neither extension @extension{ARB,compute_shader} + * (part of OpenGL 4.3) nor OpenGL ES 3.1 is available, returns zero + * vector. + * @see @fn_gl{Get} with @def_gl{MAX_COMPUTE_WORK_GROUP_SIZE} + * @requires_gles30 Not defined in OpenGL ES 2.0. + * @requires_gles Compute shaders are not available in WebGL. + */ + static Vector3i maxComputeWorkGroupSize(); /** * @brief Max supported image unit count @@ -656,6 +763,21 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { */ std::pair validate(); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /** + * @brief Dispatch compute + * @param workgroupCount Workgroup count in given dimension + * + * Valid only on programs with compute shader attached. + * @see @fn_gl{DispatchCompute} + * @requires_gl43 Extension @extension{ARB,compute_shader} + * @requires_gles31 Compute shaders are not available in OpenGL ES 3.0 + * and older. + * @requires_gles Compute shaders are not available in WebGL. + */ + void dispatchCompute(const Vector3ui& workgroupCount); + #endif + #ifdef MAGNUM_BUILD_DEPRECATED /** * @brief Use shader for rendering @@ -858,7 +980,9 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * @brief Get uniform location * @param name Uniform name * - * @see @fn_gl{GetUniformLocation} + * If given uniform is not found in the linked shader, a warning is + * printed and `-1` is returned. + * @see @ref setUniform(), @fn_gl{GetUniformLocation} * @deprecated_gl Preferred usage is to specify uniform location * explicitly in the shader instead of using this function. See * @ref AbstractShaderProgram-uniform-location "class documentation" @@ -873,6 +997,32 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { return uniformLocationInternal({name, size - 1}); } + #ifndef MAGNUM_TARGET_GLES2 + /** + * @brief Get uniform block index + * @param name Uniform block name + * + * If given uniform block name is not found in the linked shader, a + * warning is printed and `0xffffffffu` is returned. + * @see @ref setUniformBlockBinding(), @fn_gl{GetUniformBlockIndex} + * @requires_gl31 Extension @extension{ARB,uniform_buffer_object} + * @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0. + * @requires_webgl20 Uniform buffers are not available in WebGL 1.0. + * @deprecated_gl Preferred usage is to specify uniform block binding + * explicitly in the shader instead of using this function. See + * @ref AbstractShaderProgram-uniform-block-binding "class documentation" + * for more information. + */ + UnsignedInt uniformBlockIndex(const std::string& name) { + return uniformBlockIndexInternal({name.data(), name.size()}); + } + + /** @overload */ + template UnsignedInt uniformBlockIndex(const char(&name)[size]) { + return uniformBlockIndexInternal({name, size - 1}); + } + #endif + /** * @brief Set uniform value * @param location Uniform location @@ -881,6 +1031,7 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * Convenience alternative for setting one value, see * @ref setUniform(Int, Containers::ArrayView) for more * information. + * @see @ref uniformLocation() */ #ifdef DOXYGEN_GENERATING_OUTPUT template inline void setUniform(Int location, const T& value); @@ -919,8 +1070,9 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * @es_extension{EXT,separate_shader_objects} OpenGL ES extension nor * OpenGL ES 3.1 is available, the shader is marked for use before the * operation. - * @see @ref setUniform(Int, const T&), @fn_gl{UseProgram}, @fn_gl{Uniform} - * or @fn_gl{ProgramUniform}/@fn_gl_extension{ProgramUniform,EXT,direct_state_access}. + * @see @ref setUniform(Int, const T&), @ref uniformLocation(), + * @fn_gl{UseProgram}, @fn_gl{Uniform} or @fn_gl{ProgramUniform}/ + * @fn_gl_extension{ProgramUniform,EXT,direct_state_access}. */ void setUniform(Int location, Containers::ArrayView values); void setUniform(Int location, Containers::ArrayView> values); /**< @overload */ @@ -1005,6 +1157,27 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { } #endif + #ifndef MAGNUM_TARGET_GLES2 + /** + * @brief Set uniform block binding + * @param index Uniform block index + * @param binding Uniform block binding + * + * @see @ref uniformBlockIndex(), @ref Buffer::maxUniformBindings(), + * @fn_gl{UniformBlockBinding} + * @requires_gl31 Extension @extension{ARB,uniform_buffer_object} + * @requires_gles30 Uniform buffers are not available in OpenGL ES 2.0. + * @requires_webgl20 Uniform buffers are not available in WebGL 1.0. + * @deprecated_gl Preferred usage is to specify uniform block binding + * explicitly in the shader instead of using this function. See + * @ref AbstractShaderProgram-uniform-block-binding "class documentation" + * for more information. + */ + void setUniformBlockBinding(UnsignedInt index, UnsignedInt binding) { + glUniformBlockBinding(_id, index, binding); + } + #endif + private: #ifndef MAGNUM_TARGET_WEBGL AbstractShaderProgram& setLabelInternal(Containers::ArrayView label); @@ -1014,6 +1187,7 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { void bindFragmentDataLocationIndexedInternal(UnsignedInt location, UnsignedInt index, Containers::ArrayView name); void bindFragmentDataLocationInternal(UnsignedInt location, Containers::ArrayView name); Int uniformLocationInternal(Containers::ArrayView name); + UnsignedInt uniformBlockIndexInternal(Containers::ArrayView name); #ifndef MAGNUM_BUILD_DEPRECATED void use(); diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 3a1de6229..815c029ef 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -49,7 +49,7 @@ namespace Magnum { #ifndef MAGNUM_TARGET_GLES2 Float AbstractTexture::maxLodBias() { - GLfloat& value = Context::current()->state().texture->maxLodBias; + GLfloat& value = Context::current().state().texture->maxLodBias; /* Get the value, if not already cached */ if(value == 0.0f) @@ -62,13 +62,13 @@ Float AbstractTexture::maxLodBias() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Int AbstractTexture::maxColorSamples() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().texture->maxColorSamples; + GLint& value = Context::current().state().texture->maxColorSamples; /* Get the value, if not already cached */ if(value == 0) @@ -79,13 +79,13 @@ Int AbstractTexture::maxColorSamples() { Int AbstractTexture::maxDepthSamples() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().texture->maxDepthSamples; + GLint& value = Context::current().state().texture->maxDepthSamples; /* Get the value, if not already cached */ if(value == 0) @@ -96,13 +96,13 @@ Int AbstractTexture::maxDepthSamples() { Int AbstractTexture::maxIntegerSamples() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().texture->maxIntegerSamples; + GLint& value = Context::current().state().texture->maxIntegerSamples; /* Get the value, if not already cached */ if(value == 0) @@ -113,18 +113,18 @@ Int AbstractTexture::maxIntegerSamples() { #endif void AbstractTexture::unbind(const Int textureUnit) { - Implementation::TextureState& textureState = *Context::current()->state().texture; + Implementation::TextureState& textureState = *Context::current().state().texture; /* If given texture unit is already unbound, nothing to do */ if(textureState.bindings[textureUnit].second == 0) return; /* Unbind the texture, reset state tracker */ - Context::current()->state().texture->unbindImplementation(textureUnit); + Context::current().state().texture->unbindImplementation(textureUnit); textureState.bindings[textureUnit] = {}; } void AbstractTexture::unbindImplementationDefault(const GLint textureUnit) { - Implementation::TextureState& textureState = *Context::current()->state().texture; + Implementation::TextureState& textureState = *Context::current().state().texture; /* Activate given texture unit if not already active, update state tracker */ if(textureState.currentTextureUnit != textureUnit) @@ -141,12 +141,12 @@ void AbstractTexture::unbindImplementationMulti(const GLint textureUnit) { } void AbstractTexture::unbindImplementationDSA(const GLint textureUnit) { - CORRADE_INTERNAL_ASSERT(Context::current()->state().texture->bindings[textureUnit].first != 0); + CORRADE_INTERNAL_ASSERT(Context::current().state().texture->bindings[textureUnit].first != 0); glBindTextureUnit(textureUnit, 0); } void AbstractTexture::unbindImplementationDSAEXT(const GLint textureUnit) { - Implementation::TextureState& textureState = *Context::current()->state().texture; + Implementation::TextureState& textureState = *Context::current().state().texture; CORRADE_INTERNAL_ASSERT(textureState.bindings[textureUnit].first != 0); glBindMultiTextureEXT(GL_TEXTURE0 + textureUnit, textureState.bindings[textureUnit].first, 0); @@ -155,13 +155,13 @@ void AbstractTexture::unbindImplementationDSAEXT(const GLint textureUnit) { void AbstractTexture::unbind(const Int firstTextureUnit, const std::size_t count) { /* State tracker is updated in the implementations */ - Context::current()->state().texture->bindMultiImplementation(firstTextureUnit, {nullptr, count}); + Context::current().state().texture->bindMultiImplementation(firstTextureUnit, {nullptr, count}); } /** @todoc const std::initializer_list makes Doxygen grumpy */ void AbstractTexture::bind(const Int firstTextureUnit, std::initializer_list textures) { /* State tracker is updated in the implementations */ - Context::current()->state().texture->bindMultiImplementation(firstTextureUnit, {textures.begin(), textures.size()}); + Context::current().state().texture->bindMultiImplementation(firstTextureUnit, {textures.begin(), textures.size()}); } void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, const Containers::ArrayView textures) { @@ -172,7 +172,7 @@ void AbstractTexture::bindImplementationFallback(const GLint firstTextureUnit, c #ifndef MAGNUM_TARGET_GLES /** @todoc const Containers::ArrayView makes Doxygen grumpy */ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Containers::ArrayView textures) { - Implementation::TextureState& textureState = *Context::current()->state().texture; + Implementation::TextureState& textureState = *Context::current().state().texture; /* Create array of IDs and also update bindings in state tracker */ /** @todo VLAs */ @@ -197,8 +197,25 @@ void AbstractTexture::bindImplementationMulti(const GLint firstTextureUnit, Cont } #endif +#ifndef MAGNUM_TARGET_GLES +Int AbstractTexture::compressedBlockDataSize(const GLenum target, const TextureFormat format) { + return (Context::current().state().texture->compressedBlockDataSizeImplementation)(target, format); +} + +Int AbstractTexture::compressedBlockDataSizeImplementationDefault(const GLenum target, const TextureFormat format) { + GLint value; + glGetInternalformativ(target, GLenum(format), GL_TEXTURE_COMPRESSED_BLOCK_SIZE, 1, &value); + return value; +} + +Int AbstractTexture::compressedBlockDataSizeImplementationBitsWorkaround(const GLenum target, const TextureFormat format) { + /* NVidia (358.16) reports the value in bits instead of bytes */ + return compressedBlockDataSizeImplementationDefault(target, format)/8; +} +#endif + AbstractTexture::AbstractTexture(GLenum target): _target{target}, _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current()->state().texture->createImplementation)(); + (this->*Context::current().state().texture->createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -218,12 +235,19 @@ AbstractTexture::~AbstractTexture() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* Remove all bindings */ - for(auto& binding: Context::current()->state().texture->bindings) - { + for(auto& binding: Context::current().state().texture->bindings) { /* MSVC 2015 needs the parentheses around */ if(binding.second == _id) binding = {}; } + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /* Remove all image bindings */ + for(auto& binding: Context::current().state().texture->imageBindings) { + /* MSVC 2015 needs the parentheses around */ + if(std::get<0>(binding) == _id) binding = {}; + } + #endif + glDeleteTextures(1, &_id); } @@ -242,18 +266,74 @@ void AbstractTexture::createIfNotAlready() { #ifndef MAGNUM_TARGET_WEBGL std::string AbstractTexture::label() { createIfNotAlready(); - return Context::current()->state().debug->getLabelImplementation(GL_TEXTURE, _id); + return Context::current().state().debug->getLabelImplementation(GL_TEXTURE, _id); } AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayView label) { createIfNotAlready(); - Context::current()->state().debug->labelImplementation(GL_TEXTURE, _id, label); + Context::current().state().debug->labelImplementation(GL_TEXTURE, _id, label); return *this; } #endif +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +void AbstractTexture::unbindImage(const Int imageUnit) { + Implementation::TextureState& textureState = *Context::current().state().texture; + + /* If already unbound in given image unit, nothing to do */ + if(std::get<0>(textureState.imageBindings[imageUnit]) == 0) return; + + /* Update state tracker, bind the texture to the unit */ + std::get<0>(textureState.imageBindings[imageUnit]) = 0; + glBindImageTexture(imageUnit, 0, 0, false, 0, GL_READ_ONLY, GL_R8); +} + +#ifndef MAGNUM_TARGET_GLES +/** @todoc const Containers::ArrayView makes Doxygen grumpy */ +void AbstractTexture::bindImagesInternal(const Int firstImageUnit, Containers::ArrayView textures) { + Implementation::TextureState& textureState = *Context::current().state().texture; + + /* Create array of IDs and also update bindings in state tracker */ + Containers::Array ids{textures ? textures.size() : 0}; + bool different = false; + for(std::size_t i = 0; i != textures.size(); ++i) { + const std::tuple state = textures && textures[i] ? + std::tuple(textures[i]->_id, 0, true, 0, GL_READ_WRITE) : + std::tuple(0, 0, false, 0, GL_READ_ONLY); + + if(textures) { + if(textures[i]) { + textures[i]->createIfNotAlready(); + } + ids[i] = std::get<0>(state); + } + + if(textureState.imageBindings[firstImageUnit + i] != state) { + different = true; + textureState.imageBindings[firstImageUnit + i] = state; + } + } + + /* Avoid doing the binding if there is nothing different */ + if(different) glBindImageTextures(firstImageUnit, textures.size(), ids); +} +#endif + +void AbstractTexture::bindImageInternal(const Int imageUnit, const Int level, const bool layered, const Int layer, const ImageAccess access, const ImageFormat format) { + Implementation::TextureState& textureState = *Context::current().state().texture; + const std::tuple state{_id, level, layered, layer, GLenum(access)}; + + /* If already bound in given texture unit, nothing to do */ + if(textureState.imageBindings[imageUnit] == state) return; + + /* Update state tracker, bind the texture to the unit */ + textureState.imageBindings[imageUnit] = state; + glBindImageTexture(imageUnit, _id, level, layered, layer, GLenum(access), GLenum(format)); +} +#endif + void AbstractTexture::bind(Int textureUnit) { - Implementation::TextureState& textureState = *Context::current()->state().texture; + Implementation::TextureState& textureState = *Context::current().state().texture; /* If already bound in given texture unit, nothing to do */ if(textureState.bindings[textureUnit].second == _id) return; @@ -264,7 +344,7 @@ void AbstractTexture::bind(Int textureUnit) { } void AbstractTexture::bindImplementationDefault(GLint textureUnit) { - Implementation::TextureState& textureState = *Context::current()->state().texture; + Implementation::TextureState& textureState = *Context::current().state().texture; /* Activate given texture unit if not already active, update state tracker */ if(textureState.currentTextureUnit != textureUnit) @@ -293,13 +373,13 @@ void AbstractTexture::bindImplementationDSAEXT(GLint textureUnit) { #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::setBaseLevel(Int level) { - (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_BASE_LEVEL, level); + (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_BASE_LEVEL, level); } #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::setMaxLevel(Int level) { - (this->*Context::current()->state().texture->parameteriImplementation)( + (this->*Context::current().state().texture->parameteriImplementation)( #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_MAX_LEVEL #else @@ -310,32 +390,32 @@ void AbstractTexture::setMaxLevel(Int level) { #endif void AbstractTexture::setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap) { - (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap)); + (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_MIN_FILTER, GLint(filter)|GLint(mipmap)); } void AbstractTexture::setMagnificationFilter(const Sampler::Filter filter) { - (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_MAG_FILTER, GLint(filter)); + (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_MAG_FILTER, GLint(filter)); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::setMinLod(const Float lod) { - (this->*Context::current()->state().texture->parameterfImplementation)(GL_TEXTURE_MIN_LOD, lod); + (this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MIN_LOD, lod); } void AbstractTexture::setMaxLod(const Float lod) { - (this->*Context::current()->state().texture->parameterfImplementation)(GL_TEXTURE_MAX_LOD, lod); + (this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MAX_LOD, lod); } #endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::setLodBias(const Float bias) { - (this->*Context::current()->state().texture->parameterfImplementation)(GL_TEXTURE_LOD_BIAS, bias); + (this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_LOD_BIAS, bias); } #endif #ifndef MAGNUM_TARGET_WEBGL void AbstractTexture::setBorderColor(const Color4& color) { - (this->*Context::current()->state().texture->parameterfvImplementation)( + (this->*Context::current().state().texture->parameterfvImplementation)( #ifndef MAGNUM_TARGET_GLES GL_TEXTURE_BORDER_COLOR, #else @@ -346,7 +426,7 @@ void AbstractTexture::setBorderColor(const Color4& color) { #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::setBorderColor(const Vector4ui& color) { - (this->*Context::current()->state().texture->parameterIuivImplementation)( + (this->*Context::current().state().texture->parameterIuivImplementation)( #ifndef MAGNUM_TARGET_GLES GL_TEXTURE_BORDER_COLOR, #else @@ -356,7 +436,7 @@ void AbstractTexture::setBorderColor(const Vector4ui& color) { } void AbstractTexture::setBorderColor(const Vector4i& color) { - (this->*Context::current()->state().texture->parameterIivImplementation)( + (this->*Context::current().state().texture->parameterIivImplementation)( #ifndef MAGNUM_TARGET_GLES GL_TEXTURE_BORDER_COLOR, #else @@ -368,12 +448,12 @@ void AbstractTexture::setBorderColor(const Vector4i& color) { #endif void AbstractTexture::setMaxAnisotropy(const Float anisotropy) { - (this->*Context::current()->state().texture->setMaxAnisotropyImplementation)(anisotropy); + (this->*Context::current().state().texture->setMaxAnisotropyImplementation)(anisotropy); } #ifndef MAGNUM_TARGET_WEBGL void AbstractTexture::setSRGBDecode(bool decode) { - (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_SRGB_DECODE_EXT, + (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SRGB_DECODE_EXT, decode ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT); } #endif @@ -382,19 +462,19 @@ void AbstractTexture::setSRGBDecode(bool decode) { void AbstractTexture::setSwizzleInternal(const GLint r, const GLint g, const GLint b, const GLint a) { #ifndef MAGNUM_TARGET_GLES const GLint rgba[] = {r, g, b, a}; - (this->*Context::current()->state().texture->parameterivImplementation)(GL_TEXTURE_SWIZZLE_RGBA, rgba); + (this->*Context::current().state().texture->parameterivImplementation)(GL_TEXTURE_SWIZZLE_RGBA, rgba); #else - (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_R, r); - (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_G, g); - (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_B, b); - (this->*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_A, a); + (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_R, r); + (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_G, g); + (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_B, b); + (this->*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_SWIZZLE_A, a); #endif } #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::setCompareMode(const Sampler::CompareMode mode) { - (this->*Context::current()->state().texture->parameteriImplementation)( + (this->*Context::current().state().texture->parameteriImplementation)( #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_COMPARE_MODE #else @@ -404,7 +484,7 @@ void AbstractTexture::setCompareMode(const Sampler::CompareMode mode) { } void AbstractTexture::setCompareFunction(const Sampler::CompareFunction function) { - (this->*Context::current()->state().texture->parameteriImplementation)( + (this->*Context::current().state().texture->parameteriImplementation)( #ifndef MAGNUM_TARGET_GLES2 GL_TEXTURE_COMPARE_FUNC #else @@ -416,16 +496,16 @@ void AbstractTexture::setCompareFunction(const Sampler::CompareFunction function #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::setDepthStencilMode(const Sampler::DepthStencilMode mode) { - (this->*Context::current()->state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); + (this->*Context::current().state().texture->parameteriImplementation)(GL_DEPTH_STENCIL_TEXTURE_MODE, GLenum(mode)); } #endif void AbstractTexture::invalidateImage(const Int level) { - (this->*Context::current()->state().texture->invalidateImageImplementation)(level); + (this->*Context::current().state().texture->invalidateImageImplementation)(level); } void AbstractTexture::generateMipmap() { - (this->*Context::current()->state().texture->mipmapImplementation)(); + (this->*Context::current().state().texture->mipmapImplementation)(); } void AbstractTexture::mipmapImplementationDefault() { @@ -449,7 +529,7 @@ void AbstractTexture::bindInternal() { functions need to have the texture bound in *currently active* unit, so we would need to call glActiveTexture() afterwards anyway. */ - Implementation::TextureState& textureState = *Context::current()->state().texture; + Implementation::TextureState& textureState = *Context::current().state().texture; /* If the texture is already bound in current unit, nothing to do */ if(textureState.bindings[textureState.currentTextureUnit].second == _id) @@ -1090,23 +1170,23 @@ void AbstractTexture::parameterIImplementationDSAEXT(GLenum parameter, const GLi void AbstractTexture::setMaxAnisotropyImplementationNoOp(GLfloat) {} void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) { - (this->*Context::current()->state().texture->parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); + (this->*Context::current().state().texture->parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); } #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) -void AbstractTexture::getLevelParameterImplementationDefault(const GLenum target, const GLint level, const GLenum parameter, GLint* const values) { +void AbstractTexture::getLevelParameterImplementationDefault(const GLint level, const GLenum parameter, GLint* const values) { bindInternal(); - glGetTexLevelParameteriv(target, level, parameter, values); + glGetTexLevelParameteriv(_target, level, parameter, values); } #ifndef MAGNUM_TARGET_GLES -void AbstractTexture::getLevelParameterImplementationDSA(GLenum, const GLint level, const GLenum parameter, GLint* const values) { +void AbstractTexture::getLevelParameterImplementationDSA(const GLint level, const GLenum parameter, GLint* const values) { glGetTextureLevelParameteriv(_id, level, parameter, values); } -void AbstractTexture::getLevelParameterImplementationDSAEXT(const GLenum target, const GLint level, const GLenum parameter, GLint* const values) { +void AbstractTexture::getLevelParameterImplementationDSAEXT(const GLint level, const GLenum parameter, GLint* const values) { _flags |= ObjectFlag::Created; - glGetTextureLevelParameterivEXT(_id, target, level, parameter, values); + glGetTextureLevelParameterivEXT(_id, _target, level, parameter, values); } #endif #endif @@ -1493,7 +1573,7 @@ void AbstractTexture::invalidateSubImageImplementationARB(GLint level, const Vec #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_TARGET_GLES template void AbstractTexture::image(GLint level, Image& image) { - const Math::Vector size = DataHelper::imageSize(*this, _target, level); + const Math::Vector size = DataHelper::imageSize(*this, level); const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); /* Reallocate only if needed */ @@ -1503,7 +1583,7 @@ template void AbstractTexture::image(GLint level, Image< Buffer::unbindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (this->*Context::current()->state().texture->getImageImplementation)(level, image.format(), image.type(), data.size(), data); + (this->*Context::current().state().texture->getImageImplementation)(level, image.format(), image.type(), data.size(), data); image.setData(image.storage(), image.format(), image.type(), size, std::move(data)); } @@ -1512,7 +1592,7 @@ template void MAGNUM_EXPORT AbstractTexture::image<2>(GLint, Image<2>&); template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, Image<3>&); template void AbstractTexture::image(GLint level, BufferImage& image, BufferUsage usage) { - const Math::Vector size = DataHelper::imageSize(*this, _target, level); + const Math::Vector size = DataHelper::imageSize(*this, level); const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); /* Reallocate only if needed */ @@ -1523,7 +1603,7 @@ template void AbstractTexture::image(GLint level, Buffer image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (this->*Context::current()->state().texture->getImageImplementation)(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>(GLint, BufferImage<1>&, BufferUsage); @@ -1531,12 +1611,12 @@ template void MAGNUM_EXPORT AbstractTexture::image<2>(GLint, BufferImage<2>&, Bu template void MAGNUM_EXPORT AbstractTexture::image<3>(GLint, BufferImage<3>&, BufferUsage); template void AbstractTexture::compressedImage(const GLint level, CompressedImage& image) { - const Math::Vector size = DataHelper::imageSize(*this, _target, level); + const Math::Vector size = DataHelper::imageSize(*this, level); GLint textureDataSize; - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(_target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); GLint format; - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(_target, level, GL_TEXTURE_INTERNAL_FORMAT, &format); + (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ Containers::Array data{image.release()}; @@ -1545,7 +1625,7 @@ template void AbstractTexture::compressedImage(const GLi Buffer::unbindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (this->*Context::current()->state().texture->getCompressedImageImplementation)(level, data.size(), data); + (this->*Context::current().state().texture->getCompressedImageImplementation)(level, data.size(), data); image.setData(image.storage(), CompressedPixelFormat(format), size, std::move(data)); } @@ -1554,12 +1634,12 @@ template void MAGNUM_EXPORT AbstractTexture::compressedImage<2>(GLint, Compresse template void MAGNUM_EXPORT AbstractTexture::compressedImage<3>(GLint, CompressedImage<3>&); template void AbstractTexture::compressedImage(const GLint level, CompressedBufferImage& image, BufferUsage usage) { - const Math::Vector size = DataHelper::imageSize(*this, _target, level); + const Math::Vector size = DataHelper::imageSize(*this, level); GLint textureDataSize; - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(_target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); GLint format; - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(_target, level, GL_TEXTURE_INTERNAL_FORMAT, &format); + (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ if(image.dataSize() < dataSize) @@ -1569,7 +1649,7 @@ template void AbstractTexture::compressedImage(const GLi image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (this->*Context::current()->state().texture->getCompressedImageImplementation)(level, dataSize, nullptr); + (this->*Context::current().state().texture->getCompressedImageImplementation)(level, dataSize, nullptr); } template void MAGNUM_EXPORT AbstractTexture::compressedImage<1>(GLint, CompressedBufferImage<1>&, BufferUsage); @@ -1621,62 +1701,140 @@ template void AbstractTexture::subImage(const GLint leve 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); + +template std::size_t AbstractTexture::compressedSubImageSize(TextureFormat format, const Math::Vector& size) { + /* Amount of blocks in given range (rounded up) multiplied by block + data size. The user is responsible for proper block-aligned size. */ + const Math::Vector blockSize = DataHelper::compressedBlockSize(_target, format); + return ((size + blockSize - Math::Vector{1})/blockSize).product()* + compressedBlockDataSize(_target, format); +} + +template void AbstractTexture::compressedSubImage(const GLint level, const RangeTypeFor& range, CompressedImage& image) { + createIfNotAlready(); + + const Math::Vector size = range.size(); + const Vector3i paddedOffset = Vector3i::pad(range.min()); + const Vector3i paddedSize = Vector3i::pad(size, 1); + GLint format; + (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, compressedSubImageSize(TextureFormat(format), size)); + + /* Reallocate only if needed */ + Containers::Array data{image.release()}; + if(data.size() < dataSize) + data = Containers::Array{dataSize}; + + Buffer::unbindInternal(Buffer::TargetHint::PixelPack); + image.storage().applyPack(); + glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), data.size(), data); + image.setData(CompressedPixelFormat(format), size, std::move(data)); +} + +template void MAGNUM_EXPORT AbstractTexture::compressedSubImage<1>(GLint, const Range1Di&, CompressedImage<1>&); +template void MAGNUM_EXPORT AbstractTexture::compressedSubImage<2>(GLint, const Range2Di&, CompressedImage<2>&); +template void MAGNUM_EXPORT AbstractTexture::compressedSubImage<3>(GLint, const Range3Di&, CompressedImage<3>&); + +template void AbstractTexture::compressedSubImage(const GLint level, const RangeTypeFor& range, CompressedBufferImage& image, const BufferUsage usage) { + createIfNotAlready(); + + const Math::Vector size = range.size(); + const Vector3i paddedOffset = Vector3i::pad(range.min()); + const Vector3i paddedSize = Vector3i::pad(size, 1); + GLint format; + (this->*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); + const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, compressedSubImageSize(TextureFormat(format), size)); + + /* Reallocate only if needed */ + if(image.dataSize() < dataSize) + image.setData(image.storage(), CompressedPixelFormat(format), size, {nullptr, dataSize}, usage); + else + image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); + + image.buffer().bindInternal(Buffer::TargetHint::PixelPack); + image.storage().applyPack(); + glGetCompressedTextureSubImage(_id, level, paddedOffset.x(), paddedOffset.y(), paddedOffset.z(), paddedSize.x(), paddedSize.y(), paddedSize.z(), dataSize, nullptr); +} + +template void MAGNUM_EXPORT AbstractTexture::compressedSubImage<1>(GLint, const Range1Di&, CompressedBufferImage<1>&, BufferUsage); +template void MAGNUM_EXPORT AbstractTexture::compressedSubImage<2>(GLint, const Range2Di&, CompressedBufferImage<2>&, BufferUsage); +template void MAGNUM_EXPORT AbstractTexture::compressedSubImage<3>(GLint, const Range3Di&, CompressedBufferImage<3>&, BufferUsage); #endif #endif #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_TARGET_GLES -Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, GLenum, const GLint level) { +Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::compressedBlockSize(const GLenum target, const TextureFormat format) { + GLint value; + glGetInternalformativ(target, GLenum(format), GL_TEXTURE_COMPRESSED_BLOCK_WIDTH, 1, &value); + return value; +} + +Vector2i AbstractTexture::DataHelper<2>::compressedBlockSize(const GLenum target, const TextureFormat format) { + Vector2i value{Math::NoInit}; + glGetInternalformativ(target, GLenum(format), GL_TEXTURE_COMPRESSED_BLOCK_WIDTH, 1, &value.x()); + glGetInternalformativ(target, GLenum(format), GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT, 1, &value.y()); + return value; +} + +Vector3i AbstractTexture::DataHelper<3>::compressedBlockSize(const GLenum target, const TextureFormat format) { + /** @todo use real value when OpenGL has proper queries for 3D compression formats */ + return Vector3i{DataHelper<2>::compressedBlockSize(target, format), 1}; +} +#endif + +#ifndef MAGNUM_TARGET_GLES +Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture& texture, const GLint level) { Math::Vector<1, GLint> value; - (texture.*Context::current()->state().texture->getLevelParameterivImplementation)(texture._target, level, GL_TEXTURE_WIDTH, &value[0]); + (texture.*Context::current().state().texture->getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); return value; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) -Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) { - const Implementation::TextureState& state = *Context::current()->state().texture; +Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLint level) { + const Implementation::TextureState& state = *Context::current().state().texture; Vector2i value; - (texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]); - (texture.*state.getLevelParameterivImplementation)(target, level, GL_TEXTURE_HEIGHT, &value[1]); + (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); + (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]); return value; } -Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, GLenum, const GLint level) { - const Implementation::TextureState& state = *Context::current()->state().texture; +Vector3i AbstractTexture::DataHelper<3>::imageSize(AbstractTexture& texture, const GLint level) { + const Implementation::TextureState& state = *Context::current().state().texture; Vector3i value; - (texture.*state.getLevelParameterivImplementation)(texture._target, level, GL_TEXTURE_WIDTH, &value[0]); - (texture.*state.getLevelParameterivImplementation)(texture._target, level, GL_TEXTURE_HEIGHT, &value[1]); - (texture.*state.getLevelParameterivImplementation)(texture._target, level, GL_TEXTURE_DEPTH, &value[2]); + (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); + (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]); + (texture.*state.getLevelParameterivImplementation)(level, GL_TEXTURE_DEPTH, &value[2]); return value; } #endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector< 1, GLsizei >& size) { - (texture.*Context::current()->state().texture->storage1DImplementation)(levels, internalFormat, size); + (texture.*Context::current().state().texture->storage1DImplementation)(levels, internalFormat, size); } #endif void AbstractTexture::DataHelper<2>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector2i& size) { - (texture.*Context::current()->state().texture->storage2DImplementation)(levels, internalFormat, size); + (texture.*Context::current().state().texture->storage2DImplementation)(levels, internalFormat, size); } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::DataHelper<3>::setStorage(AbstractTexture& texture, const GLsizei levels, const TextureFormat internalFormat, const Vector3i& size) { - (texture.*Context::current()->state().texture->storage3DImplementation)(levels, internalFormat, size); + (texture.*Context::current().state().texture->storage3DImplementation)(levels, internalFormat, size); } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void AbstractTexture::DataHelper<2>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector2i& size, const GLboolean fixedSampleLocations) { - (texture.*Context::current()->state().texture->storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); + (texture.*Context::current().state().texture->storage2DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); } void AbstractTexture::DataHelper<3>::setStorageMultisample(AbstractTexture& texture, const GLsizei samples, const TextureFormat internalFormat, const Vector3i& size, const GLboolean fixedSampleLocations) { - (texture.*Context::current()->state().texture->storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); + (texture.*Context::current().state().texture->storage3DMultisampleImplementation)(samples, internalFormat, size, fixedSampleLocations); } #endif @@ -1712,25 +1870,25 @@ void AbstractTexture::DataHelper<1>::setCompressedImage(AbstractTexture& texture void AbstractTexture::DataHelper<1>::setSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const ImageView1D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); image.storage().applyUnpack(); - (texture.*Context::current()->state().texture->subImage1DImplementation)(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>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const CompressedImageView1D& image) { Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); image.storage().applyUnpack(); - (texture.*Context::current()->state().texture->compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size())); + (texture.*Context::current().state().texture->compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size())); } 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.storage().applyUnpack(); - (texture.*Context::current()->state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); + (texture.*Context::current().state().texture->subImage1DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); } void AbstractTexture::DataHelper<1>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, CompressedBufferImage1D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.storage().applyUnpack(); - (texture.*Context::current()->state().texture->compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); + (texture.*Context::current().state().texture->compressedSubImage1DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); } #endif @@ -1785,7 +1943,7 @@ void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif image.storage().applyUnpack(); - (texture.*Context::current()->state().texture->subImage2DImplementation)(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() #ifdef MAGNUM_TARGET_GLES2 + Implementation::pixelStorageSkipOffset(image) #endif @@ -1801,14 +1959,14 @@ void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& text to reset anything */ image.storage().applyUnpack(); #endif - (texture.*Context::current()->state().texture->compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size())); + (texture.*Context::current().state().texture->compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size())); } #ifndef MAGNUM_TARGET_GLES2 void AbstractTexture::DataHelper<2>::setSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, BufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.storage().applyUnpack(); - (texture.*Context::current()->state().texture->subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); + (texture.*Context::current().state().texture->subImage2DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); } void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, CompressedBufferImage2D& image) { @@ -1818,7 +1976,7 @@ void AbstractTexture::DataHelper<2>::setCompressedSubImage(AbstractTexture& text to reset anything */ image.storage().applyUnpack(); #endif - (texture.*Context::current()->state().texture->compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); + (texture.*Context::current().state().texture->compressedSubImage2DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); } #endif @@ -1889,7 +2047,7 @@ void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif image.storage().applyUnpack(); - (texture.*Context::current()->state().texture->subImage3DImplementation)(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() #ifdef MAGNUM_TARGET_GLES2 + Implementation::pixelStorageSkipOffset(image) #endif @@ -1905,7 +2063,7 @@ void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& text to reset anything */ image.storage().applyUnpack(); #endif - (texture.*Context::current()->state().texture->compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size())); + (texture.*Context::current().state().texture->compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size())); } #endif @@ -1913,7 +2071,7 @@ void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& text void AbstractTexture::DataHelper<3>::setSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, BufferImage3D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.storage().applyUnpack(); - (texture.*Context::current()->state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); + (texture.*Context::current().state().texture->subImage3DImplementation)(level, offset, image.size(), image.format(), image.type(), nullptr); } void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, CompressedBufferImage3D& image) { @@ -1923,32 +2081,32 @@ void AbstractTexture::DataHelper<3>::setCompressedSubImage(AbstractTexture& text to reset anything */ image.storage().applyUnpack(); #endif - (texture.*Context::current()->state().texture->compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); + (texture.*Context::current().state().texture->compressedSubImage3DImplementation)(level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); } #endif #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Math::Vector<1, GLint>& offset, const Math::Vector<1, GLint>& size) { - (texture.*Context::current()->state().texture->invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1}); + (texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, {offset[0], 0, 0}, {size[0], 1, 1}); } #endif void AbstractTexture::DataHelper<2>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector2i& offset, const Vector2i& size) { - (texture.*Context::current()->state().texture->invalidateSubImageImplementation)(level, {offset, 0}, {size, 1}); + (texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, {offset, 0}, {size, 1}); } void AbstractTexture::DataHelper<3>::invalidateSubImage(AbstractTexture& texture, const GLint level, const Vector3i& offset, const Vector3i& size) { - (texture.*Context::current()->state().texture->invalidateSubImageImplementation)(level, offset, size); + (texture.*Context::current().state().texture->invalidateSubImageImplementation)(level, offset, size); } #ifndef MAGNUM_TARGET_GLES void AbstractTexture::DataHelper<1>::setWrapping(AbstractTexture& texture, const Array1D& wrapping) { - (texture.*Context::current()->state().texture->parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); + (texture.*Context::current().state().texture->parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); } #endif void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const Array2D& wrapping) { - const Implementation::TextureState& state = *Context::current()->state().texture; + const Implementation::TextureState& state = *Context::current().state().texture; (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y())); @@ -1956,7 +2114,7 @@ void AbstractTexture::DataHelper<2>::setWrapping(AbstractTexture& texture, const #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void AbstractTexture::DataHelper<3>::setWrapping(AbstractTexture& texture, const Array3D& wrapping) { - const Implementation::TextureState& state = *Context::current()->state().texture; + const Implementation::TextureState& state = *Context::current().state().texture; (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_S, GLint(wrapping.x())); (texture.*state.parameteriImplementation)(GL_TEXTURE_WRAP_T, GLint(wrapping.y())); diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 5784f1067..77694e01f 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -69,13 +69,13 @@ documentation for details. @anchor AbstractTexture-performance-optimization ## Performance optimizations and security -The engine tracks currently bound textures in all available texture units to -avoid unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. -Texture configuration functions use dedicated highest available texture unit -to not affect active bindings in user units. Texture limits and -implementation-defined values (such as @ref maxColorSamples()) are cached, so -repeated queries don't result in repeated @fn_gl{Get} calls. See also -@ref Context::resetState() and @ref Context::State::Textures. +The engine tracks currently bound textures and images in all available texture +units to avoid unnecessary calls to @fn_gl{ActiveTexture}, @fn_gl{BindTexture} +and @fn_gl{BindImageTexture}. Texture configuration functions use dedicated +highest available texture unit to not affect active bindings in user units. +Texture limits and implementation-defined values (such as @ref maxColorSamples()) +are cached, so repeated queries don't result in repeated @fn_gl{Get} calls. See +also @ref Context::resetState() and @ref Context::State::Textures. If @extension{ARB,direct_state_access} (part of OpenGL 4.5) is available, @ref bind(Int) and @ref unbind(Int) use @fn_gl{BindTextureUnit}. Otherwise, if @@ -209,13 +209,14 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { /** * @brief Unbind textures in given range of texture units * - * Unbinds all texture in the range @f$ [ firstTextureUnit ; firstTextureUnit + count ) @f$. + * Unbinds all textures in the range @f$ [ firstTextureUnit ; firstTextureUnit + count ) @f$. * If @extension{ARB,multi_bind} (part of OpenGL 4.4) is not available, * the feature is emulated with sequence of @ref unbind(Int) calls. * @note This function is meant to be used only internally from * @ref AbstractShaderProgram subclasses. See its documentation * for more information. - * @see @ref Shader::maxCombinedTextureImageUnits(), @fn_gl{BindTextures} + * @see @ref bind(), @ref Shader::maxCombinedTextureImageUnits(), + * @fn_gl{BindTextures} */ static void unbind(Int firstTextureUnit, std::size_t count); @@ -234,6 +235,71 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { */ static void bind(Int firstTextureUnit, std::initializer_list textures); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /** + * @brief Unbind any image from given image unit + * + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref Texture::bindImage() "*Texture::bindImage()", + * @ref Texture::bindImageLayered() "*Texture::bindImageLayered()", + * @ref unbindImages(), @ref bindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + static void unbindImage(Int imageUnit); + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Unbind images in given range of image units + * + * Unbinds all texture in the range @f$ [ firstImageUnit ; firstImageUnit + count ) @f$. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref Texture::bindImage() "*Texture::bindImage()", + * @ref Texture::bindImageLayered() "*Texture::bindImageLayered()", + * @ref unbindImage(), @ref bindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTextures} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gl44 Extension @extension{ARB,multi_bind} + * @requires_gl Multi bind is not available in OpenGL ES and WebGL. + */ + static void unbindImages(Int firstImageUnit, std::size_t count) { + bindImagesInternal(firstImageUnit, {nullptr, count}); + } + + /** + * @brief Bind textures to given range of texture units + * + * Binds first level of given texture in the list to @p firstImageUnit, + * second to `firstTextureUnit + 1` etc. 3D, cube map and array + * textures are bound as layered targets. If any texture is `nullptr`, + * given image unit is unbound. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref Texture::bindImage() "*Texture::bindImage()", + * @ref Texture::bindImageLayered() "*Texture::bindImageLayered()", + * @ref unbindImages(), @ref unbindImage(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTextures} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gl44 Extension @extension{ARB,multi_bind} + * @requires_gl Multi bind is not available in OpenGL ES and WebGL. + */ + static void bindImages(Int firstImageUnit, std::initializer_list textures) { + bindImagesInternal(firstImageUnit, {textures.begin(), textures.size()}); + } + #endif + /** @brief Copying is not allowed */ AbstractTexture(const AbstractTexture&) = delete; @@ -338,6 +404,14 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { #endif template struct DataHelper {}; + #ifndef MAGNUM_TARGET_GLES + static Int compressedBlockDataSize(GLenum target, TextureFormat format); + #endif + + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + static void bindImagesInternal(Int firstImageUnit, Containers::ArrayView textures); + #endif + explicit AbstractTexture(GLenum target); explicit AbstractTexture(NoCreateT, GLenum target) noexcept: _target{target}, _id{0}, _flags{ObjectFlag::DeleteOnDestruction} {} explicit AbstractTexture(GLuint id, GLenum target, ObjectFlags flags) noexcept: _target{target}, _id{id}, _flags{flags} {} @@ -348,6 +422,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL createIfNotAlready(); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + void bindImageInternal(Int imageUnit, Int level, bool layered, Int layer, ImageAccess access, ImageFormat format); + #endif + /* Unlike bind() this also sets the texture binding unit as active */ void MAGNUM_LOCAL bindInternal(); @@ -405,11 +483,18 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { template void compressedImage(GLint level, CompressedBufferImage& image, BufferUsage usage); template void subImage(GLint level, const RangeTypeFor& range, Image& image); template void subImage(GLint level, const RangeTypeFor& range, BufferImage& image, BufferUsage usage); + template void compressedSubImage(GLint level, const RangeTypeFor& range, CompressedImage& image); + template void compressedSubImage(GLint level, const RangeTypeFor& range, CompressedBufferImage& image, BufferUsage usage); #endif GLenum _target; private: + #ifndef MAGNUM_TARGET_GLES + static Int MAGNUM_LOCAL compressedBlockDataSizeImplementationDefault(GLenum target, TextureFormat format); + static Int MAGNUM_LOCAL compressedBlockDataSizeImplementationBitsWorkaround(GLenum target, TextureFormat format); + #endif + static void MAGNUM_LOCAL unbindImplementationDefault(GLint textureUnit); #ifndef MAGNUM_TARGET_GLES static void MAGNUM_LOCAL unbindImplementationMulti(GLint textureUnit); @@ -427,6 +512,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL createImplementationDSA(); #endif + #ifndef MAGNUM_TARGET_GLES + template std::size_t MAGNUM_LOCAL compressedSubImageSize(TextureFormat format, const Math::Vector& size); + #endif + void MAGNUM_LOCAL bindImplementationDefault(GLint textureUnit); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL bindImplementationMulti(GLint textureUnit); @@ -463,10 +552,10 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { void MAGNUM_LOCAL setMaxAnisotropyImplementationExt(GLfloat anisotropy); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values); + void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLenum, GLint level, GLenum parameter, GLint* values); - 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 @@ -584,7 +673,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_TARGET_GLES template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> { - static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLenum, GLint level); + static Math::Vector<1, GLint> compressedBlockSize(GLenum target, TextureFormat format); + static Math::Vector<1, GLint> imageSize(AbstractTexture& texture, GLint level); static void setWrapping(AbstractTexture& texture, const Array1D& wrapping); @@ -604,8 +694,11 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<1> { }; #endif template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { + #ifndef MAGNUM_TARGET_GLES + static Vector2i compressedBlockSize(GLenum target, TextureFormat format); + #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - static Vector2i imageSize(AbstractTexture& texture, GLenum target, GLint level); + static Vector2i imageSize(AbstractTexture& texture, GLint level); #endif static void setWrapping(AbstractTexture& texture, const Array2D& wrapping); @@ -646,8 +739,11 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { }; template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) + #ifndef MAGNUM_TARGET_GLES + static Vector3i compressedBlockSize(GLenum target, TextureFormat format); + #endif #ifndef MAGNUM_TARGET_GLES2 - static Vector3i imageSize(AbstractTexture& texture, GLenum, GLint level); + static Vector3i imageSize(AbstractTexture& texture, GLint level); #endif static void setWrapping(AbstractTexture& texture, const Array3D& wrapping); diff --git a/src/Magnum/Array.h b/src/Magnum/Array.h index 0532958fc..a96e81eb3 100644 --- a/src/Magnum/Array.h +++ b/src/Magnum/Array.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -77,11 +77,7 @@ template class Array { constexpr /*implicit*/ Array(T value); #else template::value && dimensions != 1, T>::type> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - /*implicit*/ Array(U value): Array(typename Math::Implementation::GenerateSequence::Type(), value) {} + constexpr /*implicit*/ Array(U value): Array(typename Math::Implementation::GenerateSequence::Type(), value) {} #endif /** @brief Equality */ diff --git a/src/Magnum/Attribute.cpp b/src/Magnum/Attribute.cpp index 5341634c3..c3af6c051 100644 --- a/src/Magnum/Attribute.cpp +++ b/src/Magnum/Attribute.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Attribute.h b/src/Magnum/Attribute.h index 950ba2d0d..3645826e8 100644 --- a/src/Magnum/Attribute.h +++ b/src/Magnum/Attribute.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/AbstractImporter.cpp b/src/Magnum/Audio/AbstractImporter.cpp index 7a4e5985f..5391e25f2 100644 --- a/src/Magnum/Audio/AbstractImporter.cpp +++ b/src/Magnum/Audio/AbstractImporter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/AbstractImporter.h b/src/Magnum/Audio/AbstractImporter.h index 0d4608241..13daf32dd 100644 --- a/src/Magnum/Audio/AbstractImporter.h +++ b/src/Magnum/Audio/AbstractImporter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Audio.cpp b/src/Magnum/Audio/Audio.cpp index c901ba5a9..4384c776f 100644 --- a/src/Magnum/Audio/Audio.cpp +++ b/src/Magnum/Audio/Audio.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Audio.h b/src/Magnum/Audio/Audio.h index 3a148f7f5..05c11d726 100644 --- a/src/Magnum/Audio/Audio.h +++ b/src/Magnum/Audio/Audio.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Buffer.cpp b/src/Magnum/Audio/Buffer.cpp index 9afc2b962..cc1f00cde 100644 --- a/src/Magnum/Audio/Buffer.cpp +++ b/src/Magnum/Audio/Buffer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Buffer.h b/src/Magnum/Audio/Buffer.h index 4a45ba390..fec59322f 100644 --- a/src/Magnum/Audio/Buffer.h +++ b/src/Magnum/Audio/Buffer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/CMakeLists.txt b/src/Magnum/Audio/CMakeLists.txt index 1711eb945..1a156e3ff 100644 --- a/src/Magnum/Audio/CMakeLists.txt +++ b/src/Magnum/Audio/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -25,8 +25,6 @@ find_package(OpenAL REQUIRED) -include_directories(${OPENAL_INCLUDE_DIR}) - set(MagnumAudio_SRCS AbstractImporter.cpp Audio.cpp @@ -60,13 +58,12 @@ endif() add_library(MagnumAudio ${SHARED_OR_STATIC} ${MagnumAudio_SRCS} ${MagnumAudio_HEADERS}) +target_include_directories(MagnumAudio PUBLIC ${OPENAL_INCLUDE_DIR}) set_target_properties(MagnumAudio PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumAudio PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - -target_link_libraries(MagnumAudio Magnum ${CORRADE_PLUGINMANAGER_LIBRARIES} ${OPENAL_LIBRARY}) - +target_link_libraries(MagnumAudio Magnum Corrade::PluginManager ${OPENAL_LIBRARY}) if(WITH_SCENEGRAPH) target_link_libraries(MagnumAudio MagnumSceneGraph) endif() @@ -81,5 +78,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum Audio library for superprojects -set(MAGNUM_AUDIO_LIBRARY MagnumAudio CACHE INTERNAL "") +# Magnum Audio target alias for superprojects +add_library(Magnum::Audio ALIAS MagnumAudio) diff --git a/src/Magnum/Audio/Context.cpp b/src/Magnum/Audio/Context.cpp index 9c5d0437a..70a331db2 100644 --- a/src/Magnum/Audio/Context.cpp +++ b/src/Magnum/Audio/Context.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale @@ -70,6 +70,13 @@ Debug& operator<<(Debug& debug, const Context::HrtfStatus value) { Context* Context::_current = nullptr; +bool Context::hasCurrent() { return _current; } + +Context& Context::current() { + CORRADE_ASSERT(_current, "Audio::Context::current(): no current context", *_current); + return *_current; +} + Context::Context(): Context{Configuration{}} {} Context::Context(const Configuration& config) { diff --git a/src/Magnum/Audio/Context.h b/src/Magnum/Audio/Context.h index f1809a943..29156c348 100644 --- a/src/Magnum/Audio/Context.h +++ b/src/Magnum/Audio/Context.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale @@ -127,8 +127,20 @@ class MAGNUM_AUDIO_EXPORT Context { UnsupportedFormat = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT }; - /** @brief Current context */ - static Context* current() { return _current; } + /** + * @brief Whether there is any current context + * + * @see @ref current() + */ + static bool hasCurrent(); + + /** + * @brief Current context + * + * Expect that there is current context. + * @see @ref hasCurrent() + */ + static Context& current(); class Configuration; @@ -151,6 +163,11 @@ class MAGNUM_AUDIO_EXPORT Context { */ ~Context(); + #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(DOXYGEN_GENERATING_OUTPUT) + CORRADE_DEPRECATED("Audio::Context::current() returns reference now") Context* operator->() { return this; } + CORRADE_DEPRECATED("Audio::Context::current() returns reference now") operator Context*() { return this; } + #endif + /** * @brief Whether HRTFs (Head Related Transfer Functions) are enabled * @@ -237,7 +254,7 @@ class MAGNUM_AUDIO_EXPORT Context { * Extensions usable with this function are listed in @ref Extensions * namespace in header @ref Extensions.h. Example usage: * @code - * if(Context::current()->isExtensionSupported()) { + * if(Context::current().isExtensionSupported()) { * // amazing binaural audio * } else { * // probably left/right stereo only @@ -265,7 +282,7 @@ class MAGNUM_AUDIO_EXPORT Context { } private: - static Context* _current; + MAGNUM_AUDIO_LOCAL static Context* _current; /* Create a context with given configuration. Returns `true` on success. * @ref alcCreateContext(). */ @@ -410,9 +427,9 @@ MAGNUM_ASSERT_AUDIO_EXTENSION_SUPPORTED(Extensions::ALC::SOFTX::HRTF); #ifdef CORRADE_NO_ASSERT #define MAGNUM_ASSERT_AUDIO_EXTENSION_SUPPORTED(extension) do {} while(0) #else -#define MAGNUM_ASSERT_AUDIO_EXTENSION_SUPPORTED(extension) \ +#define MAGNUM_ASSERT_AUDIO_EXTENSION_SUPPORTED(extension) \ do { \ - if(!Magnum::Audio::Context::current()->isExtensionSupported()) { \ + if(!Magnum::Audio::Context::current().isExtensionSupported()) { \ Corrade::Utility::Error() << "Magnum: required OpenAL extension" << extension::string() << "is not supported"; \ std::abort(); \ } \ @@ -429,7 +446,7 @@ inline bool Context::isHrtfEnabled() const { } inline Context::HrtfStatus Context::hrtfStatus() const { - if(!Context::current()->isExtensionSupported()) + if(!isExtensionSupported()) return isHrtfEnabled() ? HrtfStatus::Enabled : HrtfStatus::Disabled; Int status; diff --git a/src/Magnum/Audio/Extensions.h b/src/Magnum/Audio/Extensions.h index e1039dc92..478903e56 100644 --- a/src/Magnum/Audio/Extensions.h +++ b/src/Magnum/Audio/Extensions.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale @@ -50,11 +50,11 @@ usage. This namespace is not built by default. It is built if `WITH_AUDIO` is enabled when building Magnum. To use this library, you need to request -`Audio` component of `Magnum` package in CMake, add `${MAGNUM_AUDIO_INCLUDE_DIRS}` -to include path and link to `${MAGNUM_AUDIO_LIBRARIES}`. See @ref building and -@ref cmake for more information. Additional plugins are enabled separately, see -particular `*Importer` class documentation, @ref building-plugins, -@ref cmake-plugins and @ref plugins for more information. +`Audio` component of `Magnum` package in CMake and link to `Magnum::Audio` +target. See @ref building and @ref cmake for more information. Additional +plugins are enabled separately, see particular `*Importer` class documentation, +@ref building-plugins, @ref cmake-plugins and @ref plugins for more +information. @see @ref MAGNUM_ASSERT_AUDIO_EXTENSION_SUPPORTED() @todo Manual indices for extensions, this has gaps */ diff --git a/src/Magnum/Audio/Listener.cpp b/src/Magnum/Audio/Listener.cpp index 1d5516a76..e2c1f1e7f 100644 --- a/src/Magnum/Audio/Listener.cpp +++ b/src/Magnum/Audio/Listener.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/src/Magnum/Audio/Listener.h b/src/Magnum/Audio/Listener.h index 8b9970278..d731c9f18 100644 --- a/src/Magnum/Audio/Listener.h +++ b/src/Magnum/Audio/Listener.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/src/Magnum/Audio/Playable.h b/src/Magnum/Audio/Playable.h index 5bf9ddec7..941522f4e 100644 --- a/src/Magnum/Audio/Playable.h +++ b/src/Magnum/Audio/Playable.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/src/Magnum/Audio/PlayableGroup.h b/src/Magnum/Audio/PlayableGroup.h index 0d643e63e..1ea0cfe1a 100644 --- a/src/Magnum/Audio/PlayableGroup.h +++ b/src/Magnum/Audio/PlayableGroup.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/src/Magnum/Audio/Renderer.cpp b/src/Magnum/Audio/Renderer.cpp index 85214cf5d..db5fcee9b 100644 --- a/src/Magnum/Audio/Renderer.cpp +++ b/src/Magnum/Audio/Renderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Renderer.h b/src/Magnum/Audio/Renderer.h index 41783b256..74d483f4e 100644 --- a/src/Magnum/Audio/Renderer.h +++ b/src/Magnum/Audio/Renderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Source.cpp b/src/Magnum/Audio/Source.cpp index cdc9463cb..7e47c1f5e 100644 --- a/src/Magnum/Audio/Source.cpp +++ b/src/Magnum/Audio/Source.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Source.h b/src/Magnum/Audio/Source.h index c4d6bb98b..e16feb874 100644 --- a/src/Magnum/Audio/Source.h +++ b/src/Magnum/Audio/Source.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/src/Magnum/Audio/Test/AbstractImporterTest.cpp b/src/Magnum/Audio/Test/AbstractImporterTest.cpp index 7233e9994..bd0a55880 100644 --- a/src/Magnum/Audio/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Audio/Test/AbstractImporterTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Test/BufferTest.cpp b/src/Magnum/Audio/Test/BufferTest.cpp index 187fa3d32..c98c6e746 100644 --- a/src/Magnum/Audio/Test/BufferTest.cpp +++ b/src/Magnum/Audio/Test/BufferTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Test/CMakeLists.txt b/src/Magnum/Audio/Test/CMakeLists.txt index 5385f1bfe..939cecd9c 100644 --- a/src/Magnum/Audio/Test/CMakeLists.txt +++ b/src/Magnum/Audio/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # Copyright © 2015 Jonathan Hale # @@ -27,9 +27,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(AudioAbstractImporterTest AbstractImporterTest.cpp LIBRARIES MagnumAudio) +target_include_directories(AudioAbstractImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(AudioBufferTest BufferTest.cpp LIBRARIES MagnumAudio) corrade_add_test(AudioContextTest ContextTest.cpp LIBRARIES MagnumAudio) corrade_add_test(AudioRendererTest RendererTest.cpp LIBRARIES MagnumAudio) diff --git a/src/Magnum/Audio/Test/ContextTest.cpp b/src/Magnum/Audio/Test/ContextTest.cpp index dbd384ceb..bb15c2856 100644 --- a/src/Magnum/Audio/Test/ContextTest.cpp +++ b/src/Magnum/Audio/Test/ContextTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale @@ -56,7 +56,7 @@ void ContextTest::extensionsString() { } void ContextTest::isExtensionEnabled() { - CORRADE_VERIFY(Context::current()->isExtensionSupported()); + CORRADE_VERIFY(Context::current().isExtensionSupported()); } void ContextTest::hrtfStatus() { diff --git a/src/Magnum/Audio/Test/ListenerTest.cpp b/src/Magnum/Audio/Test/ListenerTest.cpp index c64c1ce61..2e22aa32c 100644 --- a/src/Magnum/Audio/Test/ListenerTest.cpp +++ b/src/Magnum/Audio/Test/ListenerTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/src/Magnum/Audio/Test/PlayableTest.cpp b/src/Magnum/Audio/Test/PlayableTest.cpp index 9b0fd424a..3a185d18a 100644 --- a/src/Magnum/Audio/Test/PlayableTest.cpp +++ b/src/Magnum/Audio/Test/PlayableTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/src/Magnum/Audio/Test/RendererTest.cpp b/src/Magnum/Audio/Test/RendererTest.cpp index ff3b23ae6..634865b82 100644 --- a/src/Magnum/Audio/Test/RendererTest.cpp +++ b/src/Magnum/Audio/Test/RendererTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/Test/SourceTest.cpp b/src/Magnum/Audio/Test/SourceTest.cpp index d36193ecb..563d66c52 100644 --- a/src/Magnum/Audio/Test/SourceTest.cpp +++ b/src/Magnum/Audio/Test/SourceTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -144,6 +144,8 @@ void SourceTest::minGain() { } void SourceTest::coneAnglesAndGain() { + using namespace Math::Literals; + Source source; constexpr auto outerAngle = 12.0_degf; constexpr auto innerAngle = 21.0_degf; diff --git a/src/Magnum/Audio/Test/configure.h.cmake b/src/Magnum/Audio/Test/configure.h.cmake index 0cafe472d..8208c7ca8 100644 --- a/src/Magnum/Audio/Test/configure.h.cmake +++ b/src/Magnum/Audio/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Audio/visibility.h b/src/Magnum/Audio/visibility.h index a7bcc288f..566c8b594 100644 --- a/src/Magnum/Audio/visibility.h +++ b/src/Magnum/Audio/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 7b11a5534..00a72cd83 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -41,10 +41,10 @@ namespace Magnum { #ifndef MAGNUM_TARGET_GLES Int Buffer::minMapAlignment() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 1; - GLint& value = Context::current()->state().buffer->minMapAlignment; + GLint& value = Context::current().state().buffer->minMapAlignment; if(value == 0) glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT, &value); @@ -57,13 +57,13 @@ Int Buffer::minMapAlignment() { #ifndef MAGNUM_TARGET_WEBGL Int Buffer::maxAtomicCounterBindings() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().buffer->maxAtomicCounterBindings; + GLint& value = Context::current().state().buffer->maxAtomicCounterBindings; if(value == 0) glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &value); @@ -73,13 +73,13 @@ Int Buffer::maxAtomicCounterBindings() { Int Buffer::maxShaderStorageBindings() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().buffer->maxShaderStorageBindings; + GLint& value = Context::current().state().buffer->maxShaderStorageBindings; if(value == 0) glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &value); @@ -90,11 +90,11 @@ Int Buffer::maxShaderStorageBindings() { Int Buffer::uniformOffsetAlignment() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 1; #endif - GLint& value = Context::current()->state().buffer->uniformOffsetAlignment; + GLint& value = Context::current().state().buffer->uniformOffsetAlignment; if(value == 0) glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &value); @@ -105,13 +105,13 @@ Int Buffer::uniformOffsetAlignment() { #ifndef MAGNUM_TARGET_WEBGL Int Buffer::shaderStorageOffsetAlignment() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 1; - GLint& value = Context::current()->state().buffer->shaderStorageOffsetAlignment; + GLint& value = Context::current().state().buffer->shaderStorageOffsetAlignment; if(value == 0) glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &value); @@ -122,11 +122,11 @@ Int Buffer::shaderStorageOffsetAlignment() { Int Buffer::maxUniformBindings() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().buffer->maxUniformBindings; + GLint& value = Context::current().state().buffer->maxUniformBindings; if(value == 0) glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &value); @@ -153,7 +153,7 @@ void Buffer::unbind(const Target target, const UnsignedInt firstIndex, const std CORRADE_INTERNAL_ASSERT(target == Target::Uniform); #endif #endif - Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {nullptr, count}); + Context::current().state().buffer->bindBasesImplementation(target, firstIndex, {nullptr, count}); } /** @todoc const std::initializer_list makes Doxygen grumpy */ @@ -165,7 +165,7 @@ void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initia CORRADE_INTERNAL_ASSERT(target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER); #endif #endif - Context::current()->state().buffer->bindRangesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); + Context::current().state().buffer->bindRangesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); } /** @todoc const std::initializer_list makes Doxygen grumpy */ @@ -177,11 +177,11 @@ void Buffer::bind(const Target target, const UnsignedInt firstIndex, std::initia CORRADE_INTERNAL_ASSERT(target == Target::Uniform || GLenum(target) == GL_TRANSFORM_FEEDBACK_BUFFER); #endif #endif - Context::current()->state().buffer->bindBasesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); + Context::current().state().buffer->bindBasesImplementation(target, firstIndex, {buffers.begin(), buffers.size()}); } void Buffer::copy(Buffer& read, Buffer& write, const GLintptr readOffset, const GLintptr writeOffset, const GLsizeiptr size) { - Context::current()->state().buffer->copyImplementation(read, write, readOffset, writeOffset, size); + Context::current().state().buffer->copyImplementation(read, write, readOffset, writeOffset, size); } #endif @@ -190,7 +190,7 @@ Buffer::Buffer(const TargetHint targetHint): _targetHint{targetHint}, _flags{Obj , _mappedBuffer{nullptr} #endif { - (this->*Context::current()->state().buffer->createImplementation)(); + (this->*Context::current().state().buffer->createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -209,7 +209,7 @@ Buffer::~Buffer() { /* Moved out or not deleting on destruction, nothing to do */ if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; - GLuint* bindings = Context::current()->state().buffer->bindings; + GLuint* bindings = Context::current().state().buffer->bindings; /* Remove all current bindings from the state */ for(std::size_t i = 1; i != Implementation::BufferState::TargetCount; ++i) @@ -234,18 +234,18 @@ inline void Buffer::createIfNotAlready() { std::string Buffer::label() { createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES - return Context::current()->state().debug->getLabelImplementation(GL_BUFFER, _id); + return Context::current().state().debug->getLabelImplementation(GL_BUFFER, _id); #else - return Context::current()->state().debug->getLabelImplementation(GL_BUFFER_KHR, _id); + return Context::current().state().debug->getLabelImplementation(GL_BUFFER_KHR, _id); #endif } Buffer& Buffer::setLabelInternal(const Containers::ArrayView label) { createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES - Context::current()->state().debug->labelImplementation(GL_BUFFER, _id, label); + Context::current().state().debug->labelImplementation(GL_BUFFER, _id, label); #else - Context::current()->state().debug->labelImplementation(GL_BUFFER_KHR, _id, label); + Context::current().state().debug->labelImplementation(GL_BUFFER_KHR, _id, label); #endif return *this; } @@ -253,7 +253,7 @@ Buffer& Buffer::setLabelInternal(const Containers::ArrayView label) void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) { const GLuint id = buffer ? buffer->_id : 0; - GLuint& bound = Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(target)]; + GLuint& bound = Context::current().state().buffer->bindings[Implementation::BufferState::indexForTarget(target)]; /* Already bound, nothing to do */ if(bound == id) return; @@ -265,7 +265,7 @@ void Buffer::bindInternal(const TargetHint target, Buffer* const buffer) { } auto Buffer::bindSomewhereInternal(const TargetHint hint) -> TargetHint { - GLuint* bindings = Context::current()->state().buffer->bindings; + GLuint* bindings = Context::current().state().buffer->bindings; GLuint& hintBinding = bindings[Implementation::BufferState::indexForTarget(hint)]; /* Shortcut - if already bound to hint, return */ @@ -315,33 +315,33 @@ Int Buffer::size() { * couldn't find any matching extension, though) */ GLint size; - (this->*Context::current()->state().buffer->getParameterImplementation)(GL_BUFFER_SIZE, &size); + (this->*Context::current().state().buffer->getParameterImplementation)(GL_BUFFER_SIZE, &size); return size; } Buffer& Buffer::setData(const Containers::ArrayView data, const BufferUsage usage) { - (this->*Context::current()->state().buffer->dataImplementation)(data.size(), data, usage); + (this->*Context::current().state().buffer->dataImplementation)(data.size(), data, usage); return *this; } Buffer& Buffer::setSubData(const GLintptr offset, const Containers::ArrayView data) { - (this->*Context::current()->state().buffer->subDataImplementation)(offset, data.size(), data); + (this->*Context::current().state().buffer->subDataImplementation)(offset, data.size(), data); return *this; } Buffer& Buffer::invalidateData() { - (this->*Context::current()->state().buffer->invalidateImplementation)(); + (this->*Context::current().state().buffer->invalidateImplementation)(); return *this; } Buffer& Buffer::invalidateSubData(const GLintptr offset, const GLsizeiptr length) { - (this->*Context::current()->state().buffer->invalidateSubImplementation)(offset, length); + (this->*Context::current().state().buffer->invalidateSubImplementation)(offset, length); return *this; } #ifndef MAGNUM_TARGET_WEBGL void* Buffer::map(const MapAccess access) { - return (this->*Context::current()->state().buffer->mapImplementation)(access); + return (this->*Context::current().state().buffer->mapImplementation)(access); } #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_NACL) @@ -352,15 +352,15 @@ void* Buffer::mapSub(const GLintptr offset, const GLsizeiptr length, const MapAc #endif void* Buffer::map(const GLintptr offset, const GLsizeiptr length, const MapFlags flags) { - return (this->*Context::current()->state().buffer->mapRangeImplementation)(offset, length, flags); + return (this->*Context::current().state().buffer->mapRangeImplementation)(offset, length, flags); } Buffer& Buffer::flushMappedRange(const GLintptr offset, const GLsizeiptr length) { - (this->*Context::current()->state().buffer->flushMappedRangeImplementation)(offset, length); + (this->*Context::current().state().buffer->flushMappedRangeImplementation)(offset, length); return *this; } -bool Buffer::unmap() { return (this->*Context::current()->state().buffer->unmapImplementation)(); } +bool Buffer::unmap() { return (this->*Context::current().state().buffer->unmapImplementation)(); } #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_NACL) void Buffer::unmapSub() { @@ -373,7 +373,7 @@ void Buffer::unmapSub() { #ifndef MAGNUM_TARGET_GLES void Buffer::subDataInternal(GLintptr offset, GLsizeiptr size, GLvoid* data) { - (this->*Context::current()->state().buffer->getSubDataImplementation)(offset, size, data); + (this->*Context::current().state().buffer->getSubDataImplementation)(offset, size, data); } #endif diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 12f9cc791..a288276f9 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -1066,7 +1066,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}, * eventually @fn_gl{GetBufferSubData} * @requires_gl Buffer data queries are not available in OpenGL ES and - * WebGL. Use @ref map() in OpenGL ES instead. + * WebGL. Use @ref map() or @ref DebugTools::bufferData() in + * OpenGL ES instead. */ /* MinGW complains loudly if the declaration doesn't also have inline */ template inline Containers::Array data(); @@ -1085,7 +1086,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}, * eventually @fn_gl{BindBuffer} and @fn_gl{GetBufferSubData} * @requires_gl Buffer data queries are not available in OpenGL ES and - * WebGL. Use @ref map() in OpenGL ES instead. + * WebGL. Use @ref map() or @ref DebugTools::bufferData() in + * OpenGL ES instead. */ /* MinGW complains loudly if the declaration doesn't also have inline */ template inline Containers::Array subData(GLintptr offset, GLsizeiptr size); diff --git a/src/Magnum/BufferImage.cpp b/src/Magnum/BufferImage.cpp index b4f33ea45..24f801863 100644 --- a/src/Magnum/BufferImage.cpp +++ b/src/Magnum/BufferImage.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/BufferImage.h b/src/Magnum/BufferImage.h index 3db9a2a24..7e351e6eb 100644 --- a/src/Magnum/BufferImage.h +++ b/src/Magnum/BufferImage.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -247,7 +247,6 @@ template class CompressedBufferImage { * @param data Image data * @param usage Image buffer usage * - * The data are *not* deleted after filling the buffer. * @todo Make it more flexible (usable with * @extension{ARB,buffer_storage}, avoiding relocations...) * diff --git a/src/Magnum/BufferTexture.cpp b/src/Magnum/BufferTexture.cpp index 742895fb1..8491d5db7 100644 --- a/src/Magnum/BufferTexture.cpp +++ b/src/Magnum/BufferTexture.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -37,14 +37,14 @@ namespace Magnum { Int BufferTexture::maxSize() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().texture->maxBufferSize; + GLint& value = Context::current().state().texture->maxBufferSize; /* Get the value, if not already cached */ if(value == 0) glGetIntegerv( @@ -60,14 +60,14 @@ Int BufferTexture::maxSize() { Int BufferTexture::offsetAlignment() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 1; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().texture->bufferOffsetAlignment; + GLint& value = Context::current().state().texture->bufferOffsetAlignment; /* Get the value, if not already cached */ if(value == 0) glGetIntegerv( @@ -82,12 +82,12 @@ Int BufferTexture::offsetAlignment() { } BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer) { - (this->*Context::current()->state().texture->setBufferImplementation)(internalFormat, buffer); + (this->*Context::current().state().texture->setBufferImplementation)(internalFormat, buffer); return *this; } BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { - (this->*Context::current()->state().texture->setBufferRangeImplementation)(internalFormat, buffer, offset, size); + (this->*Context::current().state().texture->setBufferRangeImplementation)(internalFormat, buffer, offset, size); return *this; } diff --git a/src/Magnum/BufferTexture.h b/src/Magnum/BufferTexture.h index 41980de01..6c324f5a4 100644 --- a/src/Magnum/BufferTexture.h +++ b/src/Magnum/BufferTexture.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -157,6 +157,28 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture { AbstractTexture{NoCreate, GL_TEXTURE_BUFFER_EXT} {} #endif + /** + * @brief Bind texture to given image unit + * @param imageUnit Image unit + * @param access Image access + * @param format Image format + * + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + void bindImage(Int imageUnit, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, 0, false, 0, access, format); + } + /** * @brief Set texture buffer * @param internalFormat Internal format diff --git a/src/Magnum/BufferTextureFormat.h b/src/Magnum/BufferTextureFormat.h index cc04d1889..1ad30a8de 100644 --- a/src/Magnum/BufferTextureFormat.h +++ b/src/Magnum/BufferTextureFormat.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index 124c16061..52257c48f 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -117,6 +117,9 @@ set(Magnum_HEADERS visibility.h) +set(MagnumTest_HEADERS + Test/AbstractOpenGLTester.h) + # Header files to display in project view of IDEs only set(Magnum_PRIVATE_HEADERS Implementation/BufferState.h @@ -187,6 +190,7 @@ if(NOT TARGET_WEBGL) BufferTexture.h BufferTextureFormat.h CubeMapTextureArray.h + ImageFormat.h MultisampleTexture.h) endif() @@ -228,8 +232,9 @@ set(MagnumMath_SRCS # Objects shared between main and test library add_library(MagnumMathObjects OBJECT ${MagnumMath_SRCS}) +target_include_directories(MagnumMathObjects PUBLIC $) if(NOT BUILD_STATIC) - set_target_properties(MagnumMathObjects PROPERTIES COMPILE_FLAGS "-DMagnumMathObjects_EXPORTS") + target_compile_definitions(MagnumMathObjects PRIVATE "MagnumMathObjects_EXPORTS") endif() if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumMathObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -240,31 +245,38 @@ add_library(Magnum ${SHARED_OR_STATIC} ${Magnum_SRCS} ${Magnum_HEADERS} ${Magnum_PRIVATE_HEADERS} + ${MagnumTest_HEADERS} $) set_target_properties(Magnum PROPERTIES DEBUG_POSTFIX "-d") if(NOT BUILD_STATIC) - set_target_properties(Magnum PROPERTIES COMPILE_FLAGS "-DFlextGL_EXPORTS") + target_compile_definitions(Magnum PRIVATE "FlextGL_EXPORTS") elseif(BUILD_STATIC_PIC) set_target_properties(Magnum PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - -set(Magnum_LIBS - ${CORRADE_UTILITY_LIBRARIES} - ${CORRADE_PLUGINMANAGER_LIBRARIES}) +# We can use both implicit include path (GLES2/gl2.h) where our headers can +# be overriden with system ones or explicit (MagnumExternal/OpenGL/GLES2/gl2ext.h) +# where only our headers will be used +target_include_directories(Magnum PUBLIC + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_BINARY_DIR}/src + ${PROJECT_SOURCE_DIR}/src/MagnumExternal/OpenGL) +target_link_libraries(Magnum + Corrade::Utility + Corrade::PluginManager) if(NOT TARGET_GLES OR TARGET_DESKTOP_GLES) - set(Magnum_LIBS ${Magnum_LIBS} ${OPENGL_gl_LIBRARY}) + target_link_libraries(Magnum ${OPENGL_gl_LIBRARY}) elseif(TARGET_GLES2) - set(Magnum_LIBS ${Magnum_LIBS} ${OPENGLES2_LIBRARY}) + target_link_libraries(Magnum OpenGLES2::OpenGLES2) else() - set(Magnum_LIBS ${Magnum_LIBS} ${OPENGLES3_LIBRARY}) + target_link_libraries(Magnum OpenGLES3::OpenGLES3) endif() -target_link_libraries(Magnum ${Magnum_LIBS}) install(TARGETS Magnum RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) install(FILES ${Magnum_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}) +install(FILES ${MagnumTest_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Test) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}) add_subdirectory(Math) @@ -310,11 +322,12 @@ endif() if(BUILD_TESTS) # Library with graceful assert for testing add_library(MagnumMathTestLib ${SHARED_OR_STATIC} - $) - set_target_properties(MagnumMathTestLib PROPERTIES - COMPILE_FLAGS "-DCORRADE_GRACEFUL_ASSERT" - DEBUG_POSTFIX "-d") - target_link_libraries(MagnumMathTestLib ${CORRADE_UTILITY_LIBRARY}) + $ + dummy.cpp) # XCode workaround, see file comment for details + target_include_directories(MagnumMathTestLib PUBLIC $) + target_compile_definitions(MagnumMathTestLib PRIVATE "CORRADE_GRACEFUL_ASSERT") + set_target_properties(MagnumMathTestLib PROPERTIES DEBUG_POSTFIX "-d") + target_link_libraries(MagnumMathTestLib Corrade::Utility) # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too @@ -328,6 +341,6 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum library and configure file for superprojects -set(MAGNUM_LIBRARY Magnum CACHE INTERNAL "") +# Magnum library target alias and configure file for superprojects +add_library(Magnum::Magnum ALIAS Magnum) set(_MAGNUM_CONFIGURE_FILE ${CMAKE_CURRENT_BINARY_DIR}/configure.h CACHE INTERNAL "") diff --git a/src/Magnum/Color.h b/src/Magnum/Color.h index 77f768d16..ded07a37c 100644 --- a/src/Magnum/Color.h +++ b/src/Magnum/Color.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/ColorFormat.h b/src/Magnum/ColorFormat.h index cadc3262c..e056300d5 100644 --- a/src/Magnum/ColorFormat.h +++ b/src/Magnum/ColorFormat.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index 88460ddac..b8bf0590e 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -93,7 +93,8 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,KHR,texture_compression_astc_ldr), _extension(GL,KHR,texture_compression_astc_hdr), _extension(GL,KHR,blend_equation_advanced), - _extension(GL,KHR,blend_equation_advanced_coherent)}; + _extension(GL,KHR,blend_equation_advanced_coherent), + _extension(GL,KHR,no_error)}; static const std::vector extensions300{ _extension(GL,ARB,map_buffer_range), _extension(GL,ARB,color_buffer_float), @@ -250,6 +251,8 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,ANDROID,extension_pack_es31a), #endif _extension(GL,APPLE,texture_format_BGRA8888), + _extension(GL,ARM,shader_framebuffer_fetch), + _extension(GL,ARM,shader_framebuffer_fetch_depth_stencil), #ifdef CORRADE_TARGET_NACL _extension(GL,CHROMIUM,map_sub), #endif @@ -259,6 +262,7 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,EXT,multi_draw_arrays), _extension(GL,EXT,debug_label), _extension(GL,EXT,debug_marker), + _extension(GL,EXT,shader_framebuffer_fetch), _extension(GL,EXT,disjoint_timer_query), _extension(GL,EXT,texture_sRGB_decode), _extension(GL,EXT,sRGB_write_control), @@ -291,6 +295,7 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,KHR,robustness), _extension(GL,KHR,robust_buffer_access_behavior), _extension(GL,KHR,context_flush_control), + _extension(GL,KHR,no_error), _extension(GL,NV,read_buffer_front), _extension(GL,NV,read_depth), _extension(GL,NV,read_stencil), @@ -377,13 +382,14 @@ const std::vector& Extension::extensions(Version version) { case Version::GL320: return extensions320; case Version::GL330: return extensions330; case Version::GL400: return extensions400; - /* case Version::GLES200: */ case Version::GL410: return extensions410; case Version::GL420: return extensions420; - /* case Version::GLES300: */ case Version::GL430: return extensions430; case Version::GL440: return extensions440; case Version::GL450: return extensions450; + case Version::GLES200: + case Version::GLES300: + case Version::GLES310: return empty; #else case Version::GLES200: return empty; case Version::GLES300: @@ -403,16 +409,30 @@ const std::vector& Extension::extensions(Version version) { Context* Context::_current = nullptr; +bool Context::hasCurrent() { return _current; } + +Context& Context::current() { + CORRADE_ASSERT(_current, "Context::current(): no current context", *_current); + return *_current; +} + Context::Context(NoCreateT, Int argc, char** argv, void functionLoader()): _functionLoader{functionLoader}, _version{Version::None} { /* Parse arguments */ Utility::Arguments args{"magnum"}; - args.addOption("disable-workarounds").setHelpKey("disable-workarounds", "LIST") - .setHelp("disable-workarounds", "driver workarounds to disable\n (see src/Magnum/Implementation/driverSpecific.cpp for detailed info)") + args.addOption("disable-workarounds") + .setHelp("disable-workarounds", "driver workarounds to disable\n (see src/Magnum/Implementation/driverSpecific.cpp for detailed info)", "LIST") + .addOption("disable-extensions").setHelp("disable-extensions", "OpenGL extensions to disable", "LIST") + .setFromEnvironment("disable-workarounds") + .setFromEnvironment("disable-extensions") .parse(argc, argv); /* Disable driver workarounds */ for(auto&& workaround: Utility::String::splitWithoutEmptyParts(args.value("disable-workarounds"))) disableDriverWorkaround(workaround); + + /* Disable extensions */ + for(auto&& extension: Utility::String::splitWithoutEmptyParts(args.value("disable-extensions"))) + _disabledExtensions.push_back(extension); } Context::Context(Context&& other): _version{std::move(other._version)}, @@ -447,7 +467,9 @@ bool Context::tryCreate() { /* Load GL function pointers */ if(_functionLoader) _functionLoader(); - GLint majorVersion, minorVersion; + /* Initialize to something predictable to avoid crashes on improperly + created contexts */ + GLint majorVersion = 0, minorVersion = 0; /* Get version on ES 3.0+/WebGL 2.0+ */ #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) @@ -623,12 +645,37 @@ bool Context::tryCreate() { more info) */ Debug() << "Renderer:" << rendererString() << "by" << vendorString(); Debug() << "OpenGL version:" << versionString(); + + /* Disable extensions as requested by the user */ + if(!_disabledExtensions.empty()) { + Debug() << "Disabling extensions:"; + + /* Put remaining extensions into the hashmap for faster lookup */ + std::unordered_map allExtensions{std::move(futureExtensions)}; + for(std::size_t i = 0; i != future; ++i) + for(const Extension& extension: Extension::extensions(versions[i])) + allExtensions.emplace(extension._string, extension); + + /* Disable extensions that are known and supported and print a message + for each */ + for(auto&& extension: _disabledExtensions) { + auto found = allExtensions.find(extension); + /** @todo Error message here? I should not clutter the output at this point */ + if(found == allExtensions.end()) continue; + + _extensionRequiredVersion[found->second._index] = Version::None; + Debug() << " " << extension; + } + } + _state = new Implementation::State(*this); /* Print a list of used workarounds */ - Debug() << "Using driver workarounds:"; - for(const auto& workaround: _driverWorkarounds) - if(!workaround.second) Debug() << " " << workaround.first; + if(!_driverWorkarounds.empty()) { + Debug() << "Using driver workarounds:"; + for(const auto& workaround: _driverWorkarounds) + if(!workaround.second) Debug() << " " << workaround.first; + } /* Initialize functionality based on current OpenGL version and extensions */ /** @todo Get rid of these */ @@ -639,6 +686,22 @@ bool Context::tryCreate() { return true; } +std::string Context::vendorString() const { + return Utility::String::fromArray(reinterpret_cast(glGetString(GL_VENDOR))); +} + +std::string Context::rendererString() const { + return Utility::String::fromArray(reinterpret_cast(glGetString(GL_RENDERER))); +} + +std::string Context::versionString() const { + return Utility::String::fromArray(reinterpret_cast(glGetString(GL_VERSION))); +} + +std::string Context::shadingLanguageVersionString() const { + return Utility::String::fromArray(reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION))); +} + std::vector Context::shadingLanguageVersionStrings() const { #ifndef MAGNUM_TARGET_GLES GLint versionCount = 0; @@ -691,6 +754,19 @@ std::vector Context::extensionStrings() const { return extensions; } +bool Context::isVersionSupported(Version version) const { + #ifndef MAGNUM_TARGET_GLES + if(version == Version::GLES200) + return isExtensionSupported(); + if(version == Version::GLES300) + return isExtensionSupported(); + if(version == Version::GLES310) + return isExtensionSupported(); + #endif + + return _version >= version; +} + Version Context::supportedVersion(std::initializer_list versions) const { for(auto version: versions) if(isVersionSupported(version)) return version; @@ -736,6 +812,7 @@ Debug& operator<<(Debug& debug, const Context::Flag value) { switch(value) { #define _c(value) case Context::Flag::value: return debug << "Context::Flag::" #value; _c(Debug) + _c(NoError) #ifndef MAGNUM_TARGET_GLES _c(RobustAccess) #endif diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index 4a3e5368e..8ce3b2521 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -96,19 +96,20 @@ information. The context is configurable through command-line options, that are passed either from the `Platform::*Application` classes or from the @ref Platform::Context -class. The options are as following: +class. Usage: -``` -Usage: - [--magnum-help] [--magnum-disable-workarounds LIST] ... + [--magnum-help] [--magnum-disable-workarounds LIST] [--magnum-disable-extensions LIST] ... Arguments: - ... main application arguments - (see -h or --help for details) - --magnum-help display this help message and exit - --magnum-disable-workarounds LIST driver workarounds to disable - (see src/Magnum/Implementation/driverSpecific.cpp for detailed info) -``` + +- `...` -- main application arguments (see `-h` or `--help` for details) +- `--magnum-help` -- display this help message and exit +- `--magnum-disable-workarounds LIST` -- driver workarounds to disable (see + `src/Magnum/Implementation/driverSpecific.cpp` for detailed info) + (environment: `MAGNUM_DISABLE_WORKAROUNDS`) +- `--magnum-disable-extensions LIST` -- OpenGL extensions to disable + (environment: `MAGNUM_DISABLE_EXTENSIONS`) + */ class MAGNUM_EXPORT Context { friend Platform::Context; @@ -135,6 +136,13 @@ class MAGNUM_EXPORT Context { Debug = GL_CONTEXT_FLAG_DEBUG_BIT_KHR, #endif + /** + * Context without error reporting + * @requires_extension Extension @extension{KHR,no_error} + * @requires_es_extension Extension @es_extension2{KHR,no_error,no_error} + */ + NoError = GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR, + #ifndef MAGNUM_TARGET_GLES /** * Context with robust access @@ -210,6 +218,11 @@ class MAGNUM_EXPORT Context { IntelWindows = 1 << 1, #endif + #ifndef MAGNUM_TARGET_WEBGL + /** Binary NVidia drivers on Windows and Linux */ + NVidia = 1 << 2, + #endif + #ifdef MAGNUM_TARGET_GLES /** * OpenGL ES implementation by ANGLE (translated to D3D), used by @@ -217,7 +230,7 @@ class MAGNUM_EXPORT Context { * specification explicitly disallows exposing driver information * to the application, this check cannot be done reliably. */ - ProbablyAngle = 1 << 2 + ProbablyAngle = 1 << 3 #endif }; @@ -228,6 +241,21 @@ class MAGNUM_EXPORT Context { */ typedef Containers::EnumSet DetectedDrivers; + /** + * @brief Whether there is any current context + * + * @see @ref current() + */ + static bool hasCurrent(); + + /** + * @brief Current context + * + * Expect that there is current context. + * @see @ref hasCurrent() + */ + static Context& current(); + /** @brief Copying is not allowed */ Context(const Context&) = delete; @@ -242,8 +270,10 @@ class MAGNUM_EXPORT Context { /** @brief Move assignment is not allowed */ Context& operator=(Context&&) = delete; - /** @brief Current context */ - static Context* current() { return _current; } + #if defined(MAGNUM_BUILD_DEPRECATED) && !defined(DOXYGEN_GENERATING_OUTPUT) + CORRADE_DEPRECATED("Context::current() returns reference now") Context* operator->() { return this; } + CORRADE_DEPRECATED("Context::current() returns reference now") operator Context*() { return this; } + #endif /** * @brief OpenGL version @@ -259,9 +289,7 @@ class MAGNUM_EXPORT Context { * OpenGL calls. * @see @ref rendererString(), @fn_gl{GetString} with @def_gl{VENDOR} */ - std::string vendorString() const { - return reinterpret_cast(glGetString(GL_VENDOR)); - } + std::string vendorString() const; /** * @brief Renderer string @@ -270,9 +298,7 @@ class MAGNUM_EXPORT Context { * OpenGL calls. * @see @ref vendorString(), @fn_gl{GetString} with @def_gl{RENDERER} */ - std::string rendererString() const { - return reinterpret_cast(glGetString(GL_RENDERER)); - } + std::string rendererString() const; /** * @brief Version string @@ -282,9 +308,7 @@ class MAGNUM_EXPORT Context { * @see @ref shadingLanguageVersionString(), @ref version(), * @fn_gl{GetString} with @def_gl{VERSION} */ - std::string versionString() const { - return reinterpret_cast(glGetString(GL_VERSION)); - } + std::string versionString() const; /** * @brief Shading language version string @@ -294,9 +318,7 @@ class MAGNUM_EXPORT Context { * @see @ref versionString(), @ref version(), @fn_gl{GetString} with * @def_gl{SHADING_LANGUAGE_VERSION} */ - std::string shadingLanguageVersionString() const { - return reinterpret_cast(glGetString(GL_SHADING_LANGUAGE_VERSION)); - } + std::string shadingLanguageVersionString() const; /** * @brief Shading language version strings @@ -347,9 +369,7 @@ class MAGNUM_EXPORT Context { * * @see @ref supportedVersion(), @ref MAGNUM_ASSERT_VERSION_SUPPORTED() */ - bool isVersionSupported(Version version) const { - return _version >= version; - } + bool isVersionSupported(Version version) const; /** * @brief Get supported OpenGL version @@ -374,7 +394,7 @@ class MAGNUM_EXPORT Context { * Extensions usable with this function are listed in @ref Extensions * namespace in header @ref Extensions.h. Example usage: * @code - * if(Context::current()->isExtensionSupported()) { + * if(Context::current().isExtensionSupported()) { * // draw fancy detailed model * } else { * // texture fallback @@ -397,8 +417,8 @@ class MAGNUM_EXPORT Context { * @p version. Useful mainly in shader compilation when the decisions * depend on selected GLSL version, for example: * @code - * const Version version = Context::current()->supportedVersion({Version::GL320, Version::GL300, Version::GL210}); - * if(Context::current()->isExtensionSupported(version)) { + * const Version version = Context::current()supportedVersion({Version::GL320, Version::GL300, Version::GL210}); + * if(Context::current().isExtensionSupported(version)) { * // Called only if ARB_explicit_attrib_location is supported * // *and* version is higher than GL 3.1 * } @@ -481,7 +501,7 @@ class MAGNUM_EXPORT Context { Implementation::State& state() { return *_state; } private: - static Context* _current; + MAGNUM_LOCAL static Context* _current; explicit Context(NoCreateT, Int argc, char** argv, void functionLoader()); @@ -508,8 +528,11 @@ class MAGNUM_EXPORT Context { /* True means known and disabled, false means known */ std::vector> _driverWorkarounds; + std::vector _disabledExtensions; }; +CORRADE_ENUMSET_OPERATORS(Context::DetectedDrivers) + #ifndef MAGNUM_TARGET_WEBGL /** @debugoperatorclassenum{Magnum::Context,Magnum::Context::Flag} */ MAGNUM_EXPORT Debug& operator<<(Debug& debug, Context::Flag value); @@ -537,7 +560,7 @@ MAGNUM_ASSERT_VERSION_SUPPORTED(Version::GL330); #else #define MAGNUM_ASSERT_VERSION_SUPPORTED(version) \ do { \ - if(!Magnum::Context::current()->isVersionSupported(version)) { \ + if(!Magnum::Context::current().isVersionSupported(version)) { \ Corrade::Utility::Error() << "Magnum: required version" << version << "is not supported"; \ std::abort(); \ } \ @@ -567,7 +590,7 @@ MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4); #else #define MAGNUM_ASSERT_EXTENSION_SUPPORTED(extension) \ do { \ - if(!Magnum::Context::current()->isExtensionSupported()) { \ + if(!Magnum::Context::current().isExtensionSupported()) { \ Corrade::Utility::Error() << "Magnum: required extension" << extension::string() << "is not supported"; \ std::abort(); \ } \ diff --git a/src/Magnum/CubeMapTexture.cpp b/src/Magnum/CubeMapTexture.cpp index cc5a8c382..db18b10b1 100644 --- a/src/Magnum/CubeMapTexture.cpp +++ b/src/Magnum/CubeMapTexture.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -49,6 +49,17 @@ Vector2i CubeMapTexture::maxSize() { return Vector2i{Implementation::maxCubeMapTextureSideSize()}; } +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +Vector2i CubeMapTexture::imageSize(const Int level) { + const Implementation::TextureState& state = *Context::current().state().texture; + + Vector2i value; + (this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_WIDTH, &value[0]); + (this->*state.getCubeLevelParameterivImplementation)(level, GL_TEXTURE_HEIGHT, &value[1]); + return value; +} +#endif + #ifndef MAGNUM_TARGET_GLES void CubeMapTexture::image(const Int level, Image3D& image) { createIfNotAlready(); @@ -98,22 +109,20 @@ void CubeMapTexture::compressedImage(const Int level, CompressedImage3D& image) createIfNotAlready(); const Vector3i size{imageSize(level), 6}; - GLint textureDataSize; - /* Similarly to imageSize(), use only parameters of +X in pre-DSA code path - and assume that all other slices are the same */ - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); - const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); + const GLint textureDataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); + std::size_t dataOffset, dataSize; + std::tie(dataOffset, dataSize) = Implementation::compressedImageDataOffsetSizeFor(image, size, textureDataSize); GLint format; - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_INTERNAL_FORMAT, &format); + (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ Containers::Array data{image.release()}; - if(data.size() < dataSize) - data = Containers::Array{dataSize}; + if(data.size() < dataOffset + dataSize) + data = Containers::Array{dataOffset + dataSize}; Buffer::unbindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - glGetCompressedTextureImage(_id, level, data.size(), data); + (this->*Context::current().state().texture->getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffset, dataSize, data); image.setData(image.storage(), CompressedPixelFormat(format), size, std::move(data)); } @@ -126,23 +135,21 @@ void CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D& i createIfNotAlready(); const Vector3i size{imageSize(level), 6}; - GLint textureDataSize; - /* Similarly to imageSize(), use only parameters of +X in pre-DSA code path - and assume that all other slices are the same */ - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); - const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); + const GLint textureDataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level); + std::size_t dataOffset, dataSize; + std::tie(dataOffset, dataSize) = Implementation::compressedImageDataOffsetSizeFor(image, size, textureDataSize); GLint format; - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_INTERNAL_FORMAT, &format); + (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ - if(image.dataSize() < dataSize) - image.setData(image.storage(), CompressedPixelFormat(format), size, {nullptr, dataSize}, usage); + if(image.dataSize() < dataOffset + dataSize) + image.setData(image.storage(), CompressedPixelFormat(format), size, {nullptr, dataOffset + dataSize}, usage); else image.setData(image.storage(), CompressedPixelFormat(format), size, nullptr, usage); image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - glGetCompressedTextureImage(_id, level, dataSize, nullptr); + (this->*Context::current().state().texture->getFullCompressedCubeImageImplementation)(level, size.xy(), dataOffset, dataSize, nullptr); } CompressedBufferImage3D CubeMapTexture::compressedImage(const Int level, CompressedBufferImage3D&& image, const BufferUsage usage) { @@ -150,7 +157,7 @@ CompressedBufferImage3D CubeMapTexture::compressedImage(const Int level, Compres return std::move(image); } -void CubeMapTexture::image(const Coordinate coordinate, const Int level, Image2D& image) { +void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, Image2D& image) { const Vector2i size = imageSize(level); const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); @@ -161,16 +168,16 @@ void CubeMapTexture::image(const Coordinate coordinate, const Int level, Image2D Buffer::unbindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (this->*Context::current()->state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), data.size(), data); + (this->*Context::current().state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), data.size(), data); image.setData(image.storage(), image.format(), image.type(), size, std::move(data)); } -Image2D CubeMapTexture::image(const Coordinate coordinate, const Int level, Image2D&& image) { +Image2D CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, Image2D&& image) { this->image(coordinate, level, image); return std::move(image); } -void CubeMapTexture::image(const Coordinate coordinate, const Int level, BufferImage2D& image, const BufferUsage usage) { +void CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, BufferImage2D& image, const BufferUsage usage) { const Vector2i size = imageSize(level); const std::size_t dataSize = Implementation::imageDataSizeFor(image, size); @@ -182,23 +189,22 @@ void CubeMapTexture::image(const Coordinate coordinate, const Int level, BufferI image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (this->*Context::current()->state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), dataSize, nullptr); + (this->*Context::current().state().texture->getCubeImageImplementation)(coordinate, level, size, image.format(), image.type(), dataSize, nullptr); } -BufferImage2D CubeMapTexture::image(const Coordinate coordinate, const Int level, BufferImage2D&& image, const BufferUsage usage) { +BufferImage2D CubeMapTexture::image(const CubeMapCoordinate coordinate, const Int level, BufferImage2D&& image, const BufferUsage usage) { this->image(coordinate, level, image, usage); return std::move(image); } -void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedImage2D& image) { +void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedImage2D& image) { const Vector2i size = imageSize(level); - GLint textureDataSize; - /* Similarly to imageSize(), use only parameters of +X in pre-DSA code path - and assume that all other slices are the same */ - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + /* The function returns size of all six faces, divide the result to get size + of one face */ + const GLint textureDataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)/6; const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); GLint format; - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_INTERNAL_FORMAT, &format); + (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ Containers::Array data{image.release()}; @@ -207,24 +213,23 @@ void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int leve Buffer::unbindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (this->*Context::current()->state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), data); + (this->*Context::current().state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, data.size(), data); image.setData(image.storage(), CompressedPixelFormat(format), size, std::move(data)); } -CompressedImage2D CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedImage2D&& image) { +CompressedImage2D CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedImage2D&& image) { compressedImage(coordinate, level, image); return std::move(image); } -void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedBufferImage2D& image, const BufferUsage usage) { +void CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D& image, const BufferUsage usage) { const Vector2i size = imageSize(level); - GLint textureDataSize; - /* Similarly to imageSize(), use only parameters of +X in pre-DSA code path - and assume that all other slices are the same */ - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &textureDataSize); + /* The function returns size of all six faces, divide the result to get size + of one face */ + const GLint textureDataSize = (this->*Context::current().state().texture->getCubeLevelCompressedImageSizeImplementation)(level)/6; const std::size_t dataSize = Implementation::compressedImageDataSizeFor(image, size, textureDataSize); GLint format; - (this->*Context::current()->state().texture->getLevelParameterivImplementation)(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_INTERNAL_FORMAT, &format); + (this->*Context::current().state().texture->getCubeLevelParameterivImplementation)(level, GL_TEXTURE_INTERNAL_FORMAT, &format); /* Reallocate only if needed */ if(image.dataSize() < dataSize) @@ -234,10 +239,10 @@ void CubeMapTexture::compressedImage(const Coordinate coordinate, const Int leve image.buffer().bindInternal(Buffer::TargetHint::PixelPack); image.storage().applyPack(); - (this->*Context::current()->state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, nullptr); + (this->*Context::current().state().texture->getCompressedCubeImageImplementation)(coordinate, level, size, dataSize, nullptr); } -CompressedBufferImage2D CubeMapTexture::compressedImage(const Coordinate coordinate, const Int level, CompressedBufferImage2D&& image, const BufferUsage usage) { +CompressedBufferImage2D CubeMapTexture::compressedImage(const CubeMapCoordinate coordinate, const Int level, CompressedBufferImage2D&& image, const BufferUsage usage) { compressedImage(coordinate, level, image, usage); return std::move(image); } @@ -252,6 +257,16 @@ BufferImage3D CubeMapTexture::subImage(const Int level, const Range3Di& range, B return std::move(image); } +CompressedImage3D CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, CompressedImage3D&& image) { + compressedSubImage(level, range, image); + return std::move(image); +} + +CompressedBufferImage3D CubeMapTexture::compressedSubImage(const Int level, const Range3Di& range, CompressedBufferImage3D&& image, const BufferUsage usage) { + compressedSubImage(level, range, image, usage); + return std::move(image); +} + CubeMapTexture& CubeMapTexture::setSubImage(const Int level, const Vector3i& offset, const ImageView3D& image) { createIfNotAlready(); @@ -289,12 +304,12 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Int level, const Vec } #endif -CubeMapTexture& CubeMapTexture::setSubImage(const Coordinate coordinate, const Int level, const Vector2i& offset, const ImageView2D& image) { +CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, const ImageView2D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif image.storage().applyUnpack(); - (this->*Context::current()->state().texture->cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), image.data() + (this->*Context::current().state().texture->cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), image.data() #ifdef MAGNUM_TARGET_GLES2 + Implementation::pixelStorageSkipOffset(image) #endif @@ -303,15 +318,15 @@ CubeMapTexture& CubeMapTexture::setSubImage(const Coordinate coordinate, const I } #ifndef MAGNUM_TARGET_GLES2 -CubeMapTexture& CubeMapTexture::setSubImage(const Coordinate coordinate, const Int level, const Vector2i& offset, BufferImage2D& image) { +CubeMapTexture& CubeMapTexture::setSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, BufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); image.storage().applyUnpack(); - (this->*Context::current()->state().texture->cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), nullptr); + (this->*Context::current().state().texture->cubeSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.type(), nullptr); return *this; } #endif -CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Coordinate coordinate, const Int level, const Vector2i& offset, const CompressedImageView2D& image) { +CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, const CompressedImageView2D& image) { #ifndef MAGNUM_TARGET_GLES2 Buffer::unbindInternal(Buffer::TargetHint::PixelUnpack); #endif @@ -320,90 +335,177 @@ CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Coordinate coordinat to reset anything */ image.storage().applyUnpack(); #endif - (this->*Context::current()->state().texture->cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size())); + (this->*Context::current().state().texture->cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), image.data(), Implementation::occupiedCompressedImageDataSize(image, image.data().size())); return *this; } #ifndef MAGNUM_TARGET_GLES2 -CubeMapTexture& CubeMapTexture::setCompressedSubImage(const Coordinate coordinate, const Int level, const Vector2i& offset, CompressedBufferImage2D& image) { +CubeMapTexture& CubeMapTexture::setCompressedSubImage(const CubeMapCoordinate coordinate, const Int level, const Vector2i& offset, CompressedBufferImage2D& image) { image.buffer().bindInternal(Buffer::TargetHint::PixelUnpack); #ifndef MAGNUM_TARGET_GLES /* Pixel storage is completely ignored for compressed images on ES, no need to reset anything */ image.storage().applyUnpack(); #endif - (this->*Context::current()->state().texture->cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); + (this->*Context::current().state().texture->cubeCompressedSubImageImplementation)(coordinate, level, offset, image.size(), image.format(), nullptr, Implementation::occupiedCompressedImageDataSize(image, image.dataSize())); return *this; } #endif +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +void CubeMapTexture::getLevelParameterImplementationDefault(const GLint level, const GLenum parameter, GLint* const values) { + bindInternal(); + /* Using only parameters of +X in pre-DSA code path and assuming that all + other faces are the same */ + glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, parameter, values); +} + +#ifndef MAGNUM_TARGET_GLES +void CubeMapTexture::getLevelParameterImplementationDSA(const GLint level, const GLenum parameter, GLint* const values) { + glGetTextureLevelParameteriv(_id, level, parameter, values); +} + +void CubeMapTexture::getLevelParameterImplementationDSAEXT(const GLint level, const GLenum parameter, GLint* const values) { + _flags |= ObjectFlag::Created; + /* Using only parameters of +X in pre-DSA code path and assuming that all + other faces are the same */ + glGetTextureLevelParameterivEXT(_id, GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, parameter, values); +} +#endif +#endif + +#ifndef MAGNUM_TARGET_GLES +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefault(const GLint level) { + bindInternal(); + /* Using only parameters of +X in pre-DSA code path and assuming that all + other faces are the same */ + GLint value; + glGetTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &value); + + /* Size of all six faces */ + return value*6; +} + +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround(const GLint level) { + const GLint value = getLevelCompressedImageSizeImplementationDefault(level); + + GLint immutable; + glGetTexParameteriv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_LEVELS, &immutable); + return immutable ? value/6 : value; +} + +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSA(const GLint level) { + GLint value; + glGetTextureLevelParameteriv(_id, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &value); + return value; +} + +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround(const GLint level) { + const GLint value = getLevelCompressedImageSizeImplementationDSA(level); + + GLint immutable; + glGetTextureParameteriv(_id, GL_TEXTURE_IMMUTABLE_LEVELS, &immutable); + return immutable ? value : value*6; +} + +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSAEXT(const GLint level) { + _flags |= ObjectFlag::Created; + /* Using only parameters of +X in pre-DSA code path and assuming that all + other faces are the same */ + GLint value; + glGetTextureLevelParameterivEXT(_id, GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &value); + + /* Size of all six faces */ + return value*6; +} + +GLint CubeMapTexture::getLevelCompressedImageSizeImplementationDSAEXTImmutableWorkaround(const GLint level) { + const GLint value = getLevelCompressedImageSizeImplementationDSAEXT(level); + + GLint immutable; + glGetTextureParameterivEXT(_id, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_IMMUTABLE_LEVELS, &immutable); + return immutable ? value/6 : value; +} +#endif + #ifndef MAGNUM_TARGET_GLES -void CubeMapTexture::getImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) { +void CubeMapTexture::getCompressedImageImplementationDSA(const GLint level, const Vector2i&, const std::size_t dataOffset, const std::size_t dataSize, GLvoid* const data) { + glGetCompressedTextureImage(_id, level, dataOffset + dataSize, data); +} + +void CubeMapTexture::getCompressedImageImplementationDSASingleSliceWorkaround(const GLint level, const Vector2i& size, const std::size_t dataOffset, const std::size_t dataSize, GLvoid* const data) { + /* On NVidia (358.16) calling glGetCompressedTextureImage() extracts only + the first face */ + for(Int face = 0; face != 6; ++face) + glGetCompressedTextureSubImage(_id, level, 0, 0, face, size.x(), size.y(), 1, dataOffset + dataSize/6, static_cast(data) + dataSize*face/6); +} + +void CubeMapTexture::getImageImplementationDefault(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) { bindInternal(); glGetTexImage(GLenum(coordinate), level, GLenum(format), GLenum(type), data); } -void CubeMapTexture::getCompressedImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i&, std::size_t, GLvoid* const data) { +void CubeMapTexture::getCompressedImageImplementationDefault(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, std::size_t, GLvoid* const data) { bindInternal(); glGetCompressedTexImage(GLenum(coordinate), level, data); } -void CubeMapTexture::getImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& size, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { +void CubeMapTexture::getImageImplementationDSA(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& size, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { glGetTextureSubImage(_id, level, 0, 0, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), GLenum(type), dataSize, data); } -void CubeMapTexture::getCompressedImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& size, const std::size_t dataSize, GLvoid* const data) { +void CubeMapTexture::getCompressedImageImplementationDSA(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& size, const std::size_t dataSize, GLvoid* const data) { glGetCompressedTextureSubImage(_id, level, 0, 0, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, dataSize, data); } -void CubeMapTexture::getImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) { +void CubeMapTexture::getImageImplementationDSAEXT(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, std::size_t, GLvoid* const data) { _flags |= ObjectFlag::Created; glGetTextureImageEXT(_id, GLenum(coordinate), level, GLenum(format), GLenum(type), data); } -void CubeMapTexture::getCompressedImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i&, std::size_t, GLvoid* const data) { +void CubeMapTexture::getCompressedImageImplementationDSAEXT(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, std::size_t, GLvoid* const data) { _flags |= ObjectFlag::Created; glGetCompressedTextureImageEXT(_id, GLenum(coordinate), level, data); } -void CubeMapTexture::getImageImplementationRobustness(const Coordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { +void CubeMapTexture::getImageImplementationRobustness(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const PixelFormat format, const PixelType type, const std::size_t dataSize, GLvoid* const data) { bindInternal(); glGetnTexImageARB(GLenum(coordinate), level, GLenum(format), GLenum(type), dataSize, data); } -void CubeMapTexture::getCompressedImageImplementationRobustness(const Coordinate coordinate, const GLint level, const Vector2i&, const std::size_t dataSize, GLvoid* const data) { +void CubeMapTexture::getCompressedImageImplementationRobustness(const CubeMapCoordinate coordinate, const GLint level, const Vector2i&, const std::size_t dataSize, GLvoid* const data) { bindInternal(); glGetnCompressedTexImageARB(GLenum(coordinate), level, dataSize, data); } #endif -void CubeMapTexture::subImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { +void CubeMapTexture::subImageImplementationDefault(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { bindInternal(); glTexSubImage2D(GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); } -void CubeMapTexture::compressedSubImageImplementationDefault(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { +void CubeMapTexture::compressedSubImageImplementationDefault(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { bindInternal(); glCompressedTexSubImage2D(GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data); } #ifndef MAGNUM_TARGET_GLES -void CubeMapTexture::subImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { +void CubeMapTexture::subImageImplementationDSA(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { glTextureSubImage3D(_id, level, offset.x(), offset.y(), GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), GLenum(type), data); } -void CubeMapTexture::compressedSubImageImplementationDSA(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { +void CubeMapTexture::compressedSubImageImplementationDSA(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { glCompressedTextureSubImage3D(_id, level, offset.x(), offset.y(), GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, size.x(), size.y(), 1, GLenum(format), dataSize, data); } -void CubeMapTexture::subImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { +void CubeMapTexture::subImageImplementationDSAEXT(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const PixelFormat format, const PixelType type, const GLvoid* const data) { _flags |= ObjectFlag::Created; glTextureSubImage2DEXT(_id, GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), GLenum(type), data); } -void CubeMapTexture::compressedSubImageImplementationDSAEXT(const Coordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { +void CubeMapTexture::compressedSubImageImplementationDSAEXT(const CubeMapCoordinate coordinate, const GLint level, const Vector2i& offset, const Vector2i& size, const CompressedPixelFormat format, const GLvoid* const data, const GLsizei dataSize) { _flags |= ObjectFlag::Created; - glTextureSubImage2DEXT(_id, GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data); + glCompressedTextureSubImage2DEXT(_id, GLenum(coordinate), level, offset.x(), offset.y(), size.x(), size.y(), GLenum(format), dataSize, data); } #endif diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 11331a67e..9f89993a6 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -26,7 +26,7 @@ */ /** @file - * @brief Class @ref Magnum::CubeMapTexture + * @brief Class @ref Magnum::CubeMapTexture, enum @ref Magnum::CubeMapCoordinate */ #include "Magnum/AbstractTexture.h" @@ -35,6 +35,20 @@ namespace Magnum { +/** +@brief Cube map coordinate + +@see @ref CubeMapTexture +*/ +enum class CubeMapCoordinate: GLenum { + PositiveX = GL_TEXTURE_CUBE_MAP_POSITIVE_X, /**< +X cube side */ + NegativeX = GL_TEXTURE_CUBE_MAP_NEGATIVE_X, /**< -X cube side */ + PositiveY = GL_TEXTURE_CUBE_MAP_POSITIVE_Y, /**< +Y cube side */ + NegativeY = GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, /**< -Y cube side */ + PositiveZ = GL_TEXTURE_CUBE_MAP_POSITIVE_Z, /**< +Z cube side */ + NegativeZ = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z /**< -Z cube side */ +}; + /** @brief Cube map texture @@ -64,8 +78,8 @@ CubeMapTexture texture; texture.setMagnificationFilter(Sampler::Filter::Linear) // ... .setStorage(Math::log2(256)+1, TextureFormat::RGBA8, {256, 256}) - .setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, {}, positiveX) - .setSubImage(CubeMapTexture::Coordinate::NegativeX, 0, {}, negativeX) + .setSubImage(CubeMapCoordinate::PositiveX, 0, {}, positiveX) + .setSubImage(CubeMapCoordinate::NegativeX, 0, {}, negativeX) // ... @endcode @@ -83,15 +97,13 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { friend Implementation::TextureState; public: - /** @brief Cube map coordinate */ - enum class Coordinate: GLenum { - PositiveX = GL_TEXTURE_CUBE_MAP_POSITIVE_X, /**< +X cube side */ - NegativeX = GL_TEXTURE_CUBE_MAP_NEGATIVE_X, /**< -X cube side */ - PositiveY = GL_TEXTURE_CUBE_MAP_POSITIVE_Y, /**< +Y cube side */ - NegativeY = GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, /**< -Y cube side */ - PositiveZ = GL_TEXTURE_CUBE_MAP_POSITIVE_Z, /**< +Z cube side */ - NegativeZ = GL_TEXTURE_CUBE_MAP_NEGATIVE_Z /**< -Z cube side */ - }; + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief CubeMapCoordinate + * @deprecated Use @ref CubeMapCoordinate instead. + */ + typedef CORRADE_DEPRECATED("use CubeMapCoordinate instead") CubeMapCoordinate Coordinate; + #endif /** * @brief Max supported size of one side of cube map texture @@ -102,6 +114,34 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { */ static Vector2i maxSize(); + #ifndef MAGNUM_TARGET_GLES + /** + * @copybrief Texture::compressedBlockSize() + * + * See @ref Texture::compressedBlockSize() for more information. + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @requires_gl Compressed texture queries are not available in OpenGL + * ES. + */ + static Vector2i compressedBlockSize(TextureFormat format) { + return DataHelper<2>::compressedBlockSize(GL_TEXTURE_CUBE_MAP, format); + } + + /** + * @copybrief Texture::compressedBlockDataSize() + * + * See @ref Texture::compressedBlockDataSize() for more information. + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @requires_gl Compressed texture queries are not available in OpenGL + * ES. + * @see @ref compressedBlockSize(), @fn_gl{Getinternalformat} with + * @def_gl{TEXTURE_COMPRESSED_BLOCK_SIZE} + */ + static Int compressedBlockDataSize(TextureFormat format) { + return AbstractTexture::compressedBlockDataSize(GL_TEXTURE_CUBE_MAP, format); + } + #endif + /** * @brief Wrap existing OpenGL cube map texture object * @param id OpenGL cube map texture ID @@ -138,6 +178,55 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { */ explicit CubeMapTexture(NoCreateT) noexcept: AbstractTexture{NoCreate, GL_TEXTURE_CUBE_MAP} {} + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /** + * @brief Bind level of given cube map texture coordinate to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param coordinate Cube map coordinate + * @param access Image access + * @param format Image format + * + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + void bindImage(Int imageUnit, Int level, CubeMapCoordinate coordinate, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, false, GLenum(coordinate) - GL_TEXTURE_CUBE_MAP_POSITIVE_X, access, format); + } + + /** + * @brief Bind level of layered cube map texture to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param access Image access + * @param format Image format + * + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImage(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + void bindImageLayered(Int imageUnit, Int level, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, true, 0, access, format); + } + #endif + #ifndef MAGNUM_TARGET_GLES2 /** * @copybrief Texture::setBaseLevel() @@ -421,16 +510,14 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_gles Texture image size queries are not available in * WebGL. */ - Vector2i imageSize(Int level) { - return DataHelper<2>::imageSize(*this, GL_TEXTURE_CUBE_MAP_POSITIVE_X, level); - } + Vector2i imageSize(Int level); #ifdef MAGNUM_BUILD_DEPRECATED /** * @copybrief imageSize() * @deprecated Use @ref imageSize(Int) instead. */ - CORRADE_DEPRECATED("use imageSize(Int) instead") Vector2i imageSize(Coordinate, Int level) { + CORRADE_DEPRECATED("use imageSize(Int) instead") Vector2i imageSize(CubeMapCoordinate, Int level) { return imageSize(level); } #endif @@ -560,16 +647,16 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ - void image(Coordinate coordinate, Int level, Image2D& image); + void image(CubeMapCoordinate coordinate, Int level, Image2D& image); /** @overload * * Convenience alternative to the above, example usage: * @code - * Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}); + * Image2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}); * @endcode */ - Image2D image(Coordinate coordinate, Int level, Image2D&& image); + Image2D image(CubeMapCoordinate coordinate, Int level, Image2D&& image); /** * @brief Read given mip level and coordinate of texture to buffer image @@ -580,16 +667,16 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ - void image(Coordinate coordinate, Int level, BufferImage2D& image, BufferUsage usage); + void image(CubeMapCoordinate coordinate, Int level, BufferImage2D& image, BufferUsage usage); /** @overload * * Convenience alternative to the above, example usage: * @code - * BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); + * BufferImage2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); * @endcode */ - BufferImage2D image(Coordinate coordinate, Int level, BufferImage2D&& image, BufferUsage usage); + BufferImage2D image(CubeMapCoordinate coordinate, Int level, BufferImage2D&& image, BufferUsage usage); /** * @brief Read given mip level and coordinate of compressed texture to image @@ -620,16 +707,16 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ - void compressedImage(Coordinate coordinate, Int level, CompressedImage2D& image); + void compressedImage(CubeMapCoordinate coordinate, Int level, CompressedImage2D& image); /** @overload * * Convenience alternative to the above, example usage: * @code - * CompressedImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0, {}); + * CompressedImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {}); * @endcode */ - CompressedImage2D compressedImage(Coordinate coordinate, Int level, CompressedImage2D&& image); + CompressedImage2D compressedImage(CubeMapCoordinate coordinate, Int level, CompressedImage2D&& image); /** * @brief Read given mip level and coordinate of compressed texture to buffer image @@ -641,16 +728,16 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_gl Texture image queries are not available in OpenGL ES or * WebGL. See @ref Framebuffer::read() for possible workaround. */ - void compressedImage(Coordinate coordinate, Int level, CompressedBufferImage2D& image, BufferUsage usage); + void compressedImage(CubeMapCoordinate coordinate, Int level, CompressedBufferImage2D& image, BufferUsage usage); /** @overload * * Convenience alternative to the above, example usage: * @code - * CompressedBufferImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0, {}, BufferUsage::StaticRead); + * CompressedBufferImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {}, BufferUsage::StaticRead); * @endcode */ - CompressedBufferImage2D compressedImage(Coordinate coordinate, Int level, CompressedBufferImage2D&& image, BufferUsage usage); + CompressedBufferImage2D compressedImage(CubeMapCoordinate coordinate, Int level, CompressedBufferImage2D&& image, BufferUsage usage); /** * @copybrief Texture::subImage(Int, const RangeTypeFor&, Image&) @@ -695,6 +782,50 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @endcode */ BufferImage3D subImage(Int level, const Range3Di& range, BufferImage3D&& image, BufferUsage usage); + + /** + * @copybrief Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) + * + * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. + */ + void compressedSubImage(Int level, const Range3Di& range, CompressedImage3D& image) { + AbstractTexture::compressedSubImage<3>(level, range, image); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedImage3D image = texture.compressedSubImage(0, range, {}); + * @endcode + */ + CompressedImage3D compressedSubImage(Int level, const Range3Di& range, CompressedImage3D&& image); + + /** + * @copybrief Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * + * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. + */ + void compressedSubImage(Int level, const Range3Di& range, CompressedBufferImage3D& image, BufferUsage usage) { + AbstractTexture::compressedSubImage<3>(level, range, image, usage); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedBufferImage3D image = texture.compressedSubImage(0, range, {}, BufferUsage::StaticRead); + * @endcode + */ + CompressedBufferImage3D compressedSubImage(Int level, const Range3Di& range, CompressedBufferImage3D&& image, BufferUsage usage); #endif /** @@ -706,7 +837,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ - CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageView2D& image) { + CubeMapTexture& setImage(CubeMapCoordinate coordinate, Int level, TextureFormat internalFormat, const ImageView2D& image) { DataHelper<2>::setImage(*this, GLenum(coordinate), level, internalFormat, image); return *this; } @@ -720,7 +851,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ - CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, BufferImage2D& image) { + CubeMapTexture& setImage(CubeMapCoordinate coordinate, Int level, TextureFormat internalFormat, BufferImage2D& image) { DataHelper<2>::setImage(*this, GLenum(coordinate), level, internalFormat, image); return *this; } @@ -733,7 +864,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage() * instead. */ - CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, BufferImage2D&& image) { + CubeMapTexture& setImage(CubeMapCoordinate coordinate, Int level, TextureFormat internalFormat, BufferImage2D&& image) { return setImage(coordinate, level, internalFormat, image); } #endif @@ -747,7 +878,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and * @ref setCompressedSubImage() instead. */ - CubeMapTexture& setCompressedImage(Coordinate coordinate, Int level, const CompressedImageView2D& image) { + CubeMapTexture& setCompressedImage(CubeMapCoordinate coordinate, Int level, const CompressedImageView2D& image) { DataHelper<2>::setCompressedImage(*this, GLenum(coordinate), level, image); return *this; } @@ -761,7 +892,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and * @ref setCompressedSubImage() instead. */ - CubeMapTexture& setCompressedImage(Coordinate coordinate, Int level, CompressedBufferImage2D& image) { + CubeMapTexture& setCompressedImage(CubeMapCoordinate coordinate, Int level, CompressedBufferImage2D& image) { DataHelper<2>::setCompressedImage(*this, GLenum(coordinate), level, image); return *this; } @@ -774,7 +905,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @deprecated_gl Prefer to use @ref setStorage() and * @ref setCompressedSubImage() instead. */ - CubeMapTexture& setCompressedImage(Coordinate coordinate, Int level, CompressedBufferImage2D&& image) { + CubeMapTexture& setCompressedImage(CubeMapCoordinate coordinate, Int level, CompressedBufferImage2D&& image) { return setCompressedImage(coordinate, level, image); } #endif @@ -849,7 +980,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * * See @ref Texture::setSubImage() for more information. */ - CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const ImageView2D& image); + CubeMapTexture& setSubImage(CubeMapCoordinate coordinate, Int level, const Vector2i& offset, const ImageView2D& image); #ifndef MAGNUM_TARGET_GLES2 /** @overload @@ -858,7 +989,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_webgl20 Pixel buffer objects are not available in WebGL * 1.0. */ - CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D& image); + CubeMapTexture& setSubImage(CubeMapCoordinate coordinate, Int level, const Vector2i& offset, BufferImage2D& image); /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES @@ -866,7 +997,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_webgl20 Pixel buffer objects are not available in WebGL * 1.0. */ - CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, BufferImage2D&& image) { + CubeMapTexture& setSubImage(CubeMapCoordinate coordinate, Int level, const Vector2i& offset, BufferImage2D&& image) { return setSubImage(coordinate, level, offset, image); } #endif @@ -877,7 +1008,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * * See @ref Texture::setCompressedSubImage() for more information. */ - CubeMapTexture& setCompressedSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const CompressedImageView2D& image); + CubeMapTexture& setCompressedSubImage(CubeMapCoordinate coordinate, Int level, const Vector2i& offset, const CompressedImageView2D& image); #ifndef MAGNUM_TARGET_GLES2 /** @overload @@ -886,7 +1017,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_webgl20 Pixel buffer objects are not available in WebGL * 1.0. */ - CubeMapTexture& setCompressedSubImage(Coordinate coordinate, Int level, const Vector2i& offset, CompressedBufferImage2D& image); + CubeMapTexture& setCompressedSubImage(CubeMapCoordinate coordinate, Int level, const Vector2i& offset, CompressedBufferImage2D& image); /** @overload * @requires_gles30 Pixel buffer objects are not available in OpenGL ES @@ -894,7 +1025,7 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { * @requires_webgl20 Pixel buffer objects are not available in WebGL * 1.0. */ - CubeMapTexture& setCompressedSubImage(Coordinate coordinate, Int level, const Vector2i& offset, CompressedBufferImage2D&& image) { + CubeMapTexture& setCompressedSubImage(CubeMapCoordinate coordinate, Int level, const Vector2i& offset, CompressedBufferImage2D&& image) { return setCompressedSubImage(coordinate, level, offset, image); } #endif @@ -946,28 +1077,48 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { private: explicit CubeMapTexture(GLuint id, ObjectFlags flags) noexcept: AbstractTexture{id, GL_TEXTURE_CUBE_MAP, flags} {} + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLint level, GLenum parameter, GLint* values); + #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLint level, GLenum parameter, GLint* values); + void MAGNUM_LOCAL getLevelParameterImplementationDSAEXT(GLint level, GLenum parameter, GLint* values); + #endif + #endif + + #ifndef MAGNUM_TARGET_GLES + GLint MAGNUM_LOCAL getLevelCompressedImageSizeImplementationDefault(GLint level); + GLint MAGNUM_LOCAL getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround(GLint level); + GLint MAGNUM_LOCAL getLevelCompressedImageSizeImplementationDSA(GLint level); + GLint MAGNUM_LOCAL getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround(GLint level); + GLint MAGNUM_LOCAL getLevelCompressedImageSizeImplementationDSAEXT(GLint level); + GLint MAGNUM_LOCAL getLevelCompressedImageSizeImplementationDSAEXTImmutableWorkaround(GLint level); + #endif + #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL getImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getImageImplementationRobustness(Coordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); - - void MAGNUM_LOCAL getCompressedImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getCompressedImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getCompressedImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); - void MAGNUM_LOCAL getCompressedImageImplementationRobustness(Coordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getCompressedImageImplementationDSA(GLint level, const Vector2i& size, std::size_t dataOffset, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getCompressedImageImplementationDSASingleSliceWorkaround(GLint level, const Vector2i& size, std::size_t dataOffset, std::size_t dataSize, GLvoid* data); + + void MAGNUM_LOCAL getImageImplementationDefault(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getImageImplementationDSA(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getImageImplementationDSAEXT(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getImageImplementationRobustness(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, PixelFormat format, PixelType type, std::size_t dataSize, GLvoid* data); + + void MAGNUM_LOCAL getCompressedImageImplementationDefault(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getCompressedImageImplementationDSA(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getCompressedImageImplementationDSAEXT(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); + void MAGNUM_LOCAL getCompressedImageImplementationRobustness(CubeMapCoordinate coordinate, GLint level, const Vector2i& size, std::size_t dataSize, GLvoid* data); #endif - void MAGNUM_LOCAL subImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDefault(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL subImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); - void MAGNUM_LOCAL subImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSA(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); + void MAGNUM_LOCAL subImageImplementationDSAEXT(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, PixelFormat format, PixelType type, const GLvoid* data); #endif - void MAGNUM_LOCAL compressedSubImageImplementationDefault(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + void MAGNUM_LOCAL compressedSubImageImplementationDefault(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL compressedSubImageImplementationDSA(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); - void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(Coordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + void MAGNUM_LOCAL compressedSubImageImplementationDSA(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); + void MAGNUM_LOCAL compressedSubImageImplementationDSAEXT(CubeMapCoordinate coordinate, GLint level, const Vector2i& offset, const Vector2i& size, CompressedPixelFormat format, const GLvoid* data, GLsizei dataSize); #endif }; diff --git a/src/Magnum/CubeMapTextureArray.cpp b/src/Magnum/CubeMapTextureArray.cpp index a0a8535a0..e03863d38 100644 --- a/src/Magnum/CubeMapTextureArray.cpp +++ b/src/Magnum/CubeMapTextureArray.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -37,10 +37,10 @@ namespace Magnum { Vector3i CubeMapTextureArray::maxSize() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return {}; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return {}; #endif @@ -78,6 +78,16 @@ BufferImage3D CubeMapTextureArray::subImage(const Int level, const Range3Di& ran this->subImage(level, range, image, usage); return std::move(image); } + +CompressedImage3D CubeMapTextureArray::compressedSubImage(const Int level, const Range3Di& range, CompressedImage3D&& image) { + compressedSubImage(level, range, image); + return std::move(image); +} + +CompressedBufferImage3D CubeMapTextureArray::compressedSubImage(const Int level, const Range3Di& range, CompressedBufferImage3D&& image, const BufferUsage usage) { + compressedSubImage(level, range, image, usage); + return std::move(image); +} #endif } diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index 880a31128..fecbb4b19 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -98,6 +98,34 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { */ static Vector3i maxSize(); + #ifndef MAGNUM_TARGET_GLES + /** + * @copybrief Texture::compressedBlockSize() + * + * See @ref Texture::compressedBlockSize() for more information. + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @requires_gl Compressed texture queries are not available in OpenGL + * ES. + */ + static Vector2i compressedBlockSize(TextureFormat format) { + return DataHelper<2>::compressedBlockSize(GL_TEXTURE_CUBE_MAP_ARRAY, format); + } + + /** + * @copybrief Texture::compressedBlockDataSize() + * + * See @ref Texture::compressedBlockDataSize() for more information. + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @requires_gl Compressed texture queries are not available in OpenGL + * ES. + * @see @ref compressedBlockSize(), @fn_gl{Getinternalformat} with + * @def_gl{TEXTURE_COMPRESSED_BLOCK_SIZE} + */ + static Int compressedBlockDataSize(TextureFormat format) { + return AbstractTexture::compressedBlockDataSize(GL_TEXTURE_CUBE_MAP_ARRAY, format); + } + #endif + /** * @brief Wrap existing OpenGL cube map array texture object * @param id OpenGL cube map array texture ID @@ -145,6 +173,53 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { AbstractTexture{NoCreate, GL_TEXTURE_CUBE_MAP_ARRAY_EXT} {} #endif + /** + * @brief Bind level of given texture layer to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param layer Texture layer + * @param access Image access + * @param format Image format + * + * Layer is equivalent to layer * 6 + number of texture face, i.e. +X + * is `0` and so on, in order of (+X, -X, +Y, -Y, +Z, -Z). + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + */ + void bindImage(Int imageUnit, Int level, Int layer, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, false, layer, access, format); + } + + /** + * @brief Bind level of layered texture to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param access Image access + * @param format Image format + * + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImage(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + */ + void bindImageLayered(Int imageUnit, Int level, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, true, 0, access, format); + } + /** * @copybrief Texture::setBaseLevel() * @return Reference to self (for method chaining) @@ -368,7 +443,7 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { * See @ref Texture::imageSize() for more information. */ Vector3i imageSize(Int level) { - return DataHelper<3>::imageSize(*this, _target, level); + return DataHelper<3>::imageSize(*this, level); } #ifndef MAGNUM_TARGET_GLES @@ -498,6 +573,50 @@ class MAGNUM_EXPORT CubeMapTextureArray: public AbstractTexture { * @endcode */ BufferImage3D subImage(Int level, const Range3Di& range, BufferImage3D&& image, BufferUsage usage); + + /** + * @copybrief Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) + * + * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl Texture image queries are not available in OpenGL ES. + * See @ref Framebuffer::read() for possible workaround. + */ + void compressedSubImage(Int level, const Range3Di& range, CompressedImage3D& image) { + AbstractTexture::compressedSubImage<3>(level, range, image); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedImage3D image = texture.compressedSubImage(0, range, {}); + * @endcode + */ + CompressedImage3D compressedSubImage(Int level, const Range3Di& range, CompressedImage3D&& image); + + /** + * @copybrief Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * + * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl Texture image queries are not available in OpenGL ES. + * See @ref Framebuffer::read() for possible workaround. + */ + void compressedSubImage(Int level, const Range3Di& range, CompressedBufferImage3D& image, BufferUsage usage) { + AbstractTexture::compressedSubImage<3>(level, range, image, usage); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedBufferImage3D image = texture.compressedSubImage(0, range, {}, BufferUsage::StaticRead); + * @endcode + */ + CompressedBufferImage3D compressedSubImage(Int level, const Range3Di& range, CompressedBufferImage3D&& image, BufferUsage usage); #endif /** diff --git a/src/Magnum/DebugMessage.h b/src/Magnum/DebugMessage.h index 21926c2b5..3bbdf807f 100644 --- a/src/Magnum/DebugMessage.h +++ b/src/Magnum/DebugMessage.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugOutput.cpp b/src/Magnum/DebugOutput.cpp index 966d8f6cc..f6cfe733e 100644 --- a/src/Magnum/DebugOutput.cpp +++ b/src/Magnum/DebugOutput.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -48,7 +48,7 @@ void APIENTRY #endif callbackWrapper(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { - Context::current()->state().debug->messageCallback(DebugOutput::Source(source), DebugOutput::Type(type), id, DebugOutput::Severity(severity), std::string{message, std::size_t(length)}, userParam); + Context::current().state().debug->messageCallback(DebugOutput::Source(source), DebugOutput::Type(type), id, DebugOutput::Severity(severity), std::string{message, std::size_t(length)}, userParam); } #endif @@ -123,10 +123,10 @@ void defaultCallback(const DebugOutput::Source source, const DebugOutput::Type t } Int DebugOutput::maxLoggedMessages() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current()->state().debug->maxLoggedMessages; + GLint& value = Context::current().state().debug->maxLoggedMessages; if(value == 0) { #ifndef MAGNUM_TARGET_GLES @@ -140,10 +140,10 @@ Int DebugOutput::maxLoggedMessages() { } Int DebugOutput::maxMessageLength() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current()->state().debug->maxMessageLength; + GLint& value = Context::current().state().debug->maxMessageLength; if(value == 0) { #ifndef MAGNUM_TARGET_GLES @@ -157,7 +157,7 @@ Int DebugOutput::maxMessageLength() { } void DebugOutput::setCallback(const Callback callback, const void* userParam) { - Context::current()->state().debug->callbackImplementation(callback, userParam); + Context::current().state().debug->callbackImplementation(callback, userParam); } void DebugOutput::setDefaultCallback() { @@ -165,7 +165,7 @@ void DebugOutput::setDefaultCallback() { } void DebugOutput::setEnabledInternal(const GLenum source, const GLenum type, const GLenum severity, const std::initializer_list ids, const bool enabled) { - Context::current()->state().debug->controlImplementation(source, type, severity, ids, enabled); + Context::current().state().debug->controlImplementation(source, type, severity, ids, enabled); } void DebugOutput::controlImplementationNoOp(GLenum, GLenum, GLenum, std::initializer_list, bool) {} @@ -192,8 +192,8 @@ void DebugOutput::callbackImplementationNoOp(Callback, const void*) {} void DebugOutput::callbackImplementationKhr(const Callback callback, const void* userParam) { /* Replace the callback */ - const Callback original = Context::current()->state().debug->messageCallback; - Context::current()->state().debug->messageCallback = callback; + const Callback original = Context::current().state().debug->messageCallback; + Context::current().state().debug->messageCallback = callback; /* Adding callback */ if(!original && callback) { @@ -273,7 +273,7 @@ Debug& operator<<(Debug& debug, const DebugOutput::Severity value) { #endif void DebugMessage::insertInternal(const Source source, const Type type, const UnsignedInt id, const DebugOutput::Severity severity, const Containers::ArrayView string) { - Context::current()->state().debug->messageInsertImplementation(source, type, id, severity, string); + Context::current().state().debug->messageInsertImplementation(source, type, id, severity, string); } void DebugMessage::insertImplementationNoOp(Source, Type, UnsignedInt, DebugOutput::Severity, const Containers::ArrayView) {} @@ -348,10 +348,10 @@ Debug& operator<<(Debug& debug, const DebugMessage::Type value) { #endif Int DebugGroup::maxStackDepth() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; - GLint& value = Context::current()->state().debug->maxStackDepth; + GLint& value = Context::current().state().debug->maxStackDepth; if(value == 0) { #ifndef MAGNUM_TARGET_GLES @@ -366,13 +366,13 @@ Int DebugGroup::maxStackDepth() { void DebugGroup::pushInternal(const Source source, const UnsignedInt id, const Containers::ArrayView message) { CORRADE_ASSERT(!_active, "DebugGroup::push(): group is already active", ); - Context::current()->state().debug->pushGroupImplementation(source, id, message); + Context::current().state().debug->pushGroupImplementation(source, id, message); _active = true; } void DebugGroup::pop() { CORRADE_ASSERT(_active, "DebugGroup::pop(): group is not active", ); - Context::current()->state().debug->popGroupImplementation(); + Context::current().state().debug->popGroupImplementation(); _active = false; } diff --git a/src/Magnum/DebugOutput.h b/src/Magnum/DebugOutput.h index ba06e79c0..aa16b0c77 100644 --- a/src/Magnum/DebugOutput.h +++ b/src/Magnum/DebugOutput.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/BufferData.cpp b/src/Magnum/DebugTools/BufferData.cpp new file mode 100644 index 000000000..aff18c731 --- /dev/null +++ b/src/Magnum/DebugTools/BufferData.cpp @@ -0,0 +1,38 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "BufferData.h" + +#ifndef MAGNUM_TARGET_WEBGL +namespace Magnum { namespace DebugTools { namespace Implementation { + +void bufferSubData(Buffer& buffer, GLintptr offset, GLsizeiptr size, void* output) { + const char* data = buffer.map(offset, size, Buffer::MapFlag::Read); + std::copy(data, data + size, reinterpret_cast(output)); + buffer.unmap(); +} + +}}} +#endif diff --git a/src/Magnum/DebugTools/BufferData.h b/src/Magnum/DebugTools/BufferData.h new file mode 100644 index 000000000..4cf6a55b2 --- /dev/null +++ b/src/Magnum/DebugTools/BufferData.h @@ -0,0 +1,81 @@ +#ifndef Magnum_DebugTools_BufferData_h +#define Magnum_DebugTools_BufferData_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#ifndef MAGNUM_TARGET_WEBGL +/** @file + * @brief Function @ref Magnum::DebugTools::bufferData(), @ref Magnum::DebugTools::bufferSubData() + */ +#endif + +#include + +#include "Magnum/Buffer.h" +#include "Magnum/DebugTools/visibility.h" + +#ifndef MAGNUM_TARGET_WEBGL +namespace Magnum { namespace DebugTools { + +namespace Implementation { + MAGNUM_DEBUGTOOLS_EXPORT void bufferSubData(Buffer& buffer, GLintptr offset, GLsizeiptr size, void* output); +} + +/** +@brief Buffer subdata + +Emulates @ref Buffer::subData() call on platforms that don't support it (such +as OpenGL ES) by using @ref Buffer::map(). +@requires_gles30 Extension @es_extension{EXT,map_buffer_range} in OpenGL ES + 2.0. +@requires_gles Buffer mapping is not available in WebGL. +*/ +template Containers::Array inline bufferSubData(Buffer& buffer, GLintptr offset, GLsizeiptr size) { + Containers::Array data{std::size_t(size)}; + if(size) Implementation::bufferSubData(buffer, offset, size*sizeof(T), data); + return data; +} + +/** +@brief Buffer data + +Emulates @ref Buffer::data() call on platforms that don't support it (such as +OpenGL ES) by using @ref Buffer::map(). +@requires_gles30 Extension @es_extension{EXT,map_buffer_range} in OpenGL ES + 2.0. +@requires_gles Buffer mapping is not available in WebGL. +*/ +template Containers::Array inline bufferData(Buffer& buffer) { + const Int bufferSize = buffer.size(); + CORRADE_ASSERT(bufferSize%sizeof(T) == 0, "Buffer::data(): the buffer size is" << bufferSize << "bytes, which can't be expressed as array of types with size" << sizeof(T), nullptr); + return bufferSubData(buffer, 0, bufferSize/sizeof(T)); +} + +}} +#else +#error this header is not available in WebGL build +#endif + +#endif diff --git a/src/Magnum/DebugTools/CMakeLists.txt b/src/Magnum/DebugTools/CMakeLists.txt index 51cfe5f5b..76ca9163d 100644 --- a/src/Magnum/DebugTools/CMakeLists.txt +++ b/src/Magnum/DebugTools/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -24,47 +24,77 @@ # set(MagnumDebugTools_SRCS - ForceRenderer.cpp - ObjectRenderer.cpp Profiler.cpp ResourceManager.cpp - ShapeRenderer.cpp - - Implementation/AbstractBoxRenderer.cpp - Implementation/AbstractShapeRenderer.cpp - Implementation/AxisAlignedBoxRenderer.cpp - Implementation/BoxRenderer.cpp - Implementation/CapsuleRenderer.cpp - Implementation/CylinderRenderer.cpp - Implementation/LineSegmentRenderer.cpp - Implementation/PointRenderer.cpp - Implementation/SphereRenderer.cpp) + TextureImage.cpp) set(MagnumDebugTools_HEADERS - ForceRenderer.h DebugTools.h - ObjectRenderer.h Profiler.h ResourceManager.h - ShapeRenderer.h - + TextureImage.h visibility.h) # Header files to display in project view of IDEs only -set(MagnumDebugTools_PRIVATE_HEADERS - Implementation/AbstractBoxRenderer.h - Implementation/AbstractShapeRenderer.h - Implementation/AxisAlignedBoxRenderer.h - Implementation/BoxRenderer.h - Implementation/CapsuleRenderer.h - Implementation/CapsuleRendererTransformation.h - Implementation/CylinderRenderer.h - Implementation/CylinderRendererTransformation.h - Implementation/ForceRendererTransformation.h - Implementation/LineSegmentRenderer.h - Implementation/LineSegmentRendererTransformation.h - Implementation/PointRenderer.h - Implementation/SphereRenderer.h) +set(MagnumDebugTools_PRIVATE_HEADERS ) + +if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_GLES2) + corrade_add_resource(MagnumDebugTools_RESOURCES resources.conf) + list(APPEND MagnumDebugTools_SRCS ${MagnumDebugTools_RESOURCES}) +endif() + +if(NOT MAGNUM_TARGET_WEBGL) + list(APPEND MagnumDebugTools_SRCS + BufferData.cpp) + + list(APPEND MagnumDebugTools_HEADERS + BufferData.h) +endif() + +if(WITH_SCENEGRAPH) + list(APPEND MagnumDebugTools_SRCS + ForceRenderer.cpp + ObjectRenderer.cpp) + + list(APPEND MagnumDebugTools_HEADERS + ForceRenderer.h + ObjectRenderer.h) + + list(APPEND MagnumDebugTools_PRIVATE_HEADERS + Implementation/ForceRendererTransformation.h) +endif() + +if(WITH_SHAPES) + list(APPEND MagnumDebugTools_SRCS + ShapeRenderer.cpp + + Implementation/AbstractBoxRenderer.cpp + Implementation/AbstractShapeRenderer.cpp + Implementation/AxisAlignedBoxRenderer.cpp + Implementation/BoxRenderer.cpp + Implementation/CapsuleRenderer.cpp + Implementation/CylinderRenderer.cpp + Implementation/LineSegmentRenderer.cpp + Implementation/PointRenderer.cpp + Implementation/SphereRenderer.cpp) + + list(APPEND MagnumDebugTools_HEADERS + ShapeRenderer.h) + + list(APPEND MagnumDebugTools_PRIVATE_HEADERS + Implementation/AbstractBoxRenderer.h + Implementation/AbstractShapeRenderer.h + Implementation/AxisAlignedBoxRenderer.h + Implementation/BoxRenderer.h + Implementation/CapsuleRenderer.h + Implementation/CapsuleRendererTransformation.h + Implementation/CylinderRenderer.h + Implementation/CylinderRendererTransformation.h + Implementation/LineSegmentRenderer.h + Implementation/LineSegmentRendererTransformation.h + Implementation/PointRenderer.h + Implementation/SphereRenderer.h) +endif() # DebugTools library add_library(MagnumDebugTools ${SHARED_OR_STATIC} @@ -80,9 +110,13 @@ target_link_libraries(MagnumDebugTools Magnum MagnumMeshTools MagnumPrimitives - MagnumSceneGraph - MagnumShaders - MagnumShapes) + MagnumShaders) +if(WITH_SCENEGRAPH) + target_link_libraries(MagnumDebugTools MagnumSceneGraph) +endif() +if(WITH_SHAPES) + target_link_libraries(MagnumDebugTools MagnumShapes) +endif() install(TARGETS MagnumDebugTools RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} @@ -94,5 +128,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum DebugTools library for superprojects -set(MAGNUM_DEBUGTOOLS_LIBRARY MagnumDebugTools CACHE INTERNAL "") +# Magnum DebugTools target alias for superprojects +add_library(Magnum::DebugTools ALIAS MagnumDebugTools) diff --git a/src/Magnum/DebugTools/DebugTools.h b/src/Magnum/DebugTools/DebugTools.h index 02ac6daed..4d766a453 100644 --- a/src/Magnum/DebugTools/DebugTools.h +++ b/src/Magnum/DebugTools/DebugTools.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/ForceRenderer.cpp b/src/Magnum/DebugTools/ForceRenderer.cpp index 2857e55fb..b8d54f73e 100644 --- a/src/Magnum/DebugTools/ForceRenderer.cpp +++ b/src/Magnum/DebugTools/ForceRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/ForceRenderer.h b/src/Magnum/DebugTools/ForceRenderer.h index e0a8ea369..4b95927ae 100644 --- a/src/Magnum/DebugTools/ForceRenderer.h +++ b/src/Magnum/DebugTools/ForceRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -90,7 +90,7 @@ See @ref debug-tools-renderers for more information. Example code: @code -DebugTools::ResourceManager::instance()->set("my", DebugTools::ForceRendererOptions() +DebugTools::ResourceManager::instance().set("my", DebugTools::ForceRendererOptions() .setScale(5.0f) .setColor(Color3::fromHSV(120.0_degf, 1.0f, 0.7f)); diff --git a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp b/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp index 91dfc687c..b8c706a21 100644 --- a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h b/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h index ca2bff5a0..180e8abc0 100644 --- a/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h +++ b/src/Magnum/DebugTools/Implementation/AbstractBoxRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp index e8243d155..2da2fe733 100644 --- a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h index 1300ceead..d2beeb1e2 100644 --- a/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h +++ b/src/Magnum/DebugTools/Implementation/AbstractShapeRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp b/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp index 7212a7626..24cf0b190 100644 --- a/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h b/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h index 83463e88d..965542034 100644 --- a/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h +++ b/src/Magnum/DebugTools/Implementation/AxisAlignedBoxRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/BoxRenderer.cpp b/src/Magnum/DebugTools/Implementation/BoxRenderer.cpp index 95085395e..a8392e56c 100644 --- a/src/Magnum/DebugTools/Implementation/BoxRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/BoxRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/BoxRenderer.h b/src/Magnum/DebugTools/Implementation/BoxRenderer.h index 4bbce8ab1..6c36fb0fc 100644 --- a/src/Magnum/DebugTools/Implementation/BoxRenderer.h +++ b/src/Magnum/DebugTools/Implementation/BoxRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp b/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp index 3e6cea08a..d0cc41340 100644 --- a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/CapsuleRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.h b/src/Magnum/DebugTools/Implementation/CapsuleRenderer.h index ac3651ded..d5679d92c 100644 --- a/src/Magnum/DebugTools/Implementation/CapsuleRenderer.h +++ b/src/Magnum/DebugTools/Implementation/CapsuleRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h b/src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h index 7064c4069..f559e675c 100644 --- a/src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h +++ b/src/Magnum/DebugTools/Implementation/CapsuleRendererTransformation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp b/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp index f5d4eb058..afacb8575 100644 --- a/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/CylinderRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/CylinderRenderer.h b/src/Magnum/DebugTools/Implementation/CylinderRenderer.h index e8c84b3d7..1a27522e0 100644 --- a/src/Magnum/DebugTools/Implementation/CylinderRenderer.h +++ b/src/Magnum/DebugTools/Implementation/CylinderRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h b/src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h index aec563175..0f93b39b1 100644 --- a/src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h +++ b/src/Magnum/DebugTools/Implementation/CylinderRendererTransformation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/ForceRendererTransformation.h b/src/Magnum/DebugTools/Implementation/ForceRendererTransformation.h index a446e7f76..df600e784 100644 --- a/src/Magnum/DebugTools/Implementation/ForceRendererTransformation.h +++ b/src/Magnum/DebugTools/Implementation/ForceRendererTransformation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp b/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp index 3d209abad..000de8775 100644 --- a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h b/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h index 80bceb9c5..64507f20f 100644 --- a/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h +++ b/src/Magnum/DebugTools/Implementation/LineSegmentRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h b/src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h index fbc01eb7c..1ea144a98 100644 --- a/src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h +++ b/src/Magnum/DebugTools/Implementation/LineSegmentRendererTransformation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/PointRenderer.cpp b/src/Magnum/DebugTools/Implementation/PointRenderer.cpp index f0f87364b..b6f66839b 100644 --- a/src/Magnum/DebugTools/Implementation/PointRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/PointRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/PointRenderer.h b/src/Magnum/DebugTools/Implementation/PointRenderer.h index 310ab94e7..af145f170 100644 --- a/src/Magnum/DebugTools/Implementation/PointRenderer.h +++ b/src/Magnum/DebugTools/Implementation/PointRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp b/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp index 91d360e95..2bec5cd75 100644 --- a/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp +++ b/src/Magnum/DebugTools/Implementation/SphereRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Implementation/SphereRenderer.h b/src/Magnum/DebugTools/Implementation/SphereRenderer.h index a1c127d43..75d0fe361 100644 --- a/src/Magnum/DebugTools/Implementation/SphereRenderer.h +++ b/src/Magnum/DebugTools/Implementation/SphereRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/ObjectRenderer.cpp b/src/Magnum/DebugTools/ObjectRenderer.cpp index fd92ac06d..7e1381b46 100644 --- a/src/Magnum/DebugTools/ObjectRenderer.cpp +++ b/src/Magnum/DebugTools/ObjectRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/ObjectRenderer.h b/src/Magnum/DebugTools/ObjectRenderer.h index 45d97a53b..2ea6332ad 100644 --- a/src/Magnum/DebugTools/ObjectRenderer.h +++ b/src/Magnum/DebugTools/ObjectRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -75,7 +75,7 @@ Visualizes object position, rotation and scale using colored axes. See Example code: @code // Create some options -DebugTools::ResourceManager::instance()->set("my", DebugTools::ObjectRendererOptions().setSize(0.3f)); +DebugTools::ResourceManager::instance().set("my", DebugTools::ObjectRendererOptions().setSize(0.3f)); // Create debug renderer for given object, use "my" options for it Object3D* object; diff --git a/src/Magnum/DebugTools/Profiler.cpp b/src/Magnum/DebugTools/Profiler.cpp index a80c426ee..93d256c69 100644 --- a/src/Magnum/DebugTools/Profiler.cpp +++ b/src/Magnum/DebugTools/Profiler.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Profiler.h b/src/Magnum/DebugTools/Profiler.h index 4f08c6606..6b0641797 100644 --- a/src/Magnum/DebugTools/Profiler.h +++ b/src/Magnum/DebugTools/Profiler.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/ResourceManager.cpp b/src/Magnum/DebugTools/ResourceManager.cpp index 578634b6d..6b1554a10 100644 --- a/src/Magnum/DebugTools/ResourceManager.cpp +++ b/src/Magnum/DebugTools/ResourceManager.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/ResourceManager.h b/src/Magnum/DebugTools/ResourceManager.h index 08afbf6dd..8d9f45068 100644 --- a/src/Magnum/DebugTools/ResourceManager.h +++ b/src/Magnum/DebugTools/ResourceManager.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/ShapeRenderer.cpp b/src/Magnum/DebugTools/ShapeRenderer.cpp index a815417ba..ecb656eb3 100644 --- a/src/Magnum/DebugTools/ShapeRenderer.cpp +++ b/src/Magnum/DebugTools/ShapeRenderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/ShapeRenderer.h b/src/Magnum/DebugTools/ShapeRenderer.h index 19d573977..cbddf2168 100644 --- a/src/Magnum/DebugTools/ShapeRenderer.h +++ b/src/Magnum/DebugTools/ShapeRenderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Test/BufferDataGLTest.cpp b/src/Magnum/DebugTools/Test/BufferDataGLTest.cpp new file mode 100644 index 000000000..c9985ae26 --- /dev/null +++ b/src/Magnum/DebugTools/Test/BufferDataGLTest.cpp @@ -0,0 +1,71 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include "Magnum/DebugTools/BufferData.h" +#include "Magnum/Test/AbstractOpenGLTester.h" + +namespace Magnum { namespace DebugTools { namespace Test { + +struct BufferDataGLTest: Magnum::Test::AbstractOpenGLTester { + explicit BufferDataGLTest(); + + void data(); + void subData(); +}; + +BufferDataGLTest::BufferDataGLTest() { + addTests({&BufferDataGLTest::data, + &BufferDataGLTest::subData}); +} + +namespace { + constexpr Int Data[] = {2, 7, 5, 13, 25}; +} + +void BufferDataGLTest::data() { + Buffer buffer; + buffer.setData(Data, BufferUsage::StaticDraw); + const Containers::Array contents = bufferData(buffer); + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE_AS(contents, + Containers::ArrayView{Data}, + TestSuite::Compare::Container); +} + +void BufferDataGLTest::subData() { + Buffer buffer; + buffer.setData(Data, BufferUsage::StaticDraw); + const Containers::Array contents = bufferSubData(buffer, 4, 3); + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE_AS(contents, + Containers::ArrayView{Data}.slice(1, 4), + TestSuite::Compare::Container); +} + +}}} + +MAGNUM_GL_TEST_MAIN(Magnum::DebugTools::Test::BufferDataGLTest) diff --git a/src/Magnum/DebugTools/Test/CMakeLists.txt b/src/Magnum/DebugTools/Test/CMakeLists.txt index 6df4e5ea8..e46197d97 100644 --- a/src/Magnum/DebugTools/Test/CMakeLists.txt +++ b/src/Magnum/DebugTools/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -27,3 +27,8 @@ corrade_add_test(DebugToolsCapsuleRendererTest CapsuleRendererTest.cpp LIBRARIES corrade_add_test(DebugToolsCylinderRendererTest CylinderRendererTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(DebugToolsForceRendererTest ForceRendererTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(DebugToolsLineSegmentRendererTest LineSegmentRendererTest.cpp LIBRARIES MagnumMathTestLib) + +if(BUILD_GL_TESTS) + corrade_add_test(DebugToolsBufferDataGLTest BufferDataGLTest.cpp LIBRARIES MagnumDebugTools ${GL_TEST_LIBRARIES}) + corrade_add_test(DebugToolsTextureImageGLTest TextureImageGLTest.cpp LIBRARIES MagnumDebugTools ${GL_TEST_LIBRARIES}) +endif() diff --git a/src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp b/src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp index 94c4537fe..a1f7fb7b9 100644 --- a/src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp +++ b/src/Magnum/DebugTools/Test/CapsuleRendererTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Test/CylinderRendererTest.cpp b/src/Magnum/DebugTools/Test/CylinderRendererTest.cpp index eebf18980..849968d60 100644 --- a/src/Magnum/DebugTools/Test/CylinderRendererTest.cpp +++ b/src/Magnum/DebugTools/Test/CylinderRendererTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Test/ForceRendererTest.cpp b/src/Magnum/DebugTools/Test/ForceRendererTest.cpp index c07c3a7df..2d4a0c7a3 100644 --- a/src/Magnum/DebugTools/Test/ForceRendererTest.cpp +++ b/src/Magnum/DebugTools/Test/ForceRendererTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp b/src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp index f3f925b3e..954955292 100644 --- a/src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp +++ b/src/Magnum/DebugTools/Test/LineSegmentRendererTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DebugTools/Test/TextureImageGLTest.cpp b/src/Magnum/DebugTools/Test/TextureImageGLTest.cpp new file mode 100644 index 000000000..72e77136d --- /dev/null +++ b/src/Magnum/DebugTools/Test/TextureImageGLTest.cpp @@ -0,0 +1,203 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include "Magnum/CubeMapTexture.h" +#include "Magnum/Image.h" +#include "Magnum/PixelFormat.h" +#include "Magnum/Texture.h" +#include "Magnum/TextureFormat.h" +#include "Magnum/DebugTools/BufferData.h" +#include "Magnum/DebugTools/TextureImage.h" +#include "Magnum/Math/Range.h" +#include "Magnum/Test/AbstractOpenGLTester.h" + +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/BufferImage.h" +#endif + +namespace Magnum { namespace DebugTools { namespace Test { + +struct TextureImageGLTest: Magnum::Test::AbstractOpenGLTester { + explicit TextureImageGLTest(); + + void subImage2D(); + #ifndef MAGNUM_TARGET_GLES2 + void subImage2DBuffer(); + #endif + + void subImageCube(); + #ifndef MAGNUM_TARGET_GLES2 + void subImageCubeBuffer(); + #endif + + #ifndef MAGNUM_TARGET_GLES2 + void subImage2DUInt(); + void subImage2DFloat(); + #endif +}; + +TextureImageGLTest::TextureImageGLTest() { + addTests({&TextureImageGLTest::subImage2D, + #ifndef MAGNUM_TARGET_GLES2 + &TextureImageGLTest::subImage2DBuffer, + #endif + + &TextureImageGLTest::subImageCube, + #ifndef MAGNUM_TARGET_GLES2 + &TextureImageGLTest::subImageCubeBuffer, + #endif + + #ifndef MAGNUM_TARGET_GLES2 + &TextureImageGLTest::subImage2DUInt, + &TextureImageGLTest::subImage2DFloat, + #endif + }); +} + +namespace { + constexpr UnsignedByte Data2D[] = { 0x00, 0x01, 0x02, 0x03, + 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f }; +} + +void TextureImageGLTest::subImage2D() { + Texture2D texture; + texture.setImage(0, TextureFormat::RGBA8, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, Data2D}); + + Image2D image = textureSubImage(texture, 0, {{}, Vector2i{2}}, {PixelFormat::RGBA, PixelType::UnsignedByte}); + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE(image.size(), Vector2i{2}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{Data2D}, + TestSuite::Compare::Container); +} + +#ifndef MAGNUM_TARGET_GLES2 +void TextureImageGLTest::subImage2DBuffer() { + Texture2D texture; + texture.setImage(0, TextureFormat::RGBA8, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, Data2D}); + + BufferImage2D image = textureSubImage(texture, 0, {{}, Vector2i{2}}, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); + Containers::Array data = bufferData(image.buffer()); + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE(image.size(), Vector2i{2}); + CORRADE_COMPARE_AS(data, + Containers::ArrayView{Data2D}, + TestSuite::Compare::Container); +} +#endif + +void TextureImageGLTest::subImageCube() { + ImageView2D view{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, Data2D}; + + CubeMapTexture texture; + texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8, view); + + Image2D image = textureSubImage(texture, CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {PixelFormat::RGBA, PixelType::UnsignedByte}); + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE(image.size(), Vector2i{2}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{Data2D}, + TestSuite::Compare::Container); +} + +#ifndef MAGNUM_TARGET_GLES2 +void TextureImageGLTest::subImageCubeBuffer() { + ImageView2D view{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{2}, Data2D}; + + CubeMapTexture texture; + texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8, view) + .setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8, view); + + BufferImage2D image = textureSubImage(texture, CubeMapCoordinate::PositiveX, 0, {{}, Vector2i{2}}, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); + Containers::Array data = bufferData(image.buffer()); + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE(image.size(), Vector2i{2}); + CORRADE_COMPARE_AS(data, + Containers::ArrayView{Data2D}, + TestSuite::Compare::Container); +} +#endif + +#ifndef MAGNUM_TARGET_GLES2 +namespace { + constexpr UnsignedInt Data2DUInt[] = { 0xcafebabe, + 0xdeadbeef, + 0xbadf00d, + 0xdeadbabe }; +} + +void TextureImageGLTest::subImage2DUInt() { + Texture2D texture; + texture.setImage(0, TextureFormat::R32UI, ImageView2D{PixelFormat::RedInteger, PixelType::UnsignedInt, Vector2i{2}, Data2DUInt}); + + Image2D image = textureSubImage(texture, 0, {{}, Vector2i{2}}, {PixelFormat::RedInteger, PixelType::UnsignedInt}); + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE(image.size(), Vector2i{2}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()/4}), + Containers::ArrayView{Data2DUInt}, + TestSuite::Compare::Container); +} + +namespace { + constexpr Float Data2DFloat[] = { 1.0f, + 3.14159f, + 2.71828f, + 1.41421f }; +} + +void TextureImageGLTest::subImage2DFloat() { + Texture2D texture; + texture.setStorage(1, TextureFormat::R32F, Vector2i{2}) + .setSubImage(0, {}, ImageView2D{PixelFormat::Red, PixelType::Float, Vector2i{2}, Data2DFloat}); + + Image2D image = textureSubImage(texture, 0, {{}, Vector2i{2}}, {PixelFormat::Red, PixelType::Float}); + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE(image.size(), Vector2i{2}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()/4}), + Containers::ArrayView{Data2DFloat}, + TestSuite::Compare::Container); +} +#endif + +}}} + +MAGNUM_GL_TEST_MAIN(Magnum::DebugTools::Test::TextureImageGLTest) diff --git a/src/Magnum/DebugTools/TextureImage.cpp b/src/Magnum/DebugTools/TextureImage.cpp new file mode 100644 index 000000000..18ec16bd8 --- /dev/null +++ b/src/Magnum/DebugTools/TextureImage.cpp @@ -0,0 +1,220 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "TextureImage.h" + +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/BufferImage.h" +#endif +#include "Magnum/Context.h" +#include "Magnum/Extensions.h" +#include "Magnum/Framebuffer.h" +#include "Magnum/Image.h" +#include "Magnum/Texture.h" + +#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) +#include + +#include "Magnum/AbstractShaderProgram.h" +#include "Magnum/Mesh.h" +#include "Magnum/PixelFormat.h" +#include "Magnum/Shader.h" +#include "Magnum/TextureFormat.h" +#include "Magnum/Version.h" + +#ifdef MAGNUM_BUILD_STATIC +static void importDebugToolsResources() { + CORRADE_RESOURCE_INITIALIZE(MagnumDebugTools_RESOURCES) +} +#endif +#endif + +namespace Magnum { namespace DebugTools { + +#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) +namespace { + +class FloatReinterpretShader: public AbstractShaderProgram { + public: + explicit FloatReinterpretShader(); + + FloatReinterpretShader& setTexture(Texture2D& texture, Int level) { + texture.bind(0); + setUniform(levelUniform, level); + return *this; + } + + private: + Int levelUniform; +}; + +FloatReinterpretShader::FloatReinterpretShader() { + #ifdef MAGNUM_BUILD_STATIC + /* Import resources on static build, if not already */ + if(!Utility::Resource::hasGroup("MagnumDebugTools")) + importDebugToolsResources(); + #endif + Utility::Resource rs{"MagnumDebugTools"}; + + Shader vert{Version::GLES300, Shader::Type::Vertex}; + Shader frag{Version::GLES300, Shader::Type::Fragment}; + vert.addSource(rs.get("TextureImage.vert")); + frag.addSource(rs.get("TextureImage.frag")); + + CORRADE_INTERNAL_ASSERT(Shader::compile({vert, frag})); + attachShaders({vert, frag}); + + CORRADE_INTERNAL_ASSERT(link()); + + levelUniform = uniformLocation("level"); + setUniform(uniformLocation("textureData"), 0); +} + +} +#endif + +void textureSubImage(Texture2D& texture, const Int level, const Range2Di& range, Image2D& image) { + #ifndef MAGNUM_TARGET_GLES + if(Context::current().isExtensionSupported()) { + texture.subImage(level, range, image); + return; + } + #endif + + #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) + if(image.type() == PixelType::Float) { + const PixelFormat imageFormat = image.format(); + TextureFormat textureFormat; + PixelFormat reinterpretFormat; + switch(imageFormat) { + case PixelFormat::Red: + textureFormat = TextureFormat::R32UI; + reinterpretFormat = PixelFormat::RedInteger; + break; + case PixelFormat::RG: + textureFormat = TextureFormat::RG32UI; + reinterpretFormat = PixelFormat::RGInteger; + break; + case PixelFormat::RGB: + textureFormat = TextureFormat::RGB32UI; + reinterpretFormat = PixelFormat::RGBInteger; + break; + case PixelFormat::RGBA: + textureFormat = TextureFormat::RGBA32UI; + reinterpretFormat = PixelFormat::RGBAInteger; + break; + default: + CORRADE_ASSERT(false, "DebugTools::textureSubImage(): unsupported pixel format" << image.format(), ); + } + + Texture2D output; + output.setStorage(1, textureFormat, range.max()); + + Framebuffer fb{range}; + fb.attachTexture(Framebuffer::ColorAttachment{0}, output, 0) + .bind(); + + CORRADE_INTERNAL_ASSERT(fb.checkStatus(FramebufferTarget::Draw) == Framebuffer::Status::Complete); + CORRADE_INTERNAL_ASSERT(fb.checkStatus(FramebufferTarget::Read) == Framebuffer::Status::Complete); + + FloatReinterpretShader shader; + shader.setTexture(texture, level); + + Mesh mesh; + mesh.setCount(3) + .draw(shader); + + /* release() needs to be called after querying the size to avoid zeroing it out */ + { + Vector2i imageSize = image.size(); + image.setData(image.storage(), reinterpretFormat, PixelType::UnsignedInt, imageSize, image.release()); + } + + fb.read(range, image); + + /* release() needs to be called after querying the size to avoid zeroing it out */ + { + Vector2i imageSize = image.size(); + image.setData(image.storage(), imageFormat, PixelType::Float, imageSize, image.release()); + } + return; + } + #endif + + Framebuffer fb{range}; + fb.attachTexture(Framebuffer::ColorAttachment{0}, texture, level) + .read(range, image); +} + +Image2D textureSubImage(Texture2D& texture, const Int level, const Range2Di& range, Image2D&& image) { + textureSubImage(texture, level, range, image); + return std::move(image); +} + +#ifndef MAGNUM_TARGET_GLES2 +void textureSubImage(Texture2D& texture, const Int level, const Range2Di& range, BufferImage2D& image, const BufferUsage usage) { + #ifndef MAGNUM_TARGET_GLES + if(Context::current().isExtensionSupported()) { + texture.subImage(level, range, image, usage); + return; + } + #endif + + Framebuffer fb{range}; + fb.attachTexture(Framebuffer::ColorAttachment{0}, texture, level) + .read(range, image, usage); +} + +BufferImage2D textureSubImage(Texture2D& texture, const Int level, const Range2Di& range, BufferImage2D&& image, const BufferUsage usage) { + textureSubImage(texture, level, range, image, usage); + return std::move(image); +} +#endif + +void textureSubImage(CubeMapTexture& texture, const CubeMapCoordinate coordinate, const Int level, const Range2Di& range, Image2D& image) { + Framebuffer fb{range}; + fb.attachCubeMapTexture(Framebuffer::ColorAttachment{0}, texture, coordinate, level) + .read(range, image); +} + +Image2D textureSubImage(CubeMapTexture& texture, const CubeMapCoordinate coordinate, const Int level, const Range2Di& range, Image2D&& image) { + textureSubImage(texture, coordinate, level, range, image); + return std::move(image); +} + +#ifndef MAGNUM_TARGET_GLES2 +void textureSubImage(CubeMapTexture& texture, const CubeMapCoordinate coordinate, const Int level, const Range2Di& range, BufferImage2D& image, const BufferUsage usage) { + Framebuffer fb{range}; + fb.attachCubeMapTexture(Framebuffer::ColorAttachment{0}, texture, coordinate, level) + .read(range, image, usage); +} + +BufferImage2D textureSubImage(CubeMapTexture& texture, const CubeMapCoordinate coordinate, const Int level, const Range2Di& range, BufferImage2D&& image, const BufferUsage usage) { + textureSubImage(texture, coordinate, level, range, image, usage); + return std::move(image); +} +#endif + +}} diff --git a/src/Magnum/DebugTools/TextureImage.frag b/src/Magnum/DebugTools/TextureImage.frag new file mode 100644 index 000000000..e7c5f67f3 --- /dev/null +++ b/src/Magnum/DebugTools/TextureImage.frag @@ -0,0 +1,18 @@ +uniform highp int level; +uniform highp sampler2D textureData; + +#ifndef GL_ES +layout(pixel_center_integer) in highp vec4 gl_FragCoord; +#endif + +out highp uvec4 fragmentOutput; + +void main() { + #ifndef GL_ES + ivec2 pos = ivec2(gl_FragCoord.xy); + #else + ivec2 pos = ivec2(gl_FragCoord.xy - vec2(0.5)); + #endif + + fragmentOutput = floatBitsToUint(texelFetch(textureData, pos, level)); +} diff --git a/src/Magnum/DebugTools/TextureImage.h b/src/Magnum/DebugTools/TextureImage.h new file mode 100644 index 000000000..57c202f91 --- /dev/null +++ b/src/Magnum/DebugTools/TextureImage.h @@ -0,0 +1,139 @@ +#ifndef Magnum_DebugTools_TextureImage_h +#define Magnum_DebugTools_TextureImage_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Function @ref Magnum::DebugTools::textureSubImage() + */ + +#include "Magnum/Magnum.h" +#include "Magnum/DebugTools/visibility.h" + +namespace Magnum { namespace DebugTools { + +/** +@brief Read range of given texture mip level to image + +Emulates @ref Texture2D::subImage() call on platforms that don't support it +(such as OpenGL ES) by creating a framebuffer object and using +@ref Framebuffer::read(). On desktop OpenGL, if @extension{ARB,get_texture_sub_image} +is available, it's just an alias to @ref Texture2D::subImage(). + +Note that only @ref Magnum::PixelFormat "PixelFormat" and @ref PixelType values +that are marked as framebuffer readable are supported. In addition, on OpenGL +ES 3.0, images with @ref PixelType::Float are supported -- they are +reinterpreted as @ref PixelType::UnsignedInt using additional shader and +`floatBitsToUint()` GLSL function and then reinterpreted back to +@ref PixelType::Float when read to client memory. +*/ +MAGNUM_DEBUGTOOLS_EXPORT void textureSubImage(Texture2D& texture, Int level, const Range2Di& range, Image2D& image); + +/** +@brief Read range of given texture mip level to image + +Convenience alternative to the above, example usage: +@code +Image2D image = DebugTools::textureSubImage(texture, 0, rect, {PixelFormat::RGBA, PixelType::UnsignedByte}); +@endcode +*/ +MAGNUM_DEBUGTOOLS_EXPORT Image2D textureSubImage(Texture2D& texture, Int level, const Range2Di& range, Image2D&& image); + +/** +@brief Read range of given cube map texture coordinate mip level to image + +Emulates @ref CubeMapTexture::subImage() call on platforms that don't support +it (such as OpenGL ES) by creating a framebuffer object and using +@ref Framebuffer::read(). + +Note that only @ref Magnum::PixelFormat "PixelFormat" and @ref PixelType values +that are marked as framebuffer readable are supported. +*/ +MAGNUM_DEBUGTOOLS_EXPORT void textureSubImage(CubeMapTexture& texture, CubeMapCoordinate coordinate, Int level, const Range2Di& range, Image2D& image); + +/** +@brief Read range of given cube map texture coordinate mip level to image + +Convenience alternative to the above, example usage: +@code +Image2D image = DebugTools::textureSubImage(texture, CubeMapCoordinate::PositiveX, 0, rect, {PixelFormat::RGBA, PixelType::UnsignedByte}); +@endcode +*/ +MAGNUM_DEBUGTOOLS_EXPORT Image2D textureSubImage(CubeMapTexture& texture, CubeMapCoordinate coordinate, Int level, const Range2Di& range, Image2D&& image); + +#ifndef MAGNUM_TARGET_GLES2 +/** +@brief Read range of given texture mip level to buffer image + +Emulates @ref Texture2D::subImage() call on platforms that don't support it +(such as OpenGL ES) by creating a framebuffer object and using +@ref Framebuffer::read(). On desktop OpenGL, if @extension{ARB,get_texture_sub_image} +is available, it's just an alias to @ref Texture2D::subImage(). + +Note that only @ref Magnum::PixelFormat "PixelFormat" and @ref PixelType values +that are marked as framebuffer readable are supported. +@requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0. +@requires_webgl20 Pixel buffer objects are not available in WebGL 1.0. +*/ +MAGNUM_DEBUGTOOLS_EXPORT void textureSubImage(Texture2D& texture, Int level, const Range2Di& range, BufferImage2D& image, BufferUsage usage); + +/** +@brief Read range of given texture mip level to buffer image + +Convenience alternative to the above, example usage: +@code +BufferImage2D image = DebugTools::textureSubImage(texture, 0, rect, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); +@endcode +*/ +MAGNUM_DEBUGTOOLS_EXPORT BufferImage2D textureSubImage(Texture2D& texture, Int level, const Range2Di& range, BufferImage2D&& image, BufferUsage usage); + +/** +@brief Read range of given cube map texture coordinate mip level to buffer image + +Emulates @ref CubeMapTexture::subImage() call on platforms that don't support +it (such as OpenGL ES) by creating a framebuffer object and using +@ref Framebuffer::read(). + +Note that only @ref Magnum::PixelFormat "PixelFormat" and @ref PixelType values +that are marked as framebuffer readable are supported. +@requires_gles30 Pixel buffer objects are not available in OpenGL ES 2.0. +@requires_webgl20 Pixel buffer objects are not available in WebGL 1.0. +*/ +MAGNUM_DEBUGTOOLS_EXPORT void textureSubImage(CubeMapTexture& texture, CubeMapCoordinate coordinate, Int level, const Range2Di& range, BufferImage2D& image, BufferUsage usage); + +/** +@brief Read range of given cube map texture coordinate mip level to buffer image + +Convenience alternative to the above, example usage: +@code +BufferImage2D image = DebugTools::textureSubImage(texture, CubeMapCoordinate::PositiveX, 0, rect, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); +@endcode +*/ +MAGNUM_DEBUGTOOLS_EXPORT BufferImage2D textureSubImage(CubeMapTexture& texture, CubeMapCoordinate coordinate, Int level, const Range2Di& range, BufferImage2D&& image, BufferUsage usage); +#endif + +}} + +#endif diff --git a/src/Magnum/DebugTools/TextureImage.vert b/src/Magnum/DebugTools/TextureImage.vert new file mode 100644 index 000000000..325b2e733 --- /dev/null +++ b/src/Magnum/DebugTools/TextureImage.vert @@ -0,0 +1,4 @@ +void main() { + gl_Position = vec4((gl_VertexID == 2) ? 3.0 : -1.0, + (gl_VertexID == 1) ? -3.0 : 1.0, 0.0, 1.0); +} diff --git a/src/Magnum/DebugTools/resources.conf b/src/Magnum/DebugTools/resources.conf new file mode 100644 index 000000000..f9d480144 --- /dev/null +++ b/src/Magnum/DebugTools/resources.conf @@ -0,0 +1,7 @@ +group=MagnumDebugTools + +[file] +filename=TextureImage.vert + +[file] +filename=TextureImage.frag diff --git a/src/Magnum/DebugTools/visibility.h b/src/Magnum/DebugTools/visibility.h index 8e3c6db69..b10b6cee5 100644 --- a/src/Magnum/DebugTools/visibility.h +++ b/src/Magnum/DebugTools/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DefaultFramebuffer.cpp b/src/Magnum/DefaultFramebuffer.cpp index 0f4b8949e..c8a148676 100644 --- a/src/Magnum/DefaultFramebuffer.cpp +++ b/src/Magnum/DefaultFramebuffer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -42,7 +42,7 @@ DefaultFramebuffer::DefaultFramebuffer() { } DefaultFramebuffer::Status DefaultFramebuffer::checkStatus(const FramebufferTarget target) { - return Status((this->*Context::current()->state().framebuffer->checkStatusImplementation)(target)); + return Status((this->*Context::current().state().framebuffer->checkStatusImplementation)(target)); } DefaultFramebuffer& DefaultFramebuffer::mapForDraw(std::initializer_list> attachments) { @@ -58,22 +58,22 @@ DefaultFramebuffer& DefaultFramebuffer::mapForDraw(std::initializer_list*Context::current()->state().framebuffer->drawBuffersImplementation)(max+1, _attachments); + (this->*Context::current().state().framebuffer->drawBuffersImplementation)(max+1, _attachments); return *this; } DefaultFramebuffer& DefaultFramebuffer::mapForDraw(const DrawAttachment attachment) { #ifndef MAGNUM_TARGET_GLES - (this->*Context::current()->state().framebuffer->drawBufferImplementation)(GLenum(attachment)); + (this->*Context::current().state().framebuffer->drawBufferImplementation)(GLenum(attachment)); #else - (this->*Context::current()->state().framebuffer->drawBuffersImplementation)(1, reinterpret_cast(&attachment)); + (this->*Context::current().state().framebuffer->drawBuffersImplementation)(1, reinterpret_cast(&attachment)); #endif return *this; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) DefaultFramebuffer& DefaultFramebuffer::mapForRead(const ReadAttachment attachment) { - (this->*Context::current()->state().framebuffer->readBufferImplementation)(GLenum(attachment)); + (this->*Context::current().state().framebuffer->readBufferImplementation)(GLenum(attachment)); return *this; } @@ -83,7 +83,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list*Context::current()->state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); + (this->*Context::current().state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); } #endif @@ -94,7 +94,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list*Context::current()->state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); + (this->*Context::current().state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); } #endif diff --git a/src/Magnum/DefaultFramebuffer.h b/src/Magnum/DefaultFramebuffer.h index 5467145f9..643cbbe5f 100644 --- a/src/Magnum/DefaultFramebuffer.h +++ b/src/Magnum/DefaultFramebuffer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/DimensionTraits.h b/src/Magnum/DimensionTraits.h index 645e70f1c..7795fedd9 100644 --- a/src/Magnum/DimensionTraits.h +++ b/src/Magnum/DimensionTraits.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index 78de2c84b..a9ef8042f 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -33,6 +33,14 @@ namespace Magnum { +/* Standard Android build system thinks that it's okay to define unmangled + unprefixed macros. I think that whoever did that needs to be punished, + becuase I am then not able to use that identifier for extension names. + Use CORRADE_TARGET_ANDROID here instead. */ +#ifdef ANDROID +#undef ANDROID +#endif + /** @brief Compile-time information about OpenGL extensions @@ -50,9 +58,8 @@ but these structs are better suited for compile-time decisions rather than @ref Extension instances. See @ref Context::isExtensionSupported() for example usage. -This namespace is built by default. To use it, you need to add `${MAGNUM_INCLUDE_DIRS}` -to include path and link to `${MAGNUM_LIBRARIES}`. See @ref building and -@ref cmake for more information. +This namespace is built by default. To use it, you need to link to +`Magnum::Magnum` target. See @ref building and @ref cmake for more information. @see @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() @todo Manual indices for extensions, this has gaps */ @@ -225,6 +232,7 @@ namespace GL { _extension(GL,KHR,robustness, GL320, GL450) // #170 _extension(GL,KHR,blend_equation_advanced, GL210, None) // #174 _extension(GL,KHR,blend_equation_advanced_coherent, GL210, None) // #174 + _extension(GL,KHR,no_error, GL210, None) // #175 } namespace NV { _extension(GL,NV,primitive_restart, GL210, GL310) // #285 _extension(GL,NV,depth_buffer_float, GL210, GL300) // #334 @@ -290,6 +298,8 @@ namespace GL { #ifdef MAGNUM_TARGET_GLES2 _extension(GL,ARM,rgba8, GLES200, GLES300) // #82 #endif + _extension(GL,ARM,shader_framebuffer_fetch, GLES200, None) // #165 + _extension(GL,ARM,shader_framebuffer_fetch_depth_stencil, GLES200, None) // #166 } namespace CHROMIUM { #ifdef CORRADE_TARGET_NACL _extension(GL,CHROMIUM,map_sub, GLES200, None) @@ -327,6 +337,7 @@ namespace GL { _extension(GL,EXT,texture_storage, GLES200, GLES300) // #108 _extension(GL,EXT,map_buffer_range, GLES200, GLES300) // #121 #endif + _extension(GL,EXT,shader_framebuffer_fetch, GLES200, None) // #122 _extension(GL,EXT,disjoint_timer_query, GLES200, None) // #150 #ifdef MAGNUM_TARGET_GLES2 _extension(GL,EXT,draw_buffers, GLES200, GLES300) // #151 @@ -364,6 +375,7 @@ namespace GL { _extension(GL,KHR,robustness, GLES200, None) // #170 _extension(GL,KHR,robust_buffer_access_behavior, GLES200, None) // #189 _extension(GL,KHR,context_flush_control, GLES200, None) // #191 + _extension(GL,KHR,no_error, GLES200, None) // #243 } namespace NV { #ifdef MAGNUM_TARGET_GLES2 _extension(GL,NV,draw_buffers, GLES200, GLES300) // #91 diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index f17861a1a..096e47620 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -28,6 +28,7 @@ #include #include "Magnum/Context.h" +#include "Magnum/CubeMapTexture.h" #include "Magnum/DefaultFramebuffer.h" #include "Magnum/Extensions.h" #include "Magnum/Image.h" @@ -73,16 +74,16 @@ const Framebuffer::InvalidationAttachment Framebuffer::InvalidationAttachment::S Int Framebuffer::maxColorAttachments() { #ifdef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif #endif - GLint& value = Context::current()->state().framebuffer->maxColorAttachments; + GLint& value = Context::current().state().framebuffer->maxColorAttachments; if(value == 0) { #ifndef MAGNUM_TARGET_GLES2 @@ -98,7 +99,7 @@ Int Framebuffer::maxColorAttachments() { Framebuffer::Framebuffer(const Range2Di& viewport) { CORRADE_INTERNAL_ASSERT(viewport != Implementation::FramebufferState::DisengagedViewport); _viewport = viewport; - (this->*Context::current()->state().framebuffer->createImplementation)(); + (this->*Context::current().state().framebuffer->createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -118,7 +119,7 @@ Framebuffer::~Framebuffer() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* If bound, remove itself from state */ - Implementation::FramebufferState& state = *Context::current()->state().framebuffer; + Implementation::FramebufferState& state = *Context::current().state().framebuffer; if(state.readBinding == _id) state.readBinding = 0; /* For draw binding reset also viewport */ @@ -138,18 +139,18 @@ Framebuffer::~Framebuffer() { #ifndef MAGNUM_TARGET_WEBGL std::string Framebuffer::label() { createIfNotAlready(); - return Context::current()->state().debug->getLabelImplementation(GL_FRAMEBUFFER, _id); + return Context::current().state().debug->getLabelImplementation(GL_FRAMEBUFFER, _id); } Framebuffer& Framebuffer::setLabelInternal(const Containers::ArrayView label) { createIfNotAlready(); - Context::current()->state().debug->labelImplementation(GL_FRAMEBUFFER, _id, label); + Context::current().state().debug->labelImplementation(GL_FRAMEBUFFER, _id, label); return *this; } #endif Framebuffer::Status Framebuffer::checkStatus(const FramebufferTarget target) { - return Status((this->*Context::current()->state().framebuffer->checkStatusImplementation)(target)); + return Status((this->*Context::current().state().framebuffer->checkStatusImplementation)(target)); } Framebuffer& Framebuffer::mapForDraw(std::initializer_list> attachments) { @@ -165,22 +166,22 @@ Framebuffer& Framebuffer::mapForDraw(std::initializer_list*Context::current()->state().framebuffer->drawBuffersImplementation)(max+1, _attachments); + (this->*Context::current().state().framebuffer->drawBuffersImplementation)(max+1, _attachments); return *this; } Framebuffer& Framebuffer::mapForDraw(const DrawAttachment attachment) { #ifndef MAGNUM_TARGET_GLES - (this->*Context::current()->state().framebuffer->drawBufferImplementation)(GLenum(attachment)); + (this->*Context::current().state().framebuffer->drawBufferImplementation)(GLenum(attachment)); #else - (this->*Context::current()->state().framebuffer->drawBuffersImplementation)(1, reinterpret_cast(&attachment)); + (this->*Context::current().state().framebuffer->drawBuffersImplementation)(1, reinterpret_cast(&attachment)); #endif return *this; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Framebuffer& Framebuffer::mapForRead(const ColorAttachment attachment) { - (this->*Context::current()->state().framebuffer->readBufferImplementation)(GLenum(attachment)); + (this->*Context::current().state().framebuffer->readBufferImplementation)(GLenum(attachment)); return *this; } @@ -190,7 +191,7 @@ void Framebuffer::invalidate(std::initializer_list attac for(std::size_t i = 0; i != attachments.size(); ++i) _attachments[i] = GLenum(*(attachments.begin()+i)); - (this->*Context::current()->state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); + (this->*Context::current().state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); } #ifndef MAGNUM_TARGET_GLES2 @@ -200,116 +201,116 @@ void Framebuffer::invalidate(std::initializer_list attac for(std::size_t i = 0; i != attachments.size(); ++i) _attachments[i] = GLenum(*(attachments.begin()+i)); - (this->*Context::current()->state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); + (this->*Context::current().state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); } #endif #endif Framebuffer& Framebuffer::attachRenderbuffer(const BufferAttachment attachment, Renderbuffer& renderbuffer) { - (this->*Context::current()->state().framebuffer->renderbufferImplementation)(attachment, renderbuffer.id()); + (this->*Context::current().state().framebuffer->renderbufferImplementation)(attachment, renderbuffer.id()); return *this; } #ifndef MAGNUM_TARGET_GLES Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture1D& texture, const Int level) { - (this->*Context::current()->state().framebuffer->texture1DImplementation)(attachment, texture.id(), level); + (this->*Context::current().state().framebuffer->texture1DImplementation)(attachment, texture.id(), level); return *this; } #endif Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture2D& texture, const Int level) { - (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_2D, texture.id(), level); + (this->*Context::current().state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_2D, texture.id(), level); return *this; } #ifndef MAGNUM_TARGET_GLES Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, RectangleTexture& texture) { - (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_RECTANGLE, texture.id(), 0); + (this->*Context::current().state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_RECTANGLE, texture.id(), 0); return *this; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, MultisampleTexture2D& texture) { - (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_2D_MULTISAMPLE, texture.id(), 0); + (this->*Context::current().state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_2D_MULTISAMPLE, texture.id(), 0); return *this; } #endif -Framebuffer& Framebuffer::attachCubeMapTexture(const BufferAttachment attachment, CubeMapTexture& texture, CubeMapTexture::Coordinate coordinate, const Int level) { - (this->*Context::current()->state().framebuffer->textureCubeMapImplementation)(attachment, GLenum(coordinate), texture.id(), level); +Framebuffer& Framebuffer::attachCubeMapTexture(const BufferAttachment attachment, CubeMapTexture& texture, CubeMapCoordinate coordinate, const Int level) { + (this->*Context::current().state().framebuffer->textureCubeMapImplementation)(attachment, GLenum(coordinate), texture.id(), level); return *this; } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture3D& texture, Int level, Int layer) { - (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); + (this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); return *this; } #endif #ifndef MAGNUM_TARGET_GLES Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture1DArray& texture, Int level, Int layer) { - (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); + (this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); return *this; } #endif #ifndef MAGNUM_TARGET_GLES2 Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, Texture2DArray& texture, Int level, Int layer) { - (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); + (this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); return *this; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, CubeMapTextureArray& texture, Int level, Int layer) { - (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); + (this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); return *this; } Framebuffer& Framebuffer::attachTextureLayer(const BufferAttachment attachment, MultisampleTexture2DArray& texture, Int layer) { - (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), 0, layer); + (this->*Context::current().state().framebuffer->textureLayerImplementation)(attachment, texture.id(), 0, layer); return *this; } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture3D& texture, const Int level) { - (this->*Context::current()->state().framebuffer->textureImplementation)(attachment, texture.id(), level); + (this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); return *this; } #ifndef MAGNUM_TARGET_GLES Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture1DArray& texture, const Int level) { - (this->*Context::current()->state().framebuffer->textureImplementation)(attachment, texture.id(), level); + (this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); return *this; } #endif Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, Texture2DArray& texture, const Int level) { - (this->*Context::current()->state().framebuffer->textureImplementation)(attachment, texture.id(), level); + (this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); return *this; } Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, CubeMapTexture& texture, const Int level) { - (this->*Context::current()->state().framebuffer->textureImplementation)(attachment, texture.id(), level); + (this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); return *this; } Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, CubeMapTextureArray& texture, const Int level) { - (this->*Context::current()->state().framebuffer->textureImplementation)(attachment, texture.id(), level); + (this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), level); return *this; } Framebuffer& Framebuffer::attachLayeredTexture(const BufferAttachment attachment, MultisampleTexture2DArray& texture) { - (this->*Context::current()->state().framebuffer->textureImplementation)(attachment, texture.id(), 0); + (this->*Context::current().state().framebuffer->textureImplementation)(attachment, texture.id(), 0); return *this; } #endif Framebuffer& Framebuffer::detach(const BufferAttachment attachment) { - (this->*Context::current()->state().framebuffer->renderbufferImplementation)(attachment, 0); + (this->*Context::current().state().framebuffer->renderbufferImplementation)(attachment, 0); return *this; } diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index 71917a63b..196fa63d3 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -29,8 +29,10 @@ * @brief Class @ref Magnum::Framebuffer */ +#include + #include "Magnum/AbstractFramebuffer.h" -#include "Magnum/CubeMapTexture.h" +#include "Magnum/Tags.h" #ifdef _X11_XLIB_H_ /* Xlib.h, I hate you sincerely */ #undef Status @@ -658,7 +660,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access}, * eventually @fn_gl{BindFramebuffer} and @fn_gl2{FramebufferTexture2D,FramebufferTexture} */ - Framebuffer& attachCubeMapTexture(BufferAttachment attachment, CubeMapTexture& texture, CubeMapTexture::Coordinate coordinate, Int level); + Framebuffer& attachCubeMapTexture(BufferAttachment attachment, CubeMapTexture& texture, CubeMapCoordinate coordinate, Int level); #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) /** diff --git a/src/Magnum/Image.cpp b/src/Magnum/Image.cpp index 2b94fff65..98c9cadf3 100644 --- a/src/Magnum/Image.cpp +++ b/src/Magnum/Image.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index 55655962b..f5af9a50b 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/ImageFormat.h b/src/Magnum/ImageFormat.h new file mode 100644 index 000000000..9a5a9d4b9 --- /dev/null +++ b/src/Magnum/ImageFormat.h @@ -0,0 +1,315 @@ +#ifndef Magnum_ImageFormat_h +#define Magnum_ImageFormat_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +/** @file + * @brief Enum @ref Magnum::ImageAccess, @ref Magnum::ImageFormat + */ +#endif + +#include + +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +namespace Magnum { + +/** +@brief Image access + +@see @ref Texture::bindImage() "*Texture::bindImage()", + @ref Texture::bindImageLayered() "*Texture::bindImageLayered()" +@requires_gl42 Extension @extension{ARB,shader_image_load_store} +@requires_gles31 Shader image load/store is not available in OpenGL ES 3.0 and + older. +@requires_gles Shader image load/store is not available in WebGL. +*/ +enum class ImageAccess: GLenum { + ReadOnly = GL_READ_ONLY, + WriteOnly = GL_WRITE_ONLY, + ReadWrite = GL_READ_WRITE +}; + +/** +@brief Image format + +@see @ref Texture::bindImage() "*Texture::bindImage()", + @ref Texture::bindImageLayered() "*Texture::bindImageLayered()" +@requires_gl42 Extension @extension{ARB,shader_image_load_store} +@requires_gles31 Shader image load/store is not available in OpenGL ES 3.0 and + older. +@requires_gles Shader image load/store is not available in WebGL. +*/ +enum class ImageFormat: GLenum { + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, normalized unsigned byte. + * @requires_gl Only four-component byte image formats are available in + * OpenGL ES. + */ + R8 = GL_R8, + + /** + * Red and green component, each normalized unsigned byte. + * @requires_gl Only four-component byte image formats are available in + * OpenGL ES. + */ + RG8 = GL_RG8, + #endif + + /** RGBA, each component normalized unsigned byte. */ + RGBA8 = GL_RGBA8, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, normalized signed byte. + * @requires_gl Only four-component byte image formats are available in + * OpenGL ES. + */ + R8Snorm = GL_R8_SNORM, + + /** + * Red and green component, each normalized signed byte. + * @requires_gl Only four-component byte image formats are available in + * OpenGL ES. + */ + RG8Snorm = GL_RG8_SNORM, + #endif + + /** RGBA, each component normalized unsigned byte. */ + RGBA8Snorm = GL_RGBA8_SNORM, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, normalized unsigned short. + * @requires_gl Only byte-size normalized image formats are available in + * OpenGL ES. + */ + R16 = GL_R16, + + /** + * Red and green component, each normalized unsigned short. + * @requires_gl Only byte-size normalized image formats are available in + * OpenGL ES. + */ + RG16 = GL_RG16, + + /** + * RGBA, each component normalized unsigned short. + * @requires_gl Only byte-size normalized image formats are available in + * OpenGL ES. + */ + RGBA16 = GL_RGBA16, + + /** + * Red component, normalized signed short. + * @requires_gl Only byte-size normalized image formats are available in + * OpenGL ES. + */ + R16Snorm = GL_R16_SNORM, + + /** + * Red and green component, each normalized signed short. + * @requires_gl Only byte-size normalized image formats are available in + * OpenGL ES. + */ + RG16Snorm = GL_RG16_SNORM, + + /** + * RGBA, each component normalized unsigned short. + * @requires_gl Only byte-size normalized image formats are available in + * OpenGL ES. + */ + RGBA16Snorm = GL_RGBA16_SNORM, + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, non-normalized unsigned byte. + * @requires_gl Only four-component byte image formats are available in + * OpenGL ES. + */ + R8UI = GL_R8UI, + + /** + * Red and green component, each non-normalized unsigned byte. + * @requires_gl Only four-component byte image formats are available in + * OpenGL ES. + */ + RG8UI = GL_RG8UI, + #endif + + /** RGBA, each component non-normalized unsigned byte. */ + RGBA8UI = GL_RGBA8UI, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, non-normalized signed byte. + * @requires_gl Only four-component byte image formats are available in + * OpenGL ES. + */ + R8I = GL_R8I, + + /** + * Red and green component, each non-normalized signed byte. + * @requires_gl Only four-component byte image formats are available in + * OpenGL ES. + */ + RG8I = GL_RG8I, + #endif + + /** RGBA, each component non-normalized signed byte. */ + RGBA8I = GL_RGBA8I, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, non-normalized unsigned short. + * @requires_gl Only four-component short image formats are available in + * OpenGL ES. + */ + R16UI = GL_R16UI, + + /** + * Red and green component, each non-normalized unsigned short. + * @requires_gl Only four-component short image formats are available in + * OpenGL ES. + */ + RG16UI = GL_RG16UI, + #endif + + /** RGBA, each component non-normalized unsigned short. */ + RGBA16UI = GL_RGBA16UI, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, non-normalized signed short. + * @requires_gl Only four-component short image formats are available in + * OpenGL ES. + */ + R16I = GL_R16I, + + /** + * Red and green component, each non-normalized signed short. + * @requires_gl Only four-component short image formats are available in + * OpenGL ES. + */ + RG16I = GL_RG16I, + #endif + + /** RGBA, each component non-normalized signed short. */ + RGBA16I = GL_RGBA16I, + + /** Red component, non-normalized unsigned int. */ + R32UI = GL_R32UI, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red and green component, each non-normalized unsigned int. + * @requires_gl Only one- or four-component int image formats are available + * in OpenGL ES. + */ + RG32UI = GL_RG32UI, + #endif + + /** RGBA, each component non-normalized unsigned int. */ + RGBA32UI = GL_RGBA32UI, + + /** Red component, non-normalized signed int. */ + R32I = GL_R32I, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red and green component, each non-normalized signed int. + * @requires_gl Only one- or four-component int image formats are available + * in OpenGL ES. + */ + RG32I = GL_RG32I, + #endif + + /** RGBA, each component non-normalized signed int. */ + RGBA32I = GL_RGBA32I, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red component, half float. + * @requires_gl Only four-component half float image formats are available + * in OpenGL ES. + */ + R16F = GL_R16F, + + /** + * Red and green component, each half float. + * @requires_gl Only four-component half float image formats are available + * in OpenGL ES. + */ + RG16F = GL_RG16F, + #endif + + /** RGBA, each component half float. */ + RGBA16F = GL_RGBA16F, + + /** Red component, float. */ + R32F = GL_R32F, + + #ifndef MAGNUM_TARGET_GLES + /** + * Red and green component, each float. + * @requires_gl Only one- or four-component float image formats are + * available in OpenGL ES. + */ + RG32F = GL_RG32F, + #endif + + /** RGBA, each component float. */ + RGBA32F = GL_RGBA32F, + + #ifndef MAGNUM_TARGET_GLES + /** + * RGB, float, red and green component 11bit, blue 10bit. + * @requires_gl Packed image formats are not available in OpenGL ES. + */ + R11FG11FB10F = GL_R11F_G11F_B10F, + + /** + * RGBA, normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gl Packed image formats are not available in OpenGL ES. + */ + RGB10A2 = GL_RGB10_A2, + + /** + * RGBA, non-normalized unsigned, each RGB component 10bit, alpha 2bit. + * @requires_gl33 Extension @extension{ARB,texture_rgb10_a2ui} + * @requires_gl Packed image formats are not available in OpenGL ES. + */ + RGB10A2UI = GL_RGB10_A2UI, + #endif +}; + +} +#else +#error this header is not available in OpenGL ES 2.0 and WebGL build +#endif + +#endif diff --git a/src/Magnum/ImageReference.h b/src/Magnum/ImageReference.h index f3436652d..f4eec3f1a 100644 --- a/src/Magnum/ImageReference.h +++ b/src/Magnum/ImageReference.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/ImageView.h b/src/Magnum/ImageView.h index 6290e6a44..cdc5067f4 100644 --- a/src/Magnum/ImageView.h +++ b/src/Magnum/ImageView.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -108,11 +108,7 @@ template class ImageView { /** @overload * Similar to the above, but uses default @ref PixelStorage parameters. */ - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor& size) noexcept: ImageView{{}, format, type, size} {} + constexpr explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor& size) noexcept: ImageView{{}, format, type, size} {} /** @brief Storage of pixel data */ PixelStorage storage() const { return _storage; } @@ -241,11 +237,7 @@ template class CompressedImageView { * Similar the above, but uses default @ref CompressedPixelStorage * parameters (or the hardcoded ones in OpenGL ES and WebGL). */ - #if !defined(CORRADE_MSVC2015_COMPATIBILITY) || defined(MAGNUM_TARGET_GLES) - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit CompressedImageView(CompressedPixelFormat format, const VectorTypeFor& size, Containers::ArrayView data) noexcept; + constexpr explicit CompressedImageView(CompressedPixelFormat format, const VectorTypeFor& size, Containers::ArrayView data) noexcept; #ifndef MAGNUM_TARGET_GLES /** @@ -364,12 +356,7 @@ template constexpr CompressedImageView::Comp _format{format}, _size{size} {} #ifndef MAGNUM_TARGET_GLES -template -#ifndef CORRADE_MSVC2015_COMPATIBILITY -/* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ -constexpr -#endif -CompressedImageView::CompressedImageView(const CompressedPixelFormat format, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: CompressedImageView{{}, format, size, data} {} +template constexpr CompressedImageView::CompressedImageView(const CompressedPixelFormat format, const VectorTypeFor& size, const Containers::ArrayView data) noexcept: CompressedImageView{{}, format, size, data} {} template constexpr CompressedImageView::CompressedImageView(const CompressedPixelFormat format, const VectorTypeFor& size) noexcept: CompressedImageView{{}, format, size} {} #endif diff --git a/src/Magnum/Implementation/BufferState.cpp b/src/Magnum/Implementation/BufferState.cpp index 670481cb0..a4181ab19 100644 --- a/src/Magnum/Implementation/BufferState.cpp +++ b/src/Magnum/Implementation/BufferState.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/BufferState.h b/src/Magnum/Implementation/BufferState.h index 78501d8a6..36047a733 100644 --- a/src/Magnum/Implementation/BufferState.h +++ b/src/Magnum/Implementation/BufferState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/DebugState.cpp b/src/Magnum/Implementation/DebugState.cpp index 772316e93..04fe5615c 100644 --- a/src/Magnum/Implementation/DebugState.cpp +++ b/src/Magnum/Implementation/DebugState.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/DebugState.h b/src/Magnum/Implementation/DebugState.h index 599332190..229473a92 100644 --- a/src/Magnum/Implementation/DebugState.h +++ b/src/Magnum/Implementation/DebugState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/FramebufferState.cpp b/src/Magnum/Implementation/FramebufferState.cpp index 3a03b177c..9ba1004f5 100644 --- a/src/Magnum/Implementation/FramebufferState.cpp +++ b/src/Magnum/Implementation/FramebufferState.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -33,11 +33,7 @@ namespace Magnum { namespace Implementation { -#ifndef CORRADE_MSVC2015_COMPATIBILITY constexpr const Range2Di FramebufferState::DisengagedViewport; -#else -const Range2Di FramebufferState::DisengagedViewport{{}, {-1, -1}}; -#endif FramebufferState::FramebufferState(Context& context, std::vector& extensions): readBinding{0}, drawBinding{0}, renderbufferBinding{0}, maxDrawBuffers{0}, maxColorAttachments{0}, maxRenderbufferSize{0}, #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/Magnum/Implementation/FramebufferState.h b/src/Magnum/Implementation/FramebufferState.h index 93df48c1f..278f87d6b 100644 --- a/src/Magnum/Implementation/FramebufferState.h +++ b/src/Magnum/Implementation/FramebufferState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -40,12 +40,7 @@ namespace Magnum { namespace Implementation { struct FramebufferState { - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* MSVC complains that in-class initialization is not yet implemented */ constexpr static const Range2Di DisengagedViewport{{}, {-1, -1}}; - #else - static const Range2Di DisengagedViewport; - #endif explicit FramebufferState(Context& context, std::vector& extensions); diff --git a/src/Magnum/Implementation/MeshState.cpp b/src/Magnum/Implementation/MeshState.cpp index cbb48ea6c..61e2b9ae2 100644 --- a/src/Magnum/Implementation/MeshState.cpp +++ b/src/Magnum/Implementation/MeshState.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/MeshState.h b/src/Magnum/Implementation/MeshState.h index bfae9ef02..1abb2d971 100644 --- a/src/Magnum/Implementation/MeshState.h +++ b/src/Magnum/Implementation/MeshState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/QueryState.cpp b/src/Magnum/Implementation/QueryState.cpp index 01a0932f1..2e1ca4c14 100644 --- a/src/Magnum/Implementation/QueryState.cpp +++ b/src/Magnum/Implementation/QueryState.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/QueryState.h b/src/Magnum/Implementation/QueryState.h index 377cc697b..0377e07ad 100644 --- a/src/Magnum/Implementation/QueryState.h +++ b/src/Magnum/Implementation/QueryState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/RendererState.cpp b/src/Magnum/Implementation/RendererState.cpp index d878f7fe7..022bd1614 100644 --- a/src/Magnum/Implementation/RendererState.cpp +++ b/src/Magnum/Implementation/RendererState.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/RendererState.h b/src/Magnum/Implementation/RendererState.h index 8abb59351..3b3eb1ad4 100644 --- a/src/Magnum/Implementation/RendererState.h +++ b/src/Magnum/Implementation/RendererState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/ShaderProgramState.cpp b/src/Magnum/Implementation/ShaderProgramState.cpp index 1508b40cd..2d16fa201 100644 --- a/src/Magnum/Implementation/ShaderProgramState.cpp +++ b/src/Magnum/Implementation/ShaderProgramState.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/ShaderProgramState.h b/src/Magnum/Implementation/ShaderProgramState.h index 9c0ceba56..689875174 100644 --- a/src/Magnum/Implementation/ShaderProgramState.h +++ b/src/Magnum/Implementation/ShaderProgramState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -30,6 +30,7 @@ #include "Magnum/Magnum.h" #include "Magnum/OpenGL.h" +#include "Magnum/Math/Vector3.h" #ifdef _MSC_VER /* Otherwise the member function pointers will have different size based on @@ -101,6 +102,8 @@ struct ShaderProgramState { maxImageUnits, maxCombinedShaderOutputResources, maxUniformLocations; + Vector3i maxComputeWorkGroupCount, + maxComputeWorkGroupSize; #endif GLint minTexelOffset, maxTexelOffset, diff --git a/src/Magnum/Implementation/ShaderState.h b/src/Magnum/Implementation/ShaderState.h index 725f7e239..37e3f978a 100644 --- a/src/Magnum/Implementation/ShaderState.h +++ b/src/Magnum/Implementation/ShaderState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/State.cpp b/src/Magnum/Implementation/State.cpp index 5779529f1..3b14cbd06 100644 --- a/src/Magnum/Implementation/State.cpp +++ b/src/Magnum/Implementation/State.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/State.h b/src/Magnum/Implementation/State.h index 76a786478..1975ba37c 100644 --- a/src/Magnum/Implementation/State.h +++ b/src/Magnum/Implementation/State.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/TextureState.cpp b/src/Magnum/Implementation/TextureState.cpp index 31f5f582f..2afc9e037 100644 --- a/src/Magnum/Implementation/TextureState.cpp +++ b/src/Magnum/Implementation/TextureState.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -28,6 +28,7 @@ #include #include "Magnum/AbstractTexture.h" +#include "Magnum/CubeMapTexture.h" #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #include "Magnum/BufferTexture.h" #endif @@ -135,6 +136,7 @@ TextureState::TextureState(Context& context, std::vector& extension setBufferImplementation = &BufferTexture::setBufferImplementationDSA; setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDSA; + getCubeLevelParameterivImplementation = &CubeMapTexture::getLevelParameterImplementationDSA; cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDSA; cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDSA; @@ -159,6 +161,7 @@ TextureState::TextureState(Context& context, std::vector& extension setBufferImplementation = &BufferTexture::setBufferImplementationDSAEXT; setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDSAEXT; + getCubeLevelParameterivImplementation = &CubeMapTexture::getLevelParameterImplementationDSAEXT; cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDSAEXT; cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDSAEXT; @@ -195,6 +198,9 @@ TextureState::TextureState(Context& context, std::vector& extension setBufferRangeImplementation = &BufferTexture::setBufferRangeImplementationDefault; #endif + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + getCubeLevelParameterivImplementation = &CubeMapTexture::getLevelParameterImplementationDefault; + #endif cubeSubImageImplementation = &CubeMapTexture::subImageImplementationDefault; cubeCompressedSubImageImplementation = &CubeMapTexture::compressedSubImageImplementationDefault; } @@ -214,6 +220,23 @@ TextureState::TextureState(Context& context, std::vector& extension } #ifndef MAGNUM_TARGET_GLES + /* Compressed cubemap image size query implementation (extensions added + above) */ + if((context.detectedDriver() & Context::DetectedDriver::NVidia) && + !context.isDriverWorkaroundDisabled("nv-cubemap-inconsistent-compressed-image-size")) { + if(context.isExtensionSupported()) + getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDSANonImmutableWorkaround; + else if(context.isExtensionSupported()) + getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDSAEXTImmutableWorkaround; + else getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDefaultImmutableWorkaround; + } else { + if(context.isExtensionSupported()) + getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDSA; + else if(context.isExtensionSupported()) + getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDSAEXT; + else getCubeLevelCompressedImageSizeImplementation = &CubeMapTexture::getLevelCompressedImageSizeImplementationDefault; + } + /* Image retrieval implementation */ if(context.isExtensionSupported()) { /* Extension name added above */ @@ -255,6 +278,15 @@ TextureState::TextureState(Context& context, std::vector& extension getCubeImageImplementation = &CubeMapTexture::getImageImplementationDefault; getCompressedCubeImageImplementation = &CubeMapTexture::getCompressedImageImplementationDefault; } + + /* Full compressed cubemap image query implementation (extensions added + above) */ + if((context.detectedDriver() & Context::DetectedDriver::NVidia) && + context.isExtensionSupported() && + !context.isDriverWorkaroundDisabled("nv-cubemap-broken-full-compressed-image-query")) + getFullCompressedCubeImageImplementation = &CubeMapTexture::getCompressedImageImplementationDSASingleSliceWorkaround; + else + getFullCompressedCubeImageImplementation = &CubeMapTexture::getCompressedImageImplementationDSA; #endif /* Texture storage implementation for desktop and ES */ @@ -343,16 +375,42 @@ TextureState::TextureState(Context& context, std::vector& extension setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationExt; } else setMaxAnisotropyImplementation = &AbstractTexture::setMaxAnisotropyImplementationNoOp; - /* Resize bindings array to hold all possible texture units */ + #ifndef MAGNUM_TARGET_GLES + /* NVidia workaround for compressed block data size implementation */ + if((context.detectedDriver() & Context::DetectedDriver::NVidia) && + !context.isDriverWorkaroundDisabled("nv-compressed-block-size-in-bits")) + compressedBlockDataSizeImplementation = &AbstractTexture::compressedBlockDataSizeImplementationBitsWorkaround; + else + compressedBlockDataSizeImplementation = &AbstractTexture::compressedBlockDataSizeImplementationDefault; + #endif + + /* Allocate texture bindings array to hold all possible texture units */ glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); CORRADE_INTERNAL_ASSERT(maxTextureUnits > 0); - bindings.resize(maxTextureUnits); + bindings = Containers::Array>{Containers::ValueInit, std::size_t(maxTextureUnits)}; + + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /* Allocate image bindings array to hold all possible image units */ + #ifndef MAGNUM_TARGET_GLES + if(context.isExtensionSupported()) + #else + if(context.isVersionSupported(Version::GLES310)) + #endif + { + GLint maxImageUnits; + glGetIntegerv(GL_MAX_IMAGE_UNITS, &maxImageUnits); + imageBindings = Containers::Array>{Containers::ValueInit, std::size_t(maxImageUnits)}; + } + #endif } TextureState::~TextureState() = default; void TextureState::reset() { std::fill_n(bindings.begin(), bindings.size(), std::pair{{}, State::DisengagedBinding}); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + std::fill_n(imageBindings.begin(), imageBindings.size(), std::tuple{State::DisengagedBinding, 0, false, 0, 0}); + #endif } }} diff --git a/src/Magnum/Implementation/TextureState.h b/src/Magnum/Implementation/TextureState.h index 43035a9e2..c68f5ee45 100644 --- a/src/Magnum/Implementation/TextureState.h +++ b/src/Magnum/Implementation/TextureState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -27,14 +27,17 @@ #include #include +#include -#include "Magnum/CubeMapTexture.h" +#include "Magnum/Magnum.h" +#include "Magnum/OpenGL.h" #if defined(_MSC_VER) && !defined(MAGNUM_TARGET_GLES2) /* Otherwise the member function pointers will have different size based on whether the header was included or not. CAUSES SERIOUS MEMORY CORRUPTION AND IS NOT CAUGHT BY ANY WARNING WHATSOEVER! AARGH! */ #include "Magnum/BufferTexture.h" +#include "Magnum/CubeMapTexture.h" #endif namespace Magnum { namespace Implementation { @@ -45,6 +48,7 @@ struct TextureState { void reset(); + Int(*compressedBlockDataSizeImplementation)(GLenum, TextureFormat); void(*unbindImplementation)(GLint); void(*bindMultiImplementation)(GLint, Containers::ArrayView); void(AbstractTexture::*createImplementation)(); @@ -61,7 +65,7 @@ struct TextureState { #endif void(AbstractTexture::*setMaxAnisotropyImplementation)(GLfloat); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - void(AbstractTexture::*getLevelParameterivImplementation)(GLenum, GLint, GLenum, GLint*); + void(AbstractTexture::*getLevelParameterivImplementation)(GLint, GLenum, GLint*); #endif void(AbstractTexture::*mipmapImplementation)(); #ifndef MAGNUM_TARGET_GLES @@ -97,12 +101,17 @@ struct TextureState { void(BufferTexture::*setBufferRangeImplementation)(BufferTextureFormat, Buffer&, GLintptr, GLsizeiptr); #endif + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + void(CubeMapTexture::*getCubeLevelParameterivImplementation)(GLint, GLenum, GLint*); + #endif #ifndef MAGNUM_TARGET_GLES - void(CubeMapTexture::*getCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*); - void(CubeMapTexture::*getCompressedCubeImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, std::size_t, GLvoid*); + GLint(CubeMapTexture::*getCubeLevelCompressedImageSizeImplementation)(GLint); + void(CubeMapTexture::*getCubeImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, PixelFormat, PixelType, std::size_t, GLvoid*); + void(CubeMapTexture::*getFullCompressedCubeImageImplementation)(GLint, const Vector2i&, std::size_t, std::size_t, GLvoid*); + void(CubeMapTexture::*getCompressedCubeImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, std::size_t, GLvoid*); #endif - void(CubeMapTexture::*cubeSubImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*); - void(CubeMapTexture::*cubeCompressedSubImageImplementation)(CubeMapTexture::Coordinate, GLint, const Vector2i&, const Vector2i&, CompressedPixelFormat, const GLvoid*, GLsizei); + void(CubeMapTexture::*cubeSubImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, const Vector2i&, PixelFormat, PixelType, const GLvoid*); + void(CubeMapTexture::*cubeCompressedSubImageImplementation)(CubeMapCoordinate, GLint, const Vector2i&, const Vector2i&, CompressedPixelFormat, const GLvoid*, GLsizei); GLint maxSize, #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) @@ -133,7 +142,11 @@ struct TextureState { GLint bufferOffsetAlignment; #endif - std::vector> bindings; + Containers::Array> bindings; + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /* Texture object ID, level, layered, layer, access */ + Containers::Array> imageBindings; + #endif }; }} diff --git a/src/Magnum/Implementation/TransformFeedbackState.h b/src/Magnum/Implementation/TransformFeedbackState.h index 225dcdf0f..93047d51a 100644 --- a/src/Magnum/Implementation/TransformFeedbackState.h +++ b/src/Magnum/Implementation/TransformFeedbackState.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Implementation/driverSpecific.cpp b/src/Magnum/Implementation/driverSpecific.cpp index 3eadcbdf7..e6840aeda 100644 --- a/src/Magnum/Implementation/driverSpecific.cpp +++ b/src/Magnum/Implementation/driverSpecific.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -51,6 +51,20 @@ namespace { 1.30 on NVidia and 1.40 on Mac OS X. Everything is fine when using newer GLSL version. */ "no-layout-qualifiers-on-old-glsl", + + /* NVidia drivers (358.16) report compressed block size from internal + format query in bits instead of bytes */ + "nv-compressed-block-size-in-bits", + + /* NVidia drivers (358.16) report different compressed image size for + cubemaps based on whether the texture is immutable or not and not + based on whether I'm querying all faces (ARB_DSA) or a single face + (non-DSA, EXT_DSA) */ + "nv-cubemap-inconsistent-compressed-image-size", + + /* NVidia drivers (358.16) return only the first slice of compressed + cube map image when querying all six slice using ARB_DSA API */ + "nv-cubemap-broken-full-compressed-image-query", #endif #ifdef CORRADE_TARGET_NACL @@ -69,7 +83,7 @@ bool isShaderCompilationLogEmpty(const std::string&); bool isShaderCompilationLogEmpty(const std::string& result) { #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES) /* Intel Windows drivers are too chatty */ - if((Context::current()->detectedDriver() & Context::DetectedDriver::IntelWindows) && result == "No errors.\n") + if((Context::current().detectedDriver() & Context::DetectedDriver::IntelWindows) && result == "No errors.\n") return true; #else static_cast(result); @@ -83,7 +97,7 @@ bool isProgramLinkLogEmpty(const std::string&); bool isProgramLinkLogEmpty(const std::string& result) { #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES) /* Intel Windows drivers are too chatty */ - if((Context::current()->detectedDriver() & Context::DetectedDriver::IntelWindows) && result == "No errors.\n") + if((Context::current().detectedDriver() & Context::DetectedDriver::IntelWindows) && result == "No errors.\n") return true; #else static_cast(result); @@ -101,6 +115,8 @@ auto Context::detectedDriver() -> DetectedDrivers { const std::string vendor = vendorString(); + /* Apple has its own drivers */ + #ifndef CORRADE_TARGET_APPLE #ifndef MAGNUM_TARGET_GLES /* AMD binary desktop drivers */ if(vendor.find("ATI Technologies Inc.") != std::string::npos) @@ -113,6 +129,12 @@ auto Context::detectedDriver() -> DetectedDrivers { #endif #endif + #ifndef MAGNUM_TARGET_WEBGL + if(vendor.find("NVIDIA Corporation") != std::string::npos) + return *_detectedDrivers |= DetectedDriver::NVidia; + #endif + #endif + /** @todo there is also D3D9/D3D11 distinction on webglreport.com, is it useful? */ #ifdef MAGNUM_TARGET_GLES /* OpenGL ES implementation using ANGLE. Taken from these sources: @@ -132,7 +154,10 @@ auto Context::detectedDriver() -> DetectedDrivers { void Context::disableDriverWorkaround(const std::string& workaround) { /* Ignore unknown workarounds */ - if(std::find(KnownWorkarounds.begin(), KnownWorkarounds.end(), workaround) == KnownWorkarounds.end()) return; + if(std::find(KnownWorkarounds.begin(), KnownWorkarounds.end(), workaround) == KnownWorkarounds.end()) { + Warning() << "Unknown workaround" << workaround; + return; + } _driverWorkarounds.emplace_back(workaround, true); } diff --git a/src/Magnum/Implementation/maxTextureSize.cpp b/src/Magnum/Implementation/maxTextureSize.cpp index ed4cc2e5f..72ef0b763 100644 --- a/src/Magnum/Implementation/maxTextureSize.cpp +++ b/src/Magnum/Implementation/maxTextureSize.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -33,7 +33,7 @@ namespace Magnum { namespace Implementation { GLint maxTextureSideSize() { - GLint& value = Context::current()->state().texture->maxSize; + GLint& value = Context::current().state().texture->maxSize; if(value == 0) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); @@ -43,7 +43,7 @@ GLint maxTextureSideSize() { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) GLint max3DTextureDepth() { - GLint& value = Context::current()->state().texture->max3DSize; + GLint& value = Context::current().state().texture->max3DSize; if(value == 0) #ifndef MAGNUM_TARGET_GLES2 @@ -58,7 +58,7 @@ GLint max3DTextureDepth() { #ifndef MAGNUM_TARGET_GLES2 GLint maxTextureArrayLayers() { - GLint& value = Context::current()->state().texture->maxArrayLayers; + GLint& value = Context::current().state().texture->maxArrayLayers; if(value == 0) glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &value); @@ -68,7 +68,7 @@ GLint maxTextureArrayLayers() { #endif GLint maxCubeMapTextureSideSize() { - GLint& value = Context::current()->state().texture->maxCubeMapSize; + GLint& value = Context::current().state().texture->maxCubeMapSize; if(value == 0) glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &value); diff --git a/src/Magnum/Implementation/maxTextureSize.h b/src/Magnum/Implementation/maxTextureSize.h index 377dfe559..2e1409c24 100644 --- a/src/Magnum/Implementation/maxTextureSize.h +++ b/src/Magnum/Implementation/maxTextureSize.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 2648e0f7f..a55936625 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -48,12 +48,16 @@ namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT template struct Constants; - #ifndef MAGNUM_TARGET_GLES - constexpr Rad operator "" _rad(long double); - constexpr Deg operator "" _deg(long double); + #ifdef MAGNUM_BUILD_DEPRECATED + namespace Literals { + #ifndef MAGNUM_TARGET_GLES + constexpr Rad operator "" _rad(long double); + constexpr Deg operator "" _deg(long double); + #endif + constexpr Rad operator "" _radf(long double); + constexpr Deg operator "" _degf(long double); + } #endif - constexpr Rad operator "" _radf(long double); - constexpr Deg operator "" _degf(long double); #endif } @@ -143,6 +147,19 @@ which you might want to be aware of. Implies also @ref MAGNUM_TARGET_GLES and */ #define MAGNUM_TARGET_WEBGL #undef MAGNUM_TARGET_WEBGL + +/** +@brief Headless target + +Defined if the engine is built for use on a headless machine (without any +graphical desktop environment). Basically it means that EGL with no display +attachment is being used everywhere instead of platform-specific toolkits like +CGL, GLX or WGL. Note that this might not be supported on all platforms, see +@ref Magnum::Platform::WindowlessEglApplication "Platform::WindowlessEglApplication" +for more information. +*/ +#define MAGNUM_TARGET_HEADLESS +#undef MAGNUM_TARGET_HEADLESS #endif /** @{ @name Basic type definitions @@ -421,13 +438,14 @@ typedef Math::Range3D Range3Dd; /*@}*/ #endif -/* Using angle literals from Math namespace */ +#ifdef MAGNUM_BUILD_DEPRECATED #ifndef MAGNUM_TARGET_GLES -using Math::operator "" _deg; -using Math::operator "" _rad; +using Math::Literals::operator "" _deg; +using Math::Literals::operator "" _rad; +#endif +using Math::Literals::operator "" _degf; +using Math::Literals::operator "" _radf; #endif -using Math::operator "" _degf; -using Math::operator "" _radf; /* Forward declarations for all types in root namespace */ @@ -475,6 +493,7 @@ template using BasicColor4 CORRADE_DEPRECATED_ALIAS("use Math::Color4 i class Context; class CubeMapTexture; +enum class CubeMapCoordinate: GLenum; #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) class CubeMapTextureArray; #endif @@ -486,6 +505,11 @@ class CubeMapTextureArray; class Extension; class Framebuffer; +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +enum class ImageFormat: GLenum; +enum class ImageAccess: GLenum; +#endif + template class Image; typedef Image<1> Image1D; typedef Image<2> Image2D; diff --git a/src/Magnum/Math/Algorithms/CMakeLists.txt b/src/Magnum/Math/Algorithms/CMakeLists.txt index 05d621b4e..06c46f8bf 100644 --- a/src/Magnum/Math/Algorithms/CMakeLists.txt +++ b/src/Magnum/Math/Algorithms/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Algorithms/GaussJordan.h b/src/Magnum/Math/Algorithms/GaussJordan.h index b00f02d27..ac6ba4a8e 100644 --- a/src/Magnum/Math/Algorithms/GaussJordan.h +++ b/src/Magnum/Math/Algorithms/GaussJordan.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Algorithms/GramSchmidt.h b/src/Magnum/Math/Algorithms/GramSchmidt.h index cc78af8e3..6d50faf2d 100644 --- a/src/Magnum/Math/Algorithms/GramSchmidt.h +++ b/src/Magnum/Math/Algorithms/GramSchmidt.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Algorithms/Svd.h b/src/Magnum/Math/Algorithms/Svd.h index e3b0e3826..514a4f274 100644 --- a/src/Magnum/Math/Algorithms/Svd.h +++ b/src/Magnum/Math/Algorithms/Svd.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Algorithms/Test/CMakeLists.txt b/src/Magnum/Math/Algorithms/Test/CMakeLists.txt index f29ac1e37..5ab52b53b 100644 --- a/src/Magnum/Math/Algorithms/Test/CMakeLists.txt +++ b/src/Magnum/Math/Algorithms/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Algorithms/Test/GaussJordanTest.cpp b/src/Magnum/Math/Algorithms/Test/GaussJordanTest.cpp index c7c6a826c..d7885d1b1 100644 --- a/src/Magnum/Math/Algorithms/Test/GaussJordanTest.cpp +++ b/src/Magnum/Math/Algorithms/Test/GaussJordanTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp b/src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp index 92c35a476..677347ff5 100644 --- a/src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp +++ b/src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Algorithms/Test/SvdTest.cpp b/src/Magnum/Math/Algorithms/Test/SvdTest.cpp index 6cc826c27..1651166d9 100644 --- a/src/Magnum/Math/Algorithms/Test/SvdTest.cpp +++ b/src/Magnum/Math/Algorithms/Test/SvdTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Angle.h b/src/Magnum/Math/Angle.h index d791debfd..c5d40cdf4 100644 --- a/src/Magnum/Math/Angle.h +++ b/src/Magnum/Math/Angle.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -49,6 +49,8 @@ conversion less error-prone. You can enter the value either by using literal: @code +using namespace Literals; + auto degrees = 60.0_degf; // type is Deg auto radians = 1.047_rad; // type is Rad @endcode @@ -151,8 +153,10 @@ template class Deg: public Unit { constexpr /*implicit*/ Deg(Unit value); }; +namespace Literals { + #ifndef MAGNUM_TARGET_GLES -/** @relatesalso Deg +/** @relatesalso Magnum::Math::Deg @brief Double-precision degree value literal Example usage: @@ -166,7 +170,7 @@ Double cosine = Math::cos(1.047_rad); // cosine = 0.5 constexpr Deg operator "" _deg(long double value) { return Deg(Double(value)); } #endif -/** @relatesalso Deg +/** @relatesalso Magnum::Math::Deg @brief Single-precision degree value literal Example usage: @@ -178,6 +182,8 @@ Float tangent = Math::tan(1.047_radf); // tangent = 1.732f */ constexpr Deg operator "" _degf(long double value) { return Deg(Float(value)); } +} + /** @brief Angle in radians @@ -214,8 +220,10 @@ template class Rad: public Unit { constexpr /*implicit*/ Rad(Unit value); }; +namespace Literals { + #ifndef MAGNUM_TARGET_GLES -/** @relatesalso Rad +/** @relatesalso Magnum::Math::Rad @brief Double-precision radian value literal See @link operator""_deg() @endlink for more information. @@ -225,7 +233,7 @@ See @link operator""_deg() @endlink for more information. constexpr Rad operator "" _rad(long double value) { return Rad(Double(value)); } #endif -/** @relatesalso Rad +/** @relatesalso Magnum::Math::Rad @brief Single-precision radian value literal See @link operator""_degf() @endlink for more information. @@ -233,6 +241,8 @@ See @link operator""_degf() @endlink for more information. */ constexpr Rad operator "" _radf(long double value) { return Rad(Float(value)); } +} + template constexpr Deg::Deg(Unit value): Unit(T(180)*T(value)/Math::Constants::pi()) {} template constexpr Rad::Rad(Unit value): Unit(T(value)*Math::Constants::pi()/T(180)) {} diff --git a/src/Magnum/Math/BoolVector.h b/src/Magnum/Math/BoolVector.h index 8641abad1..40cf5e3f4 100644 --- a/src/Magnum/Math/BoolVector.h +++ b/src/Magnum/Math/BoolVector.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -93,12 +93,7 @@ template class BoolVector { #ifdef DOXYGEN_GENERATING_OUTPUT inline explicit BoolVector(T value); #else - template::value && size != 1, bool>::type> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit BoolVector(T value): BoolVector(typename Implementation::GenerateSequence::Type(), value ? FullSegmentMask : 0) {} + template::value && size != 1, bool>::type> constexpr explicit BoolVector(T value): BoolVector(typename Implementation::GenerateSequence::Type(), value ? FullSegmentMask : 0) {} #endif /** @brief Copy constructor */ @@ -232,7 +227,7 @@ template Corrade::Utility::Debug& operator<<(Corrade::Utility: return debug << Corrade::Utility::Debug::nospace << ")"; } -template inline bool BoolVector::operator==(const BoolVector< size >& other) const { +template inline bool BoolVector::operator==(const BoolVector& other) const { for(std::size_t i = 0; i != size/8; ++i) if(_data[i] != other._data[i]) return false; diff --git a/src/Magnum/Math/CMakeLists.txt b/src/Magnum/Math/CMakeLists.txt index 9e4aa1c40..a39dca0ab 100644 --- a/src/Magnum/Math/CMakeLists.txt +++ b/src/Magnum/Math/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Color.h b/src/Magnum/Math/Color.h index e36c54422..137ccc121 100644 --- a/src/Magnum/Math/Color.h +++ b/src/Magnum/Math/Color.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -151,7 +151,8 @@ Conversion from and to HSV is done always using floating-point types, so hue is always in range in range @f$ [0.0, 360.0] @f$, saturation and value in range @f$ [0.0, 1.0] @f$. -@see @ref Color4, @ref Magnum::Color3, @ref Magnum::Color3ub +@see @link operator""_rgb() @endlink, @link operator""_rgbf() @endlink, + @ref Color4, @ref Magnum::Color3, @ref Magnum::Color3ub */ /* Not using template specialization because some internal functions are impossible to explicitly instantiate */ @@ -352,7 +353,8 @@ MAGNUM_VECTORn_OPERATOR_IMPLEMENTATION(3, Color3) @brief Four-component (RGBA) color See @ref Color3 for more information. -@see @ref Magnum::Color4, @ref Magnum::Color4ub +@see @link operator""_rgba() @endlink, @link operator""_rgbaf() @endlink, + @ref Magnum::Color4, @ref Magnum::Color4ub */ /* Not using template specialization because some internal functions are impossible to explicitly instantiate */ @@ -445,10 +447,9 @@ class Color4: public Vector4 { /** * @brief Default constructor * - * RGB components are set to zero, A component is set to `1.0` for - * floating-point types and maximum positive value for integral types. + * All components are set to zero. */ - constexpr /*implicit*/ Color4(): Vector4(T(0), T(0), T(0), Implementation::fullChannel()) {} + constexpr /*implicit*/ Color4(): Vector4(T(0), T(0), T(0), T(0)) {} /** @copydoc Vector::Vector(ZeroInitT) */ constexpr explicit Color4(ZeroInitT) @@ -533,6 +534,62 @@ class Color4: public Vector4 { MAGNUM_VECTORn_OPERATOR_IMPLEMENTATION(4, Color4) #endif +namespace Literals { + +/** @relatesalso Magnum::Math::Color3 +@brief 8bit-per-channel RGB literal + +Example usage: +@code +Color3ub a = 0x33b27f_rgb; // {0x33, 0xb2, 0x7f} +@endcode +@see @link operator""_rgba() @endlink, @link operator""_rgbf() @endlink +*/ +constexpr Color3 operator "" _rgb(unsigned long long value) { + return {UnsignedByte(value >> 16), UnsignedByte(value >> 8), UnsignedByte(value)}; +} + +/** @relatesalso Magnum::Math::Color4 +@brief 8bit-per-channel RGBA literal + +Example usage: +@code +Color4ub a = 0x33b27fcc_rgba; // {0x33, 0xb2, 0x7f, 0xcc} +@endcode +@see @link operator""_rgb() @endlink, @link operator""_rgbaf() @endlink +*/ +constexpr Color4 operator "" _rgba(unsigned long long value) { + return {UnsignedByte(value >> 24), UnsignedByte(value >> 16), UnsignedByte(value >> 8), UnsignedByte(value)}; +} + +/** @relatesalso Magnum::Math::Color3 +@brief Float RGB literal + +Example usage: +@code +Color3 a = 0x33b27f_rgbf; // {0.2f, 0.7f, 0.5f} +@endcode +@see @link operator""_rgbaf() @endlink, @link operator""_rgb() @endlink +*/ +inline Color3 operator "" _rgbf(unsigned long long value) { + return Math::normalize>(Color3{UnsignedByte(value >> 16), UnsignedByte(value >> 8), UnsignedByte(value)}); +} + +/** @relatesalso Magnum::Math::Color4 +@brief Float RGBA literal + +Example usage: +@code +Color4 a = 0x33b27fcc_rgbaf; // {0.2f, 0.7f, 0.5f, 0.8f} +@endcode +@see @link operator""_rgbf() @endlink, @link operator""_rgbaf() @endlink +*/ +inline Color4 operator "" _rgbaf(unsigned long long value) { + return Math::normalize>(Color4{UnsignedByte(value >> 24), UnsignedByte(value >> 16), UnsignedByte(value >> 8), UnsignedByte(value)}); +} + +} + /** @debugoperator{Magnum::Math::Color3} */ template inline Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& debug, const Color3& value) { return debug << static_cast&>(value); diff --git a/src/Magnum/Math/Complex.h b/src/Magnum/Math/Complex.h index 0100b4682..9f2d0a614 100644 --- a/src/Magnum/Math/Complex.h +++ b/src/Magnum/Math/Complex.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -178,12 +178,7 @@ template class Complex { template constexpr explicit Complex(const Complex& other): _real{T(other._real)}, _imaginary{T(other._imaginary)} {} /** @brief Construct complex number from external representation */ - template::from(std::declval()))> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit Complex(const U& other): Complex{Implementation::ComplexConverter::from(other)} {} + template::from(std::declval()))> constexpr explicit Complex(const U& other): Complex{Implementation::ComplexConverter::from(other)} {} /** @brief Convert complex number to external representation */ template::to(std::declval>()))> constexpr explicit operator U() const { diff --git a/src/Magnum/Math/Constants.h b/src/Magnum/Math/Constants.h index a3f7670f6..dedc89e3d 100644 --- a/src/Magnum/Math/Constants.h +++ b/src/Magnum/Math/Constants.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Dual.h b/src/Magnum/Math/Dual.h index 5000d2fa6..5080c9b2d 100644 --- a/src/Magnum/Math/Dual.h +++ b/src/Magnum/Math/Dual.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/DualComplex.h b/src/Magnum/Math/DualComplex.h index 07c888e7b..e3c445839 100644 --- a/src/Magnum/Math/DualComplex.h +++ b/src/Magnum/Math/DualComplex.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -163,12 +163,7 @@ template class DualComplex: public Dual> { {} /** @brief Construct dual complex number from external representation */ - template::from(std::declval()))> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit DualComplex(const U& other): DualComplex{Implementation::DualComplexConverter::from(other)} {} + template::from(std::declval()))> constexpr explicit DualComplex(const U& other): DualComplex{Implementation::DualComplexConverter::from(other)} {} /** @brief Copy constructor */ constexpr DualComplex(const Dual>& other): Dual>(other) {} diff --git a/src/Magnum/Math/DualQuaternion.h b/src/Magnum/Math/DualQuaternion.h index 6d998eb41..4500613ab 100644 --- a/src/Magnum/Math/DualQuaternion.h +++ b/src/Magnum/Math/DualQuaternion.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -234,12 +234,7 @@ template class DualQuaternion: public Dual> { template constexpr explicit DualQuaternion(const DualQuaternion& other): Dual>(other) {} /** @brief Construct dual quaternion from external representation */ - template::from(std::declval()))> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit DualQuaternion(const U& other): DualQuaternion{Implementation::DualQuaternionConverter::from(other)} {} + template::from(std::declval()))> constexpr explicit DualQuaternion(const U& other): DualQuaternion{Implementation::DualQuaternionConverter::from(other)} {} /** @brief Copy constructor */ constexpr DualQuaternion(const Dual>& other): Dual>(other) {} diff --git a/src/Magnum/Math/Functions.cpp b/src/Magnum/Math/Functions.cpp index df264c893..514e2da7b 100644 --- a/src/Magnum/Math/Functions.cpp +++ b/src/Magnum/Math/Functions.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index bfa697ec9..3c3ff7b57 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -453,7 +453,7 @@ component-wise selection from either @p a or @p b based on values in @p t. template inline Vector lerp(const Vector& a, const Vector& b, const BoolVector& t) { Vector out{NoInit}; for(std::size_t i = 0; i != size; ++i) - out[i] = t[i] ? a[i] : b[i]; + out[i] = t[i] ? b[i] : a[i]; return out; } @@ -461,7 +461,7 @@ template inline Vector lerp(const Vector inline BoolVector lerp(const BoolVector& a, const BoolVector& b, const BoolVector& t) { BoolVector out; for(std::size_t i = 0; i != size; ++i) - out.set(i, t[i] ? a[i] : b[i]); + out.set(i, t[i] ? b[i] : a[i]); return out; } diff --git a/src/Magnum/Math/Geometry/CMakeLists.txt b/src/Magnum/Math/Geometry/CMakeLists.txt index 48f1d49c7..fc075d2aa 100644 --- a/src/Magnum/Math/Geometry/CMakeLists.txt +++ b/src/Magnum/Math/Geometry/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Geometry/Distance.h b/src/Magnum/Math/Geometry/Distance.h index 7c514990b..4d8a91f2b 100644 --- a/src/Magnum/Math/Geometry/Distance.h +++ b/src/Magnum/Math/Geometry/Distance.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Geometry/Intersection.h b/src/Magnum/Math/Geometry/Intersection.h index 78ba97b9c..8777b4869 100644 --- a/src/Magnum/Math/Geometry/Intersection.h +++ b/src/Magnum/Math/Geometry/Intersection.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Geometry/Test/CMakeLists.txt b/src/Magnum/Math/Geometry/Test/CMakeLists.txt index 913b8624f..b5aca0649 100644 --- a/src/Magnum/Math/Geometry/Test/CMakeLists.txt +++ b/src/Magnum/Math/Geometry/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -23,5 +23,5 @@ # DEALINGS IN THE SOFTWARE. # -corrade_add_test(MathGeometryDistanceTest DistanceTest.cpp) +corrade_add_test(MathGeometryDistanceTest DistanceTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathGeometryIntersectionTest IntersectionTest.cpp LIBRARIES MagnumMathTestLib) diff --git a/src/Magnum/Math/Geometry/Test/DistanceTest.cpp b/src/Magnum/Math/Geometry/Test/DistanceTest.cpp index d5f4779cd..787936aab 100644 --- a/src/Magnum/Math/Geometry/Test/DistanceTest.cpp +++ b/src/Magnum/Math/Geometry/Test/DistanceTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Geometry/Test/IntersectionTest.cpp b/src/Magnum/Math/Geometry/Test/IntersectionTest.cpp index 39036293c..f5df68d1c 100644 --- a/src/Magnum/Math/Geometry/Test/IntersectionTest.cpp +++ b/src/Magnum/Math/Geometry/Test/IntersectionTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Math.h b/src/Magnum/Math/Math.h index 40fff93d0..f9a3d19bf 100644 --- a/src/Magnum/Math/Math.h +++ b/src/Magnum/Math/Math.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Matrix.h b/src/Magnum/Math/Matrix.h index 7013f9096..6be18b9fd 100644 --- a/src/Magnum/Math/Matrix.h +++ b/src/Magnum/Math/Matrix.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -54,9 +54,6 @@ template class Matrix: public RectangularMatrix class Matrix: public RectangularMatrix class Matrix: public RectangularMatrix constexpr explicit Matrix(const RectangularMatrix& other): - #ifndef CORRADE_MSVC2015_COMPATIBILITY - RectangularMatrix(other) - #else - /* Avoid using non-constexpr version */ - RectangularMatrix(typename Implementation::GenerateSequence::Type(), other) - #endif - {} + template constexpr explicit Matrix(const RectangularMatrix& other): RectangularMatrix(other) {} /** @brief Construct matrix from external representation */ template::from(std::declval()))> constexpr explicit Matrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter::from(other)) {} diff --git a/src/Magnum/Math/Matrix3.h b/src/Magnum/Math/Matrix3.h index f4702db42..0906b4be4 100644 --- a/src/Magnum/Math/Matrix3.h +++ b/src/Magnum/Math/Matrix3.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -162,15 +162,8 @@ template class Matrix3: public Matrix3x3 { constexpr /*implicit*/ Matrix3(IdentityInitT = IdentityInit, T value = T{1}) /** @todoc remove workaround when doxygen is sane */ #ifndef DOXYGEN_GENERATING_OUTPUT - #ifndef CORRADE_MSVC2015_COMPATIBILITY - : Matrix3x3{IdentityInit, value} - #else - /* Avoid using non-constexpr version, also MSVC 2015 can't handle - {} here */ - : Matrix3x3(Vector<3, T>{value, T(0), T(0)}, - Vector<3, T>{T(0), value, T(0)}, - Vector<3, T>{T(0), T(0), value}) - #endif + /* MSVC 2015 can't handle {} here */ + : Matrix3x3(IdentityInit, value) #endif {} @@ -178,15 +171,8 @@ template class Matrix3: public Matrix3x3 { constexpr explicit Matrix3(ZeroInitT) /** @todoc remove workaround when doxygen is sane */ #ifndef DOXYGEN_GENERATING_OUTPUT - #ifndef CORRADE_MSVC2015_COMPATIBILITY + /* MSVC 2015 can't handle {} here */ : Matrix3x3(ZeroInit) - #else - /* Avoid using non-constexpr version, also MSVC 2015 can't handle - {} here */ - : Matrix3x3(Vector<3, T>{T(0), T(0), T(0)}, - Vector<3, T>{T(0), T(0), T(0)}, - Vector<3, T>{T(0), T(0), T(0)}) - #endif #endif {} diff --git a/src/Magnum/Math/Matrix4.h b/src/Magnum/Math/Matrix4.h index 1a209460a..6e30f3156 100644 --- a/src/Magnum/Math/Matrix4.h +++ b/src/Magnum/Math/Matrix4.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -258,16 +258,8 @@ template class Matrix4: public Matrix4x4 { constexpr /*implicit*/ Matrix4(IdentityInitT = IdentityInit, T value = T{1}) /** @todoc remove workaround when doxygen is sane */ #ifndef DOXYGEN_GENERATING_OUTPUT - #ifndef CORRADE_MSVC2015_COMPATIBILITY - : Matrix4x4{IdentityInit, value} - #else - /* Avoid using non-constexpr version, also MSVC 2015 can't handle - {} here */ - : Matrix4x4(Vector<4, T>{value, T(0), T(0), T(0)}, - Vector<4, T>{T(0), value, T(0), T(0)}, - Vector<4, T>{T(0), T(0), value, T(0)}, - Vector<4, T>{T(0), T(0), T(0), value}) - #endif + /* MSVC 2015 can't handle {} here */ + : Matrix4x4(IdentityInit, value) #endif {} @@ -275,16 +267,8 @@ template class Matrix4: public Matrix4x4 { constexpr explicit Matrix4(ZeroInitT) /** @todoc remove workaround when doxygen is sane */ #ifndef DOXYGEN_GENERATING_OUTPUT - #ifndef CORRADE_MSVC2015_COMPATIBILITY + /* MSVC 2015 can't handle {} here */ : Matrix4x4(ZeroInit) - #else - /* Avoid using non-constexpr version, also MSVC 2015 can't handle - {} here */ - : Matrix4x4(Vector<4, T>{T(0), T(0), T(0), T(0)}, - Vector<4, T>{T(0), T(0), T(0), T(0)}, - Vector<4, T>{T(0), T(0), T(0), T(0)}, - Vector<4, T>{T(0), T(0), T(0), T(0)}) - #endif #endif {} diff --git a/src/Magnum/Math/Quaternion.h b/src/Magnum/Math/Quaternion.h index f0c0f31c0..470f72268 100644 --- a/src/Magnum/Math/Quaternion.h +++ b/src/Magnum/Math/Quaternion.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -241,12 +241,7 @@ template class Quaternion { template constexpr explicit Quaternion(const Quaternion& other): _vector{other._vector}, _scalar{T(other._scalar)} {} /** @brief Construct quaternion from external representation */ - template::from(std::declval()))> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit Quaternion(const U& other): Quaternion{Implementation::QuaternionConverter::from(other)} {} + template::from(std::declval()))> constexpr explicit Quaternion(const U& other): Quaternion{Implementation::QuaternionConverter::from(other)} {} /** @brief Convert quaternion to external representation */ template::to(std::declval>()))> constexpr explicit operator U() const { diff --git a/src/Magnum/Math/Range.h b/src/Magnum/Math/Range.h index e8f33a4b1..4161668e9 100644 --- a/src/Magnum/Math/Range.h +++ b/src/Magnum/Math/Range.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -29,6 +29,7 @@ * @brief Class @ref Magnum::Math::Range, @ref Magnum::Math::Range2D, @ref Magnum::Math::Range3D, alias @ref Magnum::Math::Range1D */ +#include "Magnum/Math/Functions.h" #include "Magnum/Math/Vector3.h" namespace Magnum { namespace Math { @@ -62,7 +63,7 @@ template class Range { typedef typename Implementation::RangeTraits::Type VectorType; /** - * Create range from minimal coordinates and size + * @brief Create range from minimal coordinates and size * @param min Minimal coordinates * @param size Range size */ @@ -99,12 +100,7 @@ template class Range { template constexpr explicit Range(const Range& other): _min(other._min), _max(other._max) {} /** @brief Construct range from external representation */ - template::from(std::declval()))> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit Range(const U& other): Range{Implementation::RangeConverter::from(other)} {} + template::from(std::declval()))> constexpr explicit Range(const U& other): Range{Implementation::RangeConverter::from(other)} {} /** @brief Convert range to external representation */ template::to(std::declval>()))> constexpr explicit operator U() const { @@ -190,6 +186,11 @@ template class Range { */ Range scaled(const VectorType& scaling) const; + /** @brief Whether given point is contained inside the range */ + constexpr bool contains(const VectorType& a) const { + return (a >= _min).all() && (a < _max).all(); + } + private: VectorType _min, _max; }; @@ -528,6 +529,19 @@ template class Range3D: public Range<3, T> { MAGNUM_RANGE_SUBCLASS_IMPLEMENTATION(3, Range3D, Vector3) }; +/** @relates Range +@brief Join two ranges + +Returns a range that contains both input ranges. If one of the ranges is empty, +only the other is returned. Results are undefined if any range has negative +size. +*/ +template inline Range join(const Range& a, const Range& b) { + if(a.min() == a.max()) return b; + if(b.min() == b.max()) return a; + return {min(a.min(), b.min()), max(a.max(), b.max())}; +} + /** @debugoperator{Magnum::Math::Range} */ template Corrade::Utility::Debug& operator<<(Corrade::Utility::Debug& debug, const Range& value) { debug << "Range({" << Corrade::Utility::Debug::nospace << value.min()[0]; diff --git a/src/Magnum/Math/RectangularMatrix.h b/src/Magnum/Math/RectangularMatrix.h index 22d2b6bc8..544f30cc3 100644 --- a/src/Magnum/Math/RectangularMatrix.h +++ b/src/Magnum/Math/RectangularMatrix.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -57,11 +57,6 @@ template class RectangularMatrix { template friend class RectangularMatrix; - #ifdef CORRADE_MSVC2015_COMPATIBILITY - /* Delegating constexpr constructor workarounds */ - friend class Matrix; - #endif - public: typedef T Type; /**< @brief Underlying data type */ @@ -113,12 +108,7 @@ template class RectangularMatrix { } /** @brief Construct zero-filled matrix */ - /** @todo Remove MSVC workaround when fixed */ - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - /*implicit*/ RectangularMatrix(ZeroInitT = ZeroInit) + constexpr /*implicit*/ RectangularMatrix(ZeroInitT = ZeroInit) /** @todoc remove workaround when doxygen is sane */ #ifndef DOXYGEN_GENERATING_OUTPUT /* MSVC 2015 can't handle {} here */ @@ -157,20 +147,10 @@ template class RectangularMatrix { * // integral == {1, 2, -15, 7} * @endcode */ - template - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit RectangularMatrix(const RectangularMatrix& other): RectangularMatrix(typename Implementation::GenerateSequence::Type(), other) {} + template constexpr explicit RectangularMatrix(const RectangularMatrix& other): RectangularMatrix(typename Implementation::GenerateSequence::Type(), other) {} /** @brief Construct matrix from external representation */ - template::from(std::declval()))> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit RectangularMatrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter::from(other)) {} + template::from(std::declval()))> constexpr explicit RectangularMatrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter::from(other)) {} /** @brief Copy constructor */ constexpr RectangularMatrix(const RectangularMatrix&) = default; diff --git a/src/Magnum/Math/Swizzle.h b/src/Magnum/Math/Swizzle.h index 14da89371..2bda078e8 100644 --- a/src/Magnum/Math/Swizzle.h +++ b/src/Magnum/Math/Swizzle.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Tags.h b/src/Magnum/Math/Tags.h index f4f40091d..76e7717f2 100644 --- a/src/Magnum/Math/Tags.h +++ b/src/Magnum/Math/Tags.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Test/AngleTest.cpp b/src/Magnum/Math/Test/AngleTest.cpp index 70d488d28..43843e70a 100644 --- a/src/Magnum/Math/Test/AngleTest.cpp +++ b/src/Magnum/Math/Test/AngleTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -121,6 +121,8 @@ void AngleTest::constructNoInit() { } void AngleTest::literals() { + using namespace Literals; + #ifndef MAGNUM_TARGET_GLES constexpr auto a = 25.0_deg; CORRADE_VERIFY((std::is_same::value)); diff --git a/src/Magnum/Math/Test/BoolVectorTest.cpp b/src/Magnum/Math/Test/BoolVectorTest.cpp index 8ea552829..4a6d8c78d 100644 --- a/src/Magnum/Math/Test/BoolVectorTest.cpp +++ b/src/Magnum/Math/Test/BoolVectorTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -99,18 +99,10 @@ void BoolVectorTest::constructNoInit() { } void BoolVectorTest::constructOneValue() { - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - BoolVector19 a(false); + constexpr BoolVector19 a(false); CORRADE_COMPARE(a, BoolVector19(0x00, 0x00, 0x00)); - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - BoolVector19 b(true); + constexpr BoolVector19 b(true); CORRADE_COMPARE(b, BoolVector19(0xff, 0xff, 0x07)); CORRADE_VERIFY(!(std::is_convertible::value)); diff --git a/src/Magnum/Math/Test/CMakeLists.txt b/src/Magnum/Math/Test/CMakeLists.txt index 51e0f5e31..9eeba4cfb 100644 --- a/src/Magnum/Math/Test/CMakeLists.txt +++ b/src/Magnum/Math/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -23,11 +23,11 @@ # DEALINGS IN THE SOFTWARE. # -corrade_add_test(MathBoolVectorTest BoolVectorTest.cpp) -corrade_add_test(MathConstantsTest ConstantsTest.cpp) +corrade_add_test(MathBoolVectorTest BoolVectorTest.cpp LIBRARIES MagnumMathTestLib) +corrade_add_test(MathConstantsTest ConstantsTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathFunctionsTest FunctionsTest.cpp LIBRARIES MagnumMathTestLib) -corrade_add_test(MathTagsTest TagsTest.cpp) -corrade_add_test(MathTypeTraitsTest TypeTraitsTest.cpp) +corrade_add_test(MathTagsTest TagsTest.cpp LIBRARIES MagnumMathTestLib) +corrade_add_test(MathTypeTraitsTest TypeTraitsTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVectorTest VectorTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector2Test Vector2Test.cpp LIBRARIES MagnumMathTestLib) @@ -41,7 +41,7 @@ corrade_add_test(MathMatrix3Test Matrix3Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathMatrix4Test Matrix4Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathSwizzleTest SwizzleTest.cpp LIBRARIES MagnumMathTestLib) -corrade_add_test(MathUnitTest UnitTest.cpp) +corrade_add_test(MathUnitTest UnitTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathAngleTest AngleTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathRangeTest RangeTest.cpp LIBRARIES MagnumMathTestLib) @@ -51,7 +51,7 @@ corrade_add_test(MathDualComplexTest DualComplexTest.cpp LIBRARIES MagnumMathTes corrade_add_test(MathQuaternionTest QuaternionTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathDualQuaternionTest DualQuaternionTest.cpp LIBRARIES MagnumMathTestLib) -set_target_properties( +set_property(TARGET MathVectorTest MathMatrixTest MathMatrix3Test @@ -60,4 +60,4 @@ set_target_properties( MathDualComplexTest MathQuaternionTest MathDualQuaternionTest - PROPERTIES COMPILE_FLAGS -DCORRADE_GRACEFUL_ASSERT) + APPEND PROPERTY COMPILE_DEFINITIONS "CORRADE_GRACEFUL_ASSERT") diff --git a/src/Magnum/Math/Test/ColorTest.cpp b/src/Magnum/Math/Test/ColorTest.cpp index 770602039..8140b757a 100644 --- a/src/Magnum/Math/Test/ColorTest.cpp +++ b/src/Magnum/Math/Test/ColorTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -44,6 +44,8 @@ struct ColorTest: Corrade::TestSuite::Tester { void constructNormalization(); void constructCopy(); + void literals(); + void colors(); void fromHue(); @@ -73,6 +75,8 @@ typedef Math::Color4 Color4ub; typedef Math::Deg Deg; +using namespace Literals; + ColorTest::ColorTest() { addTests({&ColorTest::construct, &ColorTest::constructDefault, @@ -84,6 +88,8 @@ ColorTest::ColorTest() { &ColorTest::constructNormalization, &ColorTest::constructCopy, + &ColorTest::literals, + &ColorTest::colors, &ColorTest::fromHue, @@ -125,8 +131,8 @@ void ColorTest::constructDefault() { constexpr Color4 b; constexpr Color4ub c; - CORRADE_COMPARE(b, Color4(0.0f, 0.0f, 0.0f, 1.0f)); - CORRADE_COMPARE(c, Color4ub(0, 0, 0, 255)); + CORRADE_COMPARE(b, Color4(0.0f, 0.0f, 0.0f, 0.0f)); + CORRADE_COMPARE(c, Color4ub(0, 0, 0, 0)); } void ColorTest::constructZero() { @@ -217,6 +223,20 @@ void ColorTest::constructCopy() { CORRADE_COMPARE(d, Color4(1.0f, 0.5f, 0.75f, 0.25f)); } +void ColorTest::literals() { + using namespace Literals; + + constexpr Color3ub a = 0x33b27f_rgb; + CORRADE_COMPARE(a, (Color3ub{0x33, 0xb2, 0x7f})); + + constexpr Color4ub b = 0x33b27fcc_rgba; + CORRADE_COMPARE(b, (Color4ub{0x33, 0xb2, 0x7f, 0xcc})); + + /* Not constexpr yet */ + CORRADE_COMPARE(0x33b27f_rgbf, (Color3{0.2, 0.698039f, 0.498039f})); + CORRADE_COMPARE(0x33b27fcc_rgbaf, (Color4{0.2, 0.698039f, 0.498039f, 0.8f})); +} + void ColorTest::colors() { CORRADE_COMPARE(Color3ub::red(75), Color3ub(75, 0, 0)); CORRADE_COMPARE(Color3ub::green(75), Color3ub(0, 75, 0)); diff --git a/src/Magnum/Math/Test/ComplexTest.cpp b/src/Magnum/Math/Test/ComplexTest.cpp index c869fb391..c24dff8d4 100644 --- a/src/Magnum/Math/Test/ComplexTest.cpp +++ b/src/Magnum/Math/Test/ComplexTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -201,19 +201,14 @@ void ComplexTest::convert() { /* GCC 5.1 fills the result with zeros instead of properly calling delegated copy constructor if using constexpr. Reported here: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 - MSVC 2015: Can't use delegating constructors with constexpr: - https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - #if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY) + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */ + #if !defined(__GNUC__) || defined(__clang__) constexpr #endif Complex c(a); CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Cmpl d(b); + constexpr Cmpl d(b); CORRADE_COMPARE(d.re, a.re); CORRADE_COMPARE(d.im, a.im); @@ -307,7 +302,7 @@ void ComplexTest::inverted() { void ComplexTest::invertedNormalized() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Complex a(-0.6f, 0.8f); Complex b(-0.6f, -0.8f); @@ -323,7 +318,7 @@ void ComplexTest::invertedNormalized() { void ComplexTest::angle() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Math::angle(Complex(1.5f, -2.0f).normalized(), {-4.0f, 3.5f}); CORRADE_COMPARE(o.str(), "Math::angle(): complex numbers must be normalized\n"); @@ -361,7 +356,7 @@ void ComplexTest::matrix() { CORRADE_COMPARE(a.toMatrix(), m); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Complex::fromMatrix(m*2); CORRADE_COMPARE(o.str(), "Math::Complex::fromMatrix(): the matrix is not orthogonal\n"); diff --git a/src/Magnum/Math/Test/ConstantsTest.cpp b/src/Magnum/Math/Test/ConstantsTest.cpp index 98823f9af..578efa578 100644 --- a/src/Magnum/Math/Test/ConstantsTest.cpp +++ b/src/Magnum/Math/Test/ConstantsTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Test/DualComplexTest.cpp b/src/Magnum/Math/Test/DualComplexTest.cpp index 9e0a7096a..892f9d36c 100644 --- a/src/Magnum/Math/Test/DualComplexTest.cpp +++ b/src/Magnum/Math/Test/DualComplexTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -198,19 +198,14 @@ void DualComplexTest::convert() { /* GCC 5.1 fills the result with zeros instead of properly calling delegated copy constructor if using constexpr. Reported here: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 - MSVC 2015: Can't use delegating constructors with constexpr: - https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - #if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY) + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */ + #if !defined(__GNUC__) || defined(__clang__) constexpr #endif DualComplex c{a}; CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - DualCmpl d(b); + constexpr DualCmpl d(b); CORRADE_COMPARE(d.re, a.re); CORRADE_COMPARE(d.im, a.im); CORRADE_COMPARE(d.x, a.x); @@ -279,7 +274,7 @@ void DualComplexTest::invertedNormalized() { DualComplex b({-0.316228f, -0.9486831f}, {3.320391f, 2.05548f}); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; DualComplex({-1.0f, -2.5f}, {}).invertedNormalized(); CORRADE_COMPARE(o.str(), "Math::Complex::invertedNormalized(): complex number must be normalized\n"); @@ -327,7 +322,7 @@ void DualComplexTest::matrix() { CORRADE_COMPARE(a.toMatrix(), m); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; DualComplex::fromMatrix(m*2); CORRADE_COMPARE(o.str(), "Math::DualComplex::fromMatrix(): the matrix doesn't represent rigid transformation\n"); diff --git a/src/Magnum/Math/Test/DualQuaternionTest.cpp b/src/Magnum/Math/Test/DualQuaternionTest.cpp index b84d8a3ab..7d8884026 100644 --- a/src/Magnum/Math/Test/DualQuaternionTest.cpp +++ b/src/Magnum/Math/Test/DualQuaternionTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -101,6 +101,8 @@ typedef Math::DualQuaternion DualQuaternion; typedef Math::Quaternion Quaternion; typedef Math::Vector3 Vector3; +using namespace Literals; + DualQuaternionTest::DualQuaternionTest() { addTests({&DualQuaternionTest::construct, &DualQuaternionTest::constructVectorScalar, @@ -216,19 +218,14 @@ void DualQuaternionTest::convert() { /* GCC 5.1 fills the result with zeros instead of properly calling delegated copy constructor if using constexpr. Reported here: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 - MSVC 2015: Can't use delegating constructors with constexpr: - https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - #if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY) + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */ + #if !defined(__GNUC__) || defined(__clang__) constexpr #endif DualQuaternion c{a}; CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - DualQuat d(b); + constexpr DualQuat d(b); CORRADE_COMPARE(d.re.x, a.re.x); CORRADE_COMPARE(d.re.y, a.re.y); CORRADE_COMPARE(d.re.z, a.re.z); @@ -299,7 +296,7 @@ void DualQuaternionTest::invertedNormalized() { DualQuaternion b({{-1.0f, -2.0f, -3.0f}, -4.0f}, {{-2.5f, 3.1f, -3.3f}, 2.0f}); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; CORRADE_COMPARE(a.invertedNormalized(), DualQuaternion()); CORRADE_COMPARE(o.str(), "Math::DualQuaternion::invertedNormalized(): dual quaternion must be normalized\n"); @@ -312,7 +309,7 @@ void DualQuaternionTest::invertedNormalized() { void DualQuaternionTest::rotation() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Vector3 axis(1.0f/Constants::sqrt3()); @@ -362,7 +359,7 @@ void DualQuaternionTest::matrix() { CORRADE_COMPARE((-q).toMatrix(), m); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; DualQuaternion::fromMatrix(m*2); CORRADE_COMPARE(o.str(), "Math::DualQuaternion::fromMatrix(): the matrix doesn't represent rigid transformation\n"); @@ -394,7 +391,7 @@ void DualQuaternionTest::transformPointNormalized() { Vector3 v(0.0f, -3.6f, 0.7f); std::ostringstream o; - Corrade::Utility::Error::setOutput(&o); + Error redirectError{&o}; (a*Dual(2)).transformPointNormalized(v); CORRADE_COMPARE(o.str(), "Math::DualQuaternion::transformPointNormalized(): dual quaternion must be normalized\n"); @@ -415,7 +412,6 @@ void DualQuaternionTest::debug() { } void DualQuaternionTest::sclerp() { - const DualQuaternion from = DualQuaternion::translation(Vector3{20.0f, .0f, .0f})*DualQuaternion::rotation(180.0_degf, Vector3{.0f, 1.0f, .0f}); const DualQuaternion to = DualQuaternion::translation(Vector3{42.0f, 42.0f, 42.0f})*DualQuaternion::rotation(75.0_degf, Vector3{1.0f, .0f, .0f}); diff --git a/src/Magnum/Math/Test/DualTest.cpp b/src/Magnum/Math/Test/DualTest.cpp index a2bb6ca76..c99cebcbf 100644 --- a/src/Magnum/Math/Test/DualTest.cpp +++ b/src/Magnum/Math/Test/DualTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -67,6 +67,8 @@ typedef Math::Deg Deg; typedef Math::Rad Rad; typedef Math::Constants Constants; +using namespace Literals; + DualTest::DualTest() { addTests({&DualTest::construct, &DualTest::constructDefault, diff --git a/src/Magnum/Math/Test/FunctionsTest.cpp b/src/Magnum/Math/Test/FunctionsTest.cpp index ab7b5e694..836aa9703 100644 --- a/src/Magnum/Math/Test/FunctionsTest.cpp +++ b/src/Magnum/Math/Test/FunctionsTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -251,8 +251,8 @@ void FunctionsTest::lerp() { } void FunctionsTest::lerpBool() { - CORRADE_COMPARE(Math::lerp(Vector3i{1, 2, 3}, Vector3i{5, 6, 7}, BoolVector<3>(5)), (Vector3i{1, 6, 3})); - CORRADE_COMPARE(Math::lerp(BoolVector<3>{false}, BoolVector<3>{true}, BoolVector<3>(5)), BoolVector<3>{2}); + CORRADE_COMPARE(Math::lerp(Vector3i{1, 2, 3}, Vector3i{5, 6, 7}, BoolVector<3>(5)), (Vector3i{5, 2, 7})); + CORRADE_COMPARE(Math::lerp(BoolVector<3>{false}, BoolVector<3>{true}, BoolVector<3>(5)), BoolVector<3>{5}); } void FunctionsTest::lerpInverted() { diff --git a/src/Magnum/Math/Test/Matrix3Test.cpp b/src/Magnum/Math/Test/Matrix3Test.cpp index 9d8249f27..be6d680e0 100644 --- a/src/Magnum/Math/Test/Matrix3Test.cpp +++ b/src/Magnum/Math/Test/Matrix3Test.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -258,7 +258,7 @@ void Matrix3Test::rotation() { void Matrix3Test::reflection() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Vector2 normal(-1.0f, 2.0f); @@ -332,7 +332,7 @@ void Matrix3Test::rotationScalingPart() { void Matrix3Test::rotationNormalizedPart() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Matrix3 a({1.0f, 0.0f, 8.0f}, {1.0f, 0.1f, 7.0f}, @@ -368,7 +368,7 @@ void Matrix3Test::rotationPart() { /* Fails on non-uniform scaling */ std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Matrix2x2 rotationScaling2 = (rotation*Matrix3::scaling(Vector2::yScale(3.5f))).rotation(); CORRADE_COMPARE(o.str(), "Math::Matrix3::rotation(): the matrix doesn't have uniform scaling\n"); CORRADE_COMPARE(rotationScaling2, Matrix2x2()); @@ -382,7 +382,7 @@ void Matrix3Test::uniformScalingPart() { /* Fails on non-uniform scaling */ std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; const Float nonUniformScaling = (rotation*Matrix3::scaling(Vector2::yScale(3.0f))).uniformScaling(); CORRADE_COMPARE(o.str(), "Math::Matrix3::uniformScaling(): the matrix doesn't have uniform scaling\n"); CORRADE_COMPARE(nonUniformScaling, 0.0f); @@ -419,7 +419,7 @@ void Matrix3Test::invertedRigid() { Matrix3::rotation(Deg(74.0f)); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; (2*actual).invertedRigid(); CORRADE_COMPARE(o.str(), "Math::Matrix3::invertedRigid(): the matrix doesn't represent rigid transformation\n"); diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index 9ebd4b2ac..3969e4817 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/src/Magnum/Math/Test/Matrix4Test.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -287,7 +287,7 @@ void Matrix4Test::scaling() { void Matrix4Test::rotation() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; CORRADE_COMPARE(Matrix4::rotation(Deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Matrix4()); CORRADE_COMPARE(o.str(), "Math::Matrix4::rotation(): axis must be normalized\n"); @@ -328,7 +328,7 @@ void Matrix4Test::rotationZ() { void Matrix4Test::reflection() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Vector3 normal(-1.0f, 2.0f, 2.0f); @@ -434,7 +434,7 @@ void Matrix4Test::rotationScalingPart() { void Matrix4Test::rotationNormalizedPart() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Matrix4 a({0.0f, 0.0f, 1.0f, 4.0f}, {1.0f, 0.0f, 0.0f, 3.0f}, @@ -473,7 +473,7 @@ void Matrix4Test::rotationPart() { /* Fails on non-uniform scaling */ std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Matrix3x3 rotationScaling2 = (rotation*Matrix4::scaling(Vector3::yScale(3.5f))).rotation(); CORRADE_COMPARE(o.str(), "Math::Matrix4::rotation(): the matrix doesn't have uniform scaling\n"); CORRADE_COMPARE(rotationScaling2, Matrix3x3()); @@ -487,7 +487,7 @@ void Matrix4Test::uniformScalingPart() { /* Fails on non-uniform scaling */ std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; const Float nonUniformScaling = (rotation*Matrix4::scaling(Vector3::yScale(3.0f))).uniformScaling(); CORRADE_COMPARE(o.str(), "Math::Matrix4::uniformScaling(): the matrix doesn't have uniform scaling\n"); CORRADE_COMPARE(nonUniformScaling, 0.0f); @@ -530,7 +530,7 @@ void Matrix4Test::invertedRigid() { Matrix4::rotation(Deg(74.0f), Vector3(-1.0f, 0.5f, 2.0f).normalized()); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; (2*actual).invertedRigid(); CORRADE_COMPARE(o.str(), "Math::Matrix4::invertedRigid(): the matrix doesn't represent rigid transformation\n"); diff --git a/src/Magnum/Math/Test/MatrixTest.cpp b/src/Magnum/Math/Test/MatrixTest.cpp index 264938ec4..7a216e220 100644 --- a/src/Magnum/Math/Test/MatrixTest.cpp +++ b/src/Magnum/Math/Test/MatrixTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -126,21 +126,9 @@ void MatrixTest::construct() { } void MatrixTest::constructIdentity() { - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Matrix4x4 identity; - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Matrix4x4 identity2{IdentityInit}; - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Matrix4x4 identity3{IdentityInit, 4.0f}; + constexpr Matrix4x4 identity; + constexpr Matrix4x4 identity2{IdentityInit}; + constexpr Matrix4x4 identity3{IdentityInit, 4.0f}; Matrix4x4 identityExpected(Vector4(1.0f, 0.0f, 0.0f, 0.0f), Vector4(0.0f, 1.0f, 0.0f, 0.0f), @@ -158,11 +146,7 @@ void MatrixTest::constructIdentity() { } void MatrixTest::constructZero() { - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Matrix4x4 a{ZeroInit}; + constexpr Matrix4x4 a{ZeroInit}; CORRADE_COMPARE(a, Matrix4x4(Vector4(0.0f, 0.0f, 0.0f, 0.0f), Vector4(0.0f, 0.0f, 0.0f, 0.0f), Vector4(0.0f, 0.0f, 0.0f, 0.0f), @@ -222,10 +206,7 @@ void MatrixTest::convert() { constexpr Matrix3x3 c(b); CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Mat3 d(b); + constexpr Mat3 d(b); for(std::size_t i = 0; i != 9; ++i) CORRADE_COMPARE(d.a[i], a.a[i]); @@ -302,7 +283,7 @@ void MatrixTest::inverted() { void MatrixTest::invertedOrthogonal() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Matrix3x3 a(Vector3(Constants::sqrt3()/2.0f, 0.5f, 0.0f), Vector3(-0.5f, Constants::sqrt3()/2.0f, 0.0f), diff --git a/src/Magnum/Math/Test/QuaternionTest.cpp b/src/Magnum/Math/Test/QuaternionTest.cpp index 5fcb6ad3b..4addf3c40 100644 --- a/src/Magnum/Math/Test/QuaternionTest.cpp +++ b/src/Magnum/Math/Test/QuaternionTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -202,19 +202,14 @@ void QuaternionTest::convert() { /* GCC 5.1 fills the result with zeros instead of properly calling delegated copy constructor if using constexpr. Reported here: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 - MSVC 2015: Can't use delegating constructors with constexpr: - https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - #if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY) + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */ + #if !defined(__GNUC__) || defined(__clang__) constexpr #endif Quaternion c{a}; CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Quat d(b); + constexpr Quat d(b); CORRADE_COMPARE(d.x, a.x); CORRADE_COMPARE(d.y, a.y); CORRADE_COMPARE(d.z, a.z); @@ -305,7 +300,7 @@ void QuaternionTest::invertedNormalized() { Quaternion a = Quaternion({1.0f, 3.0f, -2.0f}, -4.0f); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; a.invertedNormalized(); CORRADE_COMPARE(o.str(), "Math::Quaternion::invertedNormalized(): quaternion must be normalized\n"); @@ -318,7 +313,7 @@ void QuaternionTest::invertedNormalized() { void QuaternionTest::rotation() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Vector3 axis(1.0f/Constants::sqrt3()); @@ -345,7 +340,7 @@ void QuaternionTest::rotation() { void QuaternionTest::angle() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Math::angle(Quaternion({1.0f, 2.0f, -3.0f}, -4.0f).normalized(), {{4.0f, -3.0f, 2.0f}, -1.0f}); CORRADE_COMPARE(o.str(), "Math::angle(): quaternions must be normalized\n"); @@ -372,7 +367,7 @@ void QuaternionTest::matrix() { CORRADE_COMPARE((-q).toMatrix(), m); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Quaternion::fromMatrix(m*2); CORRADE_COMPARE(o.str(), "Math::Quaternion::fromMatrix(): the matrix is not orthogonal\n"); @@ -409,7 +404,7 @@ void QuaternionTest::lerp() { Quaternion b = Quaternion::rotation(Deg(23.0f), Vector3::xAxis()); std::ostringstream o; - Corrade::Utility::Error::setOutput(&o); + Error redirectError{&o}; Math::lerp(a*3.0f, b, 0.35f); CORRADE_COMPARE(o.str(), "Math::lerp(): quaternions must be normalized\n"); @@ -427,7 +422,7 @@ void QuaternionTest::slerp() { Quaternion b = Quaternion::rotation(Deg(23.0f), Vector3::xAxis()); std::ostringstream o; - Corrade::Utility::Error::setOutput(&o); + Error redirectError{&o}; Math::slerp(a*3.0f, b, 0.35f); CORRADE_COMPARE(o.str(), "Math::slerp(): quaternions must be normalized\n"); @@ -460,7 +455,7 @@ void QuaternionTest::transformVectorNormalized() { Vector3 v(5.0f, -3.6f, 0.7f); std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; (a*2).transformVectorNormalized(v); CORRADE_COMPARE(o.str(), "Math::Quaternion::transformVectorNormalized(): quaternion must be normalized\n"); diff --git a/src/Magnum/Math/Test/RangeTest.cpp b/src/Magnum/Math/Test/RangeTest.cpp index d882cef88..a428f77d9 100644 --- a/src/Magnum/Math/Test/RangeTest.cpp +++ b/src/Magnum/Math/Test/RangeTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -123,6 +123,9 @@ struct RangeTest: Corrade::TestSuite::Tester { void padded(); void scaled(); + void contains(); + void join(); + void subclassTypes(); void subclass(); @@ -157,6 +160,9 @@ RangeTest::RangeTest() { &RangeTest::padded, &RangeTest::scaled, + &RangeTest::contains, + &RangeTest::join, + &RangeTest::subclassTypes, &RangeTest::subclass, @@ -215,11 +221,7 @@ void RangeTest::constructConversion() { constexpr Range2D b({1.3f, 2.7f}, {-15.0f, 7.0f}); constexpr Range3D c({1.3f, 2.7f, -1.5f}, {-15.0f, 7.0f, 0.3f}); - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Range1Di d(a); + constexpr Range1Di d(a); CORRADE_COMPARE(d, Range1Di(1, -15)); constexpr Range2Di e(b); @@ -260,14 +262,12 @@ void RangeTest::convert() { /* GCC 5.1 fills the result with zeros instead of properly calling delegated copy constructor if using constexpr. Reported here: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 - MSVC 2015: Can't use delegating constructors with constexpr: - https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - #if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY) + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */ + #if !defined(__GNUC__) || defined(__clang__) constexpr #endif Range<2, Float> g{b}; - #if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY) + #if !defined(__GNUC__) || defined(__clang__) constexpr #endif Range1D h{a}; @@ -284,26 +284,17 @@ void RangeTest::convert() { CORRADE_COMPARE(i, e); CORRADE_COMPARE(j, f); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Dim k(d); + constexpr Dim k(d); CORRADE_COMPARE(k.offset, a.offset); CORRADE_COMPARE(k.size, a.size); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Rect l(e); + constexpr Rect l(e); CORRADE_COMPARE(l.x, b.x); CORRADE_COMPARE(l.y, b.y); CORRADE_COMPARE(l.w, b.w); CORRADE_COMPARE(l.h, b.h); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Box m(f); + constexpr Box m(f); CORRADE_COMPARE(m.x, c.x); CORRADE_COMPARE(m.y, c.y); CORRADE_COMPARE(m.z, c.z); @@ -461,6 +452,26 @@ void RangeTest::scaled() { CORRADE_COMPARE(a.scaled({2, -3}), b); } +void RangeTest::contains() { + Range2Di a({34, 23}, {47, 30}); + + CORRADE_VERIFY(a.contains({40, 23})); + CORRADE_VERIFY(!a.contains({33, 23})); + CORRADE_VERIFY(!a.contains({40, 30})); +} + +void RangeTest::join() { + Range2Di a{{12, 20}, {15, 35}}; + Range2Di b{{10, 25}, {17, 105}}; + Range2Di c{{130, -15}, {130, -15}}; + Range2Di d{{10, 20}, {17, 105}}; + + CORRADE_COMPARE(Math::join(a, b), d); + CORRADE_COMPARE(Math::join(b, a), d); + CORRADE_COMPARE(Math::join(a, c), a); + CORRADE_COMPARE(Math::join(c, a), a); +} + template class BasicRect: public Math::Range<2, T> { public: /* MSVC 2015 can't handle {} here */ diff --git a/src/Magnum/Math/Test/RectangularMatrixTest.cpp b/src/Magnum/Math/Test/RectangularMatrixTest.cpp index 1246cd18d..36a496df4 100644 --- a/src/Magnum/Math/Test/RectangularMatrixTest.cpp +++ b/src/Magnum/Math/Test/RectangularMatrixTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -149,16 +149,8 @@ void RectangularMatrixTest::construct() { } void RectangularMatrixTest::constructDefault() { - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Matrix4x3 a; - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Matrix4x3 b{ZeroInit}; + constexpr Matrix4x3 a; + constexpr Matrix4x3 b{ZeroInit}; CORRADE_COMPARE(a, Matrix4x3(Vector3(0.0f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, 0.0f), @@ -182,11 +174,7 @@ void RectangularMatrixTest::constructNoInit() { void RectangularMatrixTest::constructConversion() { constexpr Matrix2x2 a(Vector2( 1.3f, 2.7f), Vector2(-15.0f, 7.0f)); - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Matrix2x2i b(a); + constexpr Matrix2x2i b(a); CORRADE_COMPARE(b, Matrix2x2i(Vector2i( 1, 2), Vector2i(-15, 7))); @@ -245,19 +233,14 @@ void RectangularMatrixTest::convert() { /* GCC 5.1 fills the result with zeros instead of properly calling delegated copy constructor if using constexpr. Reported here: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 - MSVC 2015: Can't use delegating constructors with constexpr: - https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - #if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY) + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */ + #if !defined(__GNUC__) || defined(__clang__) constexpr #endif Matrix2x3 c{a}; CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Mat2x3 d(b); + constexpr Mat2x3 d(b); for(std::size_t i = 0; i != 5; ++i) CORRADE_COMPARE(d.a[i], a.a[i]); diff --git a/src/Magnum/Math/Test/SwizzleTest.cpp b/src/Magnum/Math/Test/SwizzleTest.cpp index 4c051c7ec..0dd274471 100644 --- a/src/Magnum/Math/Test/SwizzleTest.cpp +++ b/src/Magnum/Math/Test/SwizzleTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Test/TagsTest.cpp b/src/Magnum/Math/Test/TagsTest.cpp index 0896f8cf7..8dea9c328 100644 --- a/src/Magnum/Math/Test/TagsTest.cpp +++ b/src/Magnum/Math/Test/TagsTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Test/TypeTraitsTest.cpp b/src/Magnum/Math/Test/TypeTraitsTest.cpp index 3acafbe85..7f733e6ed 100644 --- a/src/Magnum/Math/Test/TypeTraitsTest.cpp +++ b/src/Magnum/Math/Test/TypeTraitsTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -33,102 +33,71 @@ namespace Magnum { namespace Math { namespace Test { struct TypeTraitsTest: Corrade::TestSuite::Tester { explicit TypeTraitsTest(); - void equalsIntegral(); - void equalsFloatingPoint0(); - void equalsFloatingPoint1(); - void equalsFloatingPointLarge(); - void equalsFloatingPointInfinity(); - void equalsFloatingPointNaN(); - - private: - template void _equalsIntegral(); - template void _equalsFloatingPoint0(); - template void _equalsFloatingPoint1(); - template void _equalsFloatingPointLarge(); - template void _equalsFloatingPointInfinity(); - template void _equalsFloatingPointNaN(); + template void equalsIntegral(); + template void equalsFloatingPoint0(); + template void equalsFloatingPoint1(); + template void equalsFloatingPointLarge(); + template void equalsFloatingPointInfinity(); + template void equalsFloatingPointNaN(); }; TypeTraitsTest::TypeTraitsTest() { - addTests({&TypeTraitsTest::equalsIntegral, - &TypeTraitsTest::equalsFloatingPoint0, - &TypeTraitsTest::equalsFloatingPoint1, - &TypeTraitsTest::equalsFloatingPointLarge, - &TypeTraitsTest::equalsFloatingPointInfinity, - &TypeTraitsTest::equalsFloatingPointNaN}); + addTests({&TypeTraitsTest::equalsIntegral, + &TypeTraitsTest::equalsIntegral, + &TypeTraitsTest::equalsIntegral, + &TypeTraitsTest::equalsIntegral, + &TypeTraitsTest::equalsIntegral, + &TypeTraitsTest::equalsIntegral, + &TypeTraitsTest::equalsIntegral, + &TypeTraitsTest::equalsIntegral, + &TypeTraitsTest::equalsFloatingPoint0, + #ifndef MAGNUM_TARGET_GLES + &TypeTraitsTest::equalsFloatingPoint0, + #endif + &TypeTraitsTest::equalsFloatingPoint1, + #ifndef MAGNUM_TARGET_GLES + &TypeTraitsTest::equalsFloatingPoint1, + #endif + &TypeTraitsTest::equalsFloatingPointLarge, + #ifndef MAGNUM_TARGET_GLES + &TypeTraitsTest::equalsFloatingPointLarge, + #endif + &TypeTraitsTest::equalsFloatingPointInfinity, + #ifndef MAGNUM_TARGET_GLES + &TypeTraitsTest::equalsFloatingPointInfinity, + #endif + &TypeTraitsTest::equalsFloatingPointNaN, + #ifndef MAGNUM_TARGET_GLES + &TypeTraitsTest::equalsFloatingPointNaN + #endif + }); } -void TypeTraitsTest::equalsIntegral() { - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); -} - -template void TypeTraitsTest::_equalsIntegral() { +template void TypeTraitsTest::equalsIntegral() { CORRADE_VERIFY(!TypeTraits::equals(1, 1+TypeTraits::epsilon())); } -void TypeTraitsTest::equalsFloatingPoint0() { - _equalsFloatingPoint0(); - #ifndef MAGNUM_TARGET_GLES - _equalsFloatingPoint0(); - #endif -} - -template void TypeTraitsTest::_equalsFloatingPoint0() { +template void TypeTraitsTest::equalsFloatingPoint0() { CORRADE_VERIFY(TypeTraits::equals(T(0)+TypeTraits::epsilon()/T(2), T(0))); CORRADE_VERIFY(!TypeTraits::equals(T(0)+TypeTraits::epsilon()*T(2), T(0))); } -void TypeTraitsTest::equalsFloatingPoint1() { - _equalsFloatingPoint1(); - #ifndef MAGNUM_TARGET_GLES - _equalsFloatingPoint1(); - #endif -} - -template void TypeTraitsTest::_equalsFloatingPoint1() { +template void TypeTraitsTest::equalsFloatingPoint1() { CORRADE_VERIFY(TypeTraits::equals(T(1)+TypeTraits::epsilon()/T(2), T(1))); CORRADE_VERIFY(!TypeTraits::equals(T(1)+TypeTraits::epsilon()*T(3), T(1))); } -void TypeTraitsTest::equalsFloatingPointLarge() { - _equalsFloatingPointLarge(); - #ifndef MAGNUM_TARGET_GLES - _equalsFloatingPointLarge(); - #endif -} - -template void TypeTraitsTest::_equalsFloatingPointLarge() { +template void TypeTraitsTest::equalsFloatingPointLarge() { CORRADE_VERIFY(TypeTraits::equals(T(25)+TypeTraits::epsilon()*T(2), T(25))); CORRADE_VERIFY(!TypeTraits::equals(T(25)+TypeTraits::epsilon()*T(75), T(25))); } -void TypeTraitsTest::equalsFloatingPointInfinity() { - _equalsFloatingPointInfinity(); - #ifndef MAGNUM_TARGET_GLES - _equalsFloatingPointInfinity(); - #endif -} - -template void TypeTraitsTest::_equalsFloatingPointInfinity() { +template void TypeTraitsTest::equalsFloatingPointInfinity() { CORRADE_VERIFY(TypeTraits::equals(Constants::inf(), Constants::inf())); } -void TypeTraitsTest::equalsFloatingPointNaN() { - _equalsFloatingPointNaN(); - #ifndef MAGNUM_TARGET_GLES - _equalsFloatingPointNaN(); - #endif -} - -template void TypeTraitsTest::_equalsFloatingPointNaN() { +template void TypeTraitsTest::equalsFloatingPointNaN() { CORRADE_VERIFY(!TypeTraits::equals(Constants::nan(), Constants::nan())); } diff --git a/src/Magnum/Math/Test/UnitTest.cpp b/src/Magnum/Math/Test/UnitTest.cpp index 45618351b..256497e90 100644 --- a/src/Magnum/Math/Test/UnitTest.cpp +++ b/src/Magnum/Math/Test/UnitTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Test/Vector2Test.cpp b/src/Magnum/Math/Test/Vector2Test.cpp index a8cfdd448..d066d8e21 100644 --- a/src/Magnum/Math/Test/Vector2Test.cpp +++ b/src/Magnum/Math/Test/Vector2Test.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -152,10 +152,7 @@ void Vector2Test::convert() { constexpr Vector2 c(a); CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Vec2 d(b); + constexpr Vec2 d(b); CORRADE_COMPARE(d.x, a.x); CORRADE_COMPARE(d.y, a.y); diff --git a/src/Magnum/Math/Test/Vector3Test.cpp b/src/Magnum/Math/Test/Vector3Test.cpp index af2719585..8d53b8f79 100644 --- a/src/Magnum/Math/Test/Vector3Test.cpp +++ b/src/Magnum/Math/Test/Vector3Test.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -156,10 +156,7 @@ void Vector3Test::convert() { constexpr Vector3 c(a); CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Vec3 d(b); + constexpr Vec3 d(b); CORRADE_COMPARE(d.x, a.x); CORRADE_COMPARE(d.y, a.y); CORRADE_COMPARE(d.z, a.z); diff --git a/src/Magnum/Math/Test/Vector4Test.cpp b/src/Magnum/Math/Test/Vector4Test.cpp index 1fb0d4b8d..5eff2562a 100644 --- a/src/Magnum/Math/Test/Vector4Test.cpp +++ b/src/Magnum/Math/Test/Vector4Test.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -171,10 +171,7 @@ void Vector4Test::convert() { constexpr Vector4 c(a); CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Vec4 d(b); + constexpr Vec4 d(b); CORRADE_COMPARE(d.x, a.x); CORRADE_COMPARE(d.y, a.y); CORRADE_COMPARE(d.z, a.z); diff --git a/src/Magnum/Math/Test/VectorTest.cpp b/src/Magnum/Math/Test/VectorTest.cpp index 78b43bf47..64c6ec747 100644 --- a/src/Magnum/Math/Test/VectorTest.cpp +++ b/src/Magnum/Math/Test/VectorTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -68,7 +68,8 @@ struct VectorTest: Corrade::TestSuite::Tester { void constructCopy(); void convert(); - void isZero(); + void isZeroFloat(); + void isZeroInteger(); void isNormalized(); void data(); @@ -125,7 +126,8 @@ VectorTest::VectorTest() { &VectorTest::constructCopy, &VectorTest::convert, - &VectorTest::isZero, + &VectorTest::isZeroFloat, + &VectorTest::isZeroInteger, &VectorTest::isNormalized, &VectorTest::data, @@ -201,11 +203,7 @@ void VectorTest::constructNoInit() { } void VectorTest::constructOneValue() { - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Vector4 a(7.25f); + constexpr Vector4 a(7.25f); CORRADE_COMPARE(a, Vector4(7.25f, 7.25f, 7.25f, 7.25f)); @@ -223,11 +221,7 @@ void VectorTest::constructOneComponent() { void VectorTest::constructConversion() { constexpr Vector4 a(1.3f, 2.7f, -15.0f, 7.0f); - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Vector4i b(a); + constexpr Vector4i b(a); CORRADE_COMPARE(b, Vector4i(1, 2, -15, 7)); @@ -247,19 +241,14 @@ void VectorTest::convert() { /* GCC 5.1 fills the result with zeros instead of properly calling delegated copy constructor if using constexpr. Reported here: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 - MSVC 2015: Can't use delegating constructors with constexpr: - https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - #if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY) + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */ + #if !defined(__GNUC__) || defined(__clang__) constexpr #endif Vector3 c{a}; CORRADE_COMPARE(c, b); - #ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */ - constexpr - #endif - Vec3 d(b); + constexpr Vec3 d(b); CORRADE_COMPARE(d.x, a.x); CORRADE_COMPARE(d.y, a.y); CORRADE_COMPARE(d.z, a.z); @@ -269,11 +258,17 @@ void VectorTest::convert() { CORRADE_VERIFY(!(std::is_convertible::value)); } -void VectorTest::isZero() { +void VectorTest::isZeroFloat() { CORRADE_VERIFY(!Vector3(0.01f, 0.0f, 0.0f).isZero()); + CORRADE_VERIFY(Vector3(0.0f, Math::TypeTraits::epsilon()/2.0f, 0.0f).isZero()); CORRADE_VERIFY(Vector3(0.0f, 0.0f, 0.0f).isZero()); } +void VectorTest::isZeroInteger() { + CORRADE_VERIFY(!(Math::Vector<3, Int>{0, 1, 0}.isZero())); + CORRADE_VERIFY((Math::Vector<3, Int>{0, 0, 0}.isZero())); +} + void VectorTest::isNormalized() { CORRADE_VERIFY(!Vector3(1.0f, 2.0f, -1.0f).isNormalized()); CORRADE_VERIFY(Vector3(0.0f, 1.0f, 0.0f).isNormalized()); @@ -454,7 +449,7 @@ void VectorTest::projected() { void VectorTest::projectedOntoNormalized() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Vector3 vector(1.0f, 2.0f, 3.0f); Vector3 line(1.0f, -1.0f, 0.5f); @@ -469,7 +464,7 @@ void VectorTest::projectedOntoNormalized() { void VectorTest::angle() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Math::angle(Vector3(2.0f, 3.0f, 4.0f).normalized(), {1.0f, -2.0f, 3.0f}); CORRADE_COMPARE(o.str(), "Math::angle(): vectors must be normalized\n"); diff --git a/src/Magnum/Math/TypeTraits.h b/src/Magnum/Math/TypeTraits.h index 96d6efd5c..7a081dc94 100644 --- a/src/Magnum/Math/TypeTraits.h +++ b/src/Magnum/Math/TypeTraits.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -198,12 +198,6 @@ template<> struct TypeTraits: Implementation::TypeTraitsFloatingPoi namespace Implementation { -/* Proper comparison should be with epsilon^2, but the value is not - representable in given precision. Comparing to epsilon instead. */ -template inline bool isZeroSquared(T lengthSquared) { - return std::abs(lengthSquared) < TypeTraits::epsilon(); -} - /* Comparing squared length to 1 is not sufficient to compare within range [1 - epsilon, 1 + epsilon], as e.g. Quaternion with dot() = 1 + 1e-7 when converted to matrix has column vectors with dot() = 1 + 1e-6, which is just diff --git a/src/Magnum/Math/Unit.h b/src/Magnum/Math/Unit.h index ab9002e65..840df7f47 100644 --- a/src/Magnum/Math/Unit.h +++ b/src/Magnum/Math/Unit.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Math/Vector.h b/src/Magnum/Math/Vector.h index e143f7efc..8d8fc5bcf 100644 --- a/src/Magnum/Math/Vector.h +++ b/src/Magnum/Math/Vector.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -54,6 +54,20 @@ namespace Implementation { template T lerp(const T& a, const T& b, U t) { return T((U(1) - t)*a + t*b); } + + template struct IsZero; + template<> struct IsZero { + template bool operator()(const Vector& vec) const { + /* Proper comparison should be with epsilon^2, but the value is not + representable in given precision. Comparing to epsilon instead. */ + return std::abs(vec.dot()) < TypeTraits::epsilon(); + } + }; + template<> struct IsZero { + template bool operator()(const Vector& vec) const { + return vec == Vector{}; + } + }; } /** @relatesalso Vector @@ -98,13 +112,6 @@ template class Vector { template friend class Vector; - #ifdef CORRADE_MSVC2015_COMPATIBILITY - /* Delegating constexpr constructor workarounds */ - friend class Vector2; - friend class Vector3; - friend class Vector4; - #endif - public: typedef T Type; /**< @brief Underlying data type */ @@ -188,12 +195,7 @@ template class Vector { #ifdef DOXYGEN_GENERATING_OUTPUT constexpr explicit Vector(T value); #else - template::value && size != 1, T>::type> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit Vector(U value): Vector(typename Implementation::GenerateSequence::Type(), value) {} + template::value && size != 1, T>::type> constexpr explicit Vector(U value): Vector(typename Implementation::GenerateSequence::Type(), value) {} #endif /** @@ -207,20 +209,10 @@ template class Vector { * // integral == {1, 2, -15, 7} * @endcode */ - template - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit Vector(const Vector& other): Vector(typename Implementation::GenerateSequence::Type(), other) {} + template constexpr explicit Vector(const Vector& other): Vector(typename Implementation::GenerateSequence::Type(), other) {} /** @brief Construct vector from external representation */ - template::from(std::declval()))> - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - explicit Vector(const U& other): Vector(Implementation::VectorConverter::from(other)) {} + template::from(std::declval()))> constexpr explicit Vector(const U& other): Vector(Implementation::VectorConverter::from(other)) {} /** @brief Copy constructor */ constexpr Vector(const Vector&) = default; @@ -284,7 +276,7 @@ template class Vector { * @see @ref dot(), @ref normalized() */ bool isZero() const { - return Implementation::isZeroSquared(dot()); + return Implementation::IsZero::value>{}(*this); } /** diff --git a/src/Magnum/Math/Vector2.h b/src/Magnum/Math/Vector2.h index 5aca64b59..9bd0809ff 100644 --- a/src/Magnum/Math/Vector2.h +++ b/src/Magnum/Math/Vector2.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -130,14 +130,7 @@ template class Vector2: public Vector<2, T> { {} /** @copydoc Vector::Vector(T) */ - constexpr explicit Vector2(T value): - #ifndef CORRADE_MSVC2015_COMPATIBILITY - Vector<2, T>(value) - #else - /* Avoid using non-constexpr version */ - Vector<2, T>(value, value) - #endif - {} + constexpr explicit Vector2(T value): Vector<2, T>(value) {} /** * @brief Constructor @@ -149,14 +142,7 @@ template class Vector2: public Vector<2, T> { constexpr /*implicit*/ Vector2(T x, T y): Vector<2, T>(x, y) {} /** @copydoc Vector::Vector(const Vector&) */ - template constexpr explicit Vector2(const Vector<2, U>& other): - #ifndef CORRADE_MSVC2015_COMPATIBILITY - Vector<2, T>(other) - #else - /* Avoid using non-constexpr version */ - Vector<2, T>(typename Implementation::GenerateSequence<2>::Type(), other) - #endif - {} + template constexpr explicit Vector2(const Vector<2, U>& other): Vector<2, T>(other) {} /** @brief Construct vector from external representation */ template Permission is hereby granted, free of charge, to any person obtaining a @@ -152,14 +152,7 @@ template class Vector3: public Vector<3, T> { {} /** @copydoc Vector::Vector(T) */ - constexpr explicit Vector3(T value): - #ifndef CORRADE_MSVC2015_COMPATIBILITY - Vector<3, T>(value) - #else - /* Avoid using non-constexpr version */ - Vector<3, T>(value, value, value) - #endif - {} + constexpr explicit Vector3(T value): Vector<3, T>(value) {} /** * @brief Constructor @@ -180,14 +173,7 @@ template class Vector3: public Vector<3, T> { constexpr /*implicit*/ Vector3(const Vector2& xy, T z): Vector<3, T>(xy[0], xy[1], z) {} /** @copydoc Vector::Vector(const Vector&) */ - template constexpr explicit Vector3(const Vector<3, U>& other): - #ifndef CORRADE_MSVC2015_COMPATIBILITY - Vector<3, T>(other) - #else - /* Avoid using non-constexpr version */ - Vector<3, T>(typename Implementation::GenerateSequence<3>::Type(), other) - #endif - {} + template constexpr explicit Vector3(const Vector<3, U>& other): Vector<3, T>(other) {} /** @brief Construct vector from external representation */ template Permission is hereby granted, free of charge, to any person obtaining a @@ -78,14 +78,7 @@ template class Vector4: public Vector<4, T> { {} /** @copydoc Vector::Vector(T) */ - constexpr explicit Vector4(T value): - #ifndef CORRADE_MSVC2015_COMPATIBILITY - Vector<4, T>(value) - #else - /* Avoid using non-constexpr version */ - Vector<4, T>(value, value, value, value) - #endif - {} + constexpr explicit Vector4(T value): Vector<4, T>(value) {} /** * @brief Constructor @@ -106,14 +99,7 @@ template class Vector4: public Vector<4, T> { constexpr /*implicit*/ Vector4(const Vector3& xyz, T w): Vector<4, T>(xyz[0], xyz[1], xyz[2], w) {} /** @copydoc Vector::Vector(const Vector&) */ - template constexpr explicit Vector4(const Vector<4, U>& other): - #ifndef CORRADE_MSVC2015_COMPATIBILITY - Vector<4, T>(other) - #else - /* Avoid using non-constexpr version */ - Vector<4, T>(typename Implementation::GenerateSequence<4>::Type(), other) - #endif - {} + template constexpr explicit Vector4(const Vector<4, U>& other): Vector<4, T>(other) {} /** @brief Construct vector from external representation */ template::from(std::declval()))> constexpr explicit Vector4(const U& other): Vector<4, T>(Implementation::VectorConverter<4, T, U>::from(other)) {} diff --git a/src/Magnum/Math/instantiation.cpp b/src/Magnum/Math/instantiation.cpp index 0ad1bfa12..005c0fe58 100644 --- a/src/Magnum/Math/instantiation.cpp +++ b/src/Magnum/Math/instantiation.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index acf2917d6..96631277f 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -68,7 +68,7 @@ Int Mesh::maxElementIndex() #endif { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0xFFFFFFFFl; #endif @@ -77,7 +77,7 @@ Int Mesh::maxElementIndex() #else GLint& value = #endif - Context::current()->state().mesh->maxElementIndex; + Context::current().state().mesh->maxElementIndex; /* Get the value, if not already cached */ if(value == 0) { @@ -92,7 +92,7 @@ Int Mesh::maxElementIndex() } Int Mesh::maxElementsIndices() { - GLint& value = Context::current()->state().mesh->maxElementsIndices; + GLint& value = Context::current().state().mesh->maxElementsIndices; /* Get the value, if not already cached */ if(value == 0) @@ -102,7 +102,7 @@ Int Mesh::maxElementsIndices() { } Int Mesh::maxElementsVertices() { - GLint& value = Context::current()->state().mesh->maxElementsVertices; + GLint& value = Context::current().state().mesh->maxElementsVertices; /* Get the value, if not already cached */ if(value == 0) @@ -131,7 +131,7 @@ Mesh::Mesh(const MeshPrimitive primitive): _primitive{primitive}, _flags{ObjectF #endif _indexOffset(0), _indexType(IndexType::UnsignedInt), _indexBuffer(nullptr) { - (this->*Context::current()->state().mesh->createImplementation)(); + (this->*Context::current().state().mesh->createImplementation)(); } Mesh::Mesh(NoCreateT) noexcept: _id{0}, _primitive{MeshPrimitive::Triangles}, _flags{ObjectFlag::DeleteOnDestruction}, _count{0}, _baseVertex{0}, _instanceCount{1}, @@ -148,10 +148,10 @@ Mesh::~Mesh() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* Remove current vao from the state */ - GLuint& current = Context::current()->state().mesh->currentVAO; + GLuint& current = Context::current().state().mesh->currentVAO; if(current == _id) current = 0; - (this->*Context::current()->state().mesh->destroyImplementation)(); + (this->*Context::current().state().mesh->destroyImplementation)(); } Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), _flags{other._flags}, _count(other._count), _baseVertex{other._baseVertex}, _instanceCount{other._instanceCount}, @@ -207,18 +207,18 @@ inline void Mesh::createIfNotAlready() { std::string Mesh::label() { createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES - return Context::current()->state().debug->getLabelImplementation(GL_VERTEX_ARRAY, _id); + return Context::current().state().debug->getLabelImplementation(GL_VERTEX_ARRAY, _id); #else - return Context::current()->state().debug->getLabelImplementation(GL_VERTEX_ARRAY_KHR, _id); + return Context::current().state().debug->getLabelImplementation(GL_VERTEX_ARRAY_KHR, _id); #endif } Mesh& Mesh::setLabelInternal(const Containers::ArrayView label) { createIfNotAlready(); #ifndef MAGNUM_TARGET_GLES - Context::current()->state().debug->labelImplementation(GL_VERTEX_ARRAY, _id, label); + Context::current().state().debug->labelImplementation(GL_VERTEX_ARRAY, _id, label); #else - Context::current()->state().debug->labelImplementation(GL_VERTEX_ARRAY_KHR, _id, label); + Context::current().state().debug->labelImplementation(GL_VERTEX_ARRAY_KHR, _id, label); #endif return *this; } @@ -240,7 +240,7 @@ Mesh& Mesh::setIndexBuffer(Buffer& buffer, GLintptr offset, IndexType type, Unsi static_cast(start); static_cast(end); #endif - (this->*Context::current()->state().mesh->bindIndexBufferImplementation)(buffer); + (this->*Context::current().state().mesh->bindIndexBufferImplementation)(buffer); return *this; } @@ -264,7 +264,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr indexOffset) #endif { - const Implementation::MeshState& state = *Context::current()->state().mesh; + const Implementation::MeshState& state = *Context::current().state().mesh; /* Nothing to draw */ if(!count || !instanceCount) return; @@ -364,7 +364,7 @@ void Mesh::drawInternal(Int count, Int baseVertex, Int instanceCount, GLintptr i } void Mesh::bindVAO() { - GLuint& current = Context::current()->state().mesh->currentVAO; + GLuint& current = Context::current().state().mesh->currentVAO; if(current != _id) { /* Binding the VAO finally creates it */ _flags |= ObjectFlag::Created; @@ -419,7 +419,7 @@ void Mesh::attributePointerInternal(const Buffer& buffer, const GLuint location, } void Mesh::attributePointerInternal(AttributeLayout& attribute) { - (this->*Context::current()->state().mesh->attributePointerImplementation)(attribute); + (this->*Context::current().state().mesh->attributePointerImplementation)(attribute); } void Mesh::attributePointerImplementationDefault(AttributeLayout& attribute) { @@ -460,7 +460,7 @@ void Mesh::attributePointerImplementationDSAEXT(AttributeLayout& attribute) { } if(attribute.divisor) - (this->*Context::current()->state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); + (this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); } #endif @@ -485,7 +485,7 @@ void Mesh::vertexAttribPointer(AttributeLayout& attribute) { #ifndef MAGNUM_TARGET_GLES2 glVertexAttribDivisor(attribute.location, attribute.divisor); #else - (this->*Context::current()->state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); + (this->*Context::current().state().mesh->vertexAttribDivisorImplementation)(attribute.location, attribute.divisor); #endif } } @@ -537,7 +537,7 @@ void Mesh::bindIndexBufferImplementationVAO(Buffer& buffer) { /* Reset ElementArray binding to force explicit glBindBuffer call later */ /** @todo Do this cleaner way */ - Context::current()->state().buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::TargetHint::ElementArray)] = 0; + Context::current().state().buffer->bindings[Implementation::BufferState::indexForTarget(Buffer::TargetHint::ElementArray)] = 0; buffer.bindInternal(Buffer::TargetHint::ElementArray); } diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index b28d53861..8ae102e73 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/CMakeLists.txt b/src/Magnum/MeshTools/CMakeLists.txt index 2a0e8f1bc..6de79e52d 100644 --- a/src/Magnum/MeshTools/CMakeLists.txt +++ b/src/Magnum/MeshTools/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -56,8 +56,9 @@ set(MagnumMeshTools_HEADERS add_library(MagnumMeshToolsObjects OBJECT ${MagnumMeshTools_SRCS} ${MagnumMeshTools_HEADERS}) +target_include_directories(MagnumMeshToolsObjects PUBLIC $) if(NOT BUILD_STATIC) - set_target_properties(MagnumMeshToolsObjects PROPERTIES COMPILE_FLAGS "-DMagnumMeshToolsObjects_EXPORTS") + target_compile_definitions(MagnumMeshToolsObjects PRIVATE "MagnumMeshToolsObjects_EXPORTS") endif() if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumMeshToolsObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -85,13 +86,12 @@ if(BUILD_TESTS) add_library(MagnumMeshToolsTestLib ${SHARED_OR_STATIC} $ ${MagnumMeshTools_GracefulAssert_SRCS}) - set_target_properties(MagnumMeshToolsTestLib PROPERTIES - COMPILE_FLAGS "-DCORRADE_GRACEFUL_ASSERT -DMagnumMeshTools_EXPORTS" - DEBUG_POSTFIX "-d") + set_target_properties(MagnumMeshToolsTestLib PROPERTIES DEBUG_POSTFIX "-d") + target_compile_definitions(MagnumMeshToolsTestLib PRIVATE + "CORRADE_GRACEFUL_ASSERT" "MagnumMeshTools_EXPORTS") if(BUILD_STATIC_PIC) set_target_properties(MagnumMeshToolsTestLib PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(MagnumMeshToolsTestLib Magnum) # On Windows we need to install first and then run the tests to avoid "DLL @@ -106,5 +106,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum MeshTools library for superprojects -set(MAGNUM_MESHTOOLS_LIBRARY MagnumMeshTools CACHE INTERNAL "") +# Magnum MeshTools target alias for superprojects +add_library(Magnum::MeshTools ALIAS MagnumMeshTools) diff --git a/src/Magnum/MeshTools/CombineIndexedArrays.cpp b/src/Magnum/MeshTools/CombineIndexedArrays.cpp index 569458bc4..f1c17084d 100644 --- a/src/Magnum/MeshTools/CombineIndexedArrays.cpp +++ b/src/Magnum/MeshTools/CombineIndexedArrays.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/CombineIndexedArrays.h b/src/Magnum/MeshTools/CombineIndexedArrays.h index 9c3e92346..c7d07b114 100644 --- a/src/Magnum/MeshTools/CombineIndexedArrays.h +++ b/src/Magnum/MeshTools/CombineIndexedArrays.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Compile.cpp b/src/Magnum/MeshTools/Compile.cpp index 686edc056..86f91c44c 100644 --- a/src/Magnum/MeshTools/Compile.cpp +++ b/src/Magnum/MeshTools/Compile.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Compile.h b/src/Magnum/MeshTools/Compile.h index 408716ab8..f4567e228 100644 --- a/src/Magnum/MeshTools/Compile.h +++ b/src/Magnum/MeshTools/Compile.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/CompressIndices.cpp b/src/Magnum/MeshTools/CompressIndices.cpp index 5050264c5..a6cb88326 100644 --- a/src/Magnum/MeshTools/CompressIndices.cpp +++ b/src/Magnum/MeshTools/CompressIndices.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/CompressIndices.h b/src/Magnum/MeshTools/CompressIndices.h index 420168011..56bdab915 100644 --- a/src/Magnum/MeshTools/CompressIndices.h +++ b/src/Magnum/MeshTools/CompressIndices.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Duplicate.h b/src/Magnum/MeshTools/Duplicate.h index 1632b360e..1c118e0eb 100644 --- a/src/Magnum/MeshTools/Duplicate.h +++ b/src/Magnum/MeshTools/Duplicate.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/FlipNormals.cpp b/src/Magnum/MeshTools/FlipNormals.cpp index b471ffafd..64e9bdba1 100644 --- a/src/Magnum/MeshTools/FlipNormals.cpp +++ b/src/Magnum/MeshTools/FlipNormals.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/FlipNormals.h b/src/Magnum/MeshTools/FlipNormals.h index 15b9595f5..b6b71da20 100644 --- a/src/Magnum/MeshTools/FlipNormals.h +++ b/src/Magnum/MeshTools/FlipNormals.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/FullScreenTriangle.cpp b/src/Magnum/MeshTools/FullScreenTriangle.cpp index 26f317f21..27f0baf55 100644 --- a/src/Magnum/MeshTools/FullScreenTriangle.cpp +++ b/src/Magnum/MeshTools/FullScreenTriangle.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -62,7 +62,7 @@ std::pair, Mesh> fullScreenTriangle(Version version) { } std::pair, Mesh> fullScreenTriangle() { - return fullScreenTriangle(Context::current()->version()); + return fullScreenTriangle(Context::current().version()); } }} diff --git a/src/Magnum/MeshTools/FullScreenTriangle.h b/src/Magnum/MeshTools/FullScreenTriangle.h index 80af496dc..c1a95a681 100644 --- a/src/Magnum/MeshTools/FullScreenTriangle.h +++ b/src/Magnum/MeshTools/FullScreenTriangle.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/GenerateFlatNormals.cpp b/src/Magnum/MeshTools/GenerateFlatNormals.cpp index 242ff0c1c..e3a054c6c 100644 --- a/src/Magnum/MeshTools/GenerateFlatNormals.cpp +++ b/src/Magnum/MeshTools/GenerateFlatNormals.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/GenerateFlatNormals.h b/src/Magnum/MeshTools/GenerateFlatNormals.h index 7b0d0e9a8..08502fcb6 100644 --- a/src/Magnum/MeshTools/GenerateFlatNormals.h +++ b/src/Magnum/MeshTools/GenerateFlatNormals.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Interleave.h b/src/Magnum/MeshTools/Interleave.h index 67cbbb82c..ffa639103 100644 --- a/src/Magnum/MeshTools/Interleave.h +++ b/src/Magnum/MeshTools/Interleave.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -44,11 +44,12 @@ namespace Implementation { resolution (the functions would otherwise need to be de-inlined to break cyclic dependencies) */ struct AttributeCount { - template typename std::enable_if::value, std::size_t>::type operator()(const T& first, const U&... next) const { - CORRADE_ASSERT(sizeof...(next) == 0 || AttributeCount{}(next...) == first.size() || AttributeCount{}(next...) == ~std::size_t(0), "MeshTools::interleave(): attribute arrays don't have the same length, expected" << first.size() << "but got" << AttributeCount{}(next...), 0); - #if defined(CORRADE_NO_ASSERT) && !defined(CORRADE_GRACEFUL_ASSERT) - static_cast(sizeof...(next)); + template typename std::enable_if::value, std::size_t>::type operator()(const T& first, const U&... + #if !defined(CORRADE_NO_ASSERT) || defined(CORRADE_GRACEFUL_ASSERT) + next #endif + ) const { + CORRADE_ASSERT(sizeof...(next) == 0 || AttributeCount{}(next...) == first.size() || AttributeCount{}(next...) == ~std::size_t(0), "MeshTools::interleave(): attribute arrays don't have the same length, expected" << first.size() << "but got" << AttributeCount{}(next...), 0); return first.size(); } @@ -132,11 +133,8 @@ would be 21 bytes, causing possible performance loss. will be `std::vector` or `std::array`. @see @ref interleaveInto() -@todo remove `std::enable_if` when deprecated overloads are removed */ -/* enable_if to avoid clash with overloaded function below */ -template typename std::enable_if::value, Containers::Array>::type - interleave(const T& first, const U&... next) +template Containers::Array interleave(const T& first, const U&... next) { /* Compute buffer size and stride */ const std::size_t attributeCount = Implementation::AttributeCount{}(first, next...); diff --git a/src/Magnum/MeshTools/RemoveDuplicates.h b/src/Magnum/MeshTools/RemoveDuplicates.h index 51e9e5cc5..51abf7e2a 100644 --- a/src/Magnum/MeshTools/RemoveDuplicates.h +++ b/src/Magnum/MeshTools/RemoveDuplicates.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Subdivide.h b/src/Magnum/MeshTools/Subdivide.h index 4243b239b..eca357fea 100644 --- a/src/Magnum/MeshTools/Subdivide.h +++ b/src/Magnum/MeshTools/Subdivide.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Test/CMakeLists.txt b/src/Magnum/MeshTools/Test/CMakeLists.txt index c356e075d..5a324d4b6 100644 --- a/src/Magnum/MeshTools/Test/CMakeLists.txt +++ b/src/Magnum/MeshTools/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -25,18 +25,19 @@ corrade_add_test(MeshToolsCombineIndexedArraysTest CombineIndexedArraysTest.cpp LIBRARIES MagnumMeshToolsTestLib) corrade_add_test(MeshToolsCompressIndicesTest CompressIndicesTest.cpp LIBRARIES MagnumMeshToolsTestLib) -corrade_add_test(MeshToolsDuplicateTest DuplicateTest.cpp) +corrade_add_test(MeshToolsDuplicateTest DuplicateTest.cpp LIBRARIES Magnum) corrade_add_test(MeshToolsFlipNormalsTest FlipNormalsTest.cpp LIBRARIES MagnumMeshToolsTestLib) corrade_add_test(MeshToolsGenerateFlatNormalsTest GenerateFlatNormalsTest.cpp LIBRARIES MagnumMeshToolsTestLib) -corrade_add_test(MeshToolsInterleaveTest InterleaveTest.cpp) +corrade_add_test(MeshToolsInterleaveTest InterleaveTest.cpp LIBRARIES Magnum) corrade_add_test(MeshToolsRemoveDuplicatesTest RemoveDuplicatesTest.cpp LIBRARIES Magnum) -corrade_add_test(MeshToolsSubdivideTest SubdivideTest.cpp) +corrade_add_test(MeshToolsSubdivideTest SubdivideTest.cpp LIBRARIES Magnum) # corrade_add_test(MeshToolsSubdivideRemoveDuplicatesBenchmark SubdivideRemoveDuplicatesBenchmark.h SubdivideRemoveDuplicatesBenchmark.cpp MagnumPrimitives) corrade_add_test(MeshToolsTipsifyTest TipsifyTest.cpp LIBRARIES MagnumMeshTools) corrade_add_test(MeshToolsTransformTest TransformTest.cpp LIBRARIES MagnumMeshTools) # Graceful assert for testing -set_target_properties(MeshToolsCombineIndexedArraysTest +set_property(TARGET + MeshToolsCombineIndexedArraysTest MeshToolsInterleaveTest MeshToolsSubdivideTest - PROPERTIES COMPILE_FLAGS -DCORRADE_GRACEFUL_ASSERT) + APPEND PROPERTY COMPILE_DEFINITIONS "CORRADE_GRACEFUL_ASSERT") diff --git a/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp b/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp index d40dfecb4..a3a0d5264 100644 --- a/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp +++ b/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -48,7 +48,7 @@ CombineIndexedArraysTest::CombineIndexedArraysTest() { void CombineIndexedArraysTest::wrongIndexCount() { std::stringstream ss; - Error::setOutput(&ss); + Error redirectError{&ss}; std::vector a{0, 1, 0}; std::vector b{3, 4}; std::vector result = MeshTools::combineIndexArrays({a, b}); diff --git a/src/Magnum/MeshTools/Test/CompressIndicesTest.cpp b/src/Magnum/MeshTools/Test/CompressIndicesTest.cpp index 3a6125287..f6f0b8e72 100644 --- a/src/Magnum/MeshTools/Test/CompressIndicesTest.cpp +++ b/src/Magnum/MeshTools/Test/CompressIndicesTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -120,7 +120,7 @@ void CompressIndicesTest::compressAsShort() { TestSuite::Compare::Container); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; MeshTools::compressIndicesAs({65536}); CORRADE_COMPARE(out.str(), "MeshTools::compressIndicesAs(): type too small to represent value 65536\n"); } diff --git a/src/Magnum/MeshTools/Test/DuplicateTest.cpp b/src/Magnum/MeshTools/Test/DuplicateTest.cpp index 4596cbd89..872f403d0 100644 --- a/src/Magnum/MeshTools/Test/DuplicateTest.cpp +++ b/src/Magnum/MeshTools/Test/DuplicateTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Test/FlipNormalsTest.cpp b/src/Magnum/MeshTools/Test/FlipNormalsTest.cpp index 578836b3f..93b34c458 100644 --- a/src/Magnum/MeshTools/Test/FlipNormalsTest.cpp +++ b/src/Magnum/MeshTools/Test/FlipNormalsTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -47,7 +47,7 @@ FlipNormalsTest::FlipNormalsTest() { void FlipNormalsTest::wrongIndexCount() { std::stringstream ss; - Error::setOutput(&ss); + Error redirectError{&ss}; std::vector indices{0, 1}; MeshTools::flipFaceWinding(indices); diff --git a/src/Magnum/MeshTools/Test/GenerateFlatNormalsTest.cpp b/src/Magnum/MeshTools/Test/GenerateFlatNormalsTest.cpp index df1c3ae87..8d178bff5 100644 --- a/src/Magnum/MeshTools/Test/GenerateFlatNormalsTest.cpp +++ b/src/Magnum/MeshTools/Test/GenerateFlatNormalsTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -45,7 +45,7 @@ GenerateFlatNormalsTest::GenerateFlatNormalsTest() { void GenerateFlatNormalsTest::wrongIndexCount() { std::stringstream ss; - Error::setOutput(&ss); + Error redirectError{&ss}; std::vector indices; std::vector normals; std::tie(indices, normals) = MeshTools::generateFlatNormals({ diff --git a/src/Magnum/MeshTools/Test/InterleaveTest.cpp b/src/Magnum/MeshTools/Test/InterleaveTest.cpp index 9616fd5c4..3e44ce00b 100644 --- a/src/Magnum/MeshTools/Test/InterleaveTest.cpp +++ b/src/Magnum/MeshTools/Test/InterleaveTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -58,7 +58,7 @@ InterleaveTest::InterleaveTest() { void InterleaveTest::attributeCount() { std::stringstream ss; - Error::setOutput(&ss); + Error redirectError{&ss}; CORRADE_COMPARE((Implementation::AttributeCount{}(std::vector{0, 1, 2}, std::vector{0, 1, 2, 3, 4, 5})), std::size_t(0)); CORRADE_COMPARE(ss.str(), "MeshTools::interleave(): attribute arrays don't have the same length, expected 3 but got 6\n"); diff --git a/src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp b/src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp index 080d2e132..ca46f10f5 100644 --- a/src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp +++ b/src/Magnum/MeshTools/Test/RemoveDuplicatesTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.cpp b/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.cpp index 1080aa8ea..91cf0e786 100644 --- a/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.cpp +++ b/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.h b/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.h index 25defa16b..1d6fba46c 100644 --- a/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.h +++ b/src/Magnum/MeshTools/Test/SubdivideRemoveDuplicatesBenchmark.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Test/SubdivideTest.cpp b/src/Magnum/MeshTools/Test/SubdivideTest.cpp index 5a70aad95..37a8c63b3 100644 --- a/src/Magnum/MeshTools/Test/SubdivideTest.cpp +++ b/src/Magnum/MeshTools/Test/SubdivideTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -53,7 +53,7 @@ SubdivideTest::SubdivideTest() { void SubdivideTest::wrongIndexCount() { std::stringstream ss; - Error::setOutput(&ss); + Error redirectError{&ss}; std::vector positions; std::vector indices{0, 1}; diff --git a/src/Magnum/MeshTools/Test/TipsifyTest.cpp b/src/Magnum/MeshTools/Test/TipsifyTest.cpp index 5b36aa0e9..70171e479 100644 --- a/src/Magnum/MeshTools/Test/TipsifyTest.cpp +++ b/src/Magnum/MeshTools/Test/TipsifyTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Test/TransformTest.cpp b/src/Magnum/MeshTools/Test/TransformTest.cpp index 8af9c8a9f..6610adf27 100644 --- a/src/Magnum/MeshTools/Test/TransformTest.cpp +++ b/src/Magnum/MeshTools/Test/TransformTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Tipsify.cpp b/src/Magnum/MeshTools/Tipsify.cpp index d488de832..eac2cced0 100644 --- a/src/Magnum/MeshTools/Tipsify.cpp +++ b/src/Magnum/MeshTools/Tipsify.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Tipsify.h b/src/Magnum/MeshTools/Tipsify.h index a81761df7..b02d8a731 100644 --- a/src/Magnum/MeshTools/Tipsify.h +++ b/src/Magnum/MeshTools/Tipsify.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/Transform.h b/src/Magnum/MeshTools/Transform.h index ae5b7da2b..04589e5e1 100644 --- a/src/Magnum/MeshTools/Transform.h +++ b/src/Magnum/MeshTools/Transform.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshTools/visibility.h b/src/Magnum/MeshTools/visibility.h index 8cfda51de..b95f341cc 100644 --- a/src/Magnum/MeshTools/visibility.h +++ b/src/Magnum/MeshTools/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MeshView.cpp b/src/Magnum/MeshView.cpp index 154f608f4..3e5b8d70f 100644 --- a/src/Magnum/MeshView.cpp +++ b/src/Magnum/MeshView.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -52,7 +52,7 @@ void MeshView::draw(AbstractShaderProgram& shader, std::initializer_liststate().mesh->multiDrawImplementation(meshes); + Context::current().state().mesh->multiDrawImplementation(meshes); #endif } @@ -60,7 +60,7 @@ void MeshView::draw(AbstractShaderProgram& shader, std::initializer_list> meshes) { CORRADE_INTERNAL_ASSERT(meshes.size()); - const Implementation::MeshState& state = *Context::current()->state().mesh; + const Implementation::MeshState& state = *Context::current().state().mesh; Mesh& original = meshes.begin()->get()._original; Containers::Array count{meshes.size()}; diff --git a/src/Magnum/MeshView.h b/src/Magnum/MeshView.h index b135c95ec..516391fa3 100644 --- a/src/Magnum/MeshView.h +++ b/src/Magnum/MeshView.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/MultisampleTexture.cpp b/src/Magnum/MultisampleTexture.cpp index ac44ef5b8..ac9d6d1a6 100644 --- a/src/Magnum/MultisampleTexture.cpp +++ b/src/Magnum/MultisampleTexture.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -35,9 +35,9 @@ namespace Magnum { namespace Implementation { template<> Vector2i MAGNUM_EXPORT maxMultisampleTextureSize<2>() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return Vector2i{0}; @@ -46,10 +46,10 @@ template<> Vector2i MAGNUM_EXPORT maxMultisampleTextureSize<2>() { template<> Vector3i MAGNUM_EXPORT maxMultisampleTextureSize<3>() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return Vector3i{0}; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return Vector3i{0}; #endif diff --git a/src/Magnum/MultisampleTexture.h b/src/Magnum/MultisampleTexture.h index d806d4a0c..52e4e4d30 100644 --- a/src/Magnum/MultisampleTexture.h +++ b/src/Magnum/MultisampleTexture.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -160,6 +160,82 @@ template class MultisampleTexture: public AbstractTextur */ explicit MultisampleTexture(NoCreateT) noexcept: AbstractTexture{NoCreate, Implementation::multisampleTextureTarget()} {} + /** + * @brief Bind texture to given image unit + * @param imageUnit Image unit + * @param access Image access + * @param format Image format + * + * Available only on 2D multisample textures. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + template::type> + #endif + void bindImage(Int imageUnit, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, 0, false, 0, access, format); + } + + /** + * @brief Bind texture layer to given image unit + * @param imageUnit Image unit + * @param layer Texture layer + * @param access Image access + * @param format Image format + * + * Available only on 2D multisample texture arrays. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_es_extension Extension @es_extension{ANDROID,extension_pack_es31a}/ + * @es_extension{OES,texture_storage_multisample_2d_array} for + * multisample 2D array textures. + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + template::type> + #endif + void bindImage(Int imageUnit, Int layer, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, 0, false, layer, access, format); + } + + /** + * @brief Bind layered texture to given image unit + * @param imageUnit Image unit + * @param access Image access + * @param format Image format + * + * Available only on 2D multisample texture arrays. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImage(), @ref unbindImages(), @ref unbindImage(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_es_extension Extension @es_extension{ANDROID,extension_pack_es31a}/ + * @es_extension{OES,texture_storage_multisample_2d_array} for + * multisample 2D array textures. + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + template::type> + #endif + void bindImageLayered(Int imageUnit, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, 0, true, 0, access, format); + } + /** * @brief Set storage * @param samples Sample count @@ -210,7 +286,7 @@ template class MultisampleTexture: public AbstractTextur * OpenGL ES 3.0 and older. */ VectorTypeFor imageSize() { - return DataHelper::imageSize(*this, _target, 0); + return DataHelper::imageSize(*this, 0); } /** diff --git a/src/Magnum/OpenGL.cpp b/src/Magnum/OpenGL.cpp index d2570ce83..d508fe5b2 100644 --- a/src/Magnum/OpenGL.cpp +++ b/src/Magnum/OpenGL.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/OpenGL.h b/src/Magnum/OpenGL.h index fe198c051..e6e792a13 100644 --- a/src/Magnum/OpenGL.h +++ b/src/Magnum/OpenGL.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/PixelFormat.cpp b/src/Magnum/PixelFormat.cpp index 226b6295a..7059b7a38 100644 --- a/src/Magnum/PixelFormat.cpp +++ b/src/Magnum/PixelFormat.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/PixelFormat.h b/src/Magnum/PixelFormat.h index df6a44cd5..1c891fb96 100644 --- a/src/Magnum/PixelFormat.h +++ b/src/Magnum/PixelFormat.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -355,10 +355,10 @@ enum class PixelType: GLenum { /** * Each component unsigned int. - * @requires_gles30 For texture data only, extension @es_extension{OES,depth_texture} - * or @es_extension{ANGLE,depth_texture} in OpenGL ES 2.0. - * @requires_webgl20 For texture data only, extension - * @webgl_extension{WEBGL,depth_texture} in WebGL 1.0. + * @requires_gles30 In OpenGL ES 2.0 for texture data only, using extension + * @es_extension{OES,depth_texture} or @es_extension{ANGLE,depth_texture} + * @requires_webgl20 In WebGL 1.0 for texture data only, using extension + * @webgl_extension{WEBGL,depth_texture} */ UnsignedInt = GL_UNSIGNED_INT, @@ -598,8 +598,8 @@ enum class CompressedPixelFormat: GLenum { * RGTC compressed red channel, normalized unsigned. **Available only for * 2D, 2D array, cube map and cube map array textures.** * @requires_gl30 Extension @extension{EXT,texture_compression_rgtc} - * @requires_gl Generic texture compression is not available in OpenGL ES - * or WebGL. + * @requires_gl RGTC texture compression is not available in OpenGL ES or + * WebGL. */ RedRgtc1 = GL_COMPRESSED_RED_RGTC1, diff --git a/src/Magnum/PixelStorage.cpp b/src/Magnum/PixelStorage.cpp index da9d3a89b..704875b9b 100644 --- a/src/Magnum/PixelStorage.cpp +++ b/src/Magnum/PixelStorage.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -194,8 +194,8 @@ std::tuple, std::size_t> CompressedPixel void PixelStorage::applyInternal(const bool isUnpack) { Implementation::RendererState::PixelStorage& state = isUnpack ? - Context::current()->state().renderer->unpackPixelStorage : - Context::current()->state().renderer->packPixelStorage; + Context::current().state().renderer->unpackPixelStorage : + Context::current().state().renderer->packPixelStorage; #ifndef MAGNUM_TARGET_GLES /* Byte swap */ @@ -256,7 +256,7 @@ void PixelStorage::applyUnpack() { applyInternal(true); #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) - Implementation::RendererState::PixelStorage& state = Context::current()->state().renderer->unpackPixelStorage; + Implementation::RendererState::PixelStorage& state = Context::current().state().renderer->unpackPixelStorage; /* Image height (on ES for unpack only) */ if(state.imageHeight == Implementation::RendererState::PixelStorage::DisengagedValue || state.imageHeight != _imageHeight) @@ -273,8 +273,8 @@ void CompressedPixelStorage::applyInternal(const bool isUnpack) { PixelStorage::applyInternal(isUnpack); Implementation::RendererState::PixelStorage& state = isUnpack ? - Context::current()->state().renderer->unpackPixelStorage : - Context::current()->state().renderer->packPixelStorage; + Context::current().state().renderer->unpackPixelStorage : + Context::current().state().renderer->packPixelStorage; /* Compressed block width */ if(state.compressedBlockSize.x() == Implementation::RendererState::PixelStorage::DisengagedValue || state.compressedBlockSize.x() != _blockSize.x()) diff --git a/src/Magnum/PixelStorage.h b/src/Magnum/PixelStorage.h index 85cc49c8e..bd8b0420c 100644 --- a/src/Magnum/PixelStorage.h +++ b/src/Magnum/PixelStorage.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -414,25 +414,10 @@ namespace Implementation { } #endif - /* Use in compressed image upload functions */ #ifndef MAGNUM_TARGET_GLES - template std::size_t occupiedCompressedImageDataSize(const T& image, std::size_t dataSize) { - if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) - return dataSize; - - return ((Vector3i::pad(image.size(), 1) + image.storage().compressedBlockSize() - Vector3i{1})/image.storage().compressedBlockSize()).product()*image.storage().compressedBlockDataSize(); - } - #else - template std::size_t occupiedCompressedImageDataSize(const T&, std::size_t dataSize) { - return dataSize; - } - #endif - - #ifndef MAGNUM_TARGET_GLES - /* Used in image query functions */ - template std::size_t compressedImageDataSizeFor(const T& image, const Math::Vector& size, std::size_t dataSize) { + template std::pair compressedImageDataOffsetSizeFor(const T& image, const Math::Vector& size, std::size_t dataSize) { if(!image.storage().compressedBlockSize().product() || !image.storage().compressedBlockDataSize()) - return dataSize; + return {0, dataSize}; std::size_t offset; Math::Vector3 blockCount; @@ -441,7 +426,22 @@ namespace Implementation { const auto realBlockCount = Math::Vector3{(Vector3i::pad(size, 1) + image.storage().compressedBlockSize() - Vector3i{1})/image.storage().compressedBlockSize()}; - return offset + (blockCount.product() - (blockCount.x() - realBlockCount.x()) - (blockCount.y() - realBlockCount.y())*blockCount.x())*blockDataSize; + return {offset, (blockCount.product() - (blockCount.x() - realBlockCount.x()) - (blockCount.y() - realBlockCount.y())*blockCount.x())*blockDataSize}; + } + + /* Used in image query functions */ + template std::size_t compressedImageDataSizeFor(const T& image, const Math::Vector& size, std::size_t dataSize) { + auto r = compressedImageDataOffsetSizeFor(image, size, dataSize); + return r.first + r.second; + } + + /* Use in compressed image upload functions */ + template std::size_t occupiedCompressedImageDataSize(const T& image, std::size_t dataSize) { + return compressedImageDataOffsetSizeFor(image, image.size(), dataSize).second; + } + #else + template std::size_t occupiedCompressedImageDataSize(const T&, std::size_t dataSize) { + return dataSize; } #endif diff --git a/src/Magnum/Platform/AbstractXApplication.cpp b/src/Magnum/Platform/AbstractXApplication.cpp index e5e8b090e..e360f8ef6 100644 --- a/src/Magnum/Platform/AbstractXApplication.cpp +++ b/src/Magnum/Platform/AbstractXApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/AbstractXApplication.h b/src/Magnum/Platform/AbstractXApplication.h index e327d85b5..1f160651a 100644 --- a/src/Magnum/Platform/AbstractXApplication.h +++ b/src/Magnum/Platform/AbstractXApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -227,7 +227,12 @@ class AbstractXApplication::Configuration { /** @copydoc Sdl2Application::Configuration::size() */ Vector2i size() const { return _size; } - /** @copydoc Sdl2Application::Configuration::setSize() */ + /** + * @brief Set window size + * @return Reference to self (for method chaining) + * + * Default is `{800, 600}`. + */ Configuration& setSize(const Vector2i& size) { _size = size; return *this; diff --git a/src/Magnum/Platform/AndroidApplication.cpp b/src/Magnum/Platform/AndroidApplication.cpp index e1e7b0697..fadd23002 100644 --- a/src/Magnum/Platform/AndroidApplication.cpp +++ b/src/Magnum/Platform/AndroidApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -40,18 +40,18 @@ struct AndroidApplication::LogOutput { Utility::AndroidLogStreamBuffer debugBuffer, warningBuffer, errorBuffer; std::ostream debugStream, warningStream, errorStream; + Debug redirectDebug; + Warning redirectWarning; + Error redirectError; }; AndroidApplication::LogOutput::LogOutput(): debugBuffer(Utility::AndroidLogStreamBuffer::LogPriority::Info, "magnum"), warningBuffer(Utility::AndroidLogStreamBuffer::LogPriority::Warning, "magnum"), errorBuffer(Utility::AndroidLogStreamBuffer::LogPriority::Error, "magnum"), - debugStream(&debugBuffer), warningStream(&warningBuffer), errorStream(&errorBuffer) -{ - Debug::setOutput(&debugStream); - Warning::setOutput(&warningStream); - Error::setOutput(&errorStream); -} + debugStream(&debugBuffer), warningStream(&warningBuffer), errorStream(&errorBuffer), + redirectDebug{&debugStream}, redirectWarning{&warningStream}, redirectError{&errorStream} +{} #ifndef DOXYGEN_GENERATING_OUTPUT AndroidApplication::AndroidApplication(const Arguments& arguments): AndroidApplication{arguments, Configuration{}} {} diff --git a/src/Magnum/Platform/AndroidApplication.h b/src/Magnum/Platform/AndroidApplication.h index 00b869e47..5a9b5c39e 100644 --- a/src/Magnum/Platform/AndroidApplication.h +++ b/src/Magnum/Platform/AndroidApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -87,15 +87,11 @@ properly set **absolute** path to `toolchains/modules/` directory containing `Platform/Android.cmake`. mkdir build-android-arm && cd build-android-arm - cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ - -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-ARM.cmake" + cmake .. -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-ARM.cmake" cmake --build . mkdir build-android-x86 && cd build-android-x86 - cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ - -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-x86.cmake" + cmake .. -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Android-x86.cmake" cmake --build . See @ref cmake for more information. @@ -112,13 +108,11 @@ can be then installed directly on the device or emulator using `adb install`. For CMake you need to copy `FindEGL.cmake` and `FindOpenGLES2.cmake` (or `FindOpenGLES3.cmake`) from `modules/` directory in Magnum source to `modules/` dir in your project (so it is able to find EGL and OpenGL ES libraries). -Request `AndroidApplication` component, add -`${MAGNUM_ANDROIDAPPLICATION_INCLUDE_DIRS}` to include path and link to -`${MAGNUM_ANDROIDAPPLICATION_LIBRARIES}`. If no other application is requested, -you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. Again, see -@ref building and @ref cmake for more information. Note that unlike on other -platforms you need to create *shared library* instead of executable. The +Request `AndroidApplication` component of `Magnum` package and link to +`Magnum::AndroidApplication` target. If no other application is requested, you +can also use generic `Magnum::Application` alias to simplify porting. Again, +see @ref building and @ref cmake for more information. Note that unlike on +other platforms you need to create *shared library* instead of executable. The resulting binary then needs to be copied to `lib/armeabi-v7a` and `lib/x86`, you can do that automatically in CMake using the following commands: diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 6d0db0adf..1a1dbca71 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -37,7 +37,7 @@ set(MagnumPlatform_FILES ) install(FILES ${MagnumPlatform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) # Decide about platform-specific context for cross-platform toolkits -if(WITH_GLUTAPPLICATION OR WITH_SDL2APPLICATION) +if(WITH_GLFWAPPLICATION OR WITH_GLUTAPPLICATION OR WITH_SDL2APPLICATION) if(CORRADE_TARGET_APPLE AND NOT MAGNUM_TARGET_GLES) set(NEED_CGLCONTEXT 1) set(MagnumSomeContext_OBJECTS $) @@ -61,8 +61,6 @@ if(WITH_ANDROIDAPPLICATION) set(NEED_EGLCONTEXT 1) - include_directories(${ANDROID_NATIVE_APP_GLUE_INCLUDE_DIR}) - set(MagnumAndroidApplication_SRCS AndroidApplication.cpp Implementation/Egl.cpp @@ -77,9 +75,11 @@ if(WITH_ANDROIDAPPLICATION) ${MagnumAndroidApplication_HEADERS} ${MagnumAndroidApplication_PRIVATE_HEADERS} ${ANDROID_NATIVE_APP_GLUE_SRC}) + target_include_directories(MagnumAndroidApplication PUBLIC ${ANDROID_NATIVE_APP_GLUE_INCLUDE_DIR}) set_target_properties(MagnumAndroidApplication PROPERTIES DEBUG_POSTFIX "-d") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_link_libraries(MagnumAndroidApplication Magnum) install(FILES ${MagnumAndroidApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumAndroidApplication @@ -87,8 +87,38 @@ if(WITH_ANDROIDAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum AndroidApplication library for superprojects - set(MAGNUM_ANDROIDAPPLICATION_LIBRARY MagnumAndroidApplication CACHE INTERNAL "") + # Magnum AndroidApplication target alias for superprojects + add_library(Magnum::AndroidApplication ALIAS MagnumAndroidApplication) +endif() + +# GLFW application +if(WITH_GLFWAPPLICATION) + find_package(GLFW) + if(NOT GLFW_FOUND) + message(FATAL_ERROR "GLFW library, required by GlfwApplication, was not found. Set WITH_GLFWAPPLICATION to OFF to skip building it.") + endif() + + set(MagnumGlfwApplication_SRCS + GlfwApplication.cpp + ${MagnumSomeContext_OBJECTS}) + set(MagnumGlfwApplication_HEADERS GlfwApplication.h) + + add_library(MagnumGlfwApplication STATIC + ${MagnumGlfwApplication_SRCS} + ${MagnumGlfwApplication_HEADERS}) + set_target_properties(MagnumGlfwApplication PROPERTIES DEBUG_POSTFIX "-d") + # Assuming that PIC is not needed because the Application lib is always + # linked to the executable and not to any intermediate shared lib + target_link_libraries(MagnumGlfwApplication Magnum GLFW::GLFW) + + install(FILES ${MagnumGlfwApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumGlfwApplication + RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} + ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + + # Magnum GlfwApplication target alias for superprojects + add_library(Magnum::GlfwApplication ALIAS MagnumGlfwApplication) endif() # GLUT application @@ -109,6 +139,8 @@ if(WITH_GLUTAPPLICATION) set_target_properties(MagnumGlutApplication PROPERTIES DEBUG_POSTFIX "-d") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_include_directories(MagnumGlutApplication PUBLIC ${GLUT_INCLUDE_DIR}) + target_link_libraries(MagnumGlutApplication Magnum ${GLUT_glut_LIBRARY}) install(FILES ${MagnumGlutApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumGlutApplication @@ -116,8 +148,8 @@ if(WITH_GLUTAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum GlutApplication library for superprojects - set(MAGNUM_GLUTAPPLICATION_LIBRARY MagnumGlutApplication CACHE INTERNAL "") + # Magnum GlutApplication target alias for superprojects + add_library(Magnum::GlutApplication ALIAS MagnumGlutApplication) endif() # SDL2 application @@ -127,8 +159,6 @@ if(WITH_SDL2APPLICATION) message(FATAL_ERROR "SDL2 library, required by Sdl2Application, was not found. Set WITH_SDL2APPLICATION to OFF to skip building it.") endif() - include_directories(${SDL2_INCLUDE_DIR}) - set(MagnumSdl2Application_SRCS Sdl2Application.cpp ${MagnumSomeContext_OBJECTS}) @@ -140,6 +170,7 @@ if(WITH_SDL2APPLICATION) set_target_properties(MagnumSdl2Application PROPERTIES DEBUG_POSTFIX "-d") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_link_libraries(MagnumSdl2Application Magnum SDL2::SDL2) install(FILES ${MagnumSdl2Application_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumSdl2Application @@ -147,8 +178,8 @@ if(WITH_SDL2APPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum Sdl2Application library for superprojects - set(MAGNUM_SDL2APPLICATION_LIBRARY MagnumSdl2Application CACHE INTERNAL "") + # Magnum Sdl2Application target alias for superprojects + add_library(Magnum::Sdl2Application ALIAS MagnumSdl2Application) endif() # NaCl application @@ -166,12 +197,16 @@ if(WITH_NACLAPPLICATION) set_target_properties(MagnumNaClApplication PROPERTIES DEBUG_POSTFIX "-d") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_link_libraries(MagnumNaClApplication Magnum ppapi_cpp ppapi) install(FILES ${MagnumNaClApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumNaClApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + + # Magnum NaClApplication target alias for superprojects + add_library(Magnum::NaClApplication ALIAS MagnumNaClApplication) endif() # Windowless NaCl application @@ -187,9 +222,9 @@ if(WITH_WINDOWLESSNACLAPPLICATION) ${MagnumWindowlessNaClApplication_SRCS} ${MagnumWindowlessNaClApplication_HEADERS}) set_target_properties(MagnumWindowlessNaClApplication PROPERTIES DEBUG_POSTFIX "-d") - target_link_libraries(MagnumWindowlessNaClApplication Magnum ppapi_cpp ppapi) # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_link_libraries(MagnumWindowlessNaClApplication Magnum ppapi_cpp ppapi) install(FILES ${MagnumWindowlessNaClApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessNaClApplication @@ -197,8 +232,8 @@ if(WITH_WINDOWLESSNACLAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum WindowlessNaClApplication library for superprojects - set(MAGNUM_WINDOWLESSNACLAPPLICATION_LIBRARY MagnumWindowlessNaClApplication CACHE INTERNAL "") + # Magnum WindowlessNaClApplication target alias for superprojects + add_library(Magnum::WindowlessNaClApplication ALIAS MagnumWindowlessNaClApplication) endif() # JavaScript and CSS stuff for NaCl @@ -238,6 +273,8 @@ if(WITH_GLXAPPLICATION) set_target_properties(MagnumGlxApplication PROPERTIES DEBUG_POSTFIX "-d") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_include_directories(MagnumGlxApplication PUBLIC ${X11_INCLUDE_DIR}) + target_link_libraries(MagnumGlxApplication Magnum ${X11_LIBRARIES}) install(FILES ${MagnumGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumGlxApplication @@ -245,8 +282,8 @@ if(WITH_GLXAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum GlxApplication library for superprojects - set(MAGNUM_GLXAPPLICATION_LIBRARY MagnumGlxApplication CACHE INTERNAL "") + # Magnum GlxApplication target alias for superprojects + add_library(Magnum::GlxApplication ALIAS MagnumGlxApplication) endif() # X/EGL application @@ -268,6 +305,8 @@ if(WITH_XEGLAPPLICATION) set_target_properties(MagnumXEglApplication PROPERTIES DEBUG_POSTFIX "-d") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_include_directories(MagnumXEglApplication PUBLIC ${X11_INCLUDE_DIR}) + target_link_libraries(MagnumXEglApplication Magnum ${X11_LIBRARIES}) install(FILES ${MagnumXEglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumXEglApplication @@ -275,8 +314,8 @@ if(WITH_XEGLAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum XEglApplication library for superprojects - set(MAGNUM_XEGLAPPLICATION_LIBRARY MagnumXEglApplication CACHE INTERNAL "") + # Magnum XEglApplication target alias for superprojects + add_library(Magnum::XEglApplication ALIAS MagnumXEglApplication) endif() if(WITH_WINDOWLESSGLXAPPLICATION OR NEED_ABSTRACTXAPPLICATION) @@ -286,6 +325,38 @@ if(WITH_WINDOWLESSGLXAPPLICATION OR NEED_ABSTRACTXAPPLICATION) endif() endif() +# Windowless EGL application +if(WITH_WINDOWLESSEGLAPPLICATION) + set(NEED_EGLCONTEXT 1) + + set(MagnumWindowlessEglApplication_SRCS + WindowlessEglApplication.cpp + Implementation/Egl.cpp + $) + set(MagnumWindowlessEglApplication_HEADERS + WindowlessEglApplication.h) + set(MagnumWindowlessEglApplication_PRIVATE_HEADERS + Implementation/Egl.h) + + add_library(MagnumWindowlessEglApplication STATIC + ${MagnumWindowlessEglApplication_SRCS} + ${MagnumWindowlessEglApplication_HEADERS} + ${MagnumWindowlessEglApplication_PRIVATE_HEADERS}) + set_target_properties(MagnumWindowlessEglApplication PROPERTIES DEBUG_POSTFIX "-d") + target_link_libraries(MagnumWindowlessEglApplication Magnum EGL::EGL) + # Assuming that PIC is not needed because the Application lib is always + # linked to the executable and not to any intermediate shared lib + + install(FILES ${MagnumWindowlessEglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumWindowlessEglApplication + RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} + ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + + # Magnum WindowlessEglApplication target alias for superprojects + add_library(Magnum::WindowlessEglApplication ALIAS MagnumWindowlessEglApplication) +endif() + # Windowless GLX application if(WITH_WINDOWLESSGLXAPPLICATION) set(NEED_GLXCONTEXT 1) @@ -299,12 +370,12 @@ if(WITH_WINDOWLESSGLXAPPLICATION) ${MagnumWindowlessGlxApplication_SRCS} ${MagnumWindowlessGlxApplication_HEADERS}) # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumWindowlessGlxApplication PROPERTIES - COMPILE_FLAGS "-Wno-old-style-cast" - DEBUG_POSTFIX "-d") - target_link_libraries(MagnumWindowlessGlxApplication Magnum ${X11_LIBRARIES}) + set_target_properties(MagnumWindowlessGlxApplication PROPERTIES DEBUG_POSTFIX "-d") + target_compile_options(MagnumWindowlessGlxApplication PRIVATE "-Wno-old-style-cast") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_include_directories(MagnumWindowlessGlxApplication PUBLIC ${X11_INCLUDE_DIR}) + target_link_libraries(MagnumWindowlessGlxApplication Magnum ${X11_LIBRARIES}) install(FILES ${MagnumWindowlessGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessGlxApplication @@ -312,8 +383,43 @@ if(WITH_WINDOWLESSGLXAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum WindowlessGlxApplication library for superprojects - set(MAGNUM_WINDOWLESSGLXAPPLICATION_LIBRARY MagnumWindowlessGlxApplication CACHE INTERNAL "") + # Magnum WindowlessGlxApplication target alias for superprojects + add_library(Magnum::WindowlessGlxApplication ALIAS MagnumWindowlessGlxApplication) +endif() + +# Windowless iOS application +if(WITH_WINDOWLESSIOSAPPLICATION) + set(NEED_EGLCONTEXT 1) + + # We need to link to Foundation framework to use ObjC + find_library(_MAGNUM_IOS_FOUNDATION_FRAMEWORK_LIBRARY Foundation) + mark_as_advanced(_MAGNUM_IOS_FOUNDATION_FRAMEWORK_LIBRARY) + + set(MagnumWindowlessIosApplication_SRCS + WindowlessIosApplication.mm + $) + set(MagnumWindowlessIosApplication_HEADERS + WindowlessIosApplication.h) + + add_library(MagnumWindowlessIosApplication STATIC + ${MagnumWindowlessIosApplication_SRCS} + ${MagnumWindowlessIosApplication_HEADERS}) + set_target_properties(MagnumWindowlessIosApplication PROPERTIES DEBUG_POSTFIX "-d") + target_link_libraries(MagnumWindowlessIosApplication + Magnum + EGL::EGL + ${_MAGNUM_IOS_FOUNDATION_FRAMEWORK_LIBRARY}) + # Assuming that PIC is not needed because the Application lib is always + # linked to the executable and not to any intermediate shared lib + + install(FILES ${MagnumWindowlessIosApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumWindowlessIosApplication + RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} + ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + + # Magnum WindowlessIosApplication target alias for superprojects + add_library(Magnum::WindowlessIosApplication ALIAS MagnumWindowlessIosApplication) endif() # Windowless WGL application @@ -328,12 +434,11 @@ if(WITH_WINDOWLESSWGLAPPLICATION) add_library(MagnumWindowlessWglApplication STATIC ${MagnumWindowlessWglApplication_SRCS} ${MagnumWindowlessWglApplication_HEADERS}) - set_target_properties(MagnumWindowlessWglApplication PROPERTIES - COMPILE_FLAGS "-DUNICODE" - DEBUG_POSTFIX "-d") - target_link_libraries(MagnumWindowlessWglApplication Magnum) + set_target_properties(MagnumWindowlessWglApplication PROPERTIES DEBUG_POSTFIX "-d") + target_compile_definitions(MagnumWindowlessWglApplication PRIVATE "UNICODE") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_link_libraries(MagnumWindowlessWglApplication Magnum) install(FILES ${MagnumWindowlessWglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessWglApplication @@ -341,8 +446,8 @@ if(WITH_WINDOWLESSWGLAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum WindowlessWglApplication library for superprojects - set(MAGNUM_WINDOWLESSWGLAPPLICATION_LIBRARY MagnumWindowlessWglApplication CACHE INTERNAL "") + # Magnum WindowlessWglApplication target alias for superprojects + add_library(Magnum::WindowlessWglApplication ALIAS MagnumWindowlessWglApplication) endif() # Windowless Windows/EGL application @@ -362,12 +467,11 @@ if(WITH_WINDOWLESSWINDOWSEGLAPPLICATION) ${MagnumWindowlessWindowsEglApplication_SRCS} ${MagnumWindowlessWindowsEglApplication_HEADERS} ${MagnumWindowlessWindowsEglApplication_PRIVATE_HEADERS}) - set_target_properties(MagnumWindowlessWindowsEglApplication PROPERTIES - COMPILE_FLAGS "-DUNICODE" - DEBUG_POSTFIX "-d") - target_link_libraries(MagnumWindowlessWindowsEglApplication Magnum ${EGL_LIBRARY}) + set_target_properties(MagnumWindowlessWindowsEglApplication PROPERTIES DEBUG_POSTFIX "-d") + target_compile_definitions(MagnumWindowlessWindowsEglApplication PRIVATE "UNICODE") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_link_libraries(MagnumWindowlessWindowsEglApplication Magnum EGL::EGL) install(FILES ${MagnumWindowlessWindowsEglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessWindowsEglApplication @@ -375,8 +479,8 @@ if(WITH_WINDOWLESSWINDOWSEGLAPPLICATION) LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum WindowlessWindowsEglApplication library for superprojects - set(MAGNUM_WINDOWLESSWINDOWSEGLAPPLICATION_LIBRARY MagnumWindowlessWindowsEglApplication CACHE INTERNAL "") + # Magnum WindowlessWindowsEglApplication target alias for superprojects + add_library(Magnum::WindowlessWindowsEglApplication ALIAS MagnumWindowlessWindowsEglApplication) endif() # Windowless CGL application @@ -392,18 +496,18 @@ if(WITH_WINDOWLESSCGLAPPLICATION) ${MagnumWindowlessCglApplication_SRCS} ${MagnumWindowlessCglApplication_HEADERS}) set_target_properties(MagnumWindowlessCglApplication PROPERTIES DEBUG_POSTFIX "-d") - target_link_libraries(MagnumWindowlessCglApplication Magnum) # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib + target_link_libraries(MagnumWindowlessCglApplication Magnum) - install(FILES ${MagnumWindowlessGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumWindowlessCglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessCglApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) # Magnum WindowlessCglApplication library for superprojects - set(MAGNUM_WINDOWLESSCGLAPPLICATION_LIBRARY MagnumWindowlessCglApplication CACHE INTERNAL "") + add_library(Magnum::WindowlessCglApplication ALIAS MagnumWindowlessCglApplication) endif() # Abstract X application @@ -414,8 +518,9 @@ if(NEED_ABSTRACTXAPPLICATION) add_library(MagnumAbstractXApplication OBJECT ${MagnumAbstractXApplication_SRCS} ${MagnumAbstractXApplication_HEADERS}) + target_include_directories(MagnumAbstractXApplication PUBLIC $) # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumAbstractXApplication PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + target_compile_options(MagnumAbstractXApplication PRIVATE "-Wno-old-style-cast") # Assuming that PIC is not needed because the Application lib is always # linked to the executable and not to any intermediate shared lib @@ -433,8 +538,9 @@ if(NEED_GLXCONTEXTHANDLER) add_library(MagnumGlxContextHandler OBJECT ${MagnumGlxContextHandler_SRCS} ${MagnumGlxContextHandler_PRIVATE_HEADERS}) + target_include_directories(MagnumGlxContextHandler PUBLIC $) # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumGlxContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + target_compile_options(MagnumGlxContextHandler PRIVATE "-Wno-old-style-cast") # Assuming that PIC is not needed because this is part of Application lib, # which is always linked to the executable and not to any intermediate # shared lib @@ -444,11 +550,9 @@ endif() if(NEED_EGLCONTEXTHANDLER) find_package(EGL) if(NOT EGL_FOUND) - message(FATAL_ERROR "EGL library, required by some window contexts, was not found. Set WITH_*EGL*APPLICATION to OFF to skip building them.") + message(FATAL_ERROR "EGL library, required by some contexts, was not found. Set WITH_*EGL*APPLICATION to OFF to skip building them.") endif() - include_directories(${EGL_INCLUDE_DIR}) - set(MagnumEglContextHandler_SRCS Implementation/EglContextHandler.cpp Implementation/Egl.cpp) @@ -460,26 +564,41 @@ if(NEED_EGLCONTEXTHANDLER) add_library(MagnumEglContextHandler OBJECT ${MagnumEglContextHandler_SRCS} ${MagnumEglContextHandler_PRIVATE_HEADERS}) + target_include_directories(MagnumEglContextHandler PUBLIC + $ + $) # X11 macros are a mess, disable warnings for C-style casts - set_target_properties(MagnumEglContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") + target_compile_options(MagnumEglContextHandler PRIVATE "-Wno-old-style-cast") # Assuming that PIC is not needed because this is part of Application lib, # which is always linked to the executable and not to any intermediate # shared lib endif() # Platform-specific sources for context library -set(MagnumContext_SRCS Implementation/OpenGLFunctionLoader.cpp) +set(MagnumContext_SRCS ) +if(NOT CORRADE_TARGET_IOS) + list(APPEND MagnumContext_SRCS Implementation/OpenGLFunctionLoader.cpp) +endif() if(NOT MAGNUM_TARGET_GLES) list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GL/flextGLPlatform.cpp) elseif(MAGNUM_TARGET_GLES AND MAGNUM_TARGET_GLES2) - list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp) + if(CORRADE_TARGET_IOS) + list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp) + else() + list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp) + endif() elseif(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_GLES2) - list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp) + if(CORRADE_TARGET_IOS) + list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp) + else() + list(APPEND MagnumContext_SRCS ../../MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp) + endif() endif() # CGL context if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT) add_library(MagnumCglContextObjects OBJECT ${MagnumContext_SRCS}) + target_include_directories(MagnumCglContextObjects PUBLIC $) if(BUILD_STATIC_PIC) set_target_properties(MagnumCglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -494,14 +613,15 @@ if(NEED_CGLCONTEXT OR WITH_CGLCONTEXT) if(BUILD_STATIC_PIC) set_target_properties(MagnumCglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() + target_link_libraries(MagnumCglContext Magnum) install(TARGETS MagnumCglContext RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum CglContext library for superprojects - set(MAGNUM_CGLCONTEXT_LIBRARY MagnumCglContext CACHE INTERNAL "") + # Magnum CglContext target alias for superprojects + add_library(Magnum::CglContext ALIAS MagnumCglContext) endif() endif() @@ -509,39 +629,46 @@ endif() if(NEED_EGLCONTEXT OR WITH_EGLCONTEXT) find_package(EGL) if(NOT EGL_FOUND) - message(FATAL_ERROR "EGL library, required by some window contexts, was not found. Set WITH_*APPLICATION and/or WITH_EGLCONTEXT to OFF to skip building them.") + message(FATAL_ERROR "EGL library, required by some contexts, was not found. Set WITH_*APPLICATION and/or WITH_EGLCONTEXT to OFF to skip building them.") endif() - include_directories(${EGL_INCLUDE_DIR}) - add_library(MagnumEglContextObjects OBJECT ${MagnumContext_SRCS}) - set_target_properties(MagnumEglContextObjects PROPERTIES COMPILE_DEFINITIONS "MAGNUM_PLATFORM_USE_EGL") + target_include_directories(MagnumEglContextObjects PUBLIC + $ + $) + target_compile_definitions(MagnumEglContextObjects PRIVATE "MAGNUM_PLATFORM_USE_EGL") if(BUILD_STATIC_PIC) set_target_properties(MagnumEglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() # Also create proper static library, if requested if(WITH_EGLCONTEXT) - add_library(MagnumEglContext STATIC $) + add_library(MagnumEglContext STATIC + $ + ../dummy.cpp) # XCode workaround, see file comment for details set_target_properties(MagnumEglContext PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumEglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() + target_link_libraries(MagnumEglContext Magnum EGL::EGL) install(TARGETS MagnumEglContext RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum EglContext library for superprojects - set(MAGNUM_EGLCONTEXT_LIBRARY MagnumEglContext CACHE INTERNAL "") + # Magnum EglContext target alias for superprojects + add_library(Magnum::EglContext ALIAS MagnumEglContext) endif() endif() # GLX context if(NEED_GLXCONTEXT OR WITH_GLXCONTEXT) add_library(MagnumGlxContextObjects OBJECT ${MagnumContext_SRCS}) - set_target_properties(MagnumGlxContextObjects PROPERTIES COMPILE_DEFINITIONS "MAGNUM_PLATFORM_USE_GLX") + target_include_directories(MagnumGlxContextObjects PUBLIC + $ + ${X11_INCLUDE_DIR}) + target_compile_definitions(MagnumGlxContextObjects PRIVATE "MAGNUM_PLATFORM_USE_GLX") if(BUILD_STATIC_PIC) set_target_properties(MagnumGlxContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -553,46 +680,55 @@ if(NEED_GLXCONTEXT OR WITH_GLXCONTEXT) if(BUILD_STATIC_PIC) set_target_properties(MagnumGlxContext PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() + target_include_directories(MagnumGlxContext PUBLIC ${X11_INCLUDE_DIR}) + target_link_libraries(MagnumGlxContext Magnum ${X11_LIBRARIES}) install(TARGETS MagnumGlxContext RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum GlxContext library for superprojects - set(MAGNUM_GLXCONTEXT_LIBRARY MagnumGlxContext CACHE INTERNAL "") + # Magnum GlxContext target alias for superprojects + add_library(Magnum::GlxContext ALIAS MagnumGlxContext) endif() endif() # WGL context if(NEED_WGLCONTEXT OR WITH_WGLCONTEXT) add_library(MagnumWglContextObjects OBJECT ${MagnumContext_SRCS}) + target_include_directories(MagnumWglContextObjects PUBLIC $) if(BUILD_STATIC_PIC) set_target_properties(MagnumWglContextObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() # Also create proper static library, if requested - if(WITH_GLXCONTEXT) + if(WITH_WGLCONTEXT) add_library(MagnumWglContext STATIC $) set_target_properties(MagnumWglContext PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumWglContext PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() + target_link_libraries(MagnumWglContext Magnum) install(TARGETS MagnumWglContext RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - # Magnum WglContext library for superprojects - set(MAGNUM_WGLCONTEXT_LIBRARY MagnumWglContext CACHE INTERNAL "") + # Magnum WglContext target alias for superprojects + add_library(Magnum::WglContext ALIAS MagnumWglContext) endif() endif() # Magnum Info if(WITH_MAGNUMINFO) add_executable(magnum-info magnum-info.cpp) - if(CORRADE_TARGET_APPLE) + target_link_libraries(magnum-info Magnum) + if(MAGNUM_TARGET_HEADLESS) + target_link_libraries(magnum-info MagnumWindowlessEglApplication) + elseif(CORRADE_TARGET_IOS) + target_link_libraries(magnum-info MagnumWindowlessIosApplication) + elseif(CORRADE_TARGET_APPLE) target_link_libraries(magnum-info MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_NACL) target_link_libraries(magnum-info MagnumWindowlessNaClApplication) @@ -607,14 +743,21 @@ if(WITH_MAGNUMINFO) else() message(FATAL_ERROR "magnum-info is not available on this platform. Set WITH_MAGNUMINFO to OFF to skip building it.") endif() - target_link_libraries(magnum-info Magnum) install(TARGETS magnum-info DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}) if(CORRADE_TARGET_NACL) install(FILES magnum-info-nacl.html DESTINATION ${MAGNUM_DATA_INSTALL_DIR} RENAME magnum-info.html) install(FILES magnum-info-nacl.nmf DESTINATION ${MAGNUM_DATA_INSTALL_DIR} RENAME magnum-info.nmf) list(APPEND MagnumPlatform_FILES magnum-info-nacl.html magnum-info-nacl.nmf) + elseif(CORRADE_TARGET_IOS) + set_target_properties(magnum-info PROPERTIES + MACOSX_BUNDLE ON + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in + XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES") endif() + + # Magnum info target alias for superprojects + add_executable(Magnum::info ALIAS magnum-info) endif() # Force IDEs display also all header files and additional files in project view diff --git a/src/Magnum/Platform/Context.h b/src/Magnum/Platform/Context.h index e34ea4405..4bb498dcc 100644 --- a/src/Magnum/Platform/Context.h +++ b/src/Magnum/Platform/Context.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/GlfwApplication.cpp b/src/Magnum/Platform/GlfwApplication.cpp new file mode 100644 index 000000000..ff2ffddc7 --- /dev/null +++ b/src/Magnum/Platform/GlfwApplication.cpp @@ -0,0 +1,240 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + Copyright © 2016 Jonathan Hale + + 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 "GlfwApplication.h" + +#include + +#include "Magnum/Version.h" +#include "Magnum/Platform/Context.h" +#include "Magnum/Platform/ScreenedApplication.hpp" + +namespace Magnum { namespace Platform { + +GlfwApplication* GlfwApplication::_instance = nullptr; + +#ifdef GLFW_TRUE +/* The docs say that it's the same, verify that just in case */ +static_assert(GLFW_TRUE == true && GLFW_FALSE == false, "GLFW does not have sane bool values"); +#endif + +#ifndef DOXYGEN_GENERATING_OUTPUT +GlfwApplication::GlfwApplication(const Arguments& arguments): GlfwApplication{arguments, Configuration{}} {} +#endif + +GlfwApplication::GlfwApplication(const Arguments& arguments, const Configuration& configuration): GlfwApplication{arguments, nullptr} { + createContext(configuration); +} + +GlfwApplication::GlfwApplication(const Arguments& arguments, std::nullptr_t): + _context{new Context{NoCreate, arguments.argc, arguments.argv}}, + _needsRedraw(true) +{ + /* Save global instance */ + _instance = this; + + /* Init GLFW */ + glfwSetErrorCallback(staticErrorCallback); + + if(!glfwInit()) { + Error() << "Could not initialize GLFW"; + std::exit(8); + } +} + +void GlfwApplication::createContext() { createContext({}); } + +void GlfwApplication::createContext(const Configuration& configuration) { + if(!tryCreateContext(configuration)) std::exit(1); +} + +bool GlfwApplication::tryCreateContext(const Configuration& configuration) { + CORRADE_ASSERT(_context->version() == Version::None, "Platform::GlfwApplication::tryCreateContext(): context already created", false); + + /* Window flags */ + GLFWmonitor* monitor = nullptr; /* Needed for setting fullscreen */ + if (configuration.windowFlags() >= Configuration::WindowFlag::Fullscreen) { + monitor = glfwGetPrimaryMonitor(); + glfwWindowHint(GLFW_AUTO_ICONIFY, configuration.windowFlags() >= Configuration::WindowFlag::AutoIconify); + } else { + const Configuration::WindowFlags& flags = configuration.windowFlags(); + glfwWindowHint(GLFW_RESIZABLE, flags >= Configuration::WindowFlag::Resizeable); + glfwWindowHint(GLFW_VISIBLE, !(flags >= Configuration::WindowFlag::Hidden)); + #ifdef GLFW_MAXIMIZED + glfwWindowHint(GLFW_MAXIMIZED, flags >= Configuration::WindowFlag::Maximized); + #endif + glfwWindowHint(GLFW_ICONIFIED, flags >= Configuration::WindowFlag::Minimized); + glfwWindowHint(GLFW_FLOATING, flags >= Configuration::WindowFlag::Floating); + } + glfwWindowHint(GLFW_FLOATING, configuration.windowFlags() >= Configuration::WindowFlag::Focused); + + /* Context window hints */ + glfwWindowHint(GLFW_SAMPLES, configuration.sampleCount()); + glfwWindowHint(GLFW_SRGB_CAPABLE, configuration.isSRGBCapable()); + + const Configuration::Flags& flags = configuration.flags(); + #ifdef GLFW_CONTEXT_NO_ERROR + glfwWindowHint(GLFW_CONTEXT_NO_ERROR, flags >= Configuration::Flag::NoError); + #endif + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, flags >= Configuration::Flag::Debug); + glfwWindowHint(GLFW_STEREO, flags >= Configuration::Flag::Stereo); + + /* Cursor flags */ + glfwWindowHint(GLFW_CURSOR, Int(configuration.cursorMode())); + + /* Set context version, if requested */ + if(configuration.version() != Version::None) { + Int major, minor; + std::tie(major, minor) = version(configuration.version()); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor); + #ifndef MAGNUM_TARGET_GLES + if(configuration.version() >= Version::GL310) { + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, true); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + } + #else + glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); + #endif + } + + /* Set context flags */ + _window = glfwCreateWindow(configuration.size().x(), configuration.size().y(), configuration.title().c_str(), monitor, nullptr); + if(!_window) { + Error() << "Platform::GlfwApplication::tryCreateContext(): cannot create context"; + glfwTerminate(); + return false; + } + + /* Set callbacks */ + glfwSetFramebufferSizeCallback(_window, staticViewportEvent); + glfwSetKeyCallback(_window, staticKeyEvent); + glfwSetCursorPosCallback(_window, staticMouseMoveEvent); + glfwSetMouseButtonCallback(_window, staticMouseEvent); + glfwSetScrollCallback(_window, staticMouseScrollEvent); + + glfwMakeContextCurrent(_window); + + /* Return true if the initialization succeeds */ + return _context->tryCreate(); +} + +GlfwApplication::~GlfwApplication() { + glfwDestroyWindow(_window); + glfwTerminate(); +} + +void GlfwApplication::setSwapInterval(const Int interval) { + glfwSwapInterval(interval); +} + +int GlfwApplication::exec() { + while(!glfwWindowShouldClose(_window)) { + if(_needsRedraw) { + drawEvent(); + } + glfwPollEvents(); + } + return 0; +} + +void GlfwApplication::staticKeyEvent(GLFWwindow*, int key, int, int action, int mods) { + KeyEvent e(static_cast(key), {static_cast(mods)}); + + if(action == GLFW_PRESS) { + _instance->keyPressEvent(e); + } else if(action == GLFW_RELEASE) { + _instance->keyReleaseEvent(e); + } /* we don't handle GLFW_REPEAT */ +} + +void GlfwApplication::staticMouseMoveEvent(GLFWwindow* window, double x, double y) { + MouseMoveEvent e{Vector2i{Int(x), Int(y)}, KeyEvent::getCurrentGlfwModifiers(window)}; + _instance->mouseMoveEvent(e); +} + +void GlfwApplication::staticMouseEvent(GLFWwindow*, int button, int action, int mods) { + MouseEvent e(static_cast(button), {static_cast(mods)}); + + if(action == GLFW_PRESS) { + _instance->mousePressEvent(e); + } else if(action == GLFW_RELEASE) { + _instance->mouseReleaseEvent(e); + } /* we don't handle GLFW_REPEAT */ +} + +void GlfwApplication::staticMouseScrollEvent(GLFWwindow* window, double xoffset, double yoffset) { + MouseScrollEvent e(Vector2d{xoffset, yoffset}, KeyEvent::getCurrentGlfwModifiers(window)); + _instance->mouseScrollEvent(e); + + if(yoffset != 0.0) { + MouseEvent e1((yoffset > 0.0) ? MouseEvent::Button::WheelUp : MouseEvent::Button::WheelDown, KeyEvent::getCurrentGlfwModifiers(window)); + _instance->mousePressEvent(e1); + } +} + +void GlfwApplication::staticErrorCallback(int, const char* description) { + Error() << description; +} + +auto GlfwApplication::KeyEvent::getCurrentGlfwModifiers(GLFWwindow* window) -> Modifiers { + static_assert(GLFW_PRESS == true && GLFW_RELEASE == false, + "GLFW press and release constants do not correspond to bool values"); + + Modifiers mods; + if(glfwGetKey(window, Int(Key::LeftShift)) || glfwGetKey(window, Int(Key::RightShift))) + mods |= Modifier::Shift; + if(glfwGetKey(window, Int(Key::LeftAlt)) || glfwGetKey(window, Int(Key::RightAlt))) + mods |= Modifier::Alt; + if(glfwGetKey(window, Int(Key::LeftCtrl)) || glfwGetKey(window, Int(Key::RightCtrl))) + mods |= Modifier::Ctrl; + if(glfwGetKey(window, Int(Key::RightSuper))) + mods |= Modifier::AltGr; + + return mods; +} + +void GlfwApplication::viewportEvent(const Vector2i&) {} +void GlfwApplication::keyPressEvent(KeyEvent&) {} +void GlfwApplication::keyReleaseEvent(KeyEvent&) {} +void GlfwApplication::mousePressEvent(MouseEvent&) {} +void GlfwApplication::mouseReleaseEvent(MouseEvent&) {} +void GlfwApplication::mouseMoveEvent(MouseMoveEvent&) {} +void GlfwApplication::mouseScrollEvent(MouseScrollEvent&) {} + +GlfwApplication::Configuration::Configuration(): + _title{"Magnum GLFW Application"}, + _size{800, 600}, _sampleCount{0}, + _version{Version::None}, + _windowFlags{WindowFlag::Focused}, + _cursorMode{CursorMode::Normal} {} + +GlfwApplication::Configuration::~Configuration() = default; + +template class BasicScreen; +template class BasicScreenedApplication; + +}} diff --git a/src/Magnum/Platform/GlfwApplication.h b/src/Magnum/Platform/GlfwApplication.h new file mode 100644 index 000000000..77e82bf72 --- /dev/null +++ b/src/Magnum/Platform/GlfwApplication.h @@ -0,0 +1,830 @@ +#ifndef Magnum_Platform_GlfwApplication_h +#define Magnum_Platform_GlfwApplication_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + Copyright © 2016 Jonathan Hale + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Class @ref Magnum::Platform::GlfwApplication, macro @ref MAGNUM_GLFWAPPLICATION_MAIN() + */ + +#include +#include + +#include "Magnum/Magnum.h" +#include "Magnum/Math/Vector2.h" +#include "Magnum/Platform/Platform.h" + +/* We must include our own GL headers first to avoid conflicts */ +#include "Magnum/OpenGL.h" + +#include + +namespace Magnum { namespace Platform { + +/** @nosubgrouping +@brief GLFW application + +Application using GLFW toolkit. Supports keyboard and mouse handling with +support for changing cursor and mouse tracking and warping. + +This application library is available on all platforms where GLFW is ported. It +depends on **GLFW** library and is built if `WITH_GLFWAPPLICATION` is enabled +in CMake. + +## Bootstrap application + +Fully contained base application using @ref GlfwApplication along with CMake +setup is available in `base-glfw` branch of +[Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) repository, +download it as [tar.gz](https://github.com/mosra/magnum-bootstrap/archive/base-glfw.tar.gz) +or [zip](https://github.com/mosra/magnum-bootstrap/archive/base-glfw.zip) file. +After extracting the downloaded archive you can build and run the application +with these four commands: + + mkdir build && cd build + cmake .. + cmake --build . + ./src/MyApplication # or ./src/Debug/MyApplication + +See @ref cmake for more information. + +## General usage + +In CMake you need to request `GlfwApplication` component of `Magnum` package +and link to `Magnum::GlfwApplication` target. If no other application is +requested, you can also use generic `Magnum::Application` alias to simplify +porting. Again, see @ref building and @ref cmake for more information. + +In C++ code you need to implement at least @ref drawEvent() to be able to draw +on the screen. The subclass can be then used directly in `main()` -- see +convenience macro @ref MAGNUM_GLFWAPPLICATION_MAIN(). See @ref platform for +more information. +@code +class MyApplication: public Platform::GlfwApplication { + // implement required methods... +}; +MAGNUM_GLFWAPPLICATION_MAIN(MyApplication) +@endcode + +If no other application header is included, this class is also aliased to +`Platform::Application` and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` +to simplify porting. +*/ +class GlfwApplication { + public: + /** @brief Application arguments */ + struct Arguments { + /** @brief Constructor */ + /*implicit*/ constexpr Arguments(int& argc, char** argv) noexcept: argc{argc}, argv{argv} {} + + int& argc; /**< @brief Argument count */ + char** argv; /**< @brief Argument values */ + }; + + class Configuration; + class InputEvent; + class KeyEvent; + class MouseEvent; + class MouseMoveEvent; + class MouseScrollEvent; + + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, const Configuration&) */ + #ifdef DOXYGEN_GENERATING_OUTPUT + explicit GlfwApplication(const Arguments& arguments, const Configuration& configuration = Configuration()); + #else + /* To avoid "invalid use of incomplete type" */ + explicit GlfwApplication(const Arguments& arguments, const Configuration& configuration); + explicit GlfwApplication(const Arguments& arguments); + #endif + + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ + explicit GlfwApplication(const Arguments& arguments, std::nullptr_t); + + /** @brief Copying is not allowed */ + GlfwApplication(const GlfwApplication&) = delete; + + /** @brief Moving is not allowed */ + GlfwApplication(GlfwApplication&&) = delete; + + /** @brief Copying is not allowed */ + GlfwApplication& operator=(const GlfwApplication&) = delete; + + /** @brief Moving is not allowed */ + GlfwApplication& operator=(GlfwApplication&&) = delete; + + /** + * @brief Execute main loop + * @return Value for returning from `main()` + * + * See @ref MAGNUM_GLFWAPPLICATION_MAIN() for usage information. + */ + int exec(); + + /** @brief Exit application main loop */ + void exit() { + glfwSetWindowShouldClose(_window, true); + } + + protected: + /* Nobody will need to have (and delete) GlfwApplication*, thus this is + faster than public pure virtual destructor */ + ~GlfwApplication(); + + /** @copydoc Sdl2Application::createContext() */ + #ifdef DOXYGEN_GENERATING_OUTPUT + void createContext(const Configuration& configuration = Configuration()); + #else + /* To avoid "invalid use of incomplete type" */ + void createContext(const Configuration& configuration); + void createContext(); + #endif + + /** @copydoc Sdl2Application::tryCreateContext() */ + bool tryCreateContext(const Configuration& configuration); + + /** @{ @name Screen handling */ + + /** + * @brief Swap buffers + * + * Paints currently rendered framebuffer on screen. + */ + void swapBuffers() { glfwSwapBuffers(_window); } + + /** + * @brief Set swap interval + * + * Set `0` for no VSync, `1` for enabled VSync. Some platforms support + * `-1` for late swap tearing. Default is driver-dependent. + */ + void setSwapInterval(Int interval); + + /** @copydoc Sdl2Application::redraw() */ + void redraw() { _needsRedraw = true; } + + #ifdef DOXYGEN_GENERATING_OUTPUT + protected: + #else + private: + #endif + /** @copydoc Sdl2Application::viewportEvent() */ + virtual void viewportEvent(const Vector2i& size); + + /** @copydoc Sdl2Application::drawEvent() */ + virtual void drawEvent() = 0; + + /*@}*/ + + /** @{ @name Keyboard handling */ + + /** @copydoc Sdl2Application::keyPressEvent() */ + virtual void keyPressEvent(KeyEvent& event); + + /** @copydoc Sdl2Application::keyReleaseEvent() */ + virtual void keyReleaseEvent(KeyEvent& event); + + /*@}*/ + + /** @{ @name Mouse handling */ + + public: + /** + * @brief Mouse cursor + * + * @see @ref setMouseCursor() + */ + enum class MouseCursor: int { + Default = GLFW_CURSOR_NORMAL, /**< Default cursor provided by parent window */ + Hidden = GLFW_CURSOR_HIDDEN, /**< Hidden cursor */ + None = GLFW_CURSOR_DISABLED /**< No cursor */ + }; + + /** @brief Warp mouse cursor to given coordinates */ + void warpCursor(const Vector2i& position) { + glfwSetCursorPos(_window, Double(position.x()), Double(position.y())); + } + + #ifdef DOXYGEN_GENERATING_OUTPUT + protected: + #else + private: + #endif + /** @copydoc Sdl2Application::mousePressEvent() */ + virtual void mousePressEvent(MouseEvent& event); + + /** @copydoc Sdl2Application::mouseReleaseEvent() */ + virtual void mouseReleaseEvent(MouseEvent& event); + + /** + * @brief Mouse move event + * + * Called when any mouse button is pressed and mouse is moved. Default + * implementation does nothing. + * @see @ref setMouseTracking() + */ + virtual void mouseMoveEvent(MouseMoveEvent& event); + + /** + * @brief Mouse scroll event + * + * Called when a scrolling device is used (mouse wheel or scrolling area + * on touchpad). Default implementation does nothing. + */ + virtual void mouseScrollEvent(MouseScrollEvent& event); + + /*@}*/ + + private: + static void staticViewportEvent(GLFWwindow*, int w, int h) { + _instance->viewportEvent({w, h}); + } + + static void staticKeyEvent(GLFWwindow* window, int key, int scancode, int action, int mod); + + static void staticMouseEvent(GLFWwindow* window, int button, int action, int mods); + + static void staticMouseMoveEvent(GLFWwindow* window, double x, double y); + + static void staticMouseScrollEvent(GLFWwindow* window, double xoffset, double yoffset); + + static void staticErrorCallback(int error, const char* description); + + static GlfwApplication* _instance; + + GLFWwindow* _window; + std::unique_ptr _context; + bool _needsRedraw; +}; + +/** +@brief Configuration + +Double-buffered RGBA window with depth and stencil buffers. +@see @ref GlfwApplication(), @ref createContext(), @ref tryCreateContext() +*/ +class GlfwApplication::Configuration { + public: + /** + * @brief Context flag + * + * @see @ref Flags, @ref setFlags(), @ref Context::Flag + */ + enum class Flag: Int { + #ifdef GLFW_CONTEXT_NO_ERROR + /** + * Specifies whether errors should be generated by the context. + * If enabled, situations that would have generated errors instead + * cause undefined behavior. + * + * @note Supported since GLFW 3.2. + */ + NoError = GLFW_CONTEXT_NO_ERROR, + #endif + + Debug = GLFW_OPENGL_DEBUG_CONTEXT, /**< Debug context */ + Stereo = GLFW_STEREO, /**< Stereo rendering */ + }; + + /** + * @brief Context flags + * + * @see @ref setFlags() + */ + typedef Containers::EnumSet Flags; + + /** + * @brief Window flag + * + * @see @ref WindowFlags, @ref setWindowFlags() + */ + enum class WindowFlag: UnsignedShort { + Fullscreen = 1 << 0, /**< Fullscreen window */ + Resizeable = 1 << 1, /**< Resizeable window */ + Hidden = 1 << 2, /**< Hidden window */ + + #ifdef GLFW_MAXIMIZED + /** + * Maximized window + * + * @note Supported since GLFW 3.2. + */ + Maximized = 1 << 3, + #endif + + Minimized = 1 << 4, /**< Minimized window */ + Floating = 1 << 5, /**< Window floating above others, top-most */ + + /** + * Automatically iconify (minimize) if fullscreen window loses + * input focus + */ + AutoIconify = 1 << 6, + + Focused = 1 << 7 /**< Window has input focus */ + }; + + /** + * @brief Window flags + * + * @see @ref setWindowFlags() + */ + typedef Containers::EnumSet WindowFlags; + + /** @brief Cursor mode */ + enum class CursorMode: Int { + /** Visible unconstrained cursor */ + Normal = GLFW_CURSOR_NORMAL, + + /** Hidden cursor */ + Hidden = GLFW_CURSOR_HIDDEN, + + /** Cursor hidden and locked window */ + Disabled = GLFW_CURSOR_DISABLED + }; + + /*implicit*/ Configuration(); + ~Configuration(); + + /** @brief Window title */ + std::string title() const { return _title; } + + /** + * @brief Set window title + * @return Reference to self (for method chaining) + * + * Default is `"Magnum GLFW Application"`. + */ + Configuration& setTitle(std::string title) { + _title = std::move(title); + return *this; + } + + /** @brief Window size */ + Vector2i size() const { return _size; } + + /** + * @brief Set window size + * @return Reference to self (for method chaining) + * + * Default is `{800, 600}`. + */ + Configuration& setSize(const Vector2i& size) { + _size = size; + return *this; + } + + /** @brief Context flags */ + Flags flags() const { return _flags; } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. + */ + Configuration& setFlags(Flags flags) { + _flags = flags; + return *this; + } + + /** @brief Window flags */ + WindowFlags windowFlags() const { + return _windowFlags; + } + + /** + * @brief Set window flags + * @return Reference to self (for method chaining) + * + * Default is @ref WindowFlag::Focused. + */ + Configuration& setWindowFlags(WindowFlags windowFlags) { + _windowFlags = windowFlags; + return *this; + } + + /** @brief Cursor mode */ + CursorMode cursorMode() const { + return _cursorMode; + } + + /** + * @brief Set cursor mode + * @return Reference to self (for method chaining) + * + * Default is @ref CursorMode::Normal. + */ + Configuration& setCursorMode(CursorMode cursorMode) { + _cursorMode = cursorMode; + return *this; + } + + /** @brief Context version */ + Version version() const { return _version; } + + /** + * @brief Set context version + * + * If requesting version greater or equal to OpenGL 3.1, core profile + * is used. The created context will then have any version which is + * backwards-compatible with requested one. Default is + * @ref Version::None, i.e. any provided version is used. + */ + Configuration& setVersion(Version version) { + _version = version; + return *this; + } + + /** @brief Sample count */ + Int sampleCount() const { return _sampleCount; } + + /** + * @brief Set sample count + * @return Reference to self (for method chaining) + * + * Default is `0`, thus no multisampling. The actual sample count is + * ignored, GLFW either enables it or disables. See also + * @ref Renderer::Feature::Multisampling. + */ + Configuration& setSampleCount(Int count) { + _sampleCount = count; + return *this; + } + + /** @brief sRGB-capable default framebuffer */ + bool isSRGBCapable() const { + return _srgbCapable; + } + + /** + * @brief Set sRGB-capable default framebuffer + * @return Reference to self (for method chaining) + */ + Configuration& setSRGBCapable(bool enabled) { + _srgbCapable = enabled; + return *this; + } + + private: + std::string _title; + Vector2i _size; + Int _sampleCount; + Version _version; + Flags _flags; + WindowFlags _windowFlags; + CursorMode _cursorMode; + bool _srgbCapable; +}; + +CORRADE_ENUMSET_OPERATORS(GlfwApplication::Configuration::Flags) +CORRADE_ENUMSET_OPERATORS(GlfwApplication::Configuration::WindowFlags) + +/** +@brief Base for input events + +@see @ref KeyEvent, @ref MouseEvent, @ref MouseMoveEvent, @ref keyPressEvent(), + @ref mousePressEvent(), @ref mouseReleaseEvent(), @ref mouseMoveEvent() +*/ +class GlfwApplication::InputEvent { + public: + /** + * @brief Modifier + * + * @see @ref Modifiers, @ref KeyEvent::modifiers(), + * @ref MouseEvent::modifiers() + */ + enum class Modifier: Int { + Shift = GLFW_MOD_SHIFT, /**< Shift */ + Ctrl = GLFW_MOD_CONTROL, /**< Ctrl */ + Alt = GLFW_MOD_ALT, /**< Alt */ + AltGr = GLFW_MOD_SUPER /**< AltGr */ + }; + + /** + * @brief Set of modifiers + * + * @see @ref KeyEvent::modifiers(), @ref MouseEvent::modifiers(), + * @ref MouseMoveEvent::modifiers() + */ + typedef Containers::EnumSet Modifiers; + + /** @brief Copying is not allowed */ + InputEvent(const InputEvent&) = delete; + + /** @brief Moving is not allowed */ + InputEvent(InputEvent&&) = delete; + + /** @brief Copying is not allowed */ + InputEvent& operator=(const InputEvent&) = delete; + + /** @brief Moving is not allowed */ + InputEvent& operator=(InputEvent&&) = delete; + + /** @copydoc Sdl2Application::InputEvent::setAccepted() */ + void setAccepted(bool accepted = true) { _accepted = accepted; } + + /** @copydoc Sdl2Application::InputEvent::isAccepted() */ + constexpr bool isAccepted() const { return _accepted; } + + protected: + constexpr InputEvent(): _accepted(false) {} + + ~InputEvent() = default; + + private: + bool _accepted; +}; + +CORRADE_ENUMSET_OPERATORS(GlfwApplication::InputEvent::Modifiers) + +/** +@brief Key event + +@see @ref keyPressEvent() +*/ +class GlfwApplication::KeyEvent: public GlfwApplication::InputEvent { + friend GlfwApplication; + + public: + /** + * @brief Key + * + * @see @ref key() + */ + enum class Key: Int { + Unknown = GLFW_KEY_UNKNOWN, /**< Unknown key */ + + Enter = GLFW_KEY_ENTER, /**< Enter */ + Esc = GLFW_KEY_ESCAPE, /**< Escape */ + + Up = GLFW_KEY_UP, /**< Up arrow */ + Down = GLFW_KEY_DOWN, /**< Down arrow */ + Left = GLFW_KEY_LEFT, /**< Left arrow */ + Right = GLFW_KEY_RIGHT, /**< Right arrow */ + Home = GLFW_KEY_HOME, /**< Home */ + End = GLFW_KEY_END, /**< End */ + PageUp = GLFW_KEY_PAGE_UP, /**< Page up */ + PageDown = GLFW_KEY_PAGE_DOWN, /**< Page down */ + Backspace = GLFW_KEY_BACKSPACE, /**< Backspace */ + Insert = GLFW_KEY_INSERT, /**< Insert */ + Delete = GLFW_KEY_DELETE, /**< Delete */ + + F1 = GLFW_KEY_F1, /**< F1 */ + F2 = GLFW_KEY_F2, /**< F2 */ + F3 = GLFW_KEY_F3, /**< F3 */ + F4 = GLFW_KEY_F4, /**< F4 */ + F5 = GLFW_KEY_F5, /**< F5 */ + F6 = GLFW_KEY_F6, /**< F6 */ + F7 = GLFW_KEY_F7, /**< F7 */ + F8 = GLFW_KEY_F8, /**< F8 */ + F9 = GLFW_KEY_F9, /**< F9 */ + F10 = GLFW_KEY_F10, /**< F10 */ + F11 = GLFW_KEY_F11, /**< F11 */ + F12 = GLFW_KEY_F12, /**< F12 */ + + Space = ' ', /**< Space */ + Tab = '\t', /**< Tab */ + Comma = ',', /**< Comma */ + Period = '.', /**< Period */ + Minus = '-', /**< Minus */ + Plus = '+', /**< Plus */ + Slash = '/', /**< Slash */ + Percent = '%', /**< Percent */ + Smicolon = ';', /**< Semicolon */ + Equal = '=', /**< Equal */ + + Zero = '0', /**< Zero */ + One = '1', /**< One */ + Two = '2', /**< Two */ + Three = '3', /**< Three */ + Four = '4', /**< Four */ + Five = '5', /**< Five */ + Six = '6', /**< Six */ + Seven = '7', /**< Seven */ + Eight = '8', /**< Eight */ + Nine = '9', /**< Nine */ + + A = 'a', /**< Letter A */ + B = 'b', /**< Letter B */ + C = 'c', /**< Letter C */ + D = 'd', /**< Letter D */ + E = 'e', /**< Letter E */ + F = 'f', /**< Letter F */ + G = 'g', /**< Letter G */ + H = 'h', /**< Letter H */ + I = 'i', /**< Letter I */ + J = 'j', /**< Letter J */ + K = 'k', /**< Letter K */ + L = 'l', /**< Letter L */ + M = 'm', /**< Letter M */ + N = 'n', /**< Letter N */ + O = 'o', /**< Letter O */ + P = 'p', /**< Letter P */ + Q = 'q', /**< Letter Q */ + R = 'r', /**< Letter R */ + S = 's', /**< Letter S */ + T = 't', /**< Letter T */ + U = 'u', /**< Letter U */ + V = 'v', /**< Letter V */ + W = 'w', /**< Letter W */ + X = 'x', /**< Letter X */ + Y = 'y', /**< Letter Y */ + Z = 'z', /**< Letter Z */ + + /* Function keys */ + CapsLock = GLFW_KEY_CAPS_LOCK, /**< Caps lock */ + ScrollLock = GLFW_KEY_SCROLL_LOCK, /**< Scroll lock */ + NumLock = GLFW_KEY_NUM_LOCK, /**< Num lock */ + PrintScreen = GLFW_KEY_PRINT_SCREEN,/**< Print screen */ + Pause = GLFW_KEY_PAUSE, /**< Pause */ + NumZero = GLFW_KEY_KP_0, /**< Numpad zero */ + NumOne = GLFW_KEY_KP_1, /**< Numpad one */ + NumTwo = GLFW_KEY_KP_2, /**< Numpad two */ + NumThree = GLFW_KEY_KP_3, /**< Numpad three */ + NumFour = GLFW_KEY_KP_4, /**< Numpad four */ + NumFive = GLFW_KEY_KP_5, /**< Numpad five */ + NumSix = GLFW_KEY_KP_6, /**< Numpad six */ + NumSeven = GLFW_KEY_KP_7, /**< Numpad seven */ + NumEight = GLFW_KEY_KP_8, /**< Numpad eight */ + NumNine = GLFW_KEY_KP_9, /**< Numpad nine */ + NumDecimal = GLFW_KEY_KP_DECIMAL, /**< Numpad decimal */ + NumDivide = GLFW_KEY_KP_DIVIDE, /**< Numpad divide */ + NumMultiply = GLFW_KEY_KP_MULTIPLY, /**< Numpad multiply */ + NumSubtract = GLFW_KEY_KP_SUBTRACT, /**< Numpad subtract */ + NumAdd = GLFW_KEY_KP_ADD, /**< Numpad add */ + NumEnter = GLFW_KEY_KP_ENTER, /**< Numpad enter */ + NumEqual = GLFW_KEY_KP_EQUAL, /**< Numpad equal */ + LeftShift = GLFW_KEY_LEFT_SHIFT, /**< Left shift */ + LeftCtrl = GLFW_KEY_LEFT_CONTROL, /**< Left control */ + LeftAlt = GLFW_KEY_LEFT_ALT, /**< Left alt */ + LeftSuper = GLFW_KEY_LEFT_SUPER, /**< Left super */ + RightShift = GLFW_KEY_RIGHT_SHIFT, /**< Right shift */ + RightCtrl = GLFW_KEY_RIGHT_CONTROL, /**< Right control */ + RightAlt = GLFW_KEY_RIGHT_ALT, /**< Right alt */ + RightSuper = GLFW_KEY_RIGHT_SUPER, /**< Right super */ + Menu = GLFW_KEY_MENU /**< Menu */ + }; + + /** @brief Key */ + constexpr Key key() const { return _key; } + + /** @brief Modifiers */ + constexpr Modifiers modifiers() const { return _modifiers; } + + private: + static Modifiers getCurrentGlfwModifiers(GLFWwindow* window); + + constexpr KeyEvent(Key key, Modifiers modifiers): _key(key), _modifiers(modifiers) {} + + const Key _key; + const Modifiers _modifiers; +}; + +/** +@brief Mouse event + +@see @ref MouseMoveEvent, @ref MouseScrollEvent, @ref mousePressEvent(), @ref mouseReleaseEvent() +*/ +class GlfwApplication::MouseEvent: public GlfwApplication::InputEvent { + friend GlfwApplication; + + public: + /** + * @brief Mouse button + * + * @see @ref button() + */ + enum class Button: int { + Left = GLFW_MOUSE_BUTTON_LEFT, /**< Left button */ + Middle = GLFW_MOUSE_BUTTON_MIDDLE, /**< Middle button */ + Right = GLFW_MOUSE_BUTTON_RIGHT, /**< Right button */ + Button1 = GLFW_MOUSE_BUTTON_1, /**< Mouse button 1 */ + Button2 = GLFW_MOUSE_BUTTON_2, /**< Mouse button 2 */ + Button3 = GLFW_MOUSE_BUTTON_3, /**< Mouse button 3 */ + Button4 = GLFW_MOUSE_BUTTON_4, /**< Mouse button 4 */ + Button5 = GLFW_MOUSE_BUTTON_5, /**< Mouse button 5 */ + Button6 = GLFW_MOUSE_BUTTON_6, /**< Mouse button 6 */ + Button7 = GLFW_MOUSE_BUTTON_7, /**< Mouse button 7 */ + Button8 = GLFW_MOUSE_BUTTON_8, /**< Mouse button 8 */ + + WheelUp = GLFW_MOUSE_BUTTON_LAST + 1, /**< Mouse wheel up */ + WheelDown = GLFW_MOUSE_BUTTON_LAST + 2 /**< Mouse wheel down */ + }; + + /** @brief Button */ + constexpr Button button() const { return _button; } + + /** @brief Modifiers */ + constexpr Modifiers modifiers() const { return _modifiers; } + + private: + constexpr MouseEvent(Button button, Modifiers modifiers): _button(button), _modifiers(modifiers) {} + + const Button _button; + const Modifiers _modifiers; +}; + +/** +@brief Mouse move event + +@see @ref MouseEvent, @ref MouseScrollEvent, @ref mouseMoveEvent() +*/ +class GlfwApplication::MouseMoveEvent: public GlfwApplication::InputEvent { + friend GlfwApplication; + + public: + /** @brief Position */ + constexpr Vector2i position() const { return _position; } + + /** @brief Modifiers */ + constexpr Modifiers modifiers() const { return _modifiers; } + + private: + constexpr MouseMoveEvent(const Vector2i& position, Modifiers modifiers): _position(position), _modifiers(modifiers) {} + + const Vector2i _position; + const Modifiers _modifiers; +}; + +/** +@brief Mouse scroll event + +@see @ref MouseEvent, @ref MouseMoveEvent, @ref mouseScrollEvent() +*/ +class GlfwApplication::MouseScrollEvent: public GlfwApplication::InputEvent { + friend GlfwApplication; + + public: + /** @brief Scroll offset */ + constexpr Vector2d offset() const { return _offset; } + + /** @brief Modifiers */ + constexpr Modifiers modifiers() const { return _modifiers; } + + private: + constexpr MouseScrollEvent(const Vector2d& offset, Modifiers modifiers): _offset(offset), _modifiers(modifiers) {} + + const Vector2d _offset; + const Modifiers _modifiers; +}; + +/** @hideinitializer +@brief Entry point for GLFW-based applications +@param className Class name + +See @ref Magnum::Platform::GlfwApplication "Platform::GlfwApplication" for +usage information. This macro abstracts out platform-specific entry point code +and is equivalent to the following, see @ref portability-applications for more +information. +@code +int main(int argc, char** argv) { + className app({argc, argv}); + return app.exec(); +} +@endcode +When no other application header is included this macro is also aliased to +`MAGNUM_APPLICATION_MAIN()`. +*/ +#define MAGNUM_GLFWAPPLICATION_MAIN(className) \ + int main(int argc, char** argv) { \ + className app({argc, argv}); \ + return app.exec(); \ + } + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_APPLICATION_MAIN +typedef GlfwApplication Application; +typedef BasicScreen Screen; +typedef BasicScreenedApplication ScreenedApplication; +#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_GLFWAPPLICATION_MAIN(className) +#else +#undef MAGNUM_APPLICATION_MAIN +#endif +#endif + +}} + +#endif diff --git a/src/Magnum/Platform/GlutApplication.cpp b/src/Magnum/Platform/GlutApplication.cpp index 7553490ef..6fd1043c6 100644 --- a/src/Magnum/Platform/GlutApplication.cpp +++ b/src/Magnum/Platform/GlutApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/GlutApplication.h b/src/Magnum/Platform/GlutApplication.h index 36f813e22..bedc3d1ff 100644 --- a/src/Magnum/Platform/GlutApplication.h +++ b/src/Magnum/Platform/GlutApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -71,12 +71,10 @@ See @ref cmake for more information. ## General usage -In CMake you need to request `GlutApplication` component, add -`${MAGNUM_GLUTAPPLICATION_INCLUDE_DIRS}` to include path and link to -`${MAGNUM_GLUTAPPLICATION_LIBRARIES}`. If no other application is requested, -you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. Again, see -@ref building and @ref cmake for more information. +In CMake you need to request `GlutApplication` component of `Magnum` package +and link to `Magnum::GlutApplication` target. If no other application is +requested, you can also use generic `Magnum::Application` alias to simplify +porting. Again, see @ref building and @ref cmake for more information. In C++ code you need to implement at least @ref drawEvent() to be able to draw on the screen. The subclass can be then used directly in `main()` -- see diff --git a/src/Magnum/Platform/GlxApplication.cpp b/src/Magnum/Platform/GlxApplication.cpp index 63368617d..d3cb3af1d 100644 --- a/src/Magnum/Platform/GlxApplication.cpp +++ b/src/Magnum/Platform/GlxApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/GlxApplication.h b/src/Magnum/Platform/GlxApplication.h index a97165be6..674677ed4 100644 --- a/src/Magnum/Platform/GlxApplication.h +++ b/src/Magnum/Platform/GlxApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -52,11 +52,9 @@ more information. ## General usage -In CMake you need to request `GlxApplication` component, add -`${MAGNUM_GLXAPPLICATION_INCLUDE_DIRS}` to include path and link to -`${MAGNUM_GLXAPPLICATION_LIBRARIES}`. If no other application is requested, you -can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. See +In CMake you need to request `GlxApplication` component of `Magnum` package and +link to `Magnum::GlxApplication` target. If no other application is requested, +you can also use generic `Magnum::Application` alias to simplify porting. See @ref building and @ref cmake for more information. In C++ code you need to implement at least @ref drawEvent() to be able to draw diff --git a/src/Magnum/Platform/Implementation/AbstractContextHandler.h b/src/Magnum/Platform/Implementation/AbstractContextHandler.h index fd2ebbc64..cc9a70e13 100644 --- a/src/Magnum/Platform/Implementation/AbstractContextHandler.h +++ b/src/Magnum/Platform/Implementation/AbstractContextHandler.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Implementation/Egl.cpp b/src/Magnum/Platform/Implementation/Egl.cpp index 8857e1d5a..cbb9b4377 100644 --- a/src/Magnum/Platform/Implementation/Egl.cpp +++ b/src/Magnum/Platform/Implementation/Egl.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Implementation/Egl.h b/src/Magnum/Platform/Implementation/Egl.h index 1828e4c02..0d4bb743e 100644 --- a/src/Magnum/Platform/Implementation/Egl.h +++ b/src/Magnum/Platform/Implementation/Egl.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Implementation/EglContextHandler.cpp b/src/Magnum/Platform/Implementation/EglContextHandler.cpp index 42d7d6997..f3f182bdd 100644 --- a/src/Magnum/Platform/Implementation/EglContextHandler.cpp +++ b/src/Magnum/Platform/Implementation/EglContextHandler.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Implementation/EglContextHandler.h b/src/Magnum/Platform/Implementation/EglContextHandler.h index c61536b68..8d5283997 100644 --- a/src/Magnum/Platform/Implementation/EglContextHandler.h +++ b/src/Magnum/Platform/Implementation/EglContextHandler.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Implementation/GlxContextHandler.cpp b/src/Magnum/Platform/Implementation/GlxContextHandler.cpp index 6a2265610..9df50d742 100644 --- a/src/Magnum/Platform/Implementation/GlxContextHandler.cpp +++ b/src/Magnum/Platform/Implementation/GlxContextHandler.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Implementation/GlxContextHandler.h b/src/Magnum/Platform/Implementation/GlxContextHandler.h index d86a5f4bd..fb6a7450b 100644 --- a/src/Magnum/Platform/Implementation/GlxContextHandler.h +++ b/src/Magnum/Platform/Implementation/GlxContextHandler.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Implementation/OpenGLFunctionLoader.cpp b/src/Magnum/Platform/Implementation/OpenGLFunctionLoader.cpp index c96476fe0..61a2553d8 100644 --- a/src/Magnum/Platform/Implementation/OpenGLFunctionLoader.cpp +++ b/src/Magnum/Platform/Implementation/OpenGLFunctionLoader.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Implementation/OpenGLFunctionLoader.h b/src/Magnum/Platform/Implementation/OpenGLFunctionLoader.h index 9b2cb260a..250a66341 100644 --- a/src/Magnum/Platform/Implementation/OpenGLFunctionLoader.h +++ b/src/Magnum/Platform/Implementation/OpenGLFunctionLoader.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/MacOSXBundleInfo.plist.in b/src/Magnum/Platform/MacOSXBundleInfo.plist.in new file mode 100644 index 000000000..eaac87c6a --- /dev/null +++ b/src/Magnum/Platform/MacOSXBundleInfo.plist.in @@ -0,0 +1,25 @@ + + + + + CFBundleDevelopmentRegion + en-US + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleIdentifier + cz.mosra.magnum.magnum-info + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + magnum-info + CFBundlePackageType + APPL + + UIRequiredDeviceCapabilities + + opengles-2 + + NSHighResolutionCapable + + + diff --git a/src/Magnum/Platform/NaClApplication.cpp b/src/Magnum/Platform/NaClApplication.cpp index 8cc096abc..9dafcd8c9 100644 --- a/src/Magnum/Platform/NaClApplication.cpp +++ b/src/Magnum/Platform/NaClApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/NaClApplication.h b/src/Magnum/Platform/NaClApplication.h index 50435637b..488b4e742 100644 --- a/src/Magnum/Platform/NaClApplication.h +++ b/src/Magnum/Platform/NaClApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -96,7 +96,6 @@ location of your webserver to have the files installed in proper location (e.g. mkdir build-nacl-x86-32 && cd build-nacl-x86-32 cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-32.cmake" \ -DCMAKE_INSTALL_PREFIX=/srv/http/nacl cmake --build . @@ -104,7 +103,6 @@ location of your webserver to have the files installed in proper location (e.g. mkdir build-nacl-x86-64 && cd build-nacl-x86-64 cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/NaCl-newlib-x86-64.cmake" \ -DCMAKE_INSTALL_PREFIX=/srv/http/nacl cmake --build . @@ -119,11 +117,9 @@ You can then open `MyApplication` through your webserver in Chrome (e.g. For CMake you need to copy `FindOpenGLES2.cmake` from `modules/` directory in Magnum source to `modules/` dir in your project (so it is able to find OpenGL -ES). Request `NaClApplication` component, add -`${MAGNUM_NACLAPPLICATION_INCLUDE_DIRS}` to include path and link to -`${MAGNUM_NACLAPPLICATION_LIBRARIES}`. If no other application is requested, -you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. Again, see +ES). Request `NaClApplication` component of `Magnum` package and link to +`Magnum::NaClApplication` target. If no other application is requested, you can +also use generic `Magnum::Application` alias to simplify porting. Again, see @ref building and @ref cmake for more information. In C++ code you need to implement at least @ref drawEvent() to be able to draw diff --git a/src/Magnum/Platform/Platform.h b/src/Magnum/Platform/Platform.h index ebb547c33..8dea4928e 100644 --- a/src/Magnum/Platform/Platform.h +++ b/src/Magnum/Platform/Platform.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Screen.h b/src/Magnum/Platform/Screen.h index 703cd0696..8d54f3c0e 100644 --- a/src/Magnum/Platform/Screen.h +++ b/src/Magnum/Platform/Screen.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/ScreenedApplication.h b/src/Magnum/Platform/ScreenedApplication.h index 0db54e05b..ae664823f 100644 --- a/src/Magnum/Platform/ScreenedApplication.h +++ b/src/Magnum/Platform/ScreenedApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/ScreenedApplication.hpp b/src/Magnum/Platform/ScreenedApplication.hpp index da2a7b139..ef4abb1b2 100644 --- a/src/Magnum/Platform/ScreenedApplication.hpp +++ b/src/Magnum/Platform/ScreenedApplication.hpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 1e7412964..aeb6b981c 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -32,8 +32,9 @@ #include #endif -#include "Magnum/Platform/Context.h" #include "Magnum/Version.h" +#include "Magnum/Math/Range.h" +#include "Magnum/Platform/Context.h" #include "Magnum/Platform/ScreenedApplication.hpp" namespace Magnum { namespace Platform { @@ -110,11 +111,6 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, configuration.isSRGBCapable()); #endif - /* Flags: if not hidden, set as shown */ - Uint32 windowFlags(configuration.windowFlags()); - if(!(configuration.windowFlags() & Configuration::WindowFlag::Hidden)) - windowFlags |= SDL_WINDOW_SHOWN; - /** @todo Remove when Emscripten has proper SDL2 support */ #ifndef CORRADE_TARGET_EMSCRIPTEN /* Set context version, if user-specified */ @@ -163,11 +159,17 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { #endif } - /* Create window */ - if(!(_window = SDL_CreateWindow(configuration.title().data(), - SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + /* Create window. Hide it by default so we don't have distracting window + blinking in case we have to destroy it again right away */ + if(!(_window = SDL_CreateWindow( + #ifndef CORRADE_TARGET_IOS + configuration.title().data(), + #else + nullptr, + #endif + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, configuration.size().x(), configuration.size().y(), - SDL_WINDOW_OPENGL|windowFlags))) + SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN|Uint32(configuration.windowFlags())))) { Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window:" << SDL_GetError(); return false; @@ -211,9 +213,9 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, int(configuration.flags())); if(!(_window = SDL_CreateWindow(configuration.title().data(), - SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, configuration.size().x(), configuration.size().y(), - SDL_WINDOW_OPENGL|windowFlags))) + SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN|Uint32(configuration.windowFlags())))) { Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create window:" << SDL_GetError(); return false; @@ -232,13 +234,49 @@ bool Sdl2Application::tryCreateContext(const Configuration& configuration) { return false; } + #ifdef CORRADE_TARGET_IOS + /* iOS has zero initial GL_VIEWPORT size, get drawable size and put it back + in so all other code can assume that the viewport is set to sane values. + Fortunately on iOS we also don't have to load any function pointers so + it's safe to do the glViewport() call as it is linked statically. */ + Vector2i drawableSize; + SDL_GL_GetDrawableSize(_window, &drawableSize.x(), &drawableSize.y()); + glViewport(0, 0, drawableSize.x(), drawableSize.y()); + #endif #else /* Emscripten-specific initialization */ - _glContext = SDL_SetVideoMode(configuration.size().x(), configuration.size().y(), 24, SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF); + if(!(_glContext = SDL_SetVideoMode(configuration.size().x(), configuration.size().y(), 24, SDL_OPENGL|SDL_HWSURFACE|SDL_DOUBLEBUF))) { + Error() << "Platform::Sdl2Application::tryCreateContext(): cannot create context:" << SDL_GetError(); + return false; + } + #endif + + /* Destroy everything also when the Magnum context creation fails */ + if(!_context->tryCreate()) { + #ifndef CORRADE_TARGET_EMSCRIPTEN + SDL_GL_DeleteContext(_glContext); + SDL_DestroyWindow(_window); + _window = nullptr; + #else + SDL_FreeSurface(_glContext); + #endif + return false; + } + + #ifndef CORRADE_TARGET_EMSCRIPTEN + /* Show the window once we are sure that everything is okay */ + if(!(configuration.windowFlags() & Configuration::WindowFlag::Hidden)) + SDL_ShowWindow(_window); #endif /* Return true if the initialization succeeds */ - return _context->tryCreate(); + return true; +} + +Vector2i Sdl2Application::windowSize() { + Vector2i size; + SDL_GetWindowSize(_window, &size.x(), &size.y()); + return size; } void Sdl2Application::swapBuffers() { @@ -311,10 +349,18 @@ void Sdl2Application::mainLoop() { switch(event.type) { case SDL_WINDOWEVENT: switch(event.window.event) { - case SDL_WINDOWEVENT_RESIZED: + case SDL_WINDOWEVENT_RESIZED: { + #ifndef CORRADE_TARGET_IOS viewportEvent({event.window.data1, event.window.data2}); + #else + /* On iOS the window event is in points and not pixels, + but we need pixels to call glViewport() properly */ + Vector2i drawableSize; + SDL_GL_GetDrawableSize(_window, &drawableSize.x(), &drawableSize.y()); + viewportEvent(drawableSize); + #endif _flags |= Flag::Redraw; - break; + } break; case SDL_WINDOWEVENT_EXPOSED: _flags |= Flag::Redraw; break; @@ -344,6 +390,18 @@ void Sdl2Application::mainLoop() { break; } + #ifndef CORRADE_TARGET_EMSCRIPTEN + case SDL_TEXTINPUT: { + TextInputEvent e{{event.text.text, std::strlen(event.text.text)}}; + textInputEvent(e); + } break; + + case SDL_TEXTEDITING: { + TextEditingEvent e{{event.edit.text, std::strlen(event.text.text)}, event.edit.start, event.edit.length}; + textEditingEvent(e); + } break; + #endif + case SDL_QUIT: #ifndef CORRADE_TARGET_EMSCRIPTEN _flags |= Flag::Exit; @@ -399,6 +457,13 @@ void Sdl2Application::setMouseLocked(bool enabled) { #endif } +#ifndef CORRADE_TARGET_EMSCRIPTEN +void Sdl2Application::setTextInputRect(const Range2Di& rect) { + SDL_Rect r{rect.min().x(), rect.min().y(), rect.sizeX(), rect.sizeY()}; + SDL_SetTextInputRect(&r); +} +#endif + void Sdl2Application::tickEvent() { /* If this got called, the tick event is not implemented by user and thus we don't need to call it ever again */ @@ -412,11 +477,21 @@ void Sdl2Application::mousePressEvent(MouseEvent&) {} void Sdl2Application::mouseReleaseEvent(MouseEvent&) {} void Sdl2Application::mouseMoveEvent(MouseMoveEvent&) {} +#ifndef CORRADE_TARGET_EMSCRIPTEN +void Sdl2Application::textInputEvent(TextInputEvent&) {} +void Sdl2Application::textEditingEvent(TextEditingEvent&) {} +#endif + Sdl2Application::Configuration::Configuration(): - #ifndef CORRADE_TARGET_EMSCRIPTEN + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_IOS) _title("Magnum SDL2 Application"), #endif - _size(800, 600), _windowFlags{}, _sampleCount(0) + #ifndef CORRADE_TARGET_IOS + _size{800, 600}, + #else + _size{}, /* SDL2 detects someting for us */ + #endif + _windowFlags{}, _sampleCount(0) #ifndef CORRADE_TARGET_EMSCRIPTEN , _version(Version::None), _sRGBCapable{false} #endif diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index ffa7e9094..7c3c34277 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -31,6 +31,7 @@ #include #include +#include #include #include "Magnum/Magnum.h" @@ -94,14 +95,13 @@ variable in `toolchains/generic/Emscripten.cmake` to path where Emscripten is installed. Default is `/usr/emscripten`. Then create build directory and run `cmake` and build/install commands in it. -The toolchain needs access to its platform file, so be sure to properly set -**absolute** path to `toolchains/modules/` directory containing `Platform/Emscripten.cmake`. +The toolchain needs access to its platform file, so be sure to properly set **absolute** +path to `toolchains/modules/` directory containing `Platform/Emscripten.cmake`. Set `CMAKE_INSTALL_PREFIX` to have the files installed in proper location (a webserver, e.g. `/srv/http/emscripten`). mkdir build-emscripten && cd build-emscripten cmake .. \ - -DCMAKE_MODULE_PATH="/absolute/path/to/toolchains/modules" \ -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten.cmake" -DCMAKE_INSTALL_PREFIX=/srv/http/emscripten cmake --build . @@ -110,6 +110,36 @@ webserver, e.g. `/srv/http/emscripten`). You can then open `MyApplication.html` in Chrome or Firefox (through webserver, e.g. `http://localhost/emscripten/MyApplication.html`). +## Bootstrap application for iOS + +Fully contained base application using @ref Sdl2Application for both desktop +and iOS build along with pre-filled `*.plist` is available in `base-ios` branch +of [Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) repository, +download it as [tar.gz](https://github.com/mosra/magnum-bootstrap/archive/base-ios.tar.gz) +or [zip](https://github.com/mosra/magnum-bootstrap/archive/base-ios.zip) file. +After extracting the downloaded archive, you can do the desktop build in +the same way as above. For the iOS build you also need to put the contents of +toolchains repository from https://github.com/mosra/toolchains in `toolchains/` +subdirectory. + +Then create build directory and run `cmake` to generate the Xcode project. Set +`CMAKE_OSX_ROOT` to SDK you want to target and enable all desired architectures +in `CMAKE_OSX_ARCHITECTURES`. The toolchain needs access to its platform file, +so be sure to properly set **absolute** path to `toolchains/modules/` directory +containing `Platform/iOS.cmake`. Set `CMAKE_PREFIX_PATH` to the directory where +you have all the dependencies. + + mkdir build-ios && cd build-ios + cmake .. \ + -DCMAKE_TOOLCHAIN_FILE=../toolchains/generic/iOS.cmake \ + -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \ + -DCMAKE_OSX_ARCHITECTURES="arm64;armv7;armv7s" \ + -DCMAKE_PREFIX_PATH=~/ios-libs \ + -G Xcode + +You can then open the generated project file in Xcode and build/deploy it from +there. + ## Bootstrap application for Windows RT Fully contained base application using @ref Sdl2Application for both desktop @@ -138,10 +168,9 @@ final package along with a PowerShell script for easy local installation. For CMake you need to copy `FindSDL2.cmake` from `modules/` directory in Magnum source to `modules/` dir in your project (so it is able to find SDL2). In case of Emscripten you need also `FindOpenGLES2.cmake`. Request -`Sdl2Application` component, add `${MAGNUM_SDL2APPLICATION_INCLUDE_DIRS}` -to include path and link to `${MAGNUM_SDL2APPLICATION_LIBRARIES}`. If no other -application is requested, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` -and `${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. Again, see +`Sdl2Application` component of `Magnum` package and link to +`Magnum::Sdl2Application` target. If no other application is requested, you can +also use generic `Magnum::Application` alias to simplify porting. Again, see @ref building and @ref cmake for more information. In C++ code you need to implement at least @ref drawEvent() to be able to draw on the @@ -199,6 +228,53 @@ The application redirects all output (thus also @ref Corrade::Utility::Debug "De @ref Corrade::Utility::Warning "Warning" and @ref Corrade::Utility::Error "Error") to JavaScript console. +## Usage with iOS + +A lot of options for iOS build (such as HiDPI/Retina support, supported display +orientation, icons, splash screen...) is specified through the `*.plist` file. +CMake uses its own template that can be configured using various `MACOSX_BUNDLE_*` +variables, but many options are missing from there and you are much better off +rolling your own template and passing **abosolute** path to it to CMake using +the `MACOSX_BUNDLE_INFO_PLIST` property. Below are contents of the `*.plist` +file used in the bootstrap application, requesting OpenGL ES 2.0 and +advertising Retina support: +@code + + + + + CFBundleDevelopmentRegion + en-US + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleIdentifier + cz.mosra.magnum.MyApplication + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + My Application + CFBundlePackageType + APPL + + UIRequiredDeviceCapabilities + + opengles-2 + + NSHighResolutionCapable + + + +@endcode + +Some other options can be configured from runtime when creating the SDL2 +application window, see documentation of particular value for details: + +- @ref Configuration::WindowFlag::AllowHighDpi allows creating HiDPI/Retina + drawable +- @ref Configuration::WindowFlag::Borderless hides the menu bar +- @ref Configuration::WindowFlag::Resizable makes the application respond to + device orientation changes + ## Usage with Windows RT For Windows RT you need to provide logo images and splash screen, all @@ -255,6 +331,10 @@ class Sdl2Application { class KeyEvent; class MouseEvent; class MouseMoveEvent; + #ifndef CORRADE_TARGET_EMSCRIPTEN + class TextInputEvent; + class TextEditingEvent; + #endif /** * @brief Default constructor @@ -341,6 +421,15 @@ class Sdl2Application { /** @{ @name Screen handling */ + /** + * @brief Window size + * + * Window size to which all input event coordinates can be related. + * Note that especially on HiDPI systems the reported window size might + * not be the same as framebuffer size. + */ + Vector2i windowSize(); + /** * @brief Swap buffers * @@ -496,6 +585,70 @@ class Sdl2Application { /*@}*/ + #ifndef CORRADE_TARGET_EMSCRIPTEN + /** @{ @name Text input handling */ + public: + /** + * @brief Whether text input is active + * + * If text input is active, text input events go to @ref textInputEvent() + * and @ref textEditingEvent(). + * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + * @see @ref startTextInput(), @ref stopTextInput() + */ + bool isTextInputActive() { return SDL_IsTextInputActive(); } + + /** + * @brief Start text input + * + * Starts text input that will go to @ref textInputEvent() and + * @ref textEditingEvent(). + * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + * @see @ref stopTextInput(), @ref isTextInputActive(), + * @ref setTextInputRect() + */ + void startTextInput() { SDL_StartTextInput(); } + + /** + * @brief Stop text input + * + * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + * @see @ref startTextInput(), @ref isTextInputActive(), @ref textInputEvent() + * @ref textEditingEvent() + */ + void stopTextInput() { SDL_StopTextInput(); } + + /** + * @brief Set text input rectangle + * + * The @p rect defines an area where the text is being displayed, for + * example to hint the system where to place on-screen keyboard. + */ + void setTextInputRect(const Range2Di& rect); + + #ifdef DOXYGEN_GENERATING_OUTPUT + protected: + #else + private: + #endif + /** + * @brief Text input event + * + * Called when text input is active and the text is being input. + * @see @ref isTextInputActive() + */ + virtual void textInputEvent(TextInputEvent& event); + + /** + * @brief Text editing event + * + * Called when text input is active and the text is being edited. + */ + virtual void textEditingEvent(TextEditingEvent& event); + + /*@}*/ + #endif + private: enum class Flag: UnsignedByte { Redraw = 1 << 0, @@ -529,13 +682,11 @@ class Sdl2Application { Flags _flags; }; -CORRADE_ENUMSET_OPERATORS(Sdl2Application::Flags) - /** @brief Configuration -The created window is always centered with double-buffered OpenGL context and -24bit depth buffer. +The created window is always with double-buffered OpenGL context and 24bit +depth buffer. @see @ref Sdl2Application(), @ref createContext(), @ref tryCreateContext() */ class Sdl2Application::Configuration { @@ -578,8 +729,28 @@ class Sdl2Application::Configuration { * @see @ref WindowFlags, @ref setWindowFlags() */ enum class WindowFlag: Uint32 { - Resizable = SDL_WINDOW_RESIZABLE, /**< Resizable window */ + /** + * Resizable window. On iOS this allows the application to respond + * to display orientation changes. Implement @ref viewportEvent() + * to react to the resizing events. + */ + Resizable = SDL_WINDOW_RESIZABLE, + Fullscreen = SDL_WINDOW_FULLSCREEN, /**< Fullscreen window */ + + /** No window decoration. On iOS this hides the menu bar. */ + Borderless = SDL_WINDOW_BORDERLESS, + + #ifndef CORRADE_TARGET_EMSCRIPTEN + /** + * Allow high DPI. On iOS you also have to set the + * `NSHighResolutionCapable` entry in the `*.plist` file to make + * it working. + * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + */ + AllowHighDpi = SDL_WINDOW_ALLOW_HIGHDPI, + #endif + Hidden = SDL_WINDOW_HIDDEN, /**< Hidden window */ Maximized = SDL_WINDOW_MAXIMIZED, /**< Maximized window */ Minimized = SDL_WINDOW_MINIMIZED, /**< Minimized window */ @@ -602,11 +773,12 @@ class Sdl2Application::Configuration { /*implicit*/ Configuration(); ~Configuration(); - #ifndef CORRADE_TARGET_EMSCRIPTEN + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_IOS) /** * @brief Window title * - * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". + * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" + * and @ref CORRADE_TARGET_IOS "iOS". */ std::string title() const { return _title; } #endif @@ -616,11 +788,12 @@ class Sdl2Application::Configuration { * @return Reference to self (for method chaining) * * Default is `"Magnum SDL2 Application"`. - * @note In @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" this function - * does nothing and is included only for compatibility. You need - * to set the title separately in application's HTML markup. + * @note In @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten" and + * @ref CORRADE_TARGET_IOS "iOS" this function does nothing and is + * included only for compatibility. You need to set the title + * separately in platform-specific configuration file. */ - #ifndef CORRADE_TARGET_EMSCRIPTEN + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_IOS) Configuration& setTitle(std::string title) { _title = std::move(title); return *this; @@ -636,7 +809,10 @@ class Sdl2Application::Configuration { * @brief Set window size * @return Reference to self (for method chaining) * - * Default is `{800, 600}`. + * Default is `{800, 600}`. On iOS it defaults to a "reasonable" size + * based on whether HiDPI support is enabled using + * @ref WindowFlag::AllowHighDpi, but not necessarily native display + * resolution (you have to set it explicitly). */ Configuration& setSize(const Vector2i& size) { _size = size; @@ -741,7 +917,7 @@ class Sdl2Application::Configuration { #endif private: - #ifndef CORRADE_TARGET_EMSCRIPTEN + #if !defined(CORRADE_TARGET_EMSCRIPTEN) && !defined(CORRADE_TARGET_IOS) std::string _title; #endif Vector2i _size; @@ -754,11 +930,6 @@ class Sdl2Application::Configuration { #endif }; -#ifndef CORRADE_TARGET_EMSCRIPTEN -CORRADE_ENUMSET_OPERATORS(Sdl2Application::Configuration::Flags) -#endif -CORRADE_ENUMSET_OPERATORS(Sdl2Application::Configuration::WindowFlags) - /** @brief Base for input events @@ -804,6 +975,9 @@ class Sdl2Application::InputEvent { /** @brief Moving is not allowed */ InputEvent& operator=(InputEvent&&) = delete; + /** @brief Whether the event is accepted */ + constexpr bool isAccepted() const { return _accepted; } + /** * @brief Set event as accepted * @@ -814,9 +988,6 @@ class Sdl2Application::InputEvent { */ void setAccepted(bool accepted = true) { _accepted = accepted; } - /** @brief Whether the event is accepted */ - constexpr bool isAccepted() const { return _accepted; } - #ifndef DOXYGEN_GENERATING_OUTPUT protected: constexpr explicit InputEvent(): _accepted(false) {} @@ -843,6 +1014,8 @@ class Sdl2Application::KeyEvent: public Sdl2Application::InputEvent { * @see @ref key() */ enum class Key: SDL_Keycode { + Unknown = SDLK_UNKNOWN, /**< Unknown key */ + Enter = SDLK_RETURN, /**< Enter */ Esc = SDLK_ESCAPE, /**< Escape */ @@ -850,6 +1023,14 @@ class Sdl2Application::KeyEvent: public Sdl2Application::InputEvent { Down = SDLK_DOWN, /**< Down arrow */ Left = SDLK_LEFT, /**< Left arrow */ Right = SDLK_RIGHT, /**< Right arrow */ + Home = SDLK_HOME, /**< Home */ + End = SDLK_END, /**< End */ + PageUp = SDLK_PAGEUP, /**< Page up */ + PageDown = SDLK_PAGEDOWN, /**< Page down */ + Backspace = SDLK_BACKSPACE, /**< Backspace */ + Insert = SDLK_INSERT, /**< Insert */ + Delete = SDLK_DELETE, /**< Delete */ + F1 = SDLK_F1, /**< F1 */ F2 = SDLK_F2, /**< F2 */ F3 = SDLK_F3, /**< F3 */ @@ -862,18 +1043,16 @@ class Sdl2Application::KeyEvent: public Sdl2Application::InputEvent { F10 = SDLK_F10, /**< F10 */ F11 = SDLK_F11, /**< F11 */ F12 = SDLK_F12, /**< F12 */ - Home = SDLK_HOME, /**< Home */ - End = SDLK_END, /**< End */ - PageUp = SDLK_PAGEUP, /**< Page up */ - PageDown = SDLK_PAGEDOWN, /**< Page down */ Space = SDLK_SPACE, /**< Space */ + Tab = SDLK_TAB, /**< Tab */ Comma = SDLK_COMMA, /**< Comma */ Period = SDLK_PERIOD, /**< Period */ Minus = SDLK_MINUS, /**< Minus */ Plus = SDLK_PLUS, /**< Plus */ Slash = SDLK_SLASH, /**< Slash */ Percent = SDLK_PERCENT, /**< Percent */ + Semicolon = SDLK_SEMICOLON, /**< Semicolon */ Equal = SDLK_EQUALS, /**< Equal */ Zero = SDLK_0, /**< Zero */ @@ -1030,6 +1209,105 @@ class Sdl2Application::MouseMoveEvent: public Sdl2Application::InputEvent { Modifiers _modifiers; }; +#ifndef CORRADE_TARGET_EMSCRIPTEN +/** +@brief Text input event + +@note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". +@see @ref TextEditingEvent, @ref textInputEvent() +*/ +class Sdl2Application::TextInputEvent { + friend Sdl2Application; + + public: + /** @brief Copying is not allowed */ + TextInputEvent(const TextInputEvent&) = delete; + + /** @brief Moving is not allowed */ + TextInputEvent(TextInputEvent&&) = delete; + + /** @brief Copying is not allowed */ + TextInputEvent& operator=(const TextInputEvent&) = delete; + + /** @brief Moving is not allowed */ + TextInputEvent& operator=(TextInputEvent&&) = delete; + + /** @brief Whether the event is accepted */ + constexpr bool isAccepted() const { return _accepted; } + + /** + * @brief Set event as accepted + * + * If the event is ignored (i.e., not set as accepted), it might be + * propagated elsewhere, for example to another screen when using + * @ref BasicScreenedApplication "ScreenedApplication". By default is + * each event ignored and thus propagated. + */ + void setAccepted(bool accepted = true) { _accepted = accepted; } + + /** @brief Input text in UTF-8 */ + constexpr Containers::ArrayView text() const { return _text; } + + private: + constexpr TextInputEvent(Containers::ArrayView text): _text{text}, _accepted{false} {} + + Containers::ArrayView _text; + bool _accepted; +}; + +/** +@brief Text editing event + +@note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". +@see @ref textEditingEvent() +*/ +class Sdl2Application::TextEditingEvent { + friend Sdl2Application; + + public: + /** @brief Copying is not allowed */ + TextEditingEvent(const TextEditingEvent&) = delete; + + /** @brief Moving is not allowed */ + TextEditingEvent(TextEditingEvent&&) = delete; + + /** @brief Copying is not allowed */ + TextEditingEvent& operator=(const TextEditingEvent&) = delete; + + /** @brief Moving is not allowed */ + TextEditingEvent& operator=(TextEditingEvent&&) = delete; + + /** @brief Whether the event is accepted */ + constexpr bool isAccepted() const { return _accepted; } + + /** + * @brief Set event as accepted + * + * If the event is ignored (i.e., not set as accepted), it might be + * propagated elsewhere, for example to another screen when using + * @ref BasicScreenedApplication "ScreenedApplication". By default is + * each event ignored and thus propagated. + */ + void setAccepted(bool accepted = true) { _accepted = accepted; } + + /** @brief Input text in UTF-8 */ + constexpr Containers::ArrayView text() const { return _text; } + + /** @brief Location to begin editing from */ + constexpr Int start() const { return _start; } + + /** @brief Number of characters to edit from the start point */ + constexpr Int length() const { return _length; } + + private: + constexpr TextEditingEvent(Containers::ArrayView text, Int start, Int length): _text{text}, _start{start}, _length{length}, _accepted{false} {} + + Containers::ArrayView _text; + Int _start, _length; + bool _accepted; +}; +#endif + /** @hideinitializer @brief Entry point for SDL2-based applications @param className Class name @@ -1080,6 +1358,11 @@ typedef BasicScreenedApplication ScreenedApplication; #endif #endif +CORRADE_ENUMSET_OPERATORS(Sdl2Application::Flags) +#ifndef CORRADE_TARGET_EMSCRIPTEN +CORRADE_ENUMSET_OPERATORS(Sdl2Application::Configuration::Flags) +#endif +CORRADE_ENUMSET_OPERATORS(Sdl2Application::Configuration::WindowFlags) CORRADE_ENUMSET_OPERATORS(Sdl2Application::InputEvent::Modifiers) CORRADE_ENUMSET_OPERATORS(Sdl2Application::MouseMoveEvent::Buttons) diff --git a/src/Magnum/Platform/WindowlessCglApplication.cpp b/src/Magnum/Platform/WindowlessCglApplication.cpp index 9e1474984..49140e99b 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.cpp +++ b/src/Magnum/Platform/WindowlessCglApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2013 Copyright © 2014 Travis Watkins diff --git a/src/Magnum/Platform/WindowlessCglApplication.h b/src/Magnum/Platform/WindowlessCglApplication.h index be937fe92..374fa864c 100644 --- a/src/Magnum/Platform/WindowlessCglApplication.h +++ b/src/Magnum/Platform/WindowlessCglApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2013 Copyright © 2014 Travis Watkins @@ -46,7 +46,8 @@ namespace Magnum { namespace Platform { /** @brief Windowless CGL application -Application for offscreen rendering using pure CGL. +Application for offscreen rendering using pure CGL. Does not have any default +framebuffer. This application library is available on desktop OpenGL on OS X. It is built if `WITH_WINDOWLESSCGLAPPLICATION` is enabled in CMake. diff --git a/src/Magnum/Platform/WindowlessEglApplication.cpp b/src/Magnum/Platform/WindowlessEglApplication.cpp new file mode 100644 index 000000000..61d61ce22 --- /dev/null +++ b/src/Magnum/Platform/WindowlessEglApplication.cpp @@ -0,0 +1,137 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "WindowlessEglApplication.h" + +#include +#include + +#include "Magnum/Version.h" +#include "Magnum/Platform/Context.h" + +#include "Implementation/Egl.h" + +namespace Magnum { namespace Platform { + +#ifndef DOXYGEN_GENERATING_OUTPUT +WindowlessEglApplication::WindowlessEglApplication(const Arguments& arguments): WindowlessEglApplication{arguments, Configuration{}} {} +#endif + +WindowlessEglApplication::WindowlessEglApplication(const Arguments& arguments, const Configuration& configuration): WindowlessEglApplication{arguments, nullptr} { + createContext(configuration); +} + +WindowlessEglApplication::WindowlessEglApplication(const Arguments& arguments, std::nullptr_t): _context{new Context{NoCreate, arguments.argc, arguments.argv}} {} + +void WindowlessEglApplication::createContext() { createContext({}); } + +void WindowlessEglApplication::createContext(const Configuration& configuration) { + if(!tryCreateContext(configuration)) std::exit(1); +} + +bool WindowlessEglApplication::tryCreateContext(const Configuration& configuration) { + CORRADE_ASSERT(_context->version() == Version::None, "Platform::WindowlessEglApplication::tryCreateContext(): context already created", false); + + /* Initialize */ + _display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if(!eglInitialize(_display, nullptr, nullptr)) { + Error() << "Platform::WindowlessEglApplication::tryCreateContext(): cannot initialize EGL:" << Implementation::eglErrorString(eglGetError()); + return false; + } + + const EGLenum api = + #ifndef MAGNUM_TARGET_GLES + EGL_OPENGL_API + #else + EGL_OPENGL_ES_API + #endif + ; + if(!eglBindAPI(api)) { + Error() << "Platform::WindowlessEglApplication::tryCreateContext(): cannot bind EGL API:" << Implementation::eglErrorString(eglGetError()); + return false; + } + + /* Choose EGL config */ + static const EGLint attribs[] = { + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + #ifndef MAGNUM_TARGET_GLES + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, + #elif defined(MAGNUM_TARGET_GLES3) + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR, + #elif defined(MAGNUM_TARGET_GLES2) + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + #else + #error unsupported OpenGL edition + #endif + EGL_NONE + }; + EGLint configCount; + if(!eglChooseConfig(_display, attribs, &_config, 1, &configCount)) { + Error() << "Platform::WindowlessEglApplication::tryCreateContext(): cannot get EGL visual config:" << Implementation::eglErrorString(eglGetError()); + return false; + } + + if(!configCount) { + Error() << "Platform::WindowlessEglApplication::tryCreateContext(): no matching EGL visual config available"; + return false; + } + + const EGLint attributes[] = { + #ifdef MAGNUM_TARGET_GLES + EGL_CONTEXT_CLIENT_VERSION, + #ifdef MAGNUM_TARGET_GLES3 + 3, + #elif defined(MAGNUM_TARGET_GLES2) + 2, + #else + #error unsupported OpenGL ES version + #endif + #endif + EGL_CONTEXT_FLAGS_KHR, EGLint(configuration.flags()), + EGL_NONE + }; + + if(!(_glContext = eglCreateContext(_display, _config, EGL_NO_CONTEXT, attributes))) { + Error() << "Platform::WindowlessEglApplication::tryCreateContext(): cannot create EGL context:" << Implementation::eglErrorString(eglGetError()); + return false; + } + if(!eglMakeCurrent(_display, EGL_NO_SURFACE, EGL_NO_SURFACE, _glContext)) { + Error() << "Platform::WindowlessEglApplication::tryCreateContext(): cannot make context current:" << Implementation::eglErrorString(eglGetError()); + return false; + } + + /* Return true if the initialization succeeds */ + return _context->tryCreate(); +} + +WindowlessEglApplication::~WindowlessEglApplication() { + _context.reset(); + + eglDestroyContext(_display, _glContext); + eglDestroySurface(_display, EGL_NO_SURFACE); + eglTerminate(_display); +} + +}} diff --git a/src/Magnum/Platform/WindowlessEglApplication.h b/src/Magnum/Platform/WindowlessEglApplication.h new file mode 100644 index 000000000..034e66b0d --- /dev/null +++ b/src/Magnum/Platform/WindowlessEglApplication.h @@ -0,0 +1,242 @@ +#ifndef Magnum_Platform_WindowlessEglApplication_h +#define Magnum_Platform_WindowlessEglApplication_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Class @ref Magnum::Platform::WindowlessEglApplication, macro @ref MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN() + */ + +#include +#include +#include +#include +/* undef Xlib nonsense to avoid conflicts */ +#undef Always +#undef Complex +#undef None +#undef Status + +#include "Magnum/Magnum.h" +#include "Magnum/OpenGL.h" +#include "Magnum/Platform/Platform.h" + +namespace Magnum { namespace Platform { + +/** +@brief Windowless EGL application + +Application for offscreen rendering using EGL without any windowing system. +Does not have any default framebuffer. Supported mainly on OpenGL ES drivers, +for desktop OpenGL the only driver that supports this configuration is +NVidia >= 355. See other `Windowless*Application` classes for an alternative. + +It is built if `WITH_WINDOWLESSEGLAPPLICATION` is enabled in CMake. + +## Bootstrap application + +Fully contained windowless application using @ref WindowlessEglApplication +along with CMake setup is available in `windowless` branch of +[Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) repository, +download it as [tar.gz](https://github.com/mosra/magnum-bootstrap/archive/windowless.tar.gz) +or [zip](https://github.com/mosra/magnum-bootstrap/archive/windowless.zip) +file. After extracting the downloaded archive you can build and run the +application with these four commands: + + mkdir build && cd build + cmake .. + cmake --build . + ./src/MyApplication # or ./src/Debug/MyApplication + +See @ref cmake for more information. + +## General usage + +In CMake you need to request `WindowlessEglApplication` component and link to +`Magnum::WindowlessEglApplication` target. If no other windowless application +is requested, you can also use generic `Magnum::WindowlessApplication` alias to +simplify porting. Again, see @ref building and @ref cmake for more information. + +Place your code into @ref exec(). The subclass can be then used in main +function using @ref MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN() macro. See +@ref platform for more information. +@code +class MyApplication: public Platform::WindowlessEglApplication { + // implement required methods... +}; +MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN(MyApplication) +@endcode + +If no other application header is included, this class is also aliased to +`Platform::WindowlessApplication` and the macro is aliased to +`MAGNUM_WINDOWLESSAPPLICATION_MAIN()` to simplify porting. +*/ +class WindowlessEglApplication { + public: + /** @brief Application arguments */ + struct Arguments { + /** @brief Constructor */ + /*implicit*/ constexpr Arguments(int& argc, char** argv) noexcept: argc{argc}, argv{argv}{} + + int& argc; /**< @brief Argument count */ + char** argv; /**< @brief Argument values */ + }; + + class Configuration; + + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, const Configuration&) */ + #ifdef DOXYGEN_GENERATING_OUTPUT + explicit WindowlessEglApplication(const Arguments& arguments, const Configuration& configuration = Configuration()); + #else + /* To avoid "invalid use of incomplete type" */ + explicit WindowlessEglApplication(const Arguments& arguments, const Configuration& configuration); + explicit WindowlessEglApplication(const Arguments& arguments); + #endif + + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ + explicit WindowlessEglApplication(const Arguments& arguments, std::nullptr_t); + + /** @brief Copying is not allowed */ + WindowlessEglApplication(const WindowlessEglApplication&) = delete; + + /** @brief Moving is not allowed */ + WindowlessEglApplication(WindowlessEglApplication&&) = delete; + + /** @brief Copying is not allowed */ + WindowlessEglApplication& operator=(const WindowlessEglApplication&) = delete; + + /** @brief Moving is not allowed */ + WindowlessEglApplication& operator=(WindowlessEglApplication&&) = delete; + + /** + * @brief Execute application + * @return Value for returning from `main()` + * + * See @ref MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN() for usage + * information. + */ + virtual int exec() = 0; + + protected: + /* Nobody will need to have (and delete) WindowlessEglApplication*, + thus this is faster than public pure virtual destructor */ + ~WindowlessEglApplication(); + + /** @copydoc Sdl2Application::createContext() */ + #ifdef DOXYGEN_GENERATING_OUTPUT + void createContext(const Configuration& configuration = Configuration()); + #else + /* To avoid "invalid use of incomplete type" */ + void createContext(const Configuration& configuration); + void createContext(); + #endif + + /** @copydoc Sdl2Application::tryCreateContext() */ + bool tryCreateContext(const Configuration& configuration); + + private: + EGLDisplay _display; + EGLConfig _config; + EGLContext _glContext; + + std::unique_ptr _context; +}; + +/** +@brief Configuration + +@see @ref WindowlessEglApplication(), @ref createContext(), + @ref tryCreateContext() +*/ +class WindowlessEglApplication::Configuration { + public: + /** + * @brief Context flag + * + * @see @ref Flags, @ref setFlags(), @ref Context::Flag + */ + enum class Flag: int { + Debug = EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR /**< Create debug context */ + }; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + typedef Containers::EnumSet Flags; + #else + typedef Containers::EnumSet Flags; + #endif + + constexpr /*implicit*/ Configuration() {} + + /** @brief Context flags */ + Flags flags() const { return _flags; } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. See also @ref Context::flags(). + */ + Configuration& setFlags(Flags flags) { + _flags = flags; + return *this; + } + + private: + Flags _flags; +}; + +/** @hideinitializer +@brief Entry point for windowless EGL application +@param className Class name + +See @ref Magnum::Platform::WindowlessEglApplication "Platform::WindowlessEglApplication" +for usage information. This macro abstracts out platform-specific entry point +code, see @ref portability-applications for more information. When no other +windowless application header is included this macro is also aliased to +`MAGNUM_WINDOWLESSAPPLICATION_MAIN()`. +*/ +#define MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN(className) \ + int main(int argc, char** argv) { \ + className app({argc, argv}); \ + return app.exec(); \ + } + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_WINDOWLESSAPPLICATION_MAIN +typedef WindowlessEglApplication WindowlessApplication; +#define MAGNUM_WINDOWLESSAPPLICATION_MAIN(className) MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN(className) +#else +#undef MAGNUM_WINDOWLESSAPPLICATION_MAIN +#endif +#endif + +}} + +#endif diff --git a/src/Magnum/Platform/WindowlessGlxApplication.cpp b/src/Magnum/Platform/WindowlessGlxApplication.cpp index ec2b64dc8..0e1379eee 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.cpp +++ b/src/Magnum/Platform/WindowlessGlxApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -53,7 +53,7 @@ void WindowlessGlxApplication::createContext(const Configuration& configuration) if(!tryCreateContext(configuration)) std::exit(1); } -bool WindowlessGlxApplication::tryCreateContext(const Configuration&) { +bool WindowlessGlxApplication::tryCreateContext(const Configuration& configuration) { CORRADE_ASSERT(_context->version() == Version::None, "Platform::WindowlessGlxApplication::tryCreateContext(): context already created", false); _display = XOpenDisplay(nullptr); @@ -82,7 +82,7 @@ bool WindowlessGlxApplication::tryCreateContext(const Configuration&) { }; _pbuffer = glXCreatePbuffer(_display, configs[0], pbufferAttributes); - constexpr static const GLint contextAttributes[] = { + const GLint contextAttributes[] = { #ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES3 GLX_CONTEXT_MAJOR_VERSION_ARB, 3, @@ -93,18 +93,19 @@ bool WindowlessGlxApplication::tryCreateContext(const Configuration&) { #endif GLX_CONTEXT_MINOR_VERSION_ARB, 0, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EXT, + GLX_CONTEXT_FLAGS_ARB, GLint(configuration.flags()), #else /* Similarly to what's done in Sdl2Application, try to request core context first */ GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 1, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB|GLint(configuration.flags()), #endif 0 }; - const PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); + const PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast(glXGetProcAddress(reinterpret_cast("glXCreateContextAttribsARB"))); _glContext = glXCreateContextAttribsARB(_display, configs[0], nullptr, True, contextAttributes); #ifndef MAGNUM_TARGET_GLES @@ -138,7 +139,12 @@ bool WindowlessGlxApplication::tryCreateContext(const Configuration&) { glXDestroyContext(_display, _glContext); } - _glContext = glXCreateContextAttribsARB(_display, configs[0], nullptr, True, nullptr); + const GLint fallbackContextAttributes[] = { + GLX_CONTEXT_FLAGS_ARB, GLint(configuration.flags()), + 0 + }; + + _glContext = glXCreateContextAttribsARB(_display, configs[0], nullptr, True, fallbackContextAttributes); } #endif diff --git a/src/Magnum/Platform/WindowlessGlxApplication.h b/src/Magnum/Platform/WindowlessGlxApplication.h index b052e95e3..bdc2d9ee2 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.h +++ b/src/Magnum/Platform/WindowlessGlxApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -30,6 +30,7 @@ */ #include +#include #include "Magnum/OpenGL.h" #include @@ -75,13 +76,11 @@ See @ref cmake for more information. ## General usage -In CMake you need to request `WindowlessGlxApplication` component, add -`${MAGNUM_WINDOWLESSGLXAPPLICATION_INCLUDE_DIRS}` to include path and link to -`${MAGNUM_WINDOWLESSGLXAPPLICATION_LIBRARIES}`. If no other windowless -application is requested, you can also use generic -`${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. Again, -see @ref building and @ref cmake for more information. +In CMake you need to request `WindowlessGlxApplication` component of `Magnum` +package and link to `Magnum::WindowlessGlxApplication` target. If no other +windowless application is requested, you can also use generic +`Magnum::WindowlessApplication` alias to simplify porting. Again, see +@ref building and @ref cmake for more information. Place your code into @ref exec(). The subclass can be then used directly in `main()` -- see convenience macro @ref MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(). @@ -176,7 +175,44 @@ class WindowlessGlxApplication { */ class WindowlessGlxApplication::Configuration { public: + /** + * @brief Context flag + * + * @see @ref Flags, @ref setFlags(), @ref Context::Flag + */ + enum class Flag: int { + Debug = GLX_CONTEXT_DEBUG_BIT_ARB /**< Create debug context */ + }; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + typedef Containers::EnumSet Flags; + #else + typedef Containers::EnumSet Flags; + #endif + constexpr /*implicit*/ Configuration() {} + + /** @brief Context flags */ + Flags flags() const { return _flags; } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. See also @ref Context::flags(). + */ + Configuration& setFlags(Flags flags) { + _flags = flags; + return *this; + } + + private: + Flags _flags; }; /** @hideinitializer diff --git a/src/Magnum/Platform/WindowlessIosApplication.h b/src/Magnum/Platform/WindowlessIosApplication.h new file mode 100644 index 000000000..aa08accdb --- /dev/null +++ b/src/Magnum/Platform/WindowlessIosApplication.h @@ -0,0 +1,230 @@ +#ifndef Magnum_Platform_WindowlessIosApplication_h +#define Magnum_Platform_WindowlessIosApplication_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/** @file + * @brief Class @ref Magnum::Platform::WindowlessIosApplication, macro @ref MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN() + */ + +#include +#include + +#include "Magnum/Magnum.h" +#include "Magnum/OpenGL.h" +#include "Magnum/Platform/Platform.h" + +#ifdef __OBJC__ +@class EAGLContext; +#else +struct EAGLContext; +#endif + +namespace Magnum { namespace Platform { + +/** +@brief Windowless iOS application + +Application for offscreen rendering using EAGL on iOS. Does not have any +default framebuffer. It is built if `WITH_WINDOWLESSIOSAPPLICATION` is enabled +in CMake. + +## Bootstrap application + +Fully contained windowless application using @ref WindowlessIosApplication +along with CMake setup is available in `windowless` branch of +[Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) repository, +download it as [tar.gz](https://github.com/mosra/magnum-bootstrap/archive/windowless.tar.gz) +or [zip](https://github.com/mosra/magnum-bootstrap/archive/windowless.zip) +file. After extracting the downloaded archive you can build and run the +application with these four commands: + + mkdir build && cd build + cmake .. + cmake --build . + ./src/MyApplication # or ./src/Debug/MyApplication + +See @ref cmake for more information. + +## General usage + +In CMake you need to request `WindowlessIosApplication` component and link to +`Magnum::WindowlessIosApplication` target. If no other windowless application +is requested, you can also use generic `Magnum::WindowlessApplication` alias to +simplify porting. Again, see @ref building and @ref cmake for more information. + +Place your code into @ref exec(). The subclass can be then used in main +function using @ref MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN() macro. See +@ref platform for more information. +@code +class MyApplication: public Platform::WindowlessIosApplication { + // implement required methods... +}; +MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN(MyApplication) +@endcode + +If no other application header is included, this class is also aliased to +`Platform::WindowlessApplication` and the macro is aliased to +`MAGNUM_WINDOWLESSAPPLICATION_MAIN()` to simplify porting. +*/ +class WindowlessIosApplication { + public: + /** @brief Application arguments */ + struct Arguments { + /** @brief Constructor */ + /*implicit*/ constexpr Arguments(int& argc, char** argv) noexcept: argc{argc}, argv{argv} {} + + int& argc; /**< @brief Argument count */ + char** argv; /**< @brief Argument values */ + }; + + class Configuration; + + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, const Configuration&) */ + #ifdef DOXYGEN_GENERATING_OUTPUT + explicit WindowlessIosApplication(const Arguments& arguments, const Configuration& configuration = Configuration()); + #else + /* To avoid "invalid use of incomplete type" */ + explicit WindowlessIosApplication(const Arguments& arguments, const Configuration& configuration); + explicit WindowlessIosApplication(const Arguments& arguments); + #endif + + /** @copydoc Sdl2Application::Sdl2Application(const Arguments&, std::nullptr_t) */ + explicit WindowlessIosApplication(const Arguments& arguments, std::nullptr_t); + + /** @brief Copying is not allowed */ + WindowlessIosApplication(const WindowlessIosApplication&) = delete; + + /** @brief Moving is not allowed */ + WindowlessIosApplication(WindowlessIosApplication&&) = delete; + + /** @brief Copying is not allowed */ + WindowlessIosApplication& operator=(const WindowlessIosApplication&) = delete; + + /** @brief Moving is not allowed */ + WindowlessIosApplication& operator=(WindowlessIosApplication&&) = delete; + + /** + * @brief Execute application + * @return Value for returning from `main()` + * + * See @ref MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN() for usage + * information. + */ + virtual int exec() = 0; + + protected: + /* Nobody will need to have (and delete) WindowlessIosApplication*, + thus this is faster than public pure virtual destructor */ + ~WindowlessIosApplication(); + + /** @copydoc Sdl2Application::createContext() */ + #ifdef DOXYGEN_GENERATING_OUTPUT + void createContext(const Configuration& configuration = Configuration()); + #else + /* To avoid "invalid use of incomplete type" */ + void createContext(const Configuration& configuration); + void createContext(); + #endif + + /** @copydoc Sdl2Application::tryCreateContext() */ + bool tryCreateContext(const Configuration& configuration); + + private: + EAGLContext* _glContext; + + std::unique_ptr _context; +}; + +/** +@brief Configuration + +@see @ref WindowlessIosApplication(), @ref createContext(), + @ref tryCreateContext() +*/ +class WindowlessIosApplication::Configuration { + public: + /** + * @brief Context flag + * + * @see @ref Flags, @ref setFlags(), @ref Context::Flag + */ + enum class Flag: int {}; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + typedef Containers::EnumSet Flags; + + constexpr /*implicit*/ Configuration() {} + + /** @brief Context flags */ + Flags flags() const { return _flags; } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. See also @ref Context::flags(). + */ + Configuration& setFlags(Flags flags) { + _flags = flags; + return *this; + } + + private: + Flags _flags; +}; + +/** @hideinitializer +@brief Entry point for windowless EGL application +@param className Class name + +See @ref Magnum::Platform::WindowlessIosApplication "Platform::WindowlessIosApplication" +for usage information. This macro abstracts out platform-specific entry point +code, see @ref portability-applications for more information. When no other +windowless application header is included this macro is also aliased to +`MAGNUM_WINDOWLESSAPPLICATION_MAIN()`. +*/ +#define MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN(className) \ + int main(int argc, char** argv) { \ + className app({argc, argv}); \ + return app.exec(); \ + } + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_WINDOWLESSAPPLICATION_MAIN +typedef WindowlessIosApplication WindowlessApplication; +#define MAGNUM_WINDOWLESSAPPLICATION_MAIN(className) MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN(className) +#else +#undef MAGNUM_WINDOWLESSAPPLICATION_MAIN +#endif +#endif + +}} + +#endif diff --git a/src/Magnum/Platform/WindowlessIosApplication.mm b/src/Magnum/Platform/WindowlessIosApplication.mm new file mode 100644 index 000000000..921f5d261 --- /dev/null +++ b/src/Magnum/Platform/WindowlessIosApplication.mm @@ -0,0 +1,89 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "WindowlessIosApplication.h" + +#include +#include + +#include "Magnum/Version.h" +#include "Magnum/Platform/Context.h" + +#import "EAGL.h" + +#if __has_feature(objc_arc) +#error no, we want to use manual memory management +#endif + +namespace Magnum { namespace Platform { + +#ifndef DOXYGEN_GENERATING_OUTPUT +WindowlessIosApplication::WindowlessIosApplication(const Arguments& arguments): WindowlessIosApplication{arguments, Configuration{}} {} +#endif + +WindowlessIosApplication::WindowlessIosApplication(const Arguments& arguments, const Configuration& configuration): WindowlessIosApplication{arguments, nullptr} { + createContext(configuration); +} + +WindowlessIosApplication::WindowlessIosApplication(const Arguments& arguments, std::nullptr_t): _context{new Context{NoCreate, arguments.argc, arguments.argv}} {} + +void WindowlessIosApplication::createContext() { createContext({}); } + +void WindowlessIosApplication::createContext(const Configuration& configuration) { + if(!tryCreateContext(configuration)) std::exit(1); +} + +bool WindowlessIosApplication::tryCreateContext(const Configuration&) { + CORRADE_ASSERT(_context->version() == Version::None, "Platform::WindowlessIosApplication::tryCreateContext(): context already created", false); + + /* Initialize */ + if(!(_glContext = [[EAGLContext alloc] + #ifdef MAGNUM_TARGET_GLES2 + initWithAPI:kEAGLRenderingAPIOpenGLES2 + #else + initWithAPI:kEAGLRenderingAPIOpenGLES3 + #endif + ])) + { + Error() << "Platform::WindowlessIosApplication::tryCreateContext(): cannot create EAGL context"; + return false; + } + + if(![EAGLContext setCurrentContext:_glContext]) { + Error() << "Platform::WindowlessIosApplication::tryCreateContext(): cannot make context current"; + return false; + } + + /* Return true if the initialization succeeds */ + return _context->tryCreate(); +} + +WindowlessIosApplication::~WindowlessIosApplication() { + _context.reset(); + + [_glContext dealloc]; +} + +}} diff --git a/src/Magnum/Platform/WindowlessNaClApplication.cpp b/src/Magnum/Platform/WindowlessNaClApplication.cpp index 9e34589c6..fd4194d33 100644 --- a/src/Magnum/Platform/WindowlessNaClApplication.cpp +++ b/src/Magnum/Platform/WindowlessNaClApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/WindowlessNaClApplication.h b/src/Magnum/Platform/WindowlessNaClApplication.h index cbdcd0600..1156a16dd 100644 --- a/src/Magnum/Platform/WindowlessNaClApplication.h +++ b/src/Magnum/Platform/WindowlessNaClApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/WindowlessWglApplication.cpp b/src/Magnum/Platform/WindowlessWglApplication.cpp index ef6c97798..72597d12d 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.cpp +++ b/src/Magnum/Platform/WindowlessWglApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -75,7 +75,7 @@ void WindowlessWglApplication::createContext(const Configuration& configuration) if(!tryCreateContext(configuration)) std::exit(1); } -bool WindowlessWglApplication::tryCreateContext(const Configuration&) { +bool WindowlessWglApplication::tryCreateContext(const Configuration& configuration) { CORRADE_ASSERT(_context->version() == Version::None, "Platform::WindowlessWglApplication::tryCreateContext(): context already created", false); /* Get device context */ @@ -104,8 +104,29 @@ bool WindowlessWglApplication::tryCreateContext(const Configuration&) { const int pixelFormat = ChoosePixelFormat(_deviceContext, &pfd); SetPixelFormat(_deviceContext, pixelFormat, &pfd); - /* Create context and make it current */ - _renderingContext = wglCreateContext(_deviceContext); + const int attributes[] = { + WGL_CONTEXT_FLAGS_ARB, int(configuration.flags()), + 0 + }; + + /* Create temporary context so we are able to get the pointer to + wglCreateContextAttribsARB() */ + HGLRC temporaryContext = wglCreateContext(_deviceContext); + if(!wglMakeCurrent(_deviceContext, temporaryContext)) { + Error() << "Platform::WindowlessWglApplication::tryCreateContext(): cannot make temporary context current:" << GetLastError(); + return false; + } + + /* Get pointer to proper context creation function and create real context + with it */ + typedef HGLRC(WINAPI*PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int*); + const PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast( wglGetProcAddress(reinterpret_cast("wglCreateContextAttribsARB"))); + _renderingContext = wglCreateContextAttribsARB(_deviceContext, nullptr, attributes); + + /* Delete the temporary context */ + wglMakeCurrent(_deviceContext, nullptr); + wglDeleteContext(temporaryContext); + if(!_renderingContext) { Error() << "Platform::WindowlessWglApplication::tryCreateContext(): cannot create context:" << GetLastError(); return false; diff --git a/src/Magnum/Platform/WindowlessWglApplication.h b/src/Magnum/Platform/WindowlessWglApplication.h index dcb3cff0e..d5cfd2545 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.h +++ b/src/Magnum/Platform/WindowlessWglApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -35,11 +35,19 @@ #define VC_EXTRALEAN #endif #include +#include #include "Magnum/Magnum.h" #include "Magnum/OpenGL.h" #include "Magnum/Platform/Platform.h" +#ifndef DOXYGEN_GENERATING_OUTPUT +/* Define stuff that we need because I can't be bothered with creating a new + header just for two defines */ +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#endif + namespace Magnum { namespace Platform { /** @@ -69,13 +77,11 @@ See @ref cmake for more information. ## General usage -In CMake you need to request `WindowlessWglApplication` component, add -`${MAGNUM_WINDOWLESSWGLAPPLICATION_INCLUDE_DIRS}` to include path and link to -`${MAGNUM_WINDOWLESSWGLAPPLICATION_LIBRARIES}`. If no other windowless -application is requested, you can also use generic -`${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. Again, -see @ref building and @ref cmake for more information. +In CMake you need to request `WindowlessWglApplication` component of `Magnum` +package and link to `Magnum::WindowlessWglApplication` target. If no other +windowless application is requested, you can also use generic +`Magnum::WindowlessApplication` alias to simplify porting. Again, see +@ref building and @ref cmake for more information. Place your code into @ref exec(). The subclass can be then used in main function using @ref MAGNUM_WINDOWLESSWGLAPPLICATION_MAIN() macro. See @@ -177,7 +183,44 @@ class WindowlessWglApplication { */ class WindowlessWglApplication::Configuration { public: + /** + * @brief Context flag + * + * @see @ref Flags, @ref setFlags(), @ref Context::Flag + */ + enum class Flag: int { + Debug = WGL_CONTEXT_DEBUG_BIT_ARB /**< Create debug context */ + }; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + typedef Containers::EnumSet Flags; + #else + typedef Containers::EnumSet Flags; + #endif + constexpr /*implicit*/ Configuration() {} + + /** @brief Context flags */ + Flags flags() const { return _flags; } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. See also @ref Context::flags(). + */ + Configuration& setFlags(Flags flags) { + _flags = flags; + return *this; + } + + private: + Flags _flags; }; /** @hideinitializer diff --git a/src/Magnum/Platform/WindowlessWindowsEglApplication.cpp b/src/Magnum/Platform/WindowlessWindowsEglApplication.cpp index 0ab95c191..432274a8f 100644 --- a/src/Magnum/Platform/WindowlessWindowsEglApplication.cpp +++ b/src/Magnum/Platform/WindowlessWindowsEglApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -77,7 +77,7 @@ void WindowlessWindowsEglApplication::createContext(const Configuration& configu if(!tryCreateContext(configuration)) std::exit(1); } -bool WindowlessWindowsEglApplication::tryCreateContext(const Configuration&) { +bool WindowlessWindowsEglApplication::tryCreateContext(const Configuration& configuration) { CORRADE_ASSERT(_context->version() == Version::None, "Platform::WindowlessWindowsEglApplication::tryCreateContext(): context already created", false); /* Initialize */ @@ -127,7 +127,7 @@ bool WindowlessWindowsEglApplication::tryCreateContext(const Configuration&) { return false; } - static const EGLint attributes[] = { + const EGLint attributes[] = { #ifdef MAGNUM_TARGET_GLES EGL_CONTEXT_CLIENT_VERSION, #ifdef MAGNUM_TARGET_GLES3 @@ -138,7 +138,7 @@ bool WindowlessWindowsEglApplication::tryCreateContext(const Configuration&) { #error unsupported OpenGL ES version #endif #endif - + EGL_CONTEXT_FLAGS_KHR, EGLint(configuration.flags()), EGL_NONE }; diff --git a/src/Magnum/Platform/WindowlessWindowsEglApplication.h b/src/Magnum/Platform/WindowlessWindowsEglApplication.h index fb759b6a2..3910d8be1 100644 --- a/src/Magnum/Platform/WindowlessWindowsEglApplication.h +++ b/src/Magnum/Platform/WindowlessWindowsEglApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -36,6 +36,8 @@ #endif #include #include +#include +#include #include "Magnum/Magnum.h" #include "Magnum/OpenGL.h" @@ -70,13 +72,11 @@ See @ref cmake for more information. ## General usage -In CMake you need to request `WindowlessWindowsEglApplication` component, add -`${MAGNUM_WINDOWLESSWINDOWSEGLAPPLICATION_INCLUDE_DIRS}` to include path and -link to `${MAGNUM_WINDOWLESSWINDOWSEGLAPPLICATION_LIBRARIES}`. If no other -windowless application is requested, you can also use generic -`${MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS}` and -`${MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES}` aliases to simplify porting. Again, -see @ref building and @ref cmake for more information. +In CMake you need to request `WindowlessWindowsEglApplication` component of +`Magnum` package and link to `Magnum::WindowlessWindowsEglApplication` target. +If no other windowless application is requested, you can also use generic +`Magnum::WindowlessApplication` alias to simplify porting. Again, see +@ref building and @ref cmake for more information. Place your code into @ref exec(). The subclass can be then used in main function using @ref MAGNUM_WINDOWLESSWINDOWSEGLAPPLICATION_MAIN() macro. See @@ -180,11 +180,48 @@ class WindowlessWindowsEglApplication { */ class WindowlessWindowsEglApplication::Configuration { public: + /** + * @brief Context flag + * + * @see @ref Flags, @ref setFlags(), @ref Context::Flag + */ + enum class Flag: int { + Debug = EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR /**< Create debug context */ + }; + + /** + * @brief Context flags + * + * @see @ref setFlags(), @ref Context::Flags + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + typedef Containers::EnumSet Flags; + #else + typedef Containers::EnumSet Flags; + #endif + constexpr /*implicit*/ Configuration() {} + + /** @brief Context flags */ + Flags flags() const { return _flags; } + + /** + * @brief Set context flags + * @return Reference to self (for method chaining) + * + * Default is no flag. See also @ref Context::flags(). + */ + Configuration& setFlags(Flags flags) { + _flags = flags; + return *this; + } + + private: + Flags _flags; }; /** @hideinitializer -@brief Entry point for windowless WGL application +@brief Entry point for windowless Windows/EGL application @param className Class name See @ref Magnum::Platform::WindowlessWindowsEglApplication "Platform::WindowlessWindowsEglApplication" diff --git a/src/Magnum/Platform/XEglApplication.cpp b/src/Magnum/Platform/XEglApplication.cpp index 3f4818512..f250c9452 100644 --- a/src/Magnum/Platform/XEglApplication.cpp +++ b/src/Magnum/Platform/XEglApplication.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Platform/XEglApplication.h b/src/Magnum/Platform/XEglApplication.h index 83d9bad0b..8244c6db4 100644 --- a/src/Magnum/Platform/XEglApplication.h +++ b/src/Magnum/Platform/XEglApplication.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -53,10 +53,9 @@ more information. For CMake you need to copy `FindEGL.cmake` from `modules/` directory in Magnum source to `modules/` dir in your project (so it is able to find EGL), request -`XEglApplication` component, add `${MAGNUM_XEGLAPPLICATION_INCLUDE_DIRS}` to -include path and link to `${MAGNUM_XEGLAPPLICATION_LIBRARIES}`. If no other -application is requested, you can also use generic `${MAGNUM_APPLICATION_INCLUDE_DIRS}` -and `${MAGNUM_APPLICATION_LIBRARIES}` aliases to simplify porting. See +`XEglApplication` component of `Magnum` package and link to +`Magnum::XEglApplication` target. If no other application is requested, you +can also use generic `Magnum::Application` alias to simplify porting. See @ref building and @ref cmake for more information. In C++ code you need to implement at least @ref drawEvent() to be able to draw diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index 13fd977a5..68cf49f56 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -35,6 +35,7 @@ #include "Magnum/BufferTexture.h" #endif #include "Magnum/Context.h" +#include "Magnum/CubeMapTexture.h" #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #include "Magnum/CubeMapTextureArray.h" #endif @@ -56,8 +57,12 @@ #include "Magnum/TransformFeedback.h" #endif -#ifdef CORRADE_TARGET_NACL +#ifdef MAGNUM_TARGET_HEADLESS +#include "Magnum/Platform/WindowlessEglApplication.h" +#elif defined(CORRADE_TARGET_NACL) #include "Magnum/Platform/WindowlessNaClApplication.h" +#elif defined(CORRADE_TARGET_IOS) +#include "Magnum/Platform/WindowlessIosApplication.h" #elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) @@ -79,53 +84,53 @@ namespace Magnum { @section magnum-info-usage Usage - magnum-info [-h|--help] [--all-extensions] [--limits] + magnum-info [--magnum-...] [-h|--help] [-s|--short] [--all-extensions] [--limits] Arguments: - -- ` -h`, `--help` -- display this help message and exit -- `--all-extensions` -- show extensions also for fully supported versions +- `-h`, `--help` -- display this help message and exit +- `-s`, `--short` -- display just essential info and exit +- `--all-extensions` -- display extensions also for fully supported versions - `--limits` -- display also limits and implementation-defined values +- `--magnum-...` -- engine-specific options (see @ref Context for details) @section magnum-info-example Example output - +---------------------------------------------------------+ - | Information about Magnum engine and OpenGL capabilities | - +---------------------------------------------------------+ - - Used application: Platform::WindowlessGlxApplication - Compilation flags: - CORRADE_BUILD_DEPRECATED - MAGNUM_BUILD_DEPRECATED - - Vendor: NVIDIA Corporation - Renderer: GeForce GT 740M/PCIe/SSE2 - OpenGL version: OpenGL 4.4 (4.4.0 NVIDIA 337.25) - Context flags: - Supported GLSL versions: - 440 core - 430 core - 420 core - 410 core - 400 core - 330 core - 310 es - 300 es - 100 - - Vendor extension support: - GL_AMD_vertex_shader_layer - - GL_AMD_shader_trinary_minmax - - GL_ARB_robustness SUPPORTED - GL_ATI_texture_mirror_once SUPPORTED - GL_EXT_texture_filter_anisotropic SUPPORTED - GL_EXT_texture_mirror_clamp SUPPORTED - GL_EXT_direct_state_access SUPPORTED - GL_EXT_texture_sRGB_decode SUPPORTED - GL_EXT_shader_integer_mix SUPPORTED - GL_EXT_debug_label - - GL_EXT_debug_marker - - GL_GREMEDY_string_marker - +``` + +---------------------------------------------------------+ + | Information about Magnum engine and OpenGL capabilities | + +---------------------------------------------------------+ + +Used application: Platform::WindowlessGlxApplication +Compilation flags: + CORRADE_BUILD_DEPRECATED + CORRADE_TARGET_UNIX + MAGNUM_BUILD_DEPRECATED + +Renderer: AMD Radeon R7 M260 Series by ATI Technologies Inc. +OpenGL version: 4.5.13399 Compatibility Profile Context 15.201.1151 +Using optional features: + GL_ARB_ES2_compatibility + GL_ARB_direct_state_access + GL_ARB_get_texture_sub_image + GL_ARB_invalidate_subdata + ... +Using driver workarounds: + amd-nv-no-forward-compatible-core-context + no-layout-qualifiers-on-old-glsl +Context flags: +Supported GLSL versions: + 430 core + 430 compatibility + 420 core + ... + +Vendor extension support: + GL_AMD_vertex_shader_layer SUPPORTED + GL_AMD_shader_trinary_minmax SUPPORTED + GL_ARB_robustness - + GL_ARB_robustness_isolation - + ... +``` */ @@ -138,18 +143,24 @@ class MagnumInfo: public Platform::WindowlessApplication { MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplication(arguments, nullptr) { Utility::Arguments args; - args.addBooleanOption("all-extensions") - .setHelp("all-extensions", "show extensions also for fully supported versions") - .addBooleanOption("limits") + args.addBooleanOption('s', "short").setHelp("short", "display just essential info and exit") + .addBooleanOption("extension-strings").setHelp("extension-strings", "list all extension strings provided by the driver (implies --short)") + .addBooleanOption("all-extensions").setHelp("all-extensions", "display extensions also for fully supported versions") + .addBooleanOption("limits").setHelp("limits", "display also limits and implementation-defined values") .addSkippedPrefix("magnum", "engine-specific options") - .setHelp("limits", "display also limits and implementation-defined values") .setHelp("Displays information about Magnum engine and OpenGL capabilities."); /** * @todo Make this work in NaCl, somehow the arguments aren't passed to * constructor but to Init() or whatnot */ - #ifndef CORRADE_TARGET_NACL + #ifdef CORRADE_TARGET_IOS + { + static_cast(arguments); + const char* iosArguments[] = { "", "--limits" }; + args.parse(2, iosArguments); + } + #elif !defined(CORRADE_TARGET_NACL) args.parse(arguments.argc, arguments.argv); #endif @@ -166,14 +177,20 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat Debug() << " +---------------------------------------------------------+"; Debug() << ""; - #ifdef CORRADE_TARGET_NACL + #ifdef MAGNUM_WINDOWLESSEGLAPPLICATION_MAIN + Debug() << "Used application: Platform::WindowlessEglApplication"; + #elif defined(MAGNUM_WINDOWLESSNACLAPPLICATION_MAIN) Debug() << "Used application: Platform::WindowlessNaClApplication"; - #elif defined(CORRADE_TARGET_APPLE) + #elif defined(MAGNUM_WINDOWLESSIOSAPPLICATION_MAIN) + Debug() << "Used application: Platform::WindowlessIosApplication"; + #elif defined(MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN) Debug() << "Used application: Platform::WindowlessCglApplication"; - #elif defined(CORRADE_TARGET_UNIX) + #elif defined(MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN) Debug() << "Used application: Platform::WindowlessGlxApplication"; - #elif defined(CORRADE_TARGET_WINDOWS) + #elif defined(MAGNUM_WINDOWLESSWGLAPPLICATION_MAIN) Debug() << "Used application: Platform::WindowlessWglApplication"; + #elif defined(MAGNUM_WINDOWLESSWINDOWSEGLAPPLICATION_MAIN) + Debug() << "Used application: Platform::WindowlessWindowsEglApplication"; #else #error no windowless application available on this platform #endif @@ -193,9 +210,15 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifdef CORRADE_TARGET_APPLE Debug() << " CORRADE_TARGET_APPLE"; #endif + #ifdef CORRADE_TARGET_IOS + Debug() << " CORRADE_TARGET_IOS"; + #endif #ifdef CORRADE_TARGET_WINDOWS Debug() << " CORRADE_TARGET_WINDOWS"; #endif + #ifdef CORRADE_TARGET_WINDOWS_RT + Debug() << " CORRADE_TARGET_WINDOWS_RT"; + #endif #ifdef CORRADE_TARGET_NACL Debug() << " CORRADE_TARGET_NACL"; #endif @@ -211,6 +234,12 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifdef CORRADE_TARGET_ANDROID Debug() << " CORRADE_TARGET_ANDROID"; #endif + #ifdef CORRADE_TESTSUITE_TARGET_XCTEST + Debug() << " CORRADE_TESTSUITE_TARGET_XCTEST"; + #endif + #ifdef CORRADE_UTILITY_USE_ANSI_COLORS + Debug() << " CORRADE_UTILITY_USE_ANSI_COLORS"; + #endif #ifdef MAGNUM_BUILD_DEPRECATED Debug() << " MAGNUM_BUILD_DEPRECATED"; #endif @@ -229,26 +258,38 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifdef MAGNUM_TARGET_WEBGL Debug() << " MAGNUM_TARGET_WEBGL"; #endif + #ifdef MAGNUM_TARGET_HEADLESS + Debug() << " MAGNUM_TARGET_HEADLESS"; + #endif Debug() << ""; /* Create context here, so the context creation info is displayed at proper place */ createContext(); - Context* c = Context::current(); + Context& c = Context::current(); Debug() << "Context flags:"; - #ifndef MAGNUM_TARGET_GLES - for(const auto flag: {Context::Flag::Debug, Context::Flag::RobustAccess}) - #else - for(const auto flag: {Context::Flag::Debug}) - #endif - if(c->flags() & flag) Debug() << " " << flag; + for(const auto flag: {Context::Flag::Debug, + Context::Flag::NoError, + #ifndef MAGNUM_TARGET_GLES + Context::Flag::RobustAccess + #endif + }) + if(c.flags() & flag) Debug() << " " << flag; Debug() << "Supported GLSL versions:"; - const std::vector shadingLanguageVersions = c->shadingLanguageVersionStrings(); + const std::vector shadingLanguageVersions = c.shadingLanguageVersionStrings(); for(const auto& version: shadingLanguageVersions) Debug() << " " << version; + if(args.isSet("extension-strings")) { + Debug() << "Extension strings:" << Debug::newline + << c.extensionStrings(); + return; + } + + if(args.isSet("short")) return; + Debug() << ""; /* Get first future (not supported) version */ @@ -275,7 +316,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat std::size_t future = 0; if(!args.isSet("all-extensions")) - while(versions[future] != Version::None && c->isVersionSupported(versions[future])) + while(versions[future] != Version::None && c.isVersionSupported(versions[future])) ++future; /* Display supported OpenGL extensions from unsupported versions */ @@ -288,11 +329,11 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat std::string extensionName = extension.string(); Debug d; d << " " << extensionName << std::string(60-extensionName.size(), ' '); - if(c->isExtensionSupported(extension)) + if(c.isExtensionSupported(extension)) d << "SUPPORTED"; - else if(c->isExtensionDisabled(extension)) + else if(c.isExtensionDisabled(extension)) d << " removed"; - else if(c->isVersionSupported(extension.requiredVersion())) + else if(c.isVersionSupported(extension.requiredVersion())) d << " -"; else d << " n/a"; @@ -306,7 +347,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat /* Limits and implementation-defined values */ #define _h(val) Debug() << "\n " << Extensions::GL::val::string() + std::string(":"); #define _l(val) Debug() << " " << #val << (sizeof(#val) > 64 ? "\n" + std::string(68, ' ') : std::string(64 - sizeof(#val), ' ')) << val; - #define _lvec(val) Debug() << " " << #val << (sizeof(#val) > 48 ? "\n" + std::string(52, ' ') : std::string(48 - sizeof(#val), ' ')) << val; + #define _lvec(val) Debug() << " " << #val << (sizeof(#val) > 42 ? "\n" + std::string(46, ' ') : std::string(42 - sizeof(#val), ' ')) << val; Debug() << "Limits and implementation-defined values:"; _lvec(AbstractFramebuffer::maxViewportSize()) @@ -352,7 +393,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat _lvec(CubeMapTexture::maxSize()) #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) { + if(c.isExtensionSupported()) { _h(ARB::blend_func_extended) _l(AbstractFramebuffer::maxDualSourceDrawBuffers()) @@ -361,7 +402,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -370,10 +411,12 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat _l(AbstractShaderProgram::maxComputeSharedMemorySize()) _l(AbstractShaderProgram::maxComputeWorkGroupInvocations()) + _lvec(AbstractShaderProgram::maxComputeWorkGroupCount()) + _lvec(AbstractShaderProgram::maxComputeWorkGroupSize()) } #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -384,9 +427,17 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat } #endif + #ifndef MAGNUM_TARGET_GLES + if(c.isExtensionSupported()) { + _h(ARB::map_buffer_alignment) + + _l(Buffer::minMapAlignment()) + } + #endif + #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -412,7 +463,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat } #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -434,13 +485,15 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat } #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES _h(ARB::shader_storage_buffer_object) #endif + _l(Buffer::shaderStorageOffsetAlignment()) + _l(Buffer::maxShaderStorageBindings()) _l(Shader::maxShaderStorageBlocks(Shader::Type::Vertex)) _l(Shader::maxShaderStorageBlocks(Shader::Type::TessellationControl)) _l(Shader::maxShaderStorageBlocks(Shader::Type::TessellationEvaluation)) @@ -455,7 +508,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -471,7 +524,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #endif #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) { + if(c.isExtensionSupported()) { _h(ARB::texture_rectangle) _lvec(RectangleTexture::maxSize()) @@ -480,7 +533,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -488,6 +541,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #endif _l(Buffer::uniformOffsetAlignment()) + _l(Buffer::maxUniformBindings()) _l(Shader::maxUniformBlocks(Shader::Type::Vertex)) _l(Shader::maxUniformBlocks(Shader::Type::TessellationControl)) _l(Shader::maxUniformBlocks(Shader::Type::TessellationEvaluation)) @@ -505,20 +559,19 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat } #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES _h(EXT::gpu_shader4) #endif - _l(Buffer::maxUniformBindings()) _l(AbstractShaderProgram::minTexelOffset()) _l(AbstractShaderProgram::maxTexelOffset()) } #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -534,7 +587,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -548,7 +601,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #endif #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) { + if(c.isExtensionSupported()) { _h(ARB::transform_feedback3) _l(TransformFeedback::maxBuffers()) @@ -557,9 +610,9 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #else - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -576,9 +629,9 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #else - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -587,8 +640,6 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat _h(EXT::tessellation_shader) #endif - _l(Buffer::shaderStorageOffsetAlignment()) - _l(Buffer::maxShaderStorageBindings()) _l(Shader::maxTessellationControlInputComponents()) _l(Shader::maxTessellationControlOutputComponents()) _l(Shader::maxTessellationControlTotalOutputComponents()) @@ -599,9 +650,9 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #else - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -614,9 +665,9 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat } #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #else - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -629,9 +680,9 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat } #ifndef MAGNUM_TARGET_GLES - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #else - if(c->isExtensionSupported()) + if(c.isExtensionSupported()) #endif { #ifndef MAGNUM_TARGET_GLES @@ -644,13 +695,13 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat } #endif - if(c->isExtensionSupported()) { + if(c.isExtensionSupported()) { _h(EXT::texture_filter_anisotropic) _l(Sampler::maxMaxAnisotropy()) } - if(c->isExtensionSupported()) { + if(c.isExtensionSupported()) { _h(KHR::debug) _l(AbstractObject::maxLabelLength()) @@ -660,7 +711,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat } #ifdef MAGNUM_TARGET_GLES2 - if(c->isExtensionSupported()) { + if(c.isExtensionSupported()) { _h(OES::texture_3D) _lvec(Texture3D::maxSize()) diff --git a/src/Magnum/PrimitiveQuery.h b/src/Magnum/PrimitiveQuery.h index f06724eea..0e84eba61 100644 --- a/src/Magnum/PrimitiveQuery.h +++ b/src/Magnum/PrimitiveQuery.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/CMakeLists.txt b/src/Magnum/Primitives/CMakeLists.txt index c4aa1d895..5f38603aa 100644 --- a/src/Magnum/Primitives/CMakeLists.txt +++ b/src/Magnum/Primitives/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -66,7 +66,6 @@ set_target_properties(MagnumPrimitives PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumPrimitives PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(MagnumPrimitives Magnum) install(TARGETS MagnumPrimitives @@ -79,5 +78,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum Primitives library for superprojects -set(MAGNUM_PRIMITIVES_LIBRARY MagnumPrimitives CACHE INTERNAL "") +# Magnum Primitives target alias for superprojects +add_library(Magnum::Primitives ALIAS MagnumPrimitives) diff --git a/src/Magnum/Primitives/Capsule.cpp b/src/Magnum/Primitives/Capsule.cpp index 17077f80f..54f8d4984 100644 --- a/src/Magnum/Primitives/Capsule.cpp +++ b/src/Magnum/Primitives/Capsule.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Capsule.h b/src/Magnum/Primitives/Capsule.h index 5558a2191..26c01f0fb 100644 --- a/src/Magnum/Primitives/Capsule.h +++ b/src/Magnum/Primitives/Capsule.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Circle.cpp b/src/Magnum/Primitives/Circle.cpp index e561d16d0..862d69522 100644 --- a/src/Magnum/Primitives/Circle.cpp +++ b/src/Magnum/Primitives/Circle.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Circle.h b/src/Magnum/Primitives/Circle.h index 67038c8f7..c0574b5e5 100644 --- a/src/Magnum/Primitives/Circle.h +++ b/src/Magnum/Primitives/Circle.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Crosshair.cpp b/src/Magnum/Primitives/Crosshair.cpp index bb5d4d547..916a25aee 100644 --- a/src/Magnum/Primitives/Crosshair.cpp +++ b/src/Magnum/Primitives/Crosshair.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Crosshair.h b/src/Magnum/Primitives/Crosshair.h index 91de70d5b..345a6b88d 100644 --- a/src/Magnum/Primitives/Crosshair.h +++ b/src/Magnum/Primitives/Crosshair.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Cube.cpp b/src/Magnum/Primitives/Cube.cpp index 28611ac02..1e03ab33d 100644 --- a/src/Magnum/Primitives/Cube.cpp +++ b/src/Magnum/Primitives/Cube.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Cube.h b/src/Magnum/Primitives/Cube.h index 568eb887f..7da2dbd68 100644 --- a/src/Magnum/Primitives/Cube.h +++ b/src/Magnum/Primitives/Cube.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Cylinder.cpp b/src/Magnum/Primitives/Cylinder.cpp index b656132c4..62b11c221 100644 --- a/src/Magnum/Primitives/Cylinder.cpp +++ b/src/Magnum/Primitives/Cylinder.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Cylinder.h b/src/Magnum/Primitives/Cylinder.h index 52c963b35..71bade368 100644 --- a/src/Magnum/Primitives/Cylinder.h +++ b/src/Magnum/Primitives/Cylinder.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Icosphere.cpp b/src/Magnum/Primitives/Icosphere.cpp index 5f26b8764..a4c785c2c 100644 --- a/src/Magnum/Primitives/Icosphere.cpp +++ b/src/Magnum/Primitives/Icosphere.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Icosphere.h b/src/Magnum/Primitives/Icosphere.h index 15af7153c..d4be14e96 100644 --- a/src/Magnum/Primitives/Icosphere.h +++ b/src/Magnum/Primitives/Icosphere.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Implementation/Spheroid.cpp b/src/Magnum/Primitives/Implementation/Spheroid.cpp index fe7c964b2..beb376554 100644 --- a/src/Magnum/Primitives/Implementation/Spheroid.cpp +++ b/src/Magnum/Primitives/Implementation/Spheroid.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Implementation/Spheroid.h b/src/Magnum/Primitives/Implementation/Spheroid.h index 0a1b5d6ff..91bc5e408 100644 --- a/src/Magnum/Primitives/Implementation/Spheroid.h +++ b/src/Magnum/Primitives/Implementation/Spheroid.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Implementation/WireframeSpheroid.cpp b/src/Magnum/Primitives/Implementation/WireframeSpheroid.cpp index e0815d1da..296be2ff3 100644 --- a/src/Magnum/Primitives/Implementation/WireframeSpheroid.cpp +++ b/src/Magnum/Primitives/Implementation/WireframeSpheroid.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Implementation/WireframeSpheroid.h b/src/Magnum/Primitives/Implementation/WireframeSpheroid.h index 090451b78..500ba47b2 100644 --- a/src/Magnum/Primitives/Implementation/WireframeSpheroid.h +++ b/src/Magnum/Primitives/Implementation/WireframeSpheroid.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Line.cpp b/src/Magnum/Primitives/Line.cpp index e346fa437..f7637a95e 100644 --- a/src/Magnum/Primitives/Line.cpp +++ b/src/Magnum/Primitives/Line.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Line.h b/src/Magnum/Primitives/Line.h index f928aac98..306fe6362 100644 --- a/src/Magnum/Primitives/Line.h +++ b/src/Magnum/Primitives/Line.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Plane.cpp b/src/Magnum/Primitives/Plane.cpp index bd7bc34fd..d947ba4a5 100644 --- a/src/Magnum/Primitives/Plane.cpp +++ b/src/Magnum/Primitives/Plane.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Plane.h b/src/Magnum/Primitives/Plane.h index 60840d147..c8b8e9bed 100644 --- a/src/Magnum/Primitives/Plane.h +++ b/src/Magnum/Primitives/Plane.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Square.cpp b/src/Magnum/Primitives/Square.cpp index 8a1da86bd..7e29212ae 100644 --- a/src/Magnum/Primitives/Square.cpp +++ b/src/Magnum/Primitives/Square.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Square.h b/src/Magnum/Primitives/Square.h index 257fa560f..15964d0f6 100644 --- a/src/Magnum/Primitives/Square.h +++ b/src/Magnum/Primitives/Square.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Test/CMakeLists.txt b/src/Magnum/Primitives/Test/CMakeLists.txt index 466de17bd..8e1f8857a 100644 --- a/src/Magnum/Primitives/Test/CMakeLists.txt +++ b/src/Magnum/Primitives/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Test/CapsuleTest.cpp b/src/Magnum/Primitives/Test/CapsuleTest.cpp index 34595ac19..8986cfc71 100644 --- a/src/Magnum/Primitives/Test/CapsuleTest.cpp +++ b/src/Magnum/Primitives/Test/CapsuleTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Test/CircleTest.cpp b/src/Magnum/Primitives/Test/CircleTest.cpp index f90598aed..f94fea571 100644 --- a/src/Magnum/Primitives/Test/CircleTest.cpp +++ b/src/Magnum/Primitives/Test/CircleTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Test/CylinderTest.cpp b/src/Magnum/Primitives/Test/CylinderTest.cpp index 6a95fe870..7a1070482 100644 --- a/src/Magnum/Primitives/Test/CylinderTest.cpp +++ b/src/Magnum/Primitives/Test/CylinderTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Test/IcosphereTest.cpp b/src/Magnum/Primitives/Test/IcosphereTest.cpp index e9fa0e617..a87d66c1a 100644 --- a/src/Magnum/Primitives/Test/IcosphereTest.cpp +++ b/src/Magnum/Primitives/Test/IcosphereTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/Test/UVSphereTest.cpp b/src/Magnum/Primitives/Test/UVSphereTest.cpp index ac827677c..d795ea8bd 100644 --- a/src/Magnum/Primitives/Test/UVSphereTest.cpp +++ b/src/Magnum/Primitives/Test/UVSphereTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/UVSphere.cpp b/src/Magnum/Primitives/UVSphere.cpp index b5cf66fca..943a4cde5 100644 --- a/src/Magnum/Primitives/UVSphere.cpp +++ b/src/Magnum/Primitives/UVSphere.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/UVSphere.h b/src/Magnum/Primitives/UVSphere.h index 309322d7f..c88012f89 100644 --- a/src/Magnum/Primitives/UVSphere.h +++ b/src/Magnum/Primitives/UVSphere.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Primitives/visibility.h b/src/Magnum/Primitives/visibility.h index 490479881..72de4fd4b 100644 --- a/src/Magnum/Primitives/visibility.h +++ b/src/Magnum/Primitives/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Query.h b/src/Magnum/Query.h index 09861256b..4cf79a22d 100644 --- a/src/Magnum/Query.h +++ b/src/Magnum/Query.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/RectangleTexture.cpp b/src/Magnum/RectangleTexture.cpp index 1a7b93a2b..1d5916e36 100644 --- a/src/Magnum/RectangleTexture.cpp +++ b/src/Magnum/RectangleTexture.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -37,10 +37,10 @@ namespace Magnum { Vector2i RectangleTexture::maxSize() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return {}; - GLint& value = Context::current()->state().texture->maxRectangleSize; + GLint& value = Context::current().state().texture->maxRectangleSize; if(value == 0) glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &value); @@ -78,5 +78,15 @@ BufferImage2D RectangleTexture::subImage(const Range2Di& range, BufferImage2D&& return std::move(image); } +CompressedImage2D RectangleTexture::compressedSubImage(const Range2Di& range, CompressedImage2D&& image) { + compressedSubImage(range, image); + return std::move(image); +} + +CompressedBufferImage2D RectangleTexture::compressedSubImage(const Range2Di& range, CompressedBufferImage2D&& image, const BufferUsage usage) { + compressedSubImage(range, image, usage); + return std::move(image); +} + } #endif diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index dabe8f4c2..c7c5f377f 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -80,6 +80,28 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { */ static Vector2i maxSize(); + /** + * @copybrief Texture::compressedBlockSize() + * + * See @ref Texture::compressedBlockSize() for more information. + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + */ + static Vector2i compressedBlockSize(TextureFormat format) { + return DataHelper<2>::compressedBlockSize(GL_TEXTURE_RECTANGLE, format); + } + + /** + * @copybrief Texture::compressedBlockDataSize() + * + * See @ref Texture::compressedBlockDataSize() for more information. + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @see @ref compressedBlockSize(), @fn_gl{Getinternalformat} with + * @def_gl{TEXTURE_COMPRESSED_BLOCK_SIZE} + */ + static Int compressedBlockDataSize(TextureFormat format) { + return AbstractTexture::compressedBlockDataSize(GL_TEXTURE_RECTANGLE, format); + } + /** * @brief Wrap existing OpenGL rectangle texture object * @param id OpenGL rectangle texture ID @@ -117,6 +139,25 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { */ explicit RectangleTexture(NoCreateT) noexcept: AbstractTexture{NoCreate, GL_TEXTURE_RECTANGLE} {} + /** + * @brief Bind texture to given image unit + * @param imageUnit Image unit + * @param access Image access + * @param format Image format + * + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + */ + void bindImage(Int imageUnit, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, 0, false, 0, access, format); + } + /** * @copybrief Texture::setMinificationFilter() * @return Reference to self (for method chaining) @@ -275,7 +316,7 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { * * See @ref Texture::imageSize() for more information. */ - Vector2i imageSize() { return DataHelper<2>::imageSize(*this, _target, 0); } + Vector2i imageSize() { return DataHelper<2>::imageSize(*this, 0); } /** * @brief Read texture to image @@ -392,6 +433,46 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { */ BufferImage2D subImage(const Range2Di& range, BufferImage2D&& image, BufferUsage usage); + /** + * @copybrief Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) + * + * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + */ + void compressedSubImage(const Range2Di& range, CompressedImage2D& image) { + AbstractTexture::compressedSubImage<2>(0, range, image); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedImage2D image = texture.compressedSubImage(range, {}); + * @endcode + */ + CompressedImage2D compressedSubImage(const Range2Di& range, CompressedImage2D&& image); + + /** + * @copybrief Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * + * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + */ + void compressedSubImage(const Range2Di& range, CompressedBufferImage2D& image, BufferUsage usage) { + AbstractTexture::compressedSubImage<2>(0, range, image, usage); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedBufferImage2D image = texture.compressedSubImage(range, {}, BufferUsage::StaticRead); + * @endcode + */ + CompressedBufferImage2D compressedSubImage(const Range2Di& range, CompressedBufferImage2D&& image, BufferUsage usage); + /** * @copybrief Texture::setImage() * @return Reference to self (for method chaining) diff --git a/src/Magnum/Renderbuffer.cpp b/src/Magnum/Renderbuffer.cpp index 9872f7dee..6a090d29e 100644 --- a/src/Magnum/Renderbuffer.cpp +++ b/src/Magnum/Renderbuffer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -37,7 +37,7 @@ namespace Magnum { Int Renderbuffer::maxSize() { - GLint& value = Context::current()->state().framebuffer->maxRenderbufferSize; + GLint& value = Context::current().state().framebuffer->maxRenderbufferSize; /* Get the value, if not already cached */ if(value == 0) @@ -49,11 +49,11 @@ Int Renderbuffer::maxSize() { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) Int Renderbuffer::maxSamples() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && !Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().framebuffer->maxSamples; + GLint& value = Context::current().state().framebuffer->maxSamples; /* Get the value, if not already cached */ if(value == 0) { @@ -69,7 +69,7 @@ Int Renderbuffer::maxSamples() { #endif Renderbuffer::Renderbuffer(): _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current()->state().framebuffer->createRenderbufferImplementation)(); + (this->*Context::current().state().framebuffer->createRenderbufferImplementation)(); } void Renderbuffer::createImplementationDefault() { @@ -88,7 +88,7 @@ Renderbuffer::~Renderbuffer() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* If bound, remove itself from state */ - GLuint& binding = Context::current()->state().framebuffer->renderbufferBinding; + GLuint& binding = Context::current().state().framebuffer->renderbufferBinding; if(binding == _id) binding = 0; glDeleteRenderbuffers(1, &_id); @@ -108,28 +108,28 @@ inline void Renderbuffer::createIfNotAlready() { #ifndef MAGNUM_TARGET_WEBGL std::string Renderbuffer::label() { createIfNotAlready(); - return Context::current()->state().debug->getLabelImplementation(GL_RENDERBUFFER, _id); + return Context::current().state().debug->getLabelImplementation(GL_RENDERBUFFER, _id); } Renderbuffer& Renderbuffer::setLabelInternal(const Containers::ArrayView label) { createIfNotAlready(); - Context::current()->state().debug->labelImplementation(GL_RENDERBUFFER, _id, label); + Context::current().state().debug->labelImplementation(GL_RENDERBUFFER, _id, label); return *this; } #endif void Renderbuffer::setStorage(const RenderbufferFormat internalFormat, const Vector2i& size) { - (this->*Context::current()->state().framebuffer->renderbufferStorageImplementation)(internalFormat, size); + (this->*Context::current().state().framebuffer->renderbufferStorageImplementation)(internalFormat, size); } #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void Renderbuffer::setStorageMultisample(const Int samples, const RenderbufferFormat internalFormat, const Vector2i& size) { - (this->*Context::current()->state().framebuffer->renderbufferStorageMultisampleImplementation)(samples, internalFormat, size); + (this->*Context::current().state().framebuffer->renderbufferStorageMultisampleImplementation)(samples, internalFormat, size); } #endif void Renderbuffer::bind() { - GLuint& binding = Context::current()->state().framebuffer->renderbufferBinding; + GLuint& binding = Context::current().state().framebuffer->renderbufferBinding; if(binding == _id) return; diff --git a/src/Magnum/Renderbuffer.h b/src/Magnum/Renderbuffer.h index eac272558..0569f1046 100644 --- a/src/Magnum/Renderbuffer.h +++ b/src/Magnum/Renderbuffer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/RenderbufferFormat.h b/src/Magnum/RenderbufferFormat.h index 5e1c5e4bd..dc3088e4e 100644 --- a/src/Magnum/RenderbufferFormat.h +++ b/src/Magnum/RenderbufferFormat.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Renderer.cpp b/src/Magnum/Renderer.cpp index 87222fbf6..fba5e0ec1 100644 --- a/src/Magnum/Renderer.cpp +++ b/src/Magnum/Renderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -62,7 +62,7 @@ void Renderer::setClearDepth(const Double depth) { #endif void Renderer::setClearDepth(Float depth) { - Context::current()->state().renderer->clearDepthfImplementation(depth); + Context::current().state().renderer->clearDepthfImplementation(depth); } void Renderer::setClearStencil(const Int stencil) { @@ -182,13 +182,13 @@ void Renderer::setLogicOperation(const LogicOperation operation) { #ifndef MAGNUM_TARGET_WEBGL Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #endif return ResetNotificationStrategy::NoResetNotification; - ResetNotificationStrategy& strategy = Context::current()->state().renderer->resetNotificationStrategy; + ResetNotificationStrategy& strategy = Context::current().state().renderer->resetNotificationStrategy; if(strategy == ResetNotificationStrategy()) { #ifndef MAGNUM_TARGET_GLES @@ -202,7 +202,7 @@ Renderer::ResetNotificationStrategy Renderer::resetNotificationStrategy() { } Renderer::GraphicsResetStatus Renderer::graphicsResetStatus() { - return Context::current()->state().renderer->graphicsResetStatusImplementation(); + return Context::current().state().renderer->graphicsResetStatusImplementation(); } #endif diff --git a/src/Magnum/Renderer.h b/src/Magnum/Renderer.h index e7bddd740..4b1f25d8d 100644 --- a/src/Magnum/Renderer.h +++ b/src/Magnum/Renderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -1207,7 +1207,7 @@ class MAGNUM_EXPORT Renderer { /*@}*/ #endif - /** @{ @name Renderer management */ + /** @{ @name Renderer synchronization */ /** * @brief Flush the pipeline @@ -1224,6 +1224,139 @@ class MAGNUM_EXPORT Renderer { */ static void finish() { glFinish(); } + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /** + * @brief Memory barrier + * + * @see @ref MemoryBarriers, @ref setMemoryBarrier(), + * @ref setMemoryBarrierByRegion() + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + enum class MemoryBarrier: GLbitfield { + /** Vertex data */ + VertexAttributeArray = GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT, + + /** Vertex indices */ + ElementArray = GL_ELEMENT_ARRAY_BARRIER_BIT, + + /** Uniforms */ + Uniform = GL_UNIFORM_BARRIER_BIT, + + /** Texture fetches */ + TextureFetch = GL_TEXTURE_FETCH_BARRIER_BIT, + + /** Shader image access */ + ShaderImageAccess = GL_SHADER_IMAGE_ACCESS_BARRIER_BIT, + + /** Indirect command data */ + Command = GL_COMMAND_BARRIER_BIT, + + /** Pixel buffer data */ + PixelBuffer = GL_PIXEL_BUFFER_BARRIER_BIT, + + /** Texture updates */ + TextureUpdate = GL_TEXTURE_UPDATE_BARRIER_BIT, + + /** Buffer updates */ + BufferUpdate = GL_BUFFER_UPDATE_BARRIER_BIT, + + /** Framebuffer operations */ + Framebuffer = GL_FRAMEBUFFER_BARRIER_BIT, + + /** Transform feedback data */ + TransformFeedback = GL_TRANSFORM_FEEDBACK_BARRIER_BIT, + + /** Atomic counters */ + AtomicCounter = GL_ATOMIC_COUNTER_BARRIER_BIT, + + /** + * Shader storage data + * @requires_gl43 Extension @extension{ARB,shader_storage_buffer_object} + * @requires_gles31 Shader storage is not available in OpenGL ES + * 3.0 and older. + * @requires_gles Shader storage is not available in WebGL. + */ + ShaderStorage = GL_ATOMIC_COUNTER_BARRIER_BIT + }; + + /** + * @brief Memory barriers + * + * @see @ref setMemoryBarrier(), @ref setMemoryBarrierByRegion() + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + typedef Containers::EnumSet MemoryBarriers; + + /** + * @brief Set memory barrier + * + * Calling the function ensures that operations on particular data + * after the barrier will reflect all data modifications before the + * barrier. + * @see @ref setMemoryBarrierByRegion(), @fn_gl{MemoryBarrier} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader load/store is not available in OpenGL ES 3.0 and older. + * @requires_gles Shader load/store is not available in WebGL. + */ + static void setMemoryBarrier(MemoryBarriers barriers) { + glMemoryBarrier(GLbitfield(barriers)); + } + + /** + * @brief Set memory barrier by region + * + * Behaves as @ref setMemoryBarrier(), except that the region is + * narrowed around area affected by particular fragment shader, thus + * only the fragment shader-related barries are supported: + * + * - @ref MemoryBarrier::AtomicCounter + * - @ref MemoryBarrier::Framebuffer + * - @ref MemoryBarrier::ShaderImageAccess + * - @ref MemoryBarrier::ShaderStorage + * - @ref MemoryBarrier::TextureFetch + * - @ref MemoryBarrier::Uniform + * + * @see @fn_gl{MemoryBarrierByRegion} + * @requires_gl45 Extension @extension{ARB,ES3_1_compatibility} + * @requires_gles31 Shader load/store is not available in OpenGL ES 3.0 + * and older. + * @requires_gles Shader load/store is not available in WebGL. + */ + static void setMemoryBarrierByRegion(MemoryBarriers barriers) { + glMemoryBarrierByRegion(GLbitfield(barriers)); + } + #endif + + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Set texture barrier + * + * Calling the function ensures that texel fetches in drawing + * operations after the barrier will reflect texel writes before the + * barrier. + * @see @fn_gl{TextureBarrier} + * @requires_gl45 Extension @extension{ARB,texture_barrier} + * @requires_gl Texture barrier is not available in OpenGL ES or WebGL. + */ + static void setTextureBarrier() { + glTextureBarrier(); + } + #endif + + /*@}*/ + + /** @{ @name Renderer management */ + /** * @brief Error status * @@ -1435,6 +1568,10 @@ class MAGNUM_EXPORT Renderer { #endif }; +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +CORRADE_ENUMSET_OPERATORS(Renderer::MemoryBarriers) +#endif + /** @debugoperatorclassenum{Magnum::Renderer,Magnum::Renderer::Error} */ MAGNUM_EXPORT Debug& operator<<(Debug& debug, Renderer::Error value); diff --git a/src/Magnum/Resource.cpp b/src/Magnum/Resource.cpp index 2fc5c9d11..8106b18ed 100644 --- a/src/Magnum/Resource.cpp +++ b/src/Magnum/Resource.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Resource.h b/src/Magnum/Resource.h index 7738c8d2a..febe51204 100644 --- a/src/Magnum/Resource.h +++ b/src/Magnum/Resource.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/ResourceManager.h b/src/Magnum/ResourceManager.h index 43e95be60..732b11536 100644 --- a/src/Magnum/ResourceManager.h +++ b/src/Magnum/ResourceManager.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/ResourceManager.hpp b/src/Magnum/ResourceManager.hpp index 16b7f2127..d0fc54225 100644 --- a/src/Magnum/ResourceManager.hpp +++ b/src/Magnum/ResourceManager.hpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SampleQuery.h b/src/Magnum/SampleQuery.h index adb80dc55..00432c687 100644 --- a/src/Magnum/SampleQuery.h +++ b/src/Magnum/SampleQuery.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Sampler.cpp b/src/Magnum/Sampler.cpp index d9ebb810d..e2a8fee14 100644 --- a/src/Magnum/Sampler.cpp +++ b/src/Magnum/Sampler.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -48,10 +48,10 @@ static_assert((filter_or(Nearest, Base) == GL_NEAREST) && #undef filter_or Float Sampler::maxMaxAnisotropy() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0.0f; - GLfloat& value = Context::current()->state().texture->maxMaxAnisotropy; + GLfloat& value = Context::current().state().texture->maxMaxAnisotropy; /* Get the value, if not already cached */ if(value == 0.0f) diff --git a/src/Magnum/Sampler.h b/src/Magnum/Sampler.h index 3e71bc240..a8386d723 100644 --- a/src/Magnum/Sampler.h +++ b/src/Magnum/Sampler.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractCamera.h b/src/Magnum/SceneGraph/AbstractCamera.h index 75c685393..698ece77a 100644 --- a/src/Magnum/SceneGraph/AbstractCamera.h +++ b/src/Magnum/SceneGraph/AbstractCamera.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractCamera.hpp b/src/Magnum/SceneGraph/AbstractCamera.hpp index 4a22b3028..8907dbf60 100644 --- a/src/Magnum/SceneGraph/AbstractCamera.hpp +++ b/src/Magnum/SceneGraph/AbstractCamera.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractFeature.h b/src/Magnum/SceneGraph/AbstractFeature.h index 5c9a7c48d..03633d50d 100644 --- a/src/Magnum/SceneGraph/AbstractFeature.h +++ b/src/Magnum/SceneGraph/AbstractFeature.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractFeature.hpp b/src/Magnum/SceneGraph/AbstractFeature.hpp index 0794121cf..00ad7fee4 100644 --- a/src/Magnum/SceneGraph/AbstractFeature.hpp +++ b/src/Magnum/SceneGraph/AbstractFeature.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractGroupedFeature.h b/src/Magnum/SceneGraph/AbstractGroupedFeature.h index 99ef67113..3a728751a 100644 --- a/src/Magnum/SceneGraph/AbstractGroupedFeature.h +++ b/src/Magnum/SceneGraph/AbstractGroupedFeature.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractObject.h b/src/Magnum/SceneGraph/AbstractObject.h index 305543e5a..4f0c60adf 100644 --- a/src/Magnum/SceneGraph/AbstractObject.h +++ b/src/Magnum/SceneGraph/AbstractObject.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractTransformation.h b/src/Magnum/SceneGraph/AbstractTransformation.h index 9b910445c..029634cd1 100644 --- a/src/Magnum/SceneGraph/AbstractTransformation.h +++ b/src/Magnum/SceneGraph/AbstractTransformation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractTranslation.h b/src/Magnum/SceneGraph/AbstractTranslation.h index 5ba25e5f8..834a3dfb4 100644 --- a/src/Magnum/SceneGraph/AbstractTranslation.h +++ b/src/Magnum/SceneGraph/AbstractTranslation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractTranslationRotation2D.h b/src/Magnum/SceneGraph/AbstractTranslationRotation2D.h index 4111d0cc8..f5a7bf747 100644 --- a/src/Magnum/SceneGraph/AbstractTranslationRotation2D.h +++ b/src/Magnum/SceneGraph/AbstractTranslationRotation2D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractTranslationRotation3D.h b/src/Magnum/SceneGraph/AbstractTranslationRotation3D.h index 395861ac4..72a3bdef3 100644 --- a/src/Magnum/SceneGraph/AbstractTranslationRotation3D.h +++ b/src/Magnum/SceneGraph/AbstractTranslationRotation3D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractTranslationRotationScaling2D.h b/src/Magnum/SceneGraph/AbstractTranslationRotationScaling2D.h index fc2341825..e7a04425e 100644 --- a/src/Magnum/SceneGraph/AbstractTranslationRotationScaling2D.h +++ b/src/Magnum/SceneGraph/AbstractTranslationRotationScaling2D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AbstractTranslationRotationScaling3D.h b/src/Magnum/SceneGraph/AbstractTranslationRotationScaling3D.h index 885013e98..f8078b880 100644 --- a/src/Magnum/SceneGraph/AbstractTranslationRotationScaling3D.h +++ b/src/Magnum/SceneGraph/AbstractTranslationRotationScaling3D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Animable.cpp b/src/Magnum/SceneGraph/Animable.cpp index 7e537e387..4ea4ce845 100644 --- a/src/Magnum/SceneGraph/Animable.cpp +++ b/src/Magnum/SceneGraph/Animable.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Animable.h b/src/Magnum/SceneGraph/Animable.h index 4e1df2a3c..3586abd72 100644 --- a/src/Magnum/SceneGraph/Animable.h +++ b/src/Magnum/SceneGraph/Animable.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -78,7 +78,7 @@ typedef SceneGraph::Scene Scene3D; class AnimableObject: public Object3D, SceneGraph::Animable3D { public: - AnimableObject(Object3D* parent = nullptr, SceneGraph::DrawableGroup3D* group = nullptr): Object3D{parent}, SceneGraph::Animable3D{*this, group} { + AnimableObject(Object3D* parent = nullptr, SceneGraph::AnimableGroup3D* group = nullptr): Object3D{parent}, SceneGraph::Animable3D{*this, group} { setDuration(10.0f); // ... } diff --git a/src/Magnum/SceneGraph/Animable.hpp b/src/Magnum/SceneGraph/Animable.hpp index f714d32a6..dc9b71031 100644 --- a/src/Magnum/SceneGraph/Animable.hpp +++ b/src/Magnum/SceneGraph/Animable.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/AnimableGroup.h b/src/Magnum/SceneGraph/AnimableGroup.h index b3a29d650..30a8af94e 100644 --- a/src/Magnum/SceneGraph/AnimableGroup.h +++ b/src/Magnum/SceneGraph/AnimableGroup.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/CMakeLists.txt b/src/Magnum/SceneGraph/CMakeLists.txt index bb5dfddfe..80ff2cafb 100644 --- a/src/Magnum/SceneGraph/CMakeLists.txt +++ b/src/Magnum/SceneGraph/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -79,8 +79,9 @@ endif() add_library(MagnumSceneGraphObjects OBJECT ${MagnumSceneGraph_SRCS} ${MagnumSceneGraph_HEADERS}) +target_include_directories(MagnumSceneGraphObjects PUBLIC $) if(NOT BUILD_STATIC) - set_target_properties(MagnumSceneGraphObjects PROPERTIES COMPILE_FLAGS "-DMagnumSceneGraphObjects_EXPORTS") + target_compile_definitions(MagnumSceneGraphObjects PRIVATE "MagnumSceneGraphObjects_EXPORTS") endif() if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumSceneGraphObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -94,7 +95,6 @@ set_target_properties(MagnumSceneGraph PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumSceneGraph PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(MagnumSceneGraph Magnum) install(TARGETS MagnumSceneGraph @@ -108,9 +108,9 @@ if(BUILD_TESTS) add_library(MagnumSceneGraphTestLib ${SHARED_OR_STATIC} $ ${MagnumSceneGraph_GracefulAssert_SRCS}) - set_target_properties(MagnumSceneGraphTestLib PROPERTIES - COMPILE_FLAGS "-DCORRADE_GRACEFUL_ASSERT -DMagnumSceneGraph_EXPORTS" - DEBUG_POSTFIX "-d") + set_target_properties(MagnumSceneGraphTestLib PROPERTIES DEBUG_POSTFIX "-d") + target_compile_definitions(MagnumSceneGraphTestLib PRIVATE + "CORRADE_GRACEFUL_ASSERT" "MagnumSceneGraph_EXPORTS") target_link_libraries(MagnumSceneGraphTestLib MagnumMathTestLib) # On Windows we need to install first and then run the tests to avoid "DLL @@ -125,5 +125,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum SceneGraph library for superprojects -set(MAGNUM_SCENEGRAPH_LIBRARY MagnumSceneGraph CACHE INTERNAL "") +# Magnum SceneGraph target alias for superprojects +add_library(Magnum::SceneGraph ALIAS MagnumSceneGraph) diff --git a/src/Magnum/SceneGraph/Camera.h b/src/Magnum/SceneGraph/Camera.h index 0935bb817..13edca414 100644 --- a/src/Magnum/SceneGraph/Camera.h +++ b/src/Magnum/SceneGraph/Camera.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Camera.hpp b/src/Magnum/SceneGraph/Camera.hpp index 1a7e64acc..a176ada83 100644 --- a/src/Magnum/SceneGraph/Camera.hpp +++ b/src/Magnum/SceneGraph/Camera.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Camera2D.h b/src/Magnum/SceneGraph/Camera2D.h index d4cb8f191..8cd3fefd1 100644 --- a/src/Magnum/SceneGraph/Camera2D.h +++ b/src/Magnum/SceneGraph/Camera2D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Camera2D.hpp b/src/Magnum/SceneGraph/Camera2D.hpp index aaf908964..81c7eae67 100644 --- a/src/Magnum/SceneGraph/Camera2D.hpp +++ b/src/Magnum/SceneGraph/Camera2D.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Camera3D.h b/src/Magnum/SceneGraph/Camera3D.h index 11703ff70..44ffac7c2 100644 --- a/src/Magnum/SceneGraph/Camera3D.h +++ b/src/Magnum/SceneGraph/Camera3D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Camera3D.hpp b/src/Magnum/SceneGraph/Camera3D.hpp index 4449e49c6..ef1aebc91 100644 --- a/src/Magnum/SceneGraph/Camera3D.hpp +++ b/src/Magnum/SceneGraph/Camera3D.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Drawable.h b/src/Magnum/SceneGraph/Drawable.h index 3f1d8ff0f..cb4755f85 100644 --- a/src/Magnum/SceneGraph/Drawable.h +++ b/src/Magnum/SceneGraph/Drawable.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Drawable.hpp b/src/Magnum/SceneGraph/Drawable.hpp index 1800c80c5..2ba02f574 100644 --- a/src/Magnum/SceneGraph/Drawable.hpp +++ b/src/Magnum/SceneGraph/Drawable.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/DualComplexTransformation.h b/src/Magnum/SceneGraph/DualComplexTransformation.h index 6ead059a0..1df8a21d1 100644 --- a/src/Magnum/SceneGraph/DualComplexTransformation.h +++ b/src/Magnum/SceneGraph/DualComplexTransformation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/DualQuaternionTransformation.h b/src/Magnum/SceneGraph/DualQuaternionTransformation.h index 44f2c2397..364a87569 100644 --- a/src/Magnum/SceneGraph/DualQuaternionTransformation.h +++ b/src/Magnum/SceneGraph/DualQuaternionTransformation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/FeatureGroup.h b/src/Magnum/SceneGraph/FeatureGroup.h index 49bbfea73..ee162003e 100644 --- a/src/Magnum/SceneGraph/FeatureGroup.h +++ b/src/Magnum/SceneGraph/FeatureGroup.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/FeatureGroup.hpp b/src/Magnum/SceneGraph/FeatureGroup.hpp index 8b5f86a5f..ebbe86e85 100644 --- a/src/Magnum/SceneGraph/FeatureGroup.hpp +++ b/src/Magnum/SceneGraph/FeatureGroup.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/MatrixTransformation2D.h b/src/Magnum/SceneGraph/MatrixTransformation2D.h index 79fce8b85..680c35f6a 100644 --- a/src/Magnum/SceneGraph/MatrixTransformation2D.h +++ b/src/Magnum/SceneGraph/MatrixTransformation2D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/MatrixTransformation3D.h b/src/Magnum/SceneGraph/MatrixTransformation3D.h index 1528372d4..6dca54140 100644 --- a/src/Magnum/SceneGraph/MatrixTransformation3D.h +++ b/src/Magnum/SceneGraph/MatrixTransformation3D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Object.h b/src/Magnum/SceneGraph/Object.h index 26913b822..dbc4497ee 100644 --- a/src/Magnum/SceneGraph/Object.h +++ b/src/Magnum/SceneGraph/Object.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Object.hpp b/src/Magnum/SceneGraph/Object.hpp index 9d3bcffeb..e3ceaeaa4 100644 --- a/src/Magnum/SceneGraph/Object.hpp +++ b/src/Magnum/SceneGraph/Object.hpp @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -212,8 +212,10 @@ template std::vector Ob } std::vector>> jointObjects(objects); + #if !defined(CORRADE_NO_ASSERT) || defined(CORRADE_GRACEFUL_ASSERT) /* Scene object */ const Scene* scene = this->scene(); + #endif /* Nearest common ancestor not yet implemented - assert this is done on scene */ CORRADE_ASSERT(scene == this, "SceneGraph::Object::transformationMatrices(): currently implemented only for Scene", {}); diff --git a/src/Magnum/SceneGraph/RigidMatrixTransformation2D.h b/src/Magnum/SceneGraph/RigidMatrixTransformation2D.h index b0f7f1e60..81a55b41a 100644 --- a/src/Magnum/SceneGraph/RigidMatrixTransformation2D.h +++ b/src/Magnum/SceneGraph/RigidMatrixTransformation2D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/RigidMatrixTransformation3D.h b/src/Magnum/SceneGraph/RigidMatrixTransformation3D.h index 443299fc6..4d73c01e1 100644 --- a/src/Magnum/SceneGraph/RigidMatrixTransformation3D.h +++ b/src/Magnum/SceneGraph/RigidMatrixTransformation3D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Scene.h b/src/Magnum/SceneGraph/Scene.h index b6475e285..8232078fe 100644 --- a/src/Magnum/SceneGraph/Scene.h +++ b/src/Magnum/SceneGraph/Scene.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/SceneGraph.h b/src/Magnum/SceneGraph/SceneGraph.h index 262747542..7b4e292b2 100644 --- a/src/Magnum/SceneGraph/SceneGraph.h +++ b/src/Magnum/SceneGraph/SceneGraph.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Test/AnimableTest.cpp b/src/Magnum/SceneGraph/Test/AnimableTest.cpp index 5b207d60d..844cc2090 100644 --- a/src/Magnum/SceneGraph/Test/AnimableTest.cpp +++ b/src/Magnum/SceneGraph/Test/AnimableTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Test/CMakeLists.txt b/src/Magnum/SceneGraph/Test/CMakeLists.txt index fa2e0934f..4f4d7f48c 100644 --- a/src/Magnum/SceneGraph/Test/CMakeLists.txt +++ b/src/Magnum/SceneGraph/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -35,9 +35,10 @@ corrade_add_test(SceneGraphRigidMatrixTrans___3DTest RigidMatrixTransformation3D corrade_add_test(SceneGraphSceneTest SceneTest.cpp LIBRARIES MagnumSceneGraph) corrade_add_test(SceneGraphTranslationTransfo___Test TranslationTransformationTest.cpp LIBRARIES MagnumSceneGraph) -set_target_properties(SceneGraphDualComplexTransfo___Test +set_property(TARGET + SceneGraphDualComplexTransfo___Test SceneGraphDualQuaternionTran___Test SceneGraphRigidMatrixTrans___2DTest SceneGraphRigidMatrixTrans___3DTest SceneGraphTranslationTransfo___Test - PROPERTIES COMPILE_FLAGS "-DCORRADE_GRACEFUL_ASSERT") + PROPERTY COMPILE_DEFINITIONS "CORRADE_GRACEFUL_ASSERT") diff --git a/src/Magnum/SceneGraph/Test/CameraTest.cpp b/src/Magnum/SceneGraph/Test/CameraTest.cpp index 7d0ea7ea4..5a42218e6 100644 --- a/src/Magnum/SceneGraph/Test/CameraTest.cpp +++ b/src/Magnum/SceneGraph/Test/CameraTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Test/DualComplexTransformationTest.cpp b/src/Magnum/SceneGraph/Test/DualComplexTransformationTest.cpp index 0dfacc46b..7bdcbc9f5 100644 --- a/src/Magnum/SceneGraph/Test/DualComplexTransformationTest.cpp +++ b/src/Magnum/SceneGraph/Test/DualComplexTransformationTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -92,7 +92,7 @@ void DualComplexTransformationTest::setTransformation() { /* Can't transform with non-rigid transformation */ std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; o.setTransformation(DualComplex({1.0f, 2.0f}, {})); CORRADE_COMPARE(out.str(), "SceneGraph::DualComplexTransformation::setTransformation(): the dual complex number is not normalized\n"); @@ -124,7 +124,7 @@ void DualComplexTransformationTest::transform() { /* Can't transform with non-rigid transformation */ Object2D o; std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; o.transform(DualComplex({1.0f, 2.0f}, {})); CORRADE_COMPARE(out.str(), "SceneGraph::DualComplexTransformation::transform(): the dual complex number is not normalized\n"); } { diff --git a/src/Magnum/SceneGraph/Test/DualQuaternionTransformationTest.cpp b/src/Magnum/SceneGraph/Test/DualQuaternionTransformationTest.cpp index 35e7101d1..fb931d98a 100644 --- a/src/Magnum/SceneGraph/Test/DualQuaternionTransformationTest.cpp +++ b/src/Magnum/SceneGraph/Test/DualQuaternionTransformationTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -66,7 +66,7 @@ DualQuaternionTransformationTest::DualQuaternionTransformationTest() { void DualQuaternionTransformationTest::fromMatrix() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Implementation::Transformation::fromMatrix(Matrix4::scaling(Vector3(4.0f))); CORRADE_COMPARE(o.str(), "SceneGraph::DualQuaternionTransformation: the matrix doesn't represent rigid transformation\n"); @@ -97,7 +97,7 @@ void DualQuaternionTransformationTest::setTransformation() { /* Can't transform with non-rigid transformation */ std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; o.setTransformation(DualQuaternion({{1.0f, 2.0f, 3.0f}, 4.0f}, {})); CORRADE_COMPARE(out.str(), "SceneGraph::DualQuaternionTransformation::setTransformation(): the dual quaternion is not normalized\n"); @@ -130,7 +130,7 @@ void DualQuaternionTransformationTest::transform() { /* Can't transform with non-rigid transformation */ Object3D o; std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; o.transform(DualQuaternion({{1.0f, 2.0f, 3.0f}, 4.0f}, {})); CORRADE_COMPARE(out.str(), "SceneGraph::DualQuaternionTransformation::transform(): the dual quaternion is not normalized\n"); } { diff --git a/src/Magnum/SceneGraph/Test/MatrixTransformation2DTest.cpp b/src/Magnum/SceneGraph/Test/MatrixTransformation2DTest.cpp index fd0ebae72..11a83204f 100644 --- a/src/Magnum/SceneGraph/Test/MatrixTransformation2DTest.cpp +++ b/src/Magnum/SceneGraph/Test/MatrixTransformation2DTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Test/MatrixTransformation3DTest.cpp b/src/Magnum/SceneGraph/Test/MatrixTransformation3DTest.cpp index 0ccd9c71d..fef5c236e 100644 --- a/src/Magnum/SceneGraph/Test/MatrixTransformation3DTest.cpp +++ b/src/Magnum/SceneGraph/Test/MatrixTransformation3DTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Test/ObjectTest.cpp b/src/Magnum/SceneGraph/Test/ObjectTest.cpp index d084482e9..329e2eee6 100644 --- a/src/Magnum/SceneGraph/Test/ObjectTest.cpp +++ b/src/Magnum/SceneGraph/Test/ObjectTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -172,7 +172,7 @@ void ObjectTest::setParentKeepTransformation() { /* Old parent and new parent must share the same scene */ std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Scene3D scene; childOne->setParentKeepTransformation(&scene); CORRADE_COMPARE(o.str(), "SceneGraph::Object::setParentKeepTransformation(): both parents must be in the same scene\n"); @@ -278,7 +278,7 @@ void ObjectTest::transformationsRelative() { void ObjectTest::transformationsOrphan() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; /* Transformation of objects not part of the same scene */ Scene3D s; diff --git a/src/Magnum/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp b/src/Magnum/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp index 8fca0cba9..5896807d1 100644 --- a/src/Magnum/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp +++ b/src/Magnum/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -68,7 +68,7 @@ RigidMatrixTransformation2DTest::RigidMatrixTransformation2DTest() { void RigidMatrixTransformation2DTest::fromMatrix() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Implementation::Transformation::fromMatrix(Matrix3::scaling(Vector2(4.0f))); CORRADE_COMPARE(o.str(), "SceneGraph::RigidMatrixTransformation2D: the matrix doesn't represent rigid transformation\n"); @@ -97,7 +97,7 @@ void RigidMatrixTransformation2DTest::setTransformation() { /* Can't transform with non-rigid transformation */ std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; o.setTransformation(Matrix3::scaling(Vector2(3.0f))); CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation2D::setTransformation(): the matrix doesn't represent rigid transformation\n"); @@ -129,7 +129,7 @@ void RigidMatrixTransformation2DTest::transform() { /* Can't transform with non-rigid transformation */ Object2D o; std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; o.transform(Matrix3::scaling(Vector2(3.0f))); CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation2D::transform(): the matrix doesn't represent rigid transformation\n"); } { diff --git a/src/Magnum/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp b/src/Magnum/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp index a89758013..8306fd3ac 100644 --- a/src/Magnum/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp +++ b/src/Magnum/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -68,7 +68,7 @@ RigidMatrixTransformation3DTest::RigidMatrixTransformation3DTest() { void RigidMatrixTransformation3DTest::fromMatrix() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Implementation::Transformation::fromMatrix(Matrix4::scaling(Vector3(4.0f))); CORRADE_COMPARE(o.str(), "SceneGraph::RigidMatrixTransformation3D: the matrix doesn't represent rigid transformation\n"); @@ -97,7 +97,7 @@ void RigidMatrixTransformation3DTest::setTransformation() { /* Can't transform with non-rigid transformation */ std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; o.setTransformation(Matrix4::scaling(Vector3(3.0f))); CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation3D::setTransformation(): the matrix doesn't represent rigid transformation\n"); @@ -130,7 +130,7 @@ void RigidMatrixTransformation3DTest::transform() { /* Can't transform with non-rigid transformation */ Object3D o; std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; o.transform(Matrix4::scaling(Vector3(3.0f))); CORRADE_COMPARE(out.str(), "SceneGraph::RigidMatrixTransformation3D::transform(): the matrix doesn't represent rigid transformation\n"); } { diff --git a/src/Magnum/SceneGraph/Test/SceneTest.cpp b/src/Magnum/SceneGraph/Test/SceneTest.cpp index e646f1ff8..c6f1aa2f6 100644 --- a/src/Magnum/SceneGraph/Test/SceneTest.cpp +++ b/src/Magnum/SceneGraph/Test/SceneTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/Test/TranslationTransformationTest.cpp b/src/Magnum/SceneGraph/Test/TranslationTransformationTest.cpp index 6d6564ddd..e14887ca4 100644 --- a/src/Magnum/SceneGraph/Test/TranslationTransformationTest.cpp +++ b/src/Magnum/SceneGraph/Test/TranslationTransformationTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -67,7 +67,7 @@ TranslationTransformationTest::TranslationTransformationTest() { void TranslationTransformationTest::fromMatrix() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; Implementation::Transformation::fromMatrix(Matrix3::scaling(Vector2(4.0f))); CORRADE_COMPARE(o.str(), "SceneGraph::TranslationTransformation: the matrix doesn't represent pure translation\n"); diff --git a/src/Magnum/SceneGraph/TranslationTransformation.h b/src/Magnum/SceneGraph/TranslationTransformation.h index fee2f699d..c0b140391 100644 --- a/src/Magnum/SceneGraph/TranslationTransformation.h +++ b/src/Magnum/SceneGraph/TranslationTransformation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/instantiation.cpp b/src/Magnum/SceneGraph/instantiation.cpp index 44afe9799..61ee0e200 100644 --- a/src/Magnum/SceneGraph/instantiation.cpp +++ b/src/Magnum/SceneGraph/instantiation.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/SceneGraph/visibility.h b/src/Magnum/SceneGraph/visibility.h index ffe2e0cef..b7f026ef4 100644 --- a/src/Magnum/SceneGraph/visibility.h +++ b/src/Magnum/SceneGraph/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shader.cpp b/src/Magnum/Shader.cpp index cd4d6556b..eba5bb1ad 100644 --- a/src/Magnum/Shader.cpp +++ b/src/Magnum/Shader.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -89,26 +89,26 @@ UnsignedInt typeToIndex(const Shader::Type type) { #ifndef MAGNUM_TARGET_GLES bool isTypeSupported(const Shader::Type type) { - if(type == Shader::Type::Geometry && !Context::current()->isExtensionSupported()) + if(type == Shader::Type::Geometry && !Context::current().isExtensionSupported()) return false; - if((type == Shader::Type::TessellationControl || type == Shader::Type::TessellationEvaluation) && !Context::current()->isExtensionSupported()) + if((type == Shader::Type::TessellationControl || type == Shader::Type::TessellationEvaluation) && !Context::current().isExtensionSupported()) return false; - if(type == Shader::Type::Compute && !Context::current()->isExtensionSupported()) + if(type == Shader::Type::Compute && !Context::current().isExtensionSupported()) return false; return true; } #elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) bool isTypeSupported(const Shader::Type type) { - if(type == Shader::Type::Geometry && !Context::current()->isExtensionSupported()) + if(type == Shader::Type::Geometry && !Context::current().isExtensionSupported()) return false; - if((type == Shader::Type::TessellationControl || type == Shader::Type::TessellationEvaluation) && !Context::current()->isExtensionSupported()) + if((type == Shader::Type::TessellationControl || type == Shader::Type::TessellationEvaluation) && !Context::current().isExtensionSupported()) return false; - if(type == Shader::Type::Compute && !Context::current()->isVersionSupported(Version::GLES310)) + if(type == Shader::Type::Compute && !Context::current().isVersionSupported(Version::GLES310)) return false; return true; @@ -120,12 +120,12 @@ constexpr bool isTypeSupported(Shader::Type) { return true; } } Int Shader::maxVertexOutputComponents() { - GLint& value = Context::current()->state().shader->maxVertexOutputComponents; + GLint& value = Context::current().state().shader->maxVertexOutputComponents; /* Get the value, if not already cached */ if(value == 0) { #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isVersionSupported(Version::GL320)) + if(Context::current().isVersionSupported(Version::GL320)) glGetIntegerv(GL_MAX_VERTEX_OUTPUT_COMPONENTS, &value); else glGetIntegerv(GL_MAX_VARYING_COMPONENTS, &value); @@ -143,14 +143,14 @@ Int Shader::maxVertexOutputComponents() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) Int Shader::maxTessellationControlInputComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxTessellationControlInputComponents; + GLint& value = Context::current().state().shader->maxTessellationControlInputComponents; /* Get the value, if not already cached */ if(value == 0) glGetIntegerv( @@ -166,14 +166,14 @@ Int Shader::maxTessellationControlInputComponents() { Int Shader::maxTessellationControlOutputComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxTessellationControlOutputComponents; + GLint& value = Context::current().state().shader->maxTessellationControlOutputComponents; /* Get the value, if not already cached */ if(value == 0) glGetIntegerv( @@ -189,14 +189,14 @@ Int Shader::maxTessellationControlOutputComponents() { Int Shader::maxTessellationControlTotalOutputComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxTessellationControlTotalOutputComponents; + GLint& value = Context::current().state().shader->maxTessellationControlTotalOutputComponents; /* Get the value, if not already cached */ if(value == 0) glGetIntegerv( @@ -212,14 +212,14 @@ Int Shader::maxTessellationControlTotalOutputComponents() { Int Shader::maxTessellationEvaluationInputComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxTessellationEvaluationInputComponents; + GLint& value = Context::current().state().shader->maxTessellationEvaluationInputComponents; /* Get the value, if not already cached */ if(value == 0) glGetIntegerv( @@ -235,14 +235,14 @@ Int Shader::maxTessellationEvaluationInputComponents() { Int Shader::maxTessellationEvaluationOutputComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxTessellationEvaluationOutputComponents; + GLint& value = Context::current().state().shader->maxTessellationEvaluationOutputComponents; /* Get the value, if not already cached */ if(value == 0) glGetIntegerv( @@ -258,14 +258,14 @@ Int Shader::maxTessellationEvaluationOutputComponents() { Int Shader::maxGeometryInputComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxGeometryInputComponents; + GLint& value = Context::current().state().shader->maxGeometryInputComponents; /* Get the value, if not already cached */ /** @todo The extension has only `GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB`, this is supported since GL 3.2 (wtf?) */ @@ -282,14 +282,14 @@ Int Shader::maxGeometryInputComponents() { Int Shader::maxGeometryOutputComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxGeometryOutputComponents; + GLint& value = Context::current().state().shader->maxGeometryOutputComponents; /* Get the value, if not already cached */ /** @todo The extension has only `GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB`, this is supported since GL 3.2 (wtf?) */ @@ -306,14 +306,14 @@ Int Shader::maxGeometryOutputComponents() { Int Shader::maxGeometryTotalOutputComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxGeometryTotalOutputComponents; + GLint& value = Context::current().state().shader->maxGeometryTotalOutputComponents; /* Get the value, if not already cached */ if(value == 0) glGetIntegerv( @@ -329,12 +329,12 @@ Int Shader::maxGeometryTotalOutputComponents() { #endif Int Shader::maxFragmentInputComponents() { - GLint& value = Context::current()->state().shader->maxFragmentInputComponents; + GLint& value = Context::current().state().shader->maxFragmentInputComponents; /* Get the value, if not already cached */ if(value == 0) { #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isVersionSupported(Version::GL320)) + if(Context::current().isVersionSupported(Version::GL320)) glGetIntegerv(GL_MAX_FRAGMENT_INPUT_COMPONENTS, &value); else glGetIntegerv(GL_MAX_VARYING_COMPONENTS, &value); @@ -353,9 +353,9 @@ Int Shader::maxFragmentInputComponents() { Int Shader::maxAtomicCounterBuffers(const Type type) { if( #ifndef MAGNUM_TARGET_GLES - !Context::current()->isExtensionSupported() || + !Context::current().isExtensionSupported() || #else - !Context::current()->isVersionSupported(Version::GLES310) || + !Context::current().isVersionSupported(Version::GLES310) || #endif !isTypeSupported(type)) { @@ -363,7 +363,7 @@ Int Shader::maxAtomicCounterBuffers(const Type type) { } const UnsignedInt index = typeToIndex(type); - GLint& value = Context::current()->state().shader->maxAtomicCounterBuffers[index]; + GLint& value = Context::current().state().shader->maxAtomicCounterBuffers[index]; /* Get the value, if not already cached */ constexpr static GLenum what[] = { @@ -386,13 +386,13 @@ Int Shader::maxAtomicCounterBuffers(const Type type) { Int Shader::maxCombinedAtomicCounterBuffers() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shader->maxCombinedAtomicCounterBuffers; + GLint& value = Context::current().state().shader->maxCombinedAtomicCounterBuffers; /* Get the value, if not already cached */ if(value == 0) @@ -404,9 +404,9 @@ Int Shader::maxCombinedAtomicCounterBuffers() { Int Shader::maxAtomicCounters(const Type type) { if( #ifndef MAGNUM_TARGET_GLES - !Context::current()->isExtensionSupported() || + !Context::current().isExtensionSupported() || #else - !Context::current()->isVersionSupported(Version::GLES310) || + !Context::current().isVersionSupported(Version::GLES310) || #endif !isTypeSupported(type)) { @@ -414,7 +414,7 @@ Int Shader::maxAtomicCounters(const Type type) { } const UnsignedInt index = typeToIndex(type); - GLint& value = Context::current()->state().shader->maxAtomicCounters[index]; + GLint& value = Context::current().state().shader->maxAtomicCounters[index]; /* Get the value, if not already cached */ constexpr static GLenum what[] = { @@ -437,13 +437,13 @@ Int Shader::maxAtomicCounters(const Type type) { Int Shader::maxCombinedAtomicCounters() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shader->maxCombinedAtomicCounters; + GLint& value = Context::current().state().shader->maxCombinedAtomicCounters; /* Get the value, if not already cached */ if(value == 0) @@ -455,9 +455,9 @@ Int Shader::maxCombinedAtomicCounters() { Int Shader::maxImageUniforms(const Type type) { if( #ifndef MAGNUM_TARGET_GLES - !Context::current()->isExtensionSupported() || + !Context::current().isExtensionSupported() || #else - !Context::current()->isVersionSupported(Version::GLES310) || + !Context::current().isVersionSupported(Version::GLES310) || #endif !isTypeSupported(type)) { @@ -465,7 +465,7 @@ Int Shader::maxImageUniforms(const Type type) { } const UnsignedInt index = typeToIndex(type); - GLint& value = Context::current()->state().shader->maxImageUniforms[index]; + GLint& value = Context::current().state().shader->maxImageUniforms[index]; /* Get the value, if not already cached */ constexpr static GLenum what[] = { @@ -488,13 +488,13 @@ Int Shader::maxImageUniforms(const Type type) { Int Shader::maxCombinedImageUniforms() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shader->maxCombinedImageUniforms; + GLint& value = Context::current().state().shader->maxCombinedImageUniforms; /* Get the value, if not already cached */ if(value == 0) @@ -506,9 +506,9 @@ Int Shader::maxCombinedImageUniforms() { Int Shader::maxShaderStorageBlocks(const Type type) { if( #ifndef MAGNUM_TARGET_GLES - !Context::current()->isExtensionSupported() || + !Context::current().isExtensionSupported() || #else - !Context::current()->isVersionSupported(Version::GLES310) || + !Context::current().isVersionSupported(Version::GLES310) || #endif !isTypeSupported(type)) { @@ -516,7 +516,7 @@ Int Shader::maxShaderStorageBlocks(const Type type) { } const UnsignedInt index = typeToIndex(type); - GLint& value = Context::current()->state().shader->maxShaderStorageBlocks[index]; + GLint& value = Context::current().state().shader->maxShaderStorageBlocks[index]; /* Get the value, if not already cached */ constexpr static GLenum what[] = { @@ -539,13 +539,13 @@ Int Shader::maxShaderStorageBlocks(const Type type) { Int Shader::maxCombinedShaderStorageBlocks() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) #endif return 0; - GLint& value = Context::current()->state().shader->maxCombinedShaderStorageBlocks; + GLint& value = Context::current().state().shader->maxCombinedShaderStorageBlocks; /* Get the value, if not already cached */ if(value == 0) @@ -560,7 +560,7 @@ Int Shader::maxTextureImageUnits(const Type type) { return 0; const UnsignedInt index = typeToIndex(type); - GLint& value = Context::current()->state().shader->maxTextureImageUnits[index]; + GLint& value = Context::current().state().shader->maxTextureImageUnits[index]; /* Get the value, if not already cached */ constexpr static GLenum what[] = { @@ -584,7 +584,7 @@ Int Shader::maxTextureImageUnits(const Type type) { } Int Shader::maxCombinedTextureImageUnits() { - GLint& value = Context::current()->state().shader->maxTextureImageUnitsCombined; + GLint& value = Context::current().state().shader->maxTextureImageUnitsCombined; /* Get the value, if not already cached */ if(value == 0) @@ -596,14 +596,14 @@ Int Shader::maxCombinedTextureImageUnits() { #ifndef MAGNUM_TARGET_GLES2 Int Shader::maxUniformBlocks(const Type type) { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported() || !isTypeSupported(type)) + if(!Context::current().isExtensionSupported() || !isTypeSupported(type)) #else if(!isTypeSupported(type)) #endif return 0; const UnsignedInt index = typeToIndex(type); - GLint& value = Context::current()->state().shader->maxUniformBlocks[index]; + GLint& value = Context::current().state().shader->maxUniformBlocks[index]; /* Get the value, if not already cached */ constexpr static GLenum what[] = { @@ -628,11 +628,11 @@ Int Shader::maxUniformBlocks(const Type type) { Int Shader::maxCombinedUniformBlocks() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().shader->maxCombinedUniformBlocks; + GLint& value = Context::current().state().shader->maxCombinedUniformBlocks; /* Get the value, if not already cached */ if(value == 0) @@ -647,7 +647,7 @@ Int Shader::maxUniformComponents(const Type type) { return 0; const UnsignedInt index = typeToIndex(type); - GLint& value = Context::current()->state().shader->maxUniformComponents[index]; + GLint& value = Context::current().state().shader->maxUniformComponents[index]; /* Get the value, if not already cached */ #ifndef MAGNUM_TARGET_GLES2 @@ -686,14 +686,14 @@ Int Shader::maxUniformComponents(const Type type) { #ifndef MAGNUM_TARGET_GLES2 Int Shader::maxCombinedUniformComponents(const Type type) { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported() || !isTypeSupported(type)) + if(!Context::current().isExtensionSupported() || !isTypeSupported(type)) #else if(!isTypeSupported(type)) #endif return 0; const UnsignedInt index = typeToIndex(type); - GLint& value = Context::current()->state().shader->maxCombinedUniformComponents[index]; + GLint& value = Context::current().state().shader->maxCombinedUniformComponents[index]; /* Get the value, if not already cached */ constexpr static GLenum what[] = { @@ -733,13 +733,13 @@ Shader::Shader(const Version version, const Type type): _type(type), _id(0) { case Version::GL430: _sources.push_back("#version 430\n"); return; case Version::GL440: _sources.push_back("#version 440\n"); return; case Version::GL450: _sources.push_back("#version 450\n"); return; - #else + #endif + /* `#version 100` really is GLSL ES 1.00 and *not* GLSL 1.00. What a mess. */ case Version::GLES200: _sources.push_back("#version 100\n"); return; case Version::GLES300: _sources.push_back("#version 300 es\n"); return; #ifndef MAGNUM_TARGET_WEBGL case Version::GLES310: _sources.push_back("#version 310 es\n"); return; #endif - #endif /* The user is responsible for (not) adding #version directive */ case Version::None: return; @@ -758,17 +758,17 @@ Shader::~Shader() { #ifndef MAGNUM_TARGET_WEBGL std::string Shader::label() const { #ifndef MAGNUM_TARGET_GLES - return Context::current()->state().debug->getLabelImplementation(GL_SHADER, _id); + return Context::current().state().debug->getLabelImplementation(GL_SHADER, _id); #else - return Context::current()->state().debug->getLabelImplementation(GL_SHADER_KHR, _id); + return Context::current().state().debug->getLabelImplementation(GL_SHADER_KHR, _id); #endif } Shader& Shader::setLabelInternal(const Containers::ArrayView label) { #ifndef MAGNUM_TARGET_GLES - Context::current()->state().debug->labelImplementation(GL_SHADER, _id, label); + Context::current().state().debug->labelImplementation(GL_SHADER, _id, label); #else - Context::current()->state().debug->labelImplementation(GL_SHADER_KHR, _id, label); + Context::current().state().debug->labelImplementation(GL_SHADER_KHR, _id, label); #endif return *this; } @@ -856,7 +856,7 @@ bool Shader::compile(std::initializer_list> shade /* Show error log */ if(!success) { - auto out = Error::noNewlineAtTheEnd(); + Error out{Debug::Flag::NoNewlineAtTheEnd}; out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader"; if(shaders.size() != 1) { #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) @@ -869,7 +869,7 @@ bool Shader::compile(std::initializer_list> shade /* Or just warnings, if any */ } else if(!message.empty() && !Implementation::isShaderCompilationLogEmpty(message)) { - auto out = Warning::noNewlineAtTheEnd(); + Warning out{Debug::Flag::NoNewlineAtTheEnd}; out << "Shader::compile(): compilation of" << shaderName(shader._type) << "shader"; if(shaders.size() != 1) { #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) diff --git a/src/Magnum/Shader.h b/src/Magnum/Shader.h index 146debd7f..67347eaa7 100644 --- a/src/Magnum/Shader.h +++ b/src/Magnum/Shader.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/AbstractVector.cpp b/src/Magnum/Shaders/AbstractVector.cpp index 6ff6104bc..43fa726a7 100644 --- a/src/Magnum/Shaders/AbstractVector.cpp +++ b/src/Magnum/Shaders/AbstractVector.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/AbstractVector.h b/src/Magnum/Shaders/AbstractVector.h index d643f2148..bb5f796d5 100644 --- a/src/Magnum/Shaders/AbstractVector.h +++ b/src/Magnum/Shaders/AbstractVector.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/AbstractVector2D.vert b/src/Magnum/Shaders/AbstractVector2D.vert index abf05e9f1..1253bcc6e 100644 --- a/src/Magnum/Shaders/AbstractVector2D.vert +++ b/src/Magnum/Shaders/AbstractVector2D.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/AbstractVector3D.vert b/src/Magnum/Shaders/AbstractVector3D.vert index e30d1b3ee..9e9855c45 100644 --- a/src/Magnum/Shaders/AbstractVector3D.vert +++ b/src/Magnum/Shaders/AbstractVector3D.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/CMakeLists.txt b/src/Magnum/Shaders/CMakeLists.txt index 5c90a1a2b..75b5b1b25 100644 --- a/src/Magnum/Shaders/CMakeLists.txt +++ b/src/Magnum/Shaders/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -61,7 +61,6 @@ set_target_properties(MagnumShaders PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumShaders PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(MagnumShaders Magnum) install(TARGETS MagnumShaders @@ -75,4 +74,4 @@ if(BUILD_TESTS) endif() # Magnum Shaders library for superprojects -set(MAGNUM_SHADERS_LIBRARY MagnumShaders CACHE INTERNAL "") +add_library(Magnum::Shaders ALIAS MagnumShaders) diff --git a/src/Magnum/Shaders/DistanceFieldVector.cpp b/src/Magnum/Shaders/DistanceFieldVector.cpp index 6459d5005..2e308eb20 100644 --- a/src/Magnum/Shaders/DistanceFieldVector.cpp +++ b/src/Magnum/Shaders/DistanceFieldVector.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -50,9 +50,9 @@ template DistanceFieldVector::DistanceFieldV Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES - const Version version = Context::current()->supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); + const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); #else - const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); + const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); @@ -67,9 +67,9 @@ template DistanceFieldVector::DistanceFieldV AbstractShaderProgram::attachShaders({frag, vert}); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { AbstractShaderProgram::bindAttributeLocation(AbstractVector::Position::Location, "position"); @@ -79,7 +79,7 @@ template DistanceFieldVector::DistanceFieldV CORRADE_INTERNAL_ASSERT_OUTPUT(AbstractShaderProgram::link()); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix"); @@ -90,7 +90,7 @@ template DistanceFieldVector::DistanceFieldV } #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { AbstractShaderProgram::setUniform(AbstractShaderProgram::uniformLocation("vectorTexture"), diff --git a/src/Magnum/Shaders/DistanceFieldVector.frag b/src/Magnum/Shaders/DistanceFieldVector.frag index 02da7fa75..cf18ad2b9 100644 --- a/src/Magnum/Shaders/DistanceFieldVector.frag +++ b/src/Magnum/Shaders/DistanceFieldVector.frag @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/DistanceFieldVector.h b/src/Magnum/Shaders/DistanceFieldVector.h index e66b73269..3b9298fff 100644 --- a/src/Magnum/Shaders/DistanceFieldVector.h +++ b/src/Magnum/Shaders/DistanceFieldVector.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Flat.cpp b/src/Magnum/Shaders/Flat.cpp index 5d62c9acf..4249a174c 100644 --- a/src/Magnum/Shaders/Flat.cpp +++ b/src/Magnum/Shaders/Flat.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -53,9 +53,9 @@ template Flat::Flat(const Flags flags): tran Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES - const Version version = Context::current()->supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); + const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); #else - const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); + const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); @@ -72,9 +72,9 @@ template Flat::Flat(const Flags flags): tran attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); @@ -84,7 +84,7 @@ template Flat::Flat(const Flags flags): tran CORRADE_INTERNAL_ASSERT_OUTPUT(link()); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix"); @@ -92,7 +92,7 @@ template Flat::Flat(const Flags flags): tran } #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { if(flags & Flag::Textured) setUniform(uniformLocation("textureData"), TextureLayer); diff --git a/src/Magnum/Shaders/Flat.frag b/src/Magnum/Shaders/Flat.frag index 847a7c129..daf4115e8 100644 --- a/src/Magnum/Shaders/Flat.frag +++ b/src/Magnum/Shaders/Flat.frag @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Flat.h b/src/Magnum/Shaders/Flat.h index bf8c1a85c..917c315e7 100644 --- a/src/Magnum/Shaders/Flat.h +++ b/src/Magnum/Shaders/Flat.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Flat2D.vert b/src/Magnum/Shaders/Flat2D.vert index dd9156847..554a099b7 100644 --- a/src/Magnum/Shaders/Flat2D.vert +++ b/src/Magnum/Shaders/Flat2D.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Flat3D.vert b/src/Magnum/Shaders/Flat3D.vert index 0e02a0867..aac07a63e 100644 --- a/src/Magnum/Shaders/Flat3D.vert +++ b/src/Magnum/Shaders/Flat3D.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/FullScreenTriangle.glsl b/src/Magnum/Shaders/FullScreenTriangle.glsl index 45ed802f7..632c322b3 100644 --- a/src/Magnum/Shaders/FullScreenTriangle.glsl +++ b/src/Magnum/Shaders/FullScreenTriangle.glsl @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Generic.h b/src/Magnum/Shaders/Generic.h index 185f61a5b..d084465b1 100644 --- a/src/Magnum/Shaders/Generic.h +++ b/src/Magnum/Shaders/Generic.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h index 472f3a9c1..5c7f08fbb 100644 --- a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h +++ b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -45,11 +45,11 @@ inline Shader createCompatibilityShader(const Utility::Resource& rs, Version ver Shader shader(version, type); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionDisabled(version)) + if(Context::current().isExtensionDisabled(version)) shader.addSource("#define DISABLE_GL_ARB_explicit_attrib_location\n"); - if(Context::current()->isExtensionDisabled(version)) + if(Context::current().isExtensionDisabled(version)) shader.addSource("#define DISABLE_GL_ARB_shading_language_420pack\n"); - if(Context::current()->isExtensionDisabled(version)) + if(Context::current().isExtensionDisabled(version)) shader.addSource("#define DISABLE_GL_ARB_explicit_uniform_location\n"); #endif diff --git a/src/Magnum/Shaders/MeshVisualizer.cpp b/src/Magnum/Shaders/MeshVisualizer.cpp index 431918bd8..5f9979901 100644 --- a/src/Magnum/Shaders/MeshVisualizer.cpp +++ b/src/Magnum/Shaders/MeshVisualizer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -59,13 +59,13 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES - const Version version = Context::current()->supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); + const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); CORRADE_INTERNAL_ASSERT(!flags || flags & Flag::NoGeometryShader || version >= Version::GL320); #elif !defined(MAGNUM_TARGET_WEBGL) - const Version version = Context::current()->supportedVersion({Version::GLES310, Version::GLES300, Version::GLES200}); + const Version version = Context::current().supportedVersion({Version::GLES310, Version::GLES300, Version::GLES200}); CORRADE_INTERNAL_ASSERT(!flags || flags & Flag::NoGeometryShader || version >= Version::GLES310); #else - const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); + const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); @@ -76,7 +76,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP #ifdef MAGNUM_TARGET_WEBGL .addSource("#define SUBSCRIPTING_WORKAROUND\n") #elif defined(MAGNUM_TARGET_GLES2) - .addSource(Context::current()->detectedDriver() & Context::DetectedDriver::ProbablyAngle ? + .addSource(Context::current().detectedDriver() & Context::DetectedDriver::ProbablyAngle ? "#define SUBSCRIPTING_WORKAROUND\n" : "") #endif .addSource(rs.get("generic.glsl")) @@ -105,16 +105,16 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP #endif #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GL310)) + if(!Context::current().isVersionSupported(Version::GL310)) #endif { bindAttributeLocation(VertexIndex::Location, "vertexIndex"); @@ -125,7 +125,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP CORRADE_INTERNAL_ASSERT_OUTPUT(link()); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix"); diff --git a/src/Magnum/Shaders/MeshVisualizer.frag b/src/Magnum/Shaders/MeshVisualizer.frag index bc9bf5460..2f62bdc99 100644 --- a/src/Magnum/Shaders/MeshVisualizer.frag +++ b/src/Magnum/Shaders/MeshVisualizer.frag @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/MeshVisualizer.geom b/src/Magnum/Shaders/MeshVisualizer.geom index 1d22a3a31..f7e20d159 100644 --- a/src/Magnum/Shaders/MeshVisualizer.geom +++ b/src/Magnum/Shaders/MeshVisualizer.geom @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/MeshVisualizer.h b/src/Magnum/Shaders/MeshVisualizer.h index 6c2f2ee1f..8283bf4d8 100644 --- a/src/Magnum/Shaders/MeshVisualizer.h +++ b/src/Magnum/Shaders/MeshVisualizer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/MeshVisualizer.vert b/src/Magnum/Shaders/MeshVisualizer.vert index 4495b7108..dde8b0c9d 100644 --- a/src/Magnum/Shaders/MeshVisualizer.vert +++ b/src/Magnum/Shaders/MeshVisualizer.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Phong.cpp b/src/Magnum/Shaders/Phong.cpp index 61aa8a37e..bf0c5d2b9 100644 --- a/src/Magnum/Shaders/Phong.cpp +++ b/src/Magnum/Shaders/Phong.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -53,9 +53,9 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES - const Version version = Context::current()->supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); + const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); #else - const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); + const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); @@ -74,9 +74,9 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); @@ -87,7 +87,7 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri CORRADE_INTERNAL_ASSERT_OUTPUT(link()); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { transformationMatrixUniform = uniformLocation("transformationMatrix"); @@ -102,7 +102,7 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri } #ifndef MAGNUM_TARGET_GLES - if(flags && !Context::current()->isExtensionSupported(version)) + if(flags && !Context::current().isExtensionSupported(version)) #endif { if(flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"), AmbientTextureLayer); diff --git a/src/Magnum/Shaders/Phong.frag b/src/Magnum/Shaders/Phong.frag index cfd49b846..84f6ced8b 100644 --- a/src/Magnum/Shaders/Phong.frag +++ b/src/Magnum/Shaders/Phong.frag @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Phong.h b/src/Magnum/Shaders/Phong.h index 9276cf5f4..d147e69ca 100644 --- a/src/Magnum/Shaders/Phong.h +++ b/src/Magnum/Shaders/Phong.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Phong.vert b/src/Magnum/Shaders/Phong.vert index 0a3321583..37f962499 100644 --- a/src/Magnum/Shaders/Phong.vert +++ b/src/Magnum/Shaders/Phong.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Shaders.h b/src/Magnum/Shaders/Shaders.h index d213b3844..b354cd086 100644 --- a/src/Magnum/Shaders/Shaders.h +++ b/src/Magnum/Shaders/Shaders.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Test/CMakeLists.txt b/src/Magnum/Shaders/Test/CMakeLists.txt index bcabd8117..360936f2d 100644 --- a/src/Magnum/Shaders/Test/CMakeLists.txt +++ b/src/Magnum/Shaders/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp b/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp index 680f8e133..5d2893f0c 100644 --- a/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp +++ b/src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -42,12 +42,22 @@ DistanceFieldVectorGLTest::DistanceFieldVectorGLTest() { void DistanceFieldVectorGLTest::compile2D() { Shaders::DistanceFieldVector2D shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void DistanceFieldVectorGLTest::compile3D() { Shaders::DistanceFieldVector3D shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } }}} diff --git a/src/Magnum/Shaders/Test/FlatGLTest.cpp b/src/Magnum/Shaders/Test/FlatGLTest.cpp index 2991b5a67..276a7f0df 100644 --- a/src/Magnum/Shaders/Test/FlatGLTest.cpp +++ b/src/Magnum/Shaders/Test/FlatGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -46,22 +46,42 @@ FlatGLTest::FlatGLTest() { void FlatGLTest::compile2D() { Shaders::Flat2D shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void FlatGLTest::compile3D() { Shaders::Flat3D shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void FlatGLTest::compile2DTextured() { Shaders::Flat2D shader(Shaders::Flat2D::Flag::Textured); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void FlatGLTest::compile3DTextured() { Shaders::Flat3D shader(Shaders::Flat3D::Flag::Textured); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } }}} diff --git a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp index 38ab4f6f7..806b4ddee 100644 --- a/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp +++ b/src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -50,32 +50,47 @@ MeshVisualizerGLTest::MeshVisualizerGLTest() { void MeshVisualizerGLTest::compile() { Shaders::MeshVisualizer shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void MeshVisualizerGLTest::compileWireframeGeometryShader() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not supported")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not supported")); #endif #ifdef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) Debug() << "Using" << Extensions::GL::NV::shader_noperspective_interpolation::string(); #endif Shaders::MeshVisualizer shader(Shaders::MeshVisualizer::Flag::Wireframe); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } #endif void MeshVisualizerGLTest::compileWireframeNoGeometryShader() { Shaders::MeshVisualizer shader(Shaders::MeshVisualizer::Flag::Wireframe|Shaders::MeshVisualizer::Flag::NoGeometryShader); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } }}} diff --git a/src/Magnum/Shaders/Test/PhongGLTest.cpp b/src/Magnum/Shaders/Test/PhongGLTest.cpp index ccdbb33d4..6bfd000b8 100644 --- a/src/Magnum/Shaders/Test/PhongGLTest.cpp +++ b/src/Magnum/Shaders/Test/PhongGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -54,42 +54,82 @@ PhongGLTest::PhongGLTest() { void PhongGLTest::compile() { Shaders::Phong shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void PhongGLTest::compileAmbientTexture() { Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void PhongGLTest::compileDiffuseTexture() { Shaders::Phong shader(Shaders::Phong::Flag::DiffuseTexture); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void PhongGLTest::compileSpecularTexture() { Shaders::Phong shader(Shaders::Phong::Flag::SpecularTexture); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void PhongGLTest::compileAmbientDiffuseTexture() { Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::DiffuseTexture); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void PhongGLTest::compileAmbientSpecularTexture() { Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::SpecularTexture); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void PhongGLTest::compileDiffuseSpecularTexture() { Shaders::Phong shader(Shaders::Phong::Flag::DiffuseTexture|Shaders::Phong::Flag::SpecularTexture); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void PhongGLTest::compileAmbientDiffuseSpecularTexture() { Shaders::Phong shader(Shaders::Phong::Flag::AmbientTexture|Shaders::Phong::Flag::DiffuseTexture|Shaders::Phong::Flag::SpecularTexture); - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } }}} diff --git a/src/Magnum/Shaders/Test/VectorGLTest.cpp b/src/Magnum/Shaders/Test/VectorGLTest.cpp index ca78e7150..718af5f38 100644 --- a/src/Magnum/Shaders/Test/VectorGLTest.cpp +++ b/src/Magnum/Shaders/Test/VectorGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -42,12 +42,22 @@ VectorGLTest::VectorGLTest() { void VectorGLTest::compile2D() { Shaders::Vector2D shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void VectorGLTest::compile3D() { Shaders::Vector3D shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } }}} diff --git a/src/Magnum/Shaders/Test/VertexColorGLTest.cpp b/src/Magnum/Shaders/Test/VertexColorGLTest.cpp index 05b568c39..4298f2124 100644 --- a/src/Magnum/Shaders/Test/VertexColorGLTest.cpp +++ b/src/Magnum/Shaders/Test/VertexColorGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -42,12 +42,22 @@ VertexColorGLTest::VertexColorGLTest() { void VertexColorGLTest::compile2D() { Shaders::VertexColor2D shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } void VertexColorGLTest::compile3D() { Shaders::VertexColor3D shader; - CORRADE_VERIFY(shader.validate().first); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(shader.validate().first); + } } }}} diff --git a/src/Magnum/Shaders/Vector.cpp b/src/Magnum/Shaders/Vector.cpp index 05e3c3d50..641e59b57 100644 --- a/src/Magnum/Shaders/Vector.cpp +++ b/src/Magnum/Shaders/Vector.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -50,9 +50,9 @@ template Vector::Vector(): transformationPro Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES - const Version version = Context::current()->supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); + const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); #else - const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); + const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); @@ -67,9 +67,9 @@ template Vector::Vector(): transformationPro AbstractShaderProgram::attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { AbstractShaderProgram::bindAttributeLocation(AbstractVector::Position::Location, "position"); @@ -79,7 +79,7 @@ template Vector::Vector(): transformationPro CORRADE_INTERNAL_ASSERT_OUTPUT(AbstractShaderProgram::link()); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { transformationProjectionMatrixUniform = AbstractShaderProgram::uniformLocation("transformationProjectionMatrix"); @@ -88,7 +88,7 @@ template Vector::Vector(): transformationPro } #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { AbstractShaderProgram::setUniform(AbstractShaderProgram::uniformLocation("vectorTexture"), AbstractVector::VectorTextureLayer); diff --git a/src/Magnum/Shaders/Vector.frag b/src/Magnum/Shaders/Vector.frag index 6e354d8c8..279052930 100644 --- a/src/Magnum/Shaders/Vector.frag +++ b/src/Magnum/Shaders/Vector.frag @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/Vector.h b/src/Magnum/Shaders/Vector.h index b3640132c..fb511bc79 100644 --- a/src/Magnum/Shaders/Vector.h +++ b/src/Magnum/Shaders/Vector.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/VertexColor.cpp b/src/Magnum/Shaders/VertexColor.cpp index 9183a3db5..f64b5a249 100644 --- a/src/Magnum/Shaders/VertexColor.cpp +++ b/src/Magnum/Shaders/VertexColor.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -50,9 +50,9 @@ template VertexColor::VertexColor(): transfo Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES - const Version version = Context::current()->supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); + const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); #else - const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); + const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); @@ -67,9 +67,9 @@ template VertexColor::VertexColor(): transfo attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); @@ -79,7 +79,7 @@ template VertexColor::VertexColor(): transfo CORRADE_INTERNAL_ASSERT_OUTPUT(link()); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported(version)) + if(!Context::current().isExtensionSupported(version)) #endif { transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix"); diff --git a/src/Magnum/Shaders/VertexColor.frag b/src/Magnum/Shaders/VertexColor.frag index 9456d219b..9e281bebf 100644 --- a/src/Magnum/Shaders/VertexColor.frag +++ b/src/Magnum/Shaders/VertexColor.frag @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/VertexColor.h b/src/Magnum/Shaders/VertexColor.h index 15f78a509..19e5a17dd 100644 --- a/src/Magnum/Shaders/VertexColor.h +++ b/src/Magnum/Shaders/VertexColor.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/VertexColor2D.vert b/src/Magnum/Shaders/VertexColor2D.vert index ea9134fea..c803f83a9 100644 --- a/src/Magnum/Shaders/VertexColor2D.vert +++ b/src/Magnum/Shaders/VertexColor2D.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/VertexColor3D.vert b/src/Magnum/Shaders/VertexColor3D.vert index faae0e333..5542ef6dd 100644 --- a/src/Magnum/Shaders/VertexColor3D.vert +++ b/src/Magnum/Shaders/VertexColor3D.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/compatibility.glsl b/src/Magnum/Shaders/compatibility.glsl index 7fd075b63..53a6a7f00 100644 --- a/src/Magnum/Shaders/compatibility.glsl +++ b/src/Magnum/Shaders/compatibility.glsl @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/generic.glsl b/src/Magnum/Shaders/generic.glsl index 066359be8..d3fa8c6f9 100644 --- a/src/Magnum/Shaders/generic.glsl +++ b/src/Magnum/Shaders/generic.glsl @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shaders/visibility.h b/src/Magnum/Shaders/visibility.h index 0c14bdb36..540080220 100644 --- a/src/Magnum/Shaders/visibility.h +++ b/src/Magnum/Shaders/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/AbstractShape.cpp b/src/Magnum/Shapes/AbstractShape.cpp index 322c53aac..fe4fc8d5c 100644 --- a/src/Magnum/Shapes/AbstractShape.cpp +++ b/src/Magnum/Shapes/AbstractShape.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/AbstractShape.h b/src/Magnum/Shapes/AbstractShape.h index efc24fafd..25dd40106 100644 --- a/src/Magnum/Shapes/AbstractShape.h +++ b/src/Magnum/Shapes/AbstractShape.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/AxisAlignedBox.cpp b/src/Magnum/Shapes/AxisAlignedBox.cpp index 648d551b7..9d0547a9a 100644 --- a/src/Magnum/Shapes/AxisAlignedBox.cpp +++ b/src/Magnum/Shapes/AxisAlignedBox.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/AxisAlignedBox.h b/src/Magnum/Shapes/AxisAlignedBox.h index 99754b98b..aa9d8419b 100644 --- a/src/Magnum/Shapes/AxisAlignedBox.h +++ b/src/Magnum/Shapes/AxisAlignedBox.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Box.cpp b/src/Magnum/Shapes/Box.cpp index a0f5de4a8..6548b18c6 100644 --- a/src/Magnum/Shapes/Box.cpp +++ b/src/Magnum/Shapes/Box.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Box.h b/src/Magnum/Shapes/Box.h index 6cf57169c..fc7733750 100644 --- a/src/Magnum/Shapes/Box.h +++ b/src/Magnum/Shapes/Box.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/CMakeLists.txt b/src/Magnum/Shapes/CMakeLists.txt index 00b444ef5..c2c5bf0d2 100644 --- a/src/Magnum/Shapes/CMakeLists.txt +++ b/src/Magnum/Shapes/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -73,7 +73,6 @@ set_target_properties(MagnumShapes PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumShapes PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(MagnumShapes Magnum MagnumSceneGraph) install(TARGETS MagnumShapes @@ -86,5 +85,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum Shapes library for superprojects -set(MAGNUM_SHAPES_LIBRARY MagnumShapes CACHE INTERNAL "") +# Magnum Shapes target alias for superprojects +add_library(Magnum::Shapes ALIAS MagnumShapes) diff --git a/src/Magnum/Shapes/Capsule.cpp b/src/Magnum/Shapes/Capsule.cpp index 27a98ab4c..19cc8017a 100644 --- a/src/Magnum/Shapes/Capsule.cpp +++ b/src/Magnum/Shapes/Capsule.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Capsule.h b/src/Magnum/Shapes/Capsule.h index d624c4563..417863af4 100644 --- a/src/Magnum/Shapes/Capsule.h +++ b/src/Magnum/Shapes/Capsule.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Collision.h b/src/Magnum/Shapes/Collision.h index 4fba549b6..fcd716375 100644 --- a/src/Magnum/Shapes/Collision.h +++ b/src/Magnum/Shapes/Collision.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Composition.cpp b/src/Magnum/Shapes/Composition.cpp index a31a1abd5..1b096310d 100644 --- a/src/Magnum/Shapes/Composition.cpp +++ b/src/Magnum/Shapes/Composition.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Composition.h b/src/Magnum/Shapes/Composition.h index a54d5e1b8..a04899c87 100644 --- a/src/Magnum/Shapes/Composition.h +++ b/src/Magnum/Shapes/Composition.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Cylinder.cpp b/src/Magnum/Shapes/Cylinder.cpp index a09fc8095..a0391705d 100644 --- a/src/Magnum/Shapes/Cylinder.cpp +++ b/src/Magnum/Shapes/Cylinder.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Cylinder.h b/src/Magnum/Shapes/Cylinder.h index 71c590628..36048a252 100644 --- a/src/Magnum/Shapes/Cylinder.h +++ b/src/Magnum/Shapes/Cylinder.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Implementation/CollisionDispatch.cpp b/src/Magnum/Shapes/Implementation/CollisionDispatch.cpp index ce07063d8..5493e7fd8 100644 --- a/src/Magnum/Shapes/Implementation/CollisionDispatch.cpp +++ b/src/Magnum/Shapes/Implementation/CollisionDispatch.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Implementation/CollisionDispatch.h b/src/Magnum/Shapes/Implementation/CollisionDispatch.h index 938645d38..6d3a2c673 100644 --- a/src/Magnum/Shapes/Implementation/CollisionDispatch.h +++ b/src/Magnum/Shapes/Implementation/CollisionDispatch.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Line.cpp b/src/Magnum/Shapes/Line.cpp index ae3e29fdc..771e5766b 100644 --- a/src/Magnum/Shapes/Line.cpp +++ b/src/Magnum/Shapes/Line.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Line.h b/src/Magnum/Shapes/Line.h index 0d745a0be..ea1ea8cd5 100644 --- a/src/Magnum/Shapes/Line.h +++ b/src/Magnum/Shapes/Line.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/LineSegment.h b/src/Magnum/Shapes/LineSegment.h index 5d08a4031..3d4e3d8df 100644 --- a/src/Magnum/Shapes/LineSegment.h +++ b/src/Magnum/Shapes/LineSegment.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Plane.cpp b/src/Magnum/Shapes/Plane.cpp index aaa86a064..b6c6f72c5 100644 --- a/src/Magnum/Shapes/Plane.cpp +++ b/src/Magnum/Shapes/Plane.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Plane.h b/src/Magnum/Shapes/Plane.h index 9a314a668..7b5de22b0 100644 --- a/src/Magnum/Shapes/Plane.h +++ b/src/Magnum/Shapes/Plane.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Point.cpp b/src/Magnum/Shapes/Point.cpp index 3e31a60d4..8b8cf86d2 100644 --- a/src/Magnum/Shapes/Point.cpp +++ b/src/Magnum/Shapes/Point.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Point.h b/src/Magnum/Shapes/Point.h index 6fcbb1a33..4f23a2821 100644 --- a/src/Magnum/Shapes/Point.h +++ b/src/Magnum/Shapes/Point.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Shape.cpp b/src/Magnum/Shapes/Shape.cpp index 7402770d5..f330484ef 100644 --- a/src/Magnum/Shapes/Shape.cpp +++ b/src/Magnum/Shapes/Shape.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Shape.h b/src/Magnum/Shapes/Shape.h index fd002a62c..8e1cac37f 100644 --- a/src/Magnum/Shapes/Shape.h +++ b/src/Magnum/Shapes/Shape.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/ShapeGroup.cpp b/src/Magnum/Shapes/ShapeGroup.cpp index 429f2cbe7..02e30e4bc 100644 --- a/src/Magnum/Shapes/ShapeGroup.cpp +++ b/src/Magnum/Shapes/ShapeGroup.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/ShapeGroup.h b/src/Magnum/Shapes/ShapeGroup.h index fba38afe7..45a90d38a 100644 --- a/src/Magnum/Shapes/ShapeGroup.h +++ b/src/Magnum/Shapes/ShapeGroup.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Shapes.h b/src/Magnum/Shapes/Shapes.h index 1f6f3d3e4..72f20a4c3 100644 --- a/src/Magnum/Shapes/Shapes.h +++ b/src/Magnum/Shapes/Shapes.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Sphere.cpp b/src/Magnum/Shapes/Sphere.cpp index b4dce201e..09b0a51ef 100644 --- a/src/Magnum/Shapes/Sphere.cpp +++ b/src/Magnum/Shapes/Sphere.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Sphere.h b/src/Magnum/Shapes/Sphere.h index 38d232517..c8e04d71d 100644 --- a/src/Magnum/Shapes/Sphere.h +++ b/src/Magnum/Shapes/Sphere.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/AxisAlignedBoxTest.cpp b/src/Magnum/Shapes/Test/AxisAlignedBoxTest.cpp index b649dfa62..05a91c89c 100644 --- a/src/Magnum/Shapes/Test/AxisAlignedBoxTest.cpp +++ b/src/Magnum/Shapes/Test/AxisAlignedBoxTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/BoxTest.cpp b/src/Magnum/Shapes/Test/BoxTest.cpp index 19dd194eb..e04ecea11 100644 --- a/src/Magnum/Shapes/Test/BoxTest.cpp +++ b/src/Magnum/Shapes/Test/BoxTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/CMakeLists.txt b/src/Magnum/Shapes/Test/CMakeLists.txt index 7d9d5b624..58593f06f 100644 --- a/src/Magnum/Shapes/Test/CMakeLists.txt +++ b/src/Magnum/Shapes/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/CapsuleTest.cpp b/src/Magnum/Shapes/Test/CapsuleTest.cpp index 845e1f89a..daa8491e5 100644 --- a/src/Magnum/Shapes/Test/CapsuleTest.cpp +++ b/src/Magnum/Shapes/Test/CapsuleTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/CollisionTest.cpp b/src/Magnum/Shapes/Test/CollisionTest.cpp index 06345ecf6..eaa4a643b 100644 --- a/src/Magnum/Shapes/Test/CollisionTest.cpp +++ b/src/Magnum/Shapes/Test/CollisionTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/CompositionTest.cpp b/src/Magnum/Shapes/Test/CompositionTest.cpp index 970f5d257..536acbd3c 100644 --- a/src/Magnum/Shapes/Test/CompositionTest.cpp +++ b/src/Magnum/Shapes/Test/CompositionTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/CylinderTest.cpp b/src/Magnum/Shapes/Test/CylinderTest.cpp index d1ad03026..a7331cd57 100644 --- a/src/Magnum/Shapes/Test/CylinderTest.cpp +++ b/src/Magnum/Shapes/Test/CylinderTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/LineTest.cpp b/src/Magnum/Shapes/Test/LineTest.cpp index 9006ff14f..6c0e6964a 100644 --- a/src/Magnum/Shapes/Test/LineTest.cpp +++ b/src/Magnum/Shapes/Test/LineTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/PlaneTest.cpp b/src/Magnum/Shapes/Test/PlaneTest.cpp index c251384cb..b56593145 100644 --- a/src/Magnum/Shapes/Test/PlaneTest.cpp +++ b/src/Magnum/Shapes/Test/PlaneTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/PointTest.cpp b/src/Magnum/Shapes/Test/PointTest.cpp index 8e0fd27e6..21f41a9eb 100644 --- a/src/Magnum/Shapes/Test/PointTest.cpp +++ b/src/Magnum/Shapes/Test/PointTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/ShapeImplementationTest.cpp b/src/Magnum/Shapes/Test/ShapeImplementationTest.cpp index 6b3c62599..6f7d9f16c 100644 --- a/src/Magnum/Shapes/Test/ShapeImplementationTest.cpp +++ b/src/Magnum/Shapes/Test/ShapeImplementationTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/ShapeTest.cpp b/src/Magnum/Shapes/Test/ShapeTest.cpp index 0830dacc0..670ec17b4 100644 --- a/src/Magnum/Shapes/Test/ShapeTest.cpp +++ b/src/Magnum/Shapes/Test/ShapeTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/ShapeTestBase.h b/src/Magnum/Shapes/Test/ShapeTestBase.h index 9f82326d8..6dcca03c3 100644 --- a/src/Magnum/Shapes/Test/ShapeTestBase.h +++ b/src/Magnum/Shapes/Test/ShapeTestBase.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/Test/SphereTest.cpp b/src/Magnum/Shapes/Test/SphereTest.cpp index 7096b95d4..0a373fc86 100644 --- a/src/Magnum/Shapes/Test/SphereTest.cpp +++ b/src/Magnum/Shapes/Test/SphereTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/shapeImplementation.cpp b/src/Magnum/Shapes/shapeImplementation.cpp index ef70c149b..b2fc534df 100644 --- a/src/Magnum/Shapes/shapeImplementation.cpp +++ b/src/Magnum/Shapes/shapeImplementation.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/shapeImplementation.h b/src/Magnum/Shapes/shapeImplementation.h index 170172188..a9bf886a7 100644 --- a/src/Magnum/Shapes/shapeImplementation.h +++ b/src/Magnum/Shapes/shapeImplementation.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Shapes/visibility.h b/src/Magnum/Shapes/visibility.h index d54216f78..97ad061ee 100644 --- a/src/Magnum/Shapes/visibility.h +++ b/src/Magnum/Shapes/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Tags.h b/src/Magnum/Tags.h index 5f38d72b0..04963fa66 100644 --- a/src/Magnum/Tags.h +++ b/src/Magnum/Tags.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/AbstractObjectGLTest.cpp b/src/Magnum/Test/AbstractObjectGLTest.cpp index 1c1441b5a..b8dc3db89 100644 --- a/src/Magnum/Test/AbstractObjectGLTest.cpp +++ b/src/Magnum/Test/AbstractObjectGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -41,8 +41,10 @@ AbstractObjectGLTest::AbstractObjectGLTest() { } void AbstractObjectGLTest::labelNoOp() { - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::KHR::debug::string() + std::string(" is supported.")); + if(Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::debug_label::string() + std::string(" is supported.")); Buffer buffer; buffer.setLabel("MyBuffer"); diff --git a/src/Magnum/Test/AbstractOpenGLTester.h b/src/Magnum/Test/AbstractOpenGLTester.h index 460306383..9e2450d57 100644 --- a/src/Magnum/Test/AbstractOpenGLTester.h +++ b/src/Magnum/Test/AbstractOpenGLTester.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -32,7 +32,11 @@ #include "Magnum/DebugOutput.h" #include "Magnum/Renderer.h" -#if defined(CORRADE_TARGET_APPLE) +#ifdef MAGNUM_TARGET_HEADLESS +#include "Magnum/Platform/WindowlessEglApplication.h" +#elif defined(CORRADE_TARGET_IOS) +#include "Magnum/Platform/WindowlessIosApplication.h" +#elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) && (!defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_DESKTOP_GLES)) #include "Magnum/Platform/WindowlessGlxApplication.h" @@ -57,13 +61,26 @@ class AbstractOpenGLTester: public TestSuite::Tester { private: struct WindowlessApplication: Platform::WindowlessApplication { - explicit WindowlessApplication(const Arguments& arguments): Platform::WindowlessApplication{arguments} {} + explicit WindowlessApplication(const Arguments& arguments): Platform::WindowlessApplication{arguments, nullptr} {} int exec() override final { return 0; } + + using Platform::WindowlessApplication::tryCreateContext; + using Platform::WindowlessApplication::createContext; + } _windowlessApplication; }; -AbstractOpenGLTester::AbstractOpenGLTester(): _windowlessApplication{*_windowlessApplicationArguments} { - if(Context::current()->isExtensionSupported()) { +AbstractOpenGLTester::AbstractOpenGLTester(): TestSuite::Tester{TestSuite::Tester::TesterConfiguration{}.setSkippedArgumentPrefixes({"magnum"})}, _windowlessApplication{*_windowlessApplicationArguments} { + /* Try to create debug context, fallback to normal one if not possible. No + such thing on OSX or iOS. */ + #ifndef CORRADE_TARGET_APPLE + if(!_windowlessApplication.tryCreateContext(Platform::WindowlessApplication::Configuration{}.setFlags(Platform::WindowlessApplication::Configuration::Flag::Debug))) + _windowlessApplication.createContext(); + #else + _windowlessApplication.createContext(); + #endif + + if(Context::current().isExtensionSupported()) { Renderer::enable(Renderer::Feature::DebugOutput); Renderer::enable(Renderer::Feature::DebugOutputSynchronous); DebugOutput::setDefaultCallback(); @@ -77,15 +94,7 @@ std::optional AbstractOpenGLTester:: #define MAGNUM_VERIFY_NO_ERROR() CORRADE_COMPARE(Magnum::Renderer::error(), Magnum::Renderer::Error::NoError) -#ifndef CORRADE_TARGET_WINDOWS -#define MAGNUM_GL_TEST_MAIN(Class) \ - int main(int argc, char** argv) { \ - Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments.emplace(argc, argv); \ - Class t; \ - t.registerTest(__FILE__, #Class); \ - return t.exec(); \ - } -#else +#ifdef CORRADE_TARGET_WINDOWS #define MAGNUM_GL_TEST_MAIN(Class) \ LRESULT CALLBACK windowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); \ LRESULT CALLBACK windowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { \ @@ -96,7 +105,9 @@ std::optional AbstractOpenGLTester:: Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments->window = hWnd; \ Class t; \ t.registerTest(__FILE__, #Class); \ - PostQuitMessage(ret = t.exec()); \ + PostQuitMessage(ret = t.exec( \ + Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments->argc, \ + Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments->argv)); \ } \ break; \ default: return DefWindowProc(hWnd, message, wParam, lParam); \ @@ -107,6 +118,22 @@ std::optional AbstractOpenGLTester:: Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments.emplace(argc, argv, nullptr); \ return Magnum::Platform::WindowlessApplication::create(windowProcedure); \ } +#elif defined(CORRADE_TESTSUITE_TARGET_XCTEST) +#define MAGNUM_GL_TEST_MAIN(Class) \ + int CORRADE_VISIBILITY_EXPORT corradeTestMain(int argc, char** argv) { \ + Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments.emplace(argc, argv); \ + Class t; \ + t.registerTest(__FILE__, #Class); \ + return t.exec(argc, argv); \ + } +#else +#define MAGNUM_GL_TEST_MAIN(Class) \ + int main(int argc, char** argv) { \ + Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments.emplace(argc, argv); \ + Class t; \ + t.registerTest(__FILE__, #Class); \ + return t.exec(argc, argv); \ + } #endif }} diff --git a/src/Magnum/Test/AbstractQueryGLTest.cpp b/src/Magnum/Test/AbstractQueryGLTest.cpp index a4553b24a..03cfbc764 100644 --- a/src/Magnum/Test/AbstractQueryGLTest.cpp +++ b/src/Magnum/Test/AbstractQueryGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -48,7 +48,7 @@ AbstractQueryGLTest::AbstractQueryGLTest() { void AbstractQueryGLTest::construct() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not supported.")); #endif @@ -73,7 +73,7 @@ void AbstractQueryGLTest::constructCopy() { void AbstractQueryGLTest::constructMove() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not supported.")); #endif @@ -108,13 +108,13 @@ void AbstractQueryGLTest::constructMove() { void AbstractQueryGLTest::label() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not supported.")); #endif /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); #ifndef MAGNUM_TARGET_GLES @@ -124,7 +124,7 @@ void AbstractQueryGLTest::label() { #endif #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #endif { query.begin(); query.end(); diff --git a/src/Magnum/Test/AbstractShaderProgramGLTest.cpp b/src/Magnum/Test/AbstractShaderProgramGLTest.cpp index 7c6a0b6b2..5edeb0b12 100644 --- a/src/Magnum/Test/AbstractShaderProgramGLTest.cpp +++ b/src/Magnum/Test/AbstractShaderProgramGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -25,13 +25,23 @@ #include #include +#include #include "Magnum/AbstractShaderProgram.h" #include "Magnum/Context.h" #include "Magnum/Extensions.h" +#include "Magnum/Image.h" +#include "Magnum/ImageView.h" +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/ImageFormat.h" +#endif +#include "Magnum/PixelFormat.h" #include "Magnum/Shader.h" +#include "Magnum/Texture.h" +#include "Magnum/TextureFormat.h" #include "Magnum/Math/Matrix.h" #include "Magnum/Math/Vector4.h" +#include "Magnum/Math/Color.h" #include "Magnum/Test/AbstractOpenGLTester.h" namespace Magnum { namespace Test { @@ -51,11 +61,19 @@ struct AbstractShaderProgramGLTest: AbstractOpenGLTester { void createMultipleOutputsIndexed(); #endif - void uniformLocationOptimizedOut(); + void uniformNotFound(); void uniform(); void uniformVector(); void uniformMatrix(); void uniformArray(); + + #ifndef MAGNUM_TARGET_GLES2 + void createUniformBlocks(); + void uniformBlockIndexNotFound(); + void uniformBlock(); + #endif + + void compute(); }; AbstractShaderProgramGLTest::AbstractShaderProgramGLTest() { @@ -71,11 +89,20 @@ AbstractShaderProgramGLTest::AbstractShaderProgramGLTest() { &AbstractShaderProgramGLTest::createMultipleOutputsIndexed, #endif - &AbstractShaderProgramGLTest::uniformLocationOptimizedOut, + &AbstractShaderProgramGLTest::uniformNotFound, &AbstractShaderProgramGLTest::uniform, &AbstractShaderProgramGLTest::uniformVector, &AbstractShaderProgramGLTest::uniformMatrix, - &AbstractShaderProgramGLTest::uniformArray}); + &AbstractShaderProgramGLTest::uniformArray, + + #ifndef MAGNUM_TARGET_GLES2 + &AbstractShaderProgramGLTest::createUniformBlocks, + &AbstractShaderProgramGLTest::uniformBlockIndexNotFound, + &AbstractShaderProgramGLTest::uniformBlock, + + &AbstractShaderProgramGLTest::compute + #endif + }); } namespace { @@ -125,8 +152,8 @@ void AbstractShaderProgramGLTest::constructMove() { void AbstractShaderProgramGLTest::label() { /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); DummyShader shader; @@ -148,25 +175,40 @@ namespace { #endif using AbstractShaderProgram::link; using AbstractShaderProgram::uniformLocation; + #ifndef MAGNUM_TARGET_GLES2 + using AbstractShaderProgram::uniformBlockIndex; + #endif }; } void AbstractShaderProgramGLTest::create() { Utility::Resource rs("AbstractShaderProgramGLTest"); - #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL210, Shader::Type::Vertex); - #else - Shader vert(Version::GLES200, Shader::Type::Vertex); - #endif + Shader vert( + #ifndef MAGNUM_TARGET_GLES + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + #else + Version::GLES200 + #endif + , Shader::Type::Vertex); vert.addSource(rs.get("MyShader.vert")); const bool vertCompiled = vert.compile(); - #ifndef MAGNUM_TARGET_GLES - Shader frag(Version::GL210, Shader::Type::Fragment); - #else - Shader frag(Version::GLES200, Shader::Type::Fragment); - #endif + Shader frag( + #ifndef MAGNUM_TARGET_GLES + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + #else + Version::GLES200 + #endif + , Shader::Type::Fragment); frag.addSource(rs.get("MyShader.frag")); const bool fragCompiled = frag.compile(); @@ -185,7 +227,12 @@ void AbstractShaderProgramGLTest::create() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(linked); - CORRADE_VERIFY(valid); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(valid); + } const Int matrixUniform = program.uniformLocation("matrix"); const Int multiplierUniform = program.uniformLocation("multiplier"); @@ -203,11 +250,23 @@ void AbstractShaderProgramGLTest::createMultipleOutputs() { #ifndef MAGNUM_TARGET_GLES Utility::Resource rs("AbstractShaderProgramGLTest"); - Shader vert(Version::GL210, Shader::Type::Vertex); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); vert.addSource(rs.get("MyShader.vert")); const bool vertCompiled = vert.compile(); - Shader frag(Version::GL300, Shader::Type::Fragment); + Shader frag( + #ifndef CORRADE_TARGET_APPLE + Version::GL300 + #else + Version::GL310 + #endif + , Shader::Type::Fragment); frag.addSource(rs.get("MyShaderFragmentOutputs.frag")); const bool fragCompiled = frag.compile(); @@ -228,7 +287,12 @@ void AbstractShaderProgramGLTest::createMultipleOutputs() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(linked); - CORRADE_VERIFY(valid); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(valid); + } #elif !defined(MAGNUM_TARGET_GLES2) CORRADE_SKIP("Only explicit location specification supported in ES 3.0."); #else @@ -240,11 +304,23 @@ void AbstractShaderProgramGLTest::createMultipleOutputs() { void AbstractShaderProgramGLTest::createMultipleOutputsIndexed() { Utility::Resource rs("AbstractShaderProgramGLTest"); - Shader vert(Version::GL210, Shader::Type::Vertex); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); vert.addSource(rs.get("MyShader.vert")); const bool vertCompiled = vert.compile(); - Shader frag(Version::GL300, Shader::Type::Fragment); + Shader frag( + #ifndef CORRADE_TARGET_APPLE + Version::GL300 + #else + Version::GL310 + #endif + , Shader::Type::Fragment); frag.addSource(rs.get("MyShaderFragmentOutputs.frag")); const bool fragCompiled = frag.compile(); @@ -265,34 +341,61 @@ void AbstractShaderProgramGLTest::createMultipleOutputsIndexed() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(linked); - CORRADE_VERIFY(valid); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(valid); + } } #endif -void AbstractShaderProgramGLTest::uniformLocationOptimizedOut() { +void AbstractShaderProgramGLTest::uniformNotFound() { MyPublicShader program; - #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL210, Shader::Type::Vertex); - Shader frag(Version::GL210, Shader::Type::Fragment); - #else - Shader vert(Version::GLES200, Shader::Type::Vertex); - Shader frag(Version::GLES200, Shader::Type::Fragment); - #endif + Shader vert( + #ifndef MAGNUM_TARGET_GLES + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + #else + Version::GLES200 + #endif + , Shader::Type::Vertex); + Shader frag( + #ifndef MAGNUM_TARGET_GLES + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + #else + Version::GLES200 + #endif + , Shader::Type::Fragment); vert.addSource("void main() { gl_Position = vec4(0.0); }"); - frag.addSource("void main() { gl_FragColor = vec4(1.0); }"); + frag.addSource( + #ifndef CORRADE_TARGET_APPLE + "void main() { gl_FragColor = vec4(1.0); }" + #else + "out vec4 color;\n" + "void main() { color = vec4(1.0); }" + #endif + ); CORRADE_VERIFY(Shader::compile({vert, frag})); program.attachShaders({vert, frag}); CORRADE_VERIFY(program.link()); std::ostringstream out; - Warning::setOutput(&out); + Warning redirectWarning{&out}; program.uniformLocation("nonexistent"); program.uniformLocation(std::string{"another"}); CORRADE_COMPARE(out.str(), - "AbstractShaderProgram: location of uniform 'nonexistent' cannot be retrieved!\n" - "AbstractShaderProgram: location of uniform 'another' cannot be retrieved!\n"); + "AbstractShaderProgram: location of uniform 'nonexistent' cannot be retrieved\n" + "AbstractShaderProgram: location of uniform 'another' cannot be retrieved\n"); } namespace { @@ -312,13 +415,28 @@ namespace { MyShader::MyShader() { Utility::Resource rs("AbstractShaderProgramGLTest"); - #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL210, Shader::Type::Vertex); - Shader frag(Version::GL210, Shader::Type::Fragment); - #else - Shader vert(Version::GLES200, Shader::Type::Vertex); - Shader frag(Version::GLES200, Shader::Type::Fragment); - #endif + Shader vert( + #ifndef MAGNUM_TARGET_GLES + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + #else + Version::GLES200 + #endif + , Shader::Type::Vertex); + Shader frag( + #ifndef MAGNUM_TARGET_GLES + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + #else + Version::GLES200 + #endif + , Shader::Type::Fragment); vert.addSource(rs.get("MyShader.vert")); frag.addSource(rs.get("MyShader.frag")); @@ -385,6 +503,226 @@ void AbstractShaderProgramGLTest::uniformArray() { MAGNUM_VERIFY_NO_ERROR(); } +#ifndef MAGNUM_TARGET_GLES2 +void AbstractShaderProgramGLTest::createUniformBlocks() { + Utility::Resource rs("AbstractShaderProgramGLTest"); + + Shader vert( + #ifndef MAGNUM_TARGET_GLES + Version::GL310 + #else + Version::GLES300 + #endif + , Shader::Type::Vertex); + vert.addSource(rs.get("UniformBlockShader.vert")); + const bool vertCompiled = vert.compile(); + + Shader frag( + #ifndef MAGNUM_TARGET_GLES + Version::GL310 + #else + Version::GLES300 + #endif + , Shader::Type::Fragment); + frag.addSource(rs.get("UniformBlockShader.frag")); + const bool fragCompiled = frag.compile(); + + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_VERIFY(vertCompiled); + CORRADE_VERIFY(fragCompiled); + + MyPublicShader program; + program.attachShaders({vert, frag}); + + MAGNUM_VERIFY_NO_ERROR(); + + const bool linked = program.link(); + const bool valid = program.validate().first; + + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_VERIFY(linked); + { + #ifdef CORRADE_TARGET_APPLE + CORRADE_EXPECT_FAIL("OSX drivers need insane amount of state to validate properly."); + #endif + CORRADE_VERIFY(valid); + } + + const Int matricesUniformBlock = program.uniformBlockIndex("matrices"); + const Int materialUniformBlock = program.uniformBlockIndex("material"); + + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_VERIFY(matricesUniformBlock >= 0); + CORRADE_VERIFY(materialUniformBlock >= 0); +} + +void AbstractShaderProgramGLTest::uniformBlockIndexNotFound() { + MyPublicShader program; + + Shader vert( + #ifndef MAGNUM_TARGET_GLES + Version::GL310 + #else + Version::GLES300 + #endif + , Shader::Type::Vertex); + Shader frag( + #ifndef MAGNUM_TARGET_GLES + Version::GL310 + #else + Version::GLES300 + #endif + , Shader::Type::Fragment); + vert.addSource("void main() { gl_Position = vec4(0.0); }"); + frag.addSource("out lowp vec4 color;\n" + "void main() { color = vec4(1.0); }"); + + CORRADE_VERIFY(Shader::compile({vert, frag})); + program.attachShaders({vert, frag}); + CORRADE_VERIFY(program.link()); + + std::ostringstream out; + Warning redirectWarning{&out}; + program.uniformBlockIndex("nonexistent"); + program.uniformBlockIndex(std::string{"another"}); + CORRADE_COMPARE(out.str(), + "AbstractShaderProgram: index of uniform block 'nonexistent' cannot be retrieved\n" + "AbstractShaderProgram: index of uniform block 'another' cannot be retrieved\n"); +} + +namespace { + struct UniformBlockShader: AbstractShaderProgram { + explicit UniformBlockShader(); + + using AbstractShaderProgram::setUniformBlockBinding; + + Int matricesUniformBlock, + materialUniformBlock; + }; +} + +#ifndef DOXYGEN_GENERATING_OUTPUT +UniformBlockShader::UniformBlockShader() { + Utility::Resource rs("AbstractShaderProgramGLTest"); + + Shader vert( + #ifndef MAGNUM_TARGET_GLES + Version::GL310 + #else + Version::GLES300 + #endif + , Shader::Type::Vertex); + Shader frag( + #ifndef MAGNUM_TARGET_GLES + Version::GL310 + #else + Version::GLES300 + #endif + , Shader::Type::Fragment); + vert.addSource(rs.get("UniformBlockShader.vert")); + frag.addSource(rs.get("UniformBlockShader.frag")); + + Shader::compile({vert, frag}); + attachShaders({vert, frag}); + + link(); + + matricesUniformBlock = uniformBlockIndex("matrices"); + materialUniformBlock = uniformBlockIndex("material"); +} +#endif + +void AbstractShaderProgramGLTest::uniformBlock() { + UniformBlockShader shader; + + MAGNUM_VERIFY_NO_ERROR(); + + shader.setUniformBlockBinding(shader.matricesUniformBlock, 0); + shader.setUniformBlockBinding(shader.materialUniformBlock, 1); + + MAGNUM_VERIFY_NO_ERROR(); +} + +void AbstractShaderProgramGLTest::compute() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::compute_shader::string() + std::string(" is not supported.")); + #else + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + struct ComputeShader: AbstractShaderProgram { + explicit ComputeShader() { + Utility::Resource rs("AbstractShaderProgramGLTest"); + + Shader compute( + #ifndef MAGNUM_TARGET_GLES + Version::GL430, + #else + Version::GLES310, + #endif + Shader::Type::Compute); + compute.addSource(rs.get("ComputeShader.comp")); + CORRADE_INTERNAL_ASSERT(compute.compile()); + + attachShader(compute); + link(); + } + + ComputeShader& setImages(Texture2D& input, Texture2D& output) { + input.bindImage(0, 0, ImageAccess::ReadOnly, ImageFormat::RGBA8UI); + output.bindImage(1, 0, ImageAccess::WriteOnly, ImageFormat::RGBA8UI); + return *this; + } + } shader; + + MAGNUM_VERIFY_NO_ERROR(); + + const Color4ub inData[] = { + { 10, 20, 30, 40}, + { 50, 60, 70, 80}, + { 90, 100, 110, 120}, + {130, 140, 150, 160} + }; + + #ifndef MAGNUM_TARGET_GLES + const Color4ub outData[] = { + { 15, 30, 45, 60}, + { 75, 90, 105, 120}, + {135, 150, 165, 180}, + {195, 210, 225, 240} + }; + #endif + + Texture2D in; + in.setStorage(1, TextureFormat::RGBA8UI, {2, 2}) + .setSubImage(0, {}, ImageView2D{PixelFormat::RGBAInteger, PixelType::UnsignedByte, {2, 2}, inData}); + + Texture2D out; + out.setStorage(1, TextureFormat::RGBA8UI, {2, 2}); + + MAGNUM_VERIFY_NO_ERROR(); + + shader.setImages(in, out) + .dispatchCompute({1, 1, 1}); + + MAGNUM_VERIFY_NO_ERROR(); + + /** @todo Test on ES */ + #ifndef MAGNUM_TARGET_GLES + const auto data = out.image(0, {PixelFormat::RGBAInteger, PixelType::UnsignedByte}).data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE_AS( + (Corrade::Containers::ArrayView{reinterpret_cast(data.data()), 4}), + (Corrade::Containers::ArrayView{outData}), + TestSuite::Compare::Container); + #endif +} +#endif + }} MAGNUM_GL_TEST_MAIN(Magnum::Test::AbstractShaderProgramGLTest) diff --git a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/ComputeShader.comp b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/ComputeShader.comp new file mode 100644 index 000000000..8328717c1 --- /dev/null +++ b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/ComputeShader.comp @@ -0,0 +1,7 @@ +layout(local_size_x = 2, local_size_y = 2) in; +layout(binding = 0, rgba8ui) uniform mediump uimage2D inData; +layout(binding = 1, rgba8ui) uniform mediump uimage2D outData; + +void main() { + imageStore(outData, ivec2(gl_GlobalInvocationID.xy), imageLoad(inData, ivec2(gl_GlobalInvocationID.xy))*3u/2u); +} diff --git a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/MyShader.frag b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/MyShader.frag index c15b54a91..a0b53ae68 100644 --- a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/MyShader.frag +++ b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/MyShader.frag @@ -2,10 +2,18 @@ #define lowp #endif +#if defined(GL_ES) || __VERSION__ == 120 +#define fragColor gl_FragColor +#endif + uniform lowp float multiplier; uniform lowp vec4 color; uniform lowp vec4 additions[3]; +#if !defined(GL_ES) && __VERSION__ >= 130 +out lowp vec4 fragColor; +#endif + void main() { - gl_FragColor = color*multiplier + additions[0] + additions[1] + additions[2]; + fragColor = color*multiplier + additions[0] + additions[1] + additions[2]; } diff --git a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/MyShader.vert b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/MyShader.vert index 5d8ff9029..d839d0f7e 100644 --- a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/MyShader.vert +++ b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/MyShader.vert @@ -2,7 +2,11 @@ #define mediump #endif -attribute mediump vec4 position; +#if defined(GL_ES) || __VERSION__ == 120 +#define in attribute +#endif + +in mediump vec4 position; uniform mediump mat4 matrix; diff --git a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/UniformBlockShader.frag b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/UniformBlockShader.frag new file mode 100644 index 000000000..e850f3bc3 --- /dev/null +++ b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/UniformBlockShader.frag @@ -0,0 +1,11 @@ +layout(std140) uniform material { + lowp vec4 color; + lowp vec4 additions[3]; + lowp float multiplier; +}; + +out lowp vec4 fragColor; + +void main() { + fragColor = color*multiplier + additions[0] + additions[1] + additions[2]; +} diff --git a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/UniformBlockShader.vert b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/UniformBlockShader.vert new file mode 100644 index 000000000..3e0232d5f --- /dev/null +++ b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/UniformBlockShader.vert @@ -0,0 +1,10 @@ +in mediump vec4 position; + +layout(std140) uniform matrices { + mediump mat4 transformation; + mediump mat4 projection; +}; + +void main() { + gl_Position = projection*transformation*position; +} diff --git a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/resources.conf b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/resources.conf index 80d20b68e..16f02a005 100644 --- a/src/Magnum/Test/AbstractShaderProgramGLTestFiles/resources.conf +++ b/src/Magnum/Test/AbstractShaderProgramGLTestFiles/resources.conf @@ -8,3 +8,12 @@ filename=MyShader.vert [file] filename=MyShaderFragmentOutputs.frag + +[file] +filename=UniformBlockShader.frag + +[file] +filename=UniformBlockShader.vert + +[file] +filename=ComputeShader.comp diff --git a/src/Magnum/Test/AbstractShaderProgramTest.cpp b/src/Magnum/Test/AbstractShaderProgramTest.cpp index bdcd6bd0a..089b0f573 100644 --- a/src/Magnum/Test/AbstractShaderProgramTest.cpp +++ b/src/Magnum/Test/AbstractShaderProgramTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/AbstractTextureGLTest.cpp b/src/Magnum/Test/AbstractTextureGLTest.cpp index ed75c9907..5b593b288 100644 --- a/src/Magnum/Test/AbstractTextureGLTest.cpp +++ b/src/Magnum/Test/AbstractTextureGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -88,8 +88,8 @@ void AbstractTextureGLTest::constructMove() { void AbstractTextureGLTest::label() { /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); Texture2D texture; diff --git a/src/Magnum/Test/ArrayTest.cpp b/src/Magnum/Test/ArrayTest.cpp index 7a5048235..dffe19ccc 100644 --- a/src/Magnum/Test/ArrayTest.cpp +++ b/src/Magnum/Test/ArrayTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -51,11 +51,7 @@ void ArrayTest::construct() { constexpr Array<3, Int> a = {5, 6, 7}; CORRADE_COMPARE(a, (Array<3, Int>(5, 6, 7))); - #ifndef CORRADE_MSVC2015_COMPATIBILITY - /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ - constexpr - #endif - Array<3, Int> a2 = 5; + constexpr Array<3, Int> a2 = 5; CORRADE_COMPARE(a2, (Array<3, Int>(5, 5, 5))); constexpr Array1D b = 5; diff --git a/src/Magnum/Test/BufferGLTest.cpp b/src/Magnum/Test/BufferGLTest.cpp index c64b702cc..55129e983 100644 --- a/src/Magnum/Test/BufferGLTest.cpp +++ b/src/Magnum/Test/BufferGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -26,6 +26,7 @@ #include #include #include +#include #include "Magnum/Buffer.h" #include "Magnum/Context.h" @@ -158,8 +159,8 @@ void BufferGLTest::wrap() { void BufferGLTest::label() { /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); Buffer buffer; @@ -176,7 +177,7 @@ void BufferGLTest::label() { #ifndef MAGNUM_TARGET_GLES2 void BufferGLTest::bindBase() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::uniform_buffer_object::string() + std::string{" is not supported."}); #endif @@ -200,7 +201,7 @@ void BufferGLTest::bindBase() { void BufferGLTest::bindRange() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::uniform_buffer_object::string() + std::string{" is not supported."}); #endif @@ -247,12 +248,9 @@ void BufferGLTest::data() { #ifndef MAGNUM_TARGET_GLES const Containers::Array contents = buffer.data(); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_COMPARE(contents.size(), 5); - CORRADE_COMPARE(contents[0], 2); - CORRADE_COMPARE(contents[1], 7); - CORRADE_COMPARE(contents[2], 5); - CORRADE_COMPARE(contents[3], 13); - CORRADE_COMPARE(contents[4], 25); + CORRADE_COMPARE_AS(contents, + Containers::ArrayView{data}, + TestSuite::Compare::Container); #endif /* Plain array */ @@ -277,16 +275,15 @@ void BufferGLTest::data() { #ifndef MAGNUM_TARGET_GLES const Containers::Array subContents = buffer.subData(4, 3); MAGNUM_VERIFY_NO_ERROR(); - CORRADE_COMPARE(subContents.size(), 3); - CORRADE_COMPARE(subContents[0], 125); - CORRADE_COMPARE(subContents[1], 3); - CORRADE_COMPARE(subContents[2], 15); + CORRADE_COMPARE_AS(subContents, + Containers::ArrayView{subData}, + TestSuite::Compare::Container); #endif } void BufferGLTest::map() { #ifdef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::mapbuffer::string() + std::string(" is not supported")); #endif Buffer buffer; @@ -320,7 +317,7 @@ void BufferGLTest::map() { #ifdef CORRADE_TARGET_NACL void BufferGLTest::mapSub() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::CHROMIUM::map_sub::string() + std::string(" is not supported")); Buffer buffer; @@ -343,10 +340,10 @@ void BufferGLTest::mapSub() { void BufferGLTest::mapRange() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::map_buffer_range::string() + std::string(" is not supported")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::map_buffer_range::string() + std::string(" is not supported")); #endif @@ -374,10 +371,10 @@ void BufferGLTest::mapRange() { void BufferGLTest::mapRangeExplicitFlush() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::map_buffer_range::string() + std::string(" is not supported")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::map_buffer_range::string() + std::string(" is not supported")); #endif @@ -427,10 +424,9 @@ void BufferGLTest::copy() { /** @todo How to verify the contents in ES? */ #ifndef MAGNUM_TARGET_GLES const Containers::Array subContents = buffer2.subData(2, 3); - CORRADE_COMPARE(subContents.size(), 3); - CORRADE_COMPARE(subContents[0], 7); - CORRADE_COMPARE(subContents[1], 5); - CORRADE_COMPARE(subContents[2], 13); + CORRADE_COMPARE_AS(subContents, + Containers::ArrayView{data}.slice(1, 4), + TestSuite::Compare::Container); #endif } #endif diff --git a/src/Magnum/Test/BufferImageGLTest.cpp b/src/Magnum/Test/BufferImageGLTest.cpp index 1aeb7629e..e424552fc 100644 --- a/src/Magnum/Test/BufferImageGLTest.cpp +++ b/src/Magnum/Test/BufferImageGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/BufferTextureGLTest.cpp b/src/Magnum/Test/BufferTextureGLTest.cpp index 52b266b4a..fc2a7946b 100644 --- a/src/Magnum/Test/BufferTextureGLTest.cpp +++ b/src/Magnum/Test/BufferTextureGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -28,6 +28,7 @@ #include "Magnum/Buffer.h" #include "Magnum/BufferTexture.h" #include "Magnum/BufferTextureFormat.h" +#include "Magnum/ImageFormat.h" #include "Magnum/Test/AbstractOpenGLTester.h" namespace Magnum { namespace Test { @@ -40,6 +41,8 @@ struct BufferTextureGLTest: AbstractOpenGLTester { void wrap(); void bind(); + void bindImage(); + void setBuffer(); void setBufferOffset(); }; @@ -50,16 +53,18 @@ BufferTextureGLTest::BufferTextureGLTest() { &BufferTextureGLTest::wrap, &BufferTextureGLTest::bind, + &BufferTextureGLTest::bindImage, + &BufferTextureGLTest::setBuffer, &BufferTextureGLTest::setBufferOffset}); } void BufferTextureGLTest::construct() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_buffer::string() + std::string(" is not supported.")); #endif @@ -86,10 +91,10 @@ void BufferTextureGLTest::constructNoCreate() { void BufferTextureGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_buffer::string() + std::string(" is not supported.")); #endif @@ -109,10 +114,10 @@ void BufferTextureGLTest::wrap() { void BufferTextureGLTest::bind() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_buffer::string() + std::string(" is not supported.")); #endif @@ -134,12 +139,49 @@ void BufferTextureGLTest::bind() { MAGNUM_VERIFY_NO_ERROR(); } +void BufferTextureGLTest::bindImage() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + #else + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_buffer::string() + std::string(" is not supported.")); + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + Buffer buffer; + buffer.setData({nullptr, 32}, BufferUsage::StaticDraw); + + BufferTexture texture; + texture.setBuffer(BufferTextureFormat::RGBA8, buffer) + .bindImage(2, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImage(2); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); + #endif +} + void BufferTextureGLTest::setBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_buffer::string() + std::string(" is not supported.")); #endif @@ -157,12 +199,12 @@ void BufferTextureGLTest::setBuffer() { void BufferTextureGLTest::setBufferOffset() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_object::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_buffer_range::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_buffer::string() + std::string(" is not supported.")); #endif diff --git a/src/Magnum/Test/CMakeLists.txt b/src/Magnum/Test/CMakeLists.txt index c84e74c97..a2bca782f 100644 --- a/src/Magnum/Test/CMakeLists.txt +++ b/src/Magnum/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,7 @@ # corrade_add_test(AbstractShaderProgramTest AbstractShaderProgramTest.cpp LIBRARIES Magnum) -corrade_add_test(ArrayTest ArrayTest.cpp) +corrade_add_test(ArrayTest ArrayTest.cpp LIBRARIES Magnum) corrade_add_test(FormatTest FormatTest.cpp LIBRARIES Magnum) corrade_add_test(ContextTest ContextTest.cpp LIBRARIES Magnum) corrade_add_test(DebugOutputTest DebugOutputTest.cpp LIBRARIES Magnum) @@ -36,15 +36,16 @@ corrade_add_test(MeshTest MeshTest.cpp LIBRARIES Magnum) corrade_add_test(PixelStorageTest PixelStorageTest.cpp LIBRARIES Magnum) corrade_add_test(RendererTest RendererTest.cpp LIBRARIES Magnum) corrade_add_test(ResourceManagerTest ResourceManagerTest.cpp LIBRARIES Magnum) +target_compile_definitions(ResourceManagerTest PRIVATE "CORRADE_GRACEFUL_ASSERT") corrade_add_test(SamplerTest SamplerTest.cpp LIBRARIES Magnum) corrade_add_test(ShaderTest ShaderTest.cpp LIBRARIES Magnum) corrade_add_test(VersionTest VersionTest.cpp LIBRARIES Magnum) -corrade_add_test(TagsTest TagsTest.cpp) +corrade_add_test(TagsTest TagsTest.cpp LIBRARIES Magnum) add_library(ResourceManagerLocalInstanceTestLib ${SHARED_OR_STATIC} ResourceManagerLocalInstanceTestLib.cpp) target_link_libraries(ResourceManagerLocalInstanceTestLib Magnum) if(NOT BUILD_STATIC) - set_target_properties(ResourceManagerLocalInstanceTestLib PROPERTIES COMPILE_FLAGS "-DResourceManagerLocalInstanceTestLib_EXPORTS") + target_compile_definitions(ResourceManagerLocalInstanceTestLib PRIVATE "ResourceManagerLocalInstanceTestLib_EXPORTS") endif() corrade_add_test(ResourceManagerLocalInstanceTest ResourceManagerLocalInstanceTest.cpp LIBRARIES Magnum ResourceManagerLocalInstanceTestLib) @@ -72,8 +73,8 @@ if(BUILD_GL_TESTS) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) - include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(ShaderGLTest ShaderGLTest.cpp LIBRARIES ${GL_TEST_LIBRARIES}) + target_include_directories(ShaderGLTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) if(NOT MAGNUM_TARGET_GLES2) corrade_add_test(BufferImageGLTest BufferImageGLTest.cpp LIBRARIES ${GL_TEST_LIBRARIES}) @@ -89,13 +90,3 @@ if(BUILD_GL_TESTS) corrade_add_test(RectangleTextureGLTest RectangleTextureGLTest.cpp LIBRARIES ${GL_TEST_LIBRARIES}) endif() endif() - -set_target_properties(ResourceManagerTest PROPERTIES COMPILE_FLAGS -DCORRADE_GRACEFUL_ASSERT) - -set(MagnumGLTests_HEADERS AbstractOpenGLTester.h) - -# Add the header to project list of IDEs -add_custom_target(MagnumGLTests SOURCES ${MagnumGLTests_HEADERS}) - -# Install bootstrap header for GL tests to be used in dependent projects -install(FILES ${MagnumGLTests_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Test) diff --git a/src/Magnum/Test/ContextGLTest.cpp b/src/Magnum/Test/ContextGLTest.cpp index 650bd42db..7f0986a0f 100644 --- a/src/Magnum/Test/ContextGLTest.cpp +++ b/src/Magnum/Test/ContextGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -37,6 +37,9 @@ struct ContextGLTest: AbstractOpenGLTester { void constructCopyMove(); void isVersionSupported(); + #ifndef MAGNUM_TARGET_GLES + void isVersionSupportedES(); + #endif void supportedVersion(); void isExtensionSupported(); void isExtensionDisabled(); @@ -46,6 +49,9 @@ ContextGLTest::ContextGLTest() { addTests({&ContextGLTest::constructCopyMove, &ContextGLTest::isVersionSupported, + #ifndef MAGNUM_TARGET_GLES + &ContextGLTest::isVersionSupportedES, + #endif &ContextGLTest::supportedVersion, &ContextGLTest::isExtensionSupported, &ContextGLTest::isExtensionDisabled}); @@ -60,45 +66,55 @@ void ContextGLTest::constructCopyMove() { } void ContextGLTest::isVersionSupported() { - const Version v = Context::current()->version(); - CORRADE_VERIFY(Context::current()->isVersionSupported(v)); - CORRADE_VERIFY(Context::current()->isVersionSupported(Version(Int(v)-1))); - CORRADE_VERIFY(!Context::current()->isVersionSupported(Version(Int(v)+1))); + const Version v = Context::current().version(); + CORRADE_VERIFY(Context::current().isVersionSupported(v)); + CORRADE_VERIFY(Context::current().isVersionSupported(Version(Int(v)-1))); + CORRADE_VERIFY(!Context::current().isVersionSupported(Version(Int(v)+1))); /* No assertions should be fired */ MAGNUM_ASSERT_VERSION_SUPPORTED(v); MAGNUM_ASSERT_VERSION_SUPPORTED(Version(Int(v)-1)); } +#ifndef MAGNUM_TARGET_GLES +void ContextGLTest::isVersionSupportedES() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::ES2_compatibility::string() + std::string(" extension should not be supported, can't test")); + + /* No assertions should be fired */ + CORRADE_VERIFY(Context::current().isVersionSupported(Version::GLES200)); +} +#endif + void ContextGLTest::supportedVersion() { - const Version v = Context::current()->version(); + const Version v = Context::current().version(); /* Selects first supported version (thus not necessarily the highest) */ - CORRADE_VERIFY(Context::current()->supportedVersion({Version(Int(v)+1), v, Version(Int(v)-1)}) == v); - CORRADE_VERIFY(Context::current()->supportedVersion({Version(Int(v)+1), Version(Int(v)-1), v}) == Version(Int(v)-1)); + CORRADE_VERIFY(Context::current().supportedVersion({Version(Int(v)+1), v, Version(Int(v)-1)}) == v); + CORRADE_VERIFY(Context::current().supportedVersion({Version(Int(v)+1), Version(Int(v)-1), v}) == Version(Int(v)-1)); } void ContextGLTest::isExtensionSupported() { #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::GREMEDY::string_marker::string() + std::string(" extension should not be supported, can't test")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_filter_anisotropic::string() + std::string(" extension should be supported, can't test")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::explicit_attrib_location::string() + std::string(" extension should be supported, can't test")); /* Test that we have proper extension list parser */ - std::vector extensions = Context::current()->extensionStrings(); + std::vector extensions = Context::current().extensionStrings(); CORRADE_VERIFY(std::find(extensions.begin(), extensions.end(), Extensions::GL::EXT::texture_filter_anisotropic::string()) != extensions.end()); CORRADE_VERIFY(std::find(extensions.begin(), extensions.end(), Extensions::GL::GREMEDY::string_marker::string()) == extensions.end()); /* This is disabled in GL < 3.2 to work around GLSL compiler bugs */ - CORRADE_VERIFY(!Context::current()->isExtensionSupported(Version::GL310)); - CORRADE_VERIFY(Context::current()->isExtensionSupported(Version::GL320)); + CORRADE_VERIFY(!Context::current().isExtensionSupported(Version::GL310)); + CORRADE_VERIFY(Context::current().isExtensionSupported(Version::GL320)); #else CORRADE_SKIP("No useful extensions to test on OpenGL ES"); #endif @@ -106,18 +122,18 @@ void ContextGLTest::isExtensionSupported() { void ContextGLTest::isExtensionDisabled() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_array_object::string() + std::string(" extension should be supported, can't test")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::explicit_attrib_location::string() + std::string(" extension should be supported, can't test")); /* This is not disabled anywhere */ - CORRADE_VERIFY(!Context::current()->isExtensionDisabled()); + CORRADE_VERIFY(!Context::current().isExtensionDisabled()); /* This is disabled in GL < 3.2 to work around GLSL compiler bugs */ - CORRADE_VERIFY(Context::current()->isExtensionDisabled(Version::GL310)); - CORRADE_VERIFY(!Context::current()->isExtensionDisabled(Version::GL320)); + CORRADE_VERIFY(Context::current().isExtensionDisabled(Version::GL310)); + CORRADE_VERIFY(!Context::current().isExtensionDisabled(Version::GL320)); #else CORRADE_SKIP("No useful extensions to test on OpenGL ES"); #endif diff --git a/src/Magnum/Test/ContextTest.cpp b/src/Magnum/Test/ContextTest.cpp index fab4650df..67d9346bf 100644 --- a/src/Magnum/Test/ContextTest.cpp +++ b/src/Magnum/Test/ContextTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp index e6e14e5ea..b7d44ea01 100644 --- a/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureArrayGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -28,6 +28,7 @@ #include "Magnum/BufferImage.h" #include "Magnum/CubeMapTextureArray.h" #include "Magnum/Image.h" +#include "Magnum/ImageFormat.h" #include "Magnum/PixelFormat.h" #include "Magnum/TextureFormat.h" #include "Magnum/Math/Color.h" @@ -44,6 +45,7 @@ struct CubeMapTextureArrayGLTest: AbstractOpenGLTester { void wrap(); void bind(); + void bindImage(); void sampling(); void samplingSRGBDecode(); @@ -66,7 +68,9 @@ struct CubeMapTextureArrayGLTest: AbstractOpenGLTester { void compressedSubImageBuffer(); #ifndef MAGNUM_TARGET_GLES void subImageQuery(); + void compressedSubImageQuery(); void subImageQueryBuffer(); + void compressedSubImageQueryBuffer(); #endif void generateMipmap(); @@ -87,6 +91,7 @@ CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() { &CubeMapTextureArrayGLTest::wrap, &CubeMapTextureArrayGLTest::bind, + &CubeMapTextureArrayGLTest::bindImage, &CubeMapTextureArrayGLTest::sampling, &CubeMapTextureArrayGLTest::samplingSRGBDecode, @@ -109,7 +114,9 @@ CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() { &CubeMapTextureArrayGLTest::compressedSubImageBuffer, #ifndef MAGNUM_TARGET_GLES &CubeMapTextureArrayGLTest::subImageQuery, + &CubeMapTextureArrayGLTest::compressedSubImageQuery, &CubeMapTextureArrayGLTest::subImageQueryBuffer, + &CubeMapTextureArrayGLTest::compressedSubImageQueryBuffer, #endif &CubeMapTextureArrayGLTest::generateMipmap, @@ -118,7 +125,7 @@ CubeMapTextureArrayGLTest::CubeMapTextureArrayGLTest() { &CubeMapTextureArrayGLTest::invalidateSubImage}); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) { _compressedDataStorage = _compressedSubDataStorage = CompressedPixelStorage{} .setCompressedBlockSize({4, 4, 1}) @@ -144,10 +151,10 @@ namespace { void CubeMapTextureArrayGLTest::construct() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -174,10 +181,10 @@ void CubeMapTextureArrayGLTest::constructNoCreate() { void CubeMapTextureArrayGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -197,10 +204,10 @@ void CubeMapTextureArrayGLTest::wrap() { void CubeMapTextureArrayGLTest::bind() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -222,12 +229,49 @@ void CubeMapTextureArrayGLTest::bind() { MAGNUM_VERIFY_NO_ERROR(); } +void CubeMapTextureArrayGLTest::bindImage() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + #else + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + CubeMapTextureArray texture; + texture.setStorage(1, TextureFormat::RGBA8, {32, 32, 12}) + .bindImage(2, 0, 1, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + texture.bindImageLayered(3, 0, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + AbstractTexture::unbindImage(2); + AbstractTexture::unbindImage(3); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); + #endif +} + void CubeMapTextureArrayGLTest::sampling() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -256,13 +300,13 @@ void CubeMapTextureArrayGLTest::sampling() { void CubeMapTextureArrayGLTest::samplingSRGBDecode() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); CubeMapTextureArray texture; @@ -273,14 +317,14 @@ void CubeMapTextureArrayGLTest::samplingSRGBDecode() { void CubeMapTextureArrayGLTest::samplingBorderInteger() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_border_clamp::string() + std::string(" is not supported.")); #endif @@ -296,12 +340,12 @@ void CubeMapTextureArrayGLTest::samplingBorderInteger() { void CubeMapTextureArrayGLTest::samplingSwizzle() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -313,12 +357,12 @@ void CubeMapTextureArrayGLTest::samplingSwizzle() { void CubeMapTextureArrayGLTest::samplingDepthStencilMode() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -330,9 +374,9 @@ void CubeMapTextureArrayGLTest::samplingDepthStencilMode() { #ifdef MAGNUM_TARGET_GLES void CubeMapTextureArrayGLTest::samplingBorder() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_border_clamp::string() + std::string(" is not supported.")); CubeMapTextureArray texture; @@ -345,10 +389,10 @@ void CubeMapTextureArrayGLTest::samplingBorder() { void CubeMapTextureArrayGLTest::storage() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -412,10 +456,10 @@ namespace { void CubeMapTextureArrayGLTest::image() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -440,13 +484,13 @@ void CubeMapTextureArrayGLTest::image() { void CubeMapTextureArrayGLTest::compressedImage() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); CubeMapTextureArray texture; @@ -472,10 +516,10 @@ void CubeMapTextureArrayGLTest::compressedImage() { void CubeMapTextureArrayGLTest::imageBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -500,13 +544,13 @@ void CubeMapTextureArrayGLTest::imageBuffer() { void CubeMapTextureArrayGLTest::compressedImageBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); CubeMapTextureArray texture; @@ -662,10 +706,10 @@ namespace { void CubeMapTextureArrayGLTest::subImage() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -692,15 +736,38 @@ void CubeMapTextureArrayGLTest::subImage() { void CubeMapTextureArrayGLTest::compressedSubImage() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + #ifndef MAGNUM_TARGET_GLES + /* Compressed pixel storage for array textures is underspecified. If the + extension is supported, first test with default values to ensure we are + not that far off, then continue as usual */ + if(Context::current().isExtensionSupported()) { + CubeMapTextureArray texture; + texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, + {12, 12, 6}, CompressedZero}); + texture.setCompressedSubImage(0, {4, 4, 1}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{4}, CompressedSubData}); + + MAGNUM_VERIFY_NO_ERROR(); + + CompressedImage3D image = texture.compressedImage(0, {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{12, 12, 6})); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedSubDataComplete}, TestSuite::Compare::Container); + } + #endif + CubeMapTextureArray texture; texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 12, 6}, CompressedZero}); @@ -718,18 +785,24 @@ void CubeMapTextureArrayGLTest::compressedSubImage() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{12, 12, 6})); - CORRADE_COMPARE_AS( - (Containers::ArrayView{image.data(), image.data().size()}), - Containers::ArrayView{CompressedSubDataComplete}, TestSuite::Compare::Container); + + { + CORRADE_EXPECT_FAIL_IF(Context::current().isExtensionSupported() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), + "Non-default compressed pixel storage for cube map textures behaves weirdly on NVidia for client-memory images"); + + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedSubDataComplete}, TestSuite::Compare::Container); + } #endif } void CubeMapTextureArrayGLTest::subImageBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -755,13 +828,13 @@ void CubeMapTextureArrayGLTest::subImageBuffer() { void CubeMapTextureArrayGLTest::compressedSubImageBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); CubeMapTextureArray texture; @@ -789,9 +862,9 @@ void CubeMapTextureArrayGLTest::compressedSubImageBuffer() { #ifndef MAGNUM_TARGET_GLES void CubeMapTextureArrayGLTest::subImageQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); CubeMapTextureArray texture; @@ -811,10 +884,47 @@ void CubeMapTextureArrayGLTest::subImageQuery() { Containers::ArrayView{SubData}, TestSuite::Compare::Container); } +void CubeMapTextureArrayGLTest::compressedSubImageQuery() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + CubeMapTextureArray texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 12, 6}) + .setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 12, 6}, CompressedSubDataComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 1}, Vector3i{4}), {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector3i{4}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedSubData}, TestSuite::Compare::Container); + } + + CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 1}, Vector3i{4}), {_compressedSubDataStorage}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector3i{4}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}.suffix(_compressedSubDataOffset)), + Containers::ArrayView{CompressedSubData}, TestSuite::Compare::Container); +} + void CubeMapTextureArrayGLTest::subImageQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); CubeMapTextureArray texture; @@ -833,16 +943,51 @@ void CubeMapTextureArrayGLTest::subImageQueryBuffer() { CORRADE_COMPARE_AS(imageData.suffix(SubDataOffset), Containers::ArrayView{SubData}, TestSuite::Compare::Container); } + +void CubeMapTextureArrayGLTest::compressedSubImageQueryBuffer() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + CubeMapTextureArray texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 12, 6}) + .setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 12, 6}, CompressedSubDataComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 1}, Vector3i{4}), {}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector3i{4}); + CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedSubData}, TestSuite::Compare::Container); + } + + CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 1}, Vector3i{4}), {_compressedSubDataStorage}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector3i{4}); + CORRADE_COMPARE_AS(imageData.suffix(_compressedSubDataOffset), Containers::ArrayView{CompressedSubData}, TestSuite::Compare::Container); +} #endif void CubeMapTextureArrayGLTest::generateMipmap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -869,10 +1014,10 @@ void CubeMapTextureArrayGLTest::generateMipmap() { void CubeMapTextureArrayGLTest::invalidateImage() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif @@ -885,10 +1030,10 @@ void CubeMapTextureArrayGLTest::invalidateImage() { void CubeMapTextureArrayGLTest::invalidateSubImage() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not supported.")); #endif diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index 7b66a7f8e..80bfe2911 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -31,6 +31,9 @@ #endif #include "Magnum/CubeMapTexture.h" #include "Magnum/Image.h" +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +#include "Magnum/ImageFormat.h" +#endif #include "Magnum/PixelFormat.h" #include "Magnum/TextureFormat.h" #include "Magnum/Math/Color.h" @@ -47,6 +50,9 @@ struct CubeMapTextureGLTest: AbstractOpenGLTester { void wrap(); void bind(); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + void bindImage(); + #endif void sampling(); void samplingSRGBDecode(); @@ -74,6 +80,7 @@ struct CubeMapTextureGLTest: AbstractOpenGLTester { void imageBuffer(); void compressedImageBuffer(); #endif + void immutableCompressedImage(); #ifndef MAGNUM_TARGET_GLES void fullImageQuery(); void compressedFullImageQuery(); @@ -89,7 +96,9 @@ struct CubeMapTextureGLTest: AbstractOpenGLTester { #endif #ifndef MAGNUM_TARGET_GLES void subImageQuery(); + void compressedSubImageQuery(); void subImageQueryBuffer(); + void compressedSubImageQueryBuffer(); #endif void generateMipmap(); @@ -113,6 +122,9 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { &CubeMapTextureGLTest::wrap, &CubeMapTextureGLTest::bind, + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + &CubeMapTextureGLTest::bindImage, + #endif &CubeMapTextureGLTest::sampling, &CubeMapTextureGLTest::samplingSRGBDecode, @@ -140,6 +152,7 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { &CubeMapTextureGLTest::imageBuffer, &CubeMapTextureGLTest::compressedImageBuffer, #endif + &CubeMapTextureGLTest::immutableCompressedImage, #ifndef MAGNUM_TARGET_GLES &CubeMapTextureGLTest::fullImageQuery, &CubeMapTextureGLTest::compressedFullImageQuery, @@ -155,7 +168,9 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { #endif #ifndef MAGNUM_TARGET_GLES &CubeMapTextureGLTest::subImageQuery, + &CubeMapTextureGLTest::compressedSubImageQuery, &CubeMapTextureGLTest::subImageQueryBuffer, + &CubeMapTextureGLTest::compressedSubImageQueryBuffer, #endif &CubeMapTextureGLTest::generateMipmap, @@ -167,7 +182,7 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { _dataOffset = 8; #ifdef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #endif { _dataStorage = {}; @@ -176,7 +191,7 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { #endif #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) { _compressedDataStorage = CompressedPixelStorage{} .setCompressedBlockSize({4, 4, 1}) @@ -195,6 +210,7 @@ CubeMapTextureGLTest::CubeMapTextureGLTest() { _compressedDataStorage = {}; #endif _compressedDataOffset = 0; + _compressedFullDataOffset = 0; } } @@ -261,6 +277,41 @@ void CubeMapTextureGLTest::bind() { MAGNUM_VERIFY_NO_ERROR(); } +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +void CubeMapTextureGLTest::bindImage() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + #else + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + CubeMapTexture texture; + texture.setStorage(1, TextureFormat::RGBA8, Vector2i{32}) + .bindImage(2, 0, CubeMapCoordinate::NegativeX, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + texture.bindImageLayered(3, 0, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + AbstractTexture::unbindImage(2); + AbstractTexture::unbindImage(3); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); + #endif +} +#endif + void CubeMapTextureGLTest::sampling() { CubeMapTexture texture; texture.setMinificationFilter(Sampler::Filter::Linear, Sampler::Mipmap::Linear) @@ -292,10 +343,10 @@ void CubeMapTextureGLTest::sampling() { void CubeMapTextureGLTest::samplingSRGBDecode() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::sRGB::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -307,7 +358,7 @@ void CubeMapTextureGLTest::samplingSRGBDecode() { #ifndef MAGNUM_TARGET_GLES2 void CubeMapTextureGLTest::samplingSwizzle() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); #endif @@ -318,7 +369,7 @@ void CubeMapTextureGLTest::samplingSwizzle() { } #else void CubeMapTextureGLTest::samplingMaxLevel() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -328,8 +379,8 @@ void CubeMapTextureGLTest::samplingMaxLevel() { } void CubeMapTextureGLTest::samplingCompare() { - if(!Context::current()->isExtensionSupported() || - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() || + !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::NV::shadow_samplers_cube::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -343,10 +394,10 @@ void CubeMapTextureGLTest::samplingCompare() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void CubeMapTextureGLTest::samplingBorderInteger() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_border_clamp::string() + std::string(" is not supported.")); #endif @@ -364,10 +415,10 @@ void CubeMapTextureGLTest::samplingBorderInteger() { #ifndef MAGNUM_TARGET_GLES2 void CubeMapTextureGLTest::samplingDepthStencilMode() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 not supported."); #endif @@ -380,8 +431,8 @@ void CubeMapTextureGLTest::samplingDepthStencilMode() { #ifdef MAGNUM_TARGET_GLES void CubeMapTextureGLTest::samplingBorder() { - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("No required extension is supported."); CubeMapTexture texture; @@ -400,7 +451,7 @@ void CubeMapTextureGLTest::storage() { #ifndef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing"); #endif @@ -431,14 +482,14 @@ namespace { void CubeMapTextureGLTest::image() { CubeMapTexture texture; - texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, ImageView2D{_dataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), unsafeSuffix(Data, _dataOffset)}); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES - Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, + Image2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {_dataStorage, PixelFormat::RGBA, PixelType::UnsignedByte}); MAGNUM_VERIFY_NO_ERROR(); @@ -452,24 +503,31 @@ void CubeMapTextureGLTest::image() { void CubeMapTextureGLTest::compressedImage() { #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif - CubeMapTexture texture; - texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0, CompressedImageView2D{ + const CompressedImageView2D view{ #ifndef MAGNUM_TARGET_GLES _compressedDataStorage, #endif - CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, unsafeSuffix(CompressedData, _compressedDataOffset)}); + CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, unsafeSuffix(CompressedData, _compressedDataOffset)}; + + CubeMapTexture texture; + texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0, view) + .setCompressedImage(CubeMapCoordinate::NegativeX, 0, view) + .setCompressedImage(CubeMapCoordinate::PositiveY, 0, view) + .setCompressedImage(CubeMapCoordinate::NegativeY, 0, view) + .setCompressedImage(CubeMapCoordinate::PositiveZ, 0, view) + .setCompressedImage(CubeMapCoordinate::NegativeZ, 0, view); MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - CompressedImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0, {_compressedDataStorage}); + CompressedImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {_compressedDataStorage}); MAGNUM_VERIFY_NO_ERROR(); @@ -483,14 +541,14 @@ void CubeMapTextureGLTest::compressedImage() { #ifndef MAGNUM_TARGET_GLES2 void CubeMapTextureGLTest::imageBuffer() { CubeMapTexture texture; - texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, BufferImage2D{ + texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, BufferImage2D{ _dataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), unsafeSuffix(Data, _dataOffset), BufferUsage::StaticDraw}); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES - BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, + BufferImage2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {_dataStorage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); const auto imageData = image.buffer().data(); @@ -504,24 +562,31 @@ void CubeMapTextureGLTest::imageBuffer() { void CubeMapTextureGLTest::compressedImageBuffer() { #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif - CubeMapTexture texture; - texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0, CompressedBufferImage2D{ + CompressedBufferImage2D buffer{ #ifndef MAGNUM_TARGET_GLES _compressedDataStorage, #endif - CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, unsafeSuffix(CompressedData, _compressedDataOffset), BufferUsage::StaticDraw}); + CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, unsafeSuffix(CompressedData, _compressedDataOffset), BufferUsage::StaticDraw}; + + CubeMapTexture texture; + texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0, buffer) + .setCompressedImage(CubeMapCoordinate::NegativeX, 0, buffer) + .setCompressedImage(CubeMapCoordinate::PositiveY, 0, buffer) + .setCompressedImage(CubeMapCoordinate::NegativeY, 0, buffer) + .setCompressedImage(CubeMapCoordinate::PositiveZ, 0, buffer) + .setCompressedImage(CubeMapCoordinate::NegativeZ, 0, buffer); MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - CompressedBufferImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0, + CompressedBufferImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {_compressedDataStorage}, BufferUsage::StaticRead); const auto imageData = image.buffer().data(); @@ -534,6 +599,53 @@ void CubeMapTextureGLTest::compressedImageBuffer() { } #endif +void CubeMapTextureGLTest::immutableCompressedImage() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_storage::string() + std::string(" is not supported.")); + #elif defined(MAGNUM_TARGET_GLES2) + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_storage::string() + std::string(" is not supported.")); + #endif + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + /* Testing that GL_TEXTURE_COMPRESSED_IMAGE_SIZE is consistent and returns + the same value regardless whether the texture is immutable or not. (Not + the case, at least on NVidia 358.16, compare with compressedImage() test + case that just calls setImage() six times instead of setStorage() and + gets value that's six times smaller. I couldn't find anything in the + specs so I suspect it's a bug). */ + + const CompressedImageView2D view{ + #ifndef MAGNUM_TARGET_GLES + _compressedDataStorage, + #endif + CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, unsafeSuffix(CompressedData, _compressedDataOffset)}; + + CubeMapTexture texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{4}) + .setCompressedSubImage(CubeMapCoordinate::PositiveX, 0, {}, view) + .setCompressedSubImage(CubeMapCoordinate::NegativeX, 0, {}, view) + .setCompressedSubImage(CubeMapCoordinate::PositiveY, 0, {}, view) + .setCompressedSubImage(CubeMapCoordinate::NegativeY, 0, {}, view) + .setCompressedSubImage(CubeMapCoordinate::PositiveZ, 0, {}, view) + .setCompressedSubImage(CubeMapCoordinate::NegativeZ, 0, {}, view); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + CompressedImage2D image = texture.compressedImage(CubeMapCoordinate::NegativeY, 0, {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector2i{4}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedData}, TestSuite::Compare::Container); + #endif +} + #ifndef MAGNUM_TARGET_GLES namespace { constexpr UnsignedByte FullData[] = { 0x00, 0x01, 0x02, 0x03, @@ -589,7 +701,7 @@ namespace { } void CubeMapTextureGLTest::fullImageQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -610,9 +722,9 @@ void CubeMapTextureGLTest::fullImageQuery() { } void CubeMapTextureGLTest::compressedFullImageQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -632,7 +744,7 @@ void CubeMapTextureGLTest::compressedFullImageQuery() { } void CubeMapTextureGLTest::fullImageQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -653,9 +765,9 @@ void CubeMapTextureGLTest::fullImageQueryBuffer() { } void CubeMapTextureGLTest::compressedFullImageQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -715,16 +827,26 @@ namespace { void CubeMapTextureGLTest::subImage() { CubeMapTexture texture; - texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); - texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), ImageView2D{ + texture.setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i(1), ImageView2D{ _dataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), unsafeSuffix(Data, _dataOffset)}); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES - Image2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}); + Image2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}); MAGNUM_VERIFY_NO_ERROR(); @@ -737,17 +859,61 @@ void CubeMapTextureGLTest::subImage() { void CubeMapTextureGLTest::compressedSubImage() { #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif + #ifndef MAGNUM_TARGET_GLES + /* Compressed pixel storage for array textures is underspecified. If the + extension is supported, first test with default values to ensure we are + not that far off, then continue as usual */ + if(Context::current().isExtensionSupported()) { + CubeMapTexture texture; + texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeX, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::PositiveY, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeY, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::PositiveZ, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeZ, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i{4}, CompressedImageView2D{ + CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{4}, CompressedData}); + + MAGNUM_VERIFY_NO_ERROR(); + + CompressedImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector2i{12}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedSubDataComplete}, TestSuite::Compare::Container); + } + #endif + CubeMapTexture texture; - texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0, + texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeX, 0, CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); - texture.setCompressedSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i{4}, CompressedImageView2D{ + texture.setCompressedImage(CubeMapCoordinate::PositiveY, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeY, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::PositiveZ, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeZ, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i{4}, CompressedImageView2D{ #ifndef MAGNUM_TARGET_GLES _compressedDataStorage, #endif @@ -756,30 +922,46 @@ void CubeMapTextureGLTest::compressedSubImage() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - CompressedImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0, {}); + CompressedImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {}); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), Vector2i{12}); - CORRADE_COMPARE_AS( - (Containers::ArrayView{image.data(), image.data().size()}), - Containers::ArrayView{CompressedSubDataComplete}, TestSuite::Compare::Container); + + { + CORRADE_EXPECT_FAIL_IF(Context::current().isExtensionSupported() && Context::current().isExtensionSupported() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), + "Non-default compressed pixel storage for cube map textures behaves weirdly on NVidia for client-memory images when using ARB_direct_state_access"); + + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedSubDataComplete}, TestSuite::Compare::Container); + } #endif } #ifndef MAGNUM_TARGET_GLES2 void CubeMapTextureGLTest::subImageBuffer() { CubeMapTexture texture; - texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8, ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); - texture.setSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i(1), BufferImage2D{ + texture.setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8, + ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero)); + texture.setSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i(1), BufferImage2D{ _dataStorage, PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), unsafeSuffix(Data, _dataOffset), BufferUsage::StaticDraw}); MAGNUM_VERIFY_NO_ERROR(); /** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES - BufferImage2D image = texture.image(CubeMapTexture::Coordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); + BufferImage2D image = texture.image(CubeMapCoordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead); const auto imageData = image.buffer().data(); MAGNUM_VERIFY_NO_ERROR(); @@ -791,17 +973,27 @@ void CubeMapTextureGLTest::subImageBuffer() { void CubeMapTextureGLTest::compressedSubImageBuffer() { #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif CubeMapTexture texture; - texture.setCompressedImage(CubeMapTexture::Coordinate::PositiveX, 0, + texture.setCompressedImage(CubeMapCoordinate::PositiveX, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeX, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::PositiveY, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeY, 0, CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); - texture.setCompressedSubImage(CubeMapTexture::Coordinate::PositiveX, 0, Vector2i{4}, CompressedBufferImage2D{ + texture.setCompressedImage(CubeMapCoordinate::PositiveZ, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedImage(CubeMapCoordinate::NegativeZ, 0, + CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, Vector2i{12}, CompressedZero}); + texture.setCompressedSubImage(CubeMapCoordinate::PositiveX, 0, Vector2i{4}, CompressedBufferImage2D{ #ifndef MAGNUM_TARGET_GLES _compressedDataStorage, #endif @@ -810,7 +1002,7 @@ void CubeMapTextureGLTest::compressedSubImageBuffer() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - CompressedBufferImage2D image = texture.compressedImage(CubeMapTexture::Coordinate::PositiveX, 0, + CompressedBufferImage2D image = texture.compressedImage(CubeMapCoordinate::PositiveX, 0, {}, BufferUsage::StaticRead); const auto imageData = image.buffer().data(); @@ -824,10 +1016,10 @@ void CubeMapTextureGLTest::compressedSubImageBuffer() { #ifndef MAGNUM_TARGET_GLES void CubeMapTextureGLTest::subImageQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); /* I'm too lazy to call setSubImage() six times */ - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -847,11 +1039,49 @@ void CubeMapTextureGLTest::subImageQuery() { Containers::ArrayView{Data}, TestSuite::Compare::Container); } +void CubeMapTextureGLTest::compressedSubImageQuery() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + /* I'm too lazy to call setSubImage() six times */ + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + CubeMapTexture texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{12}) + .setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 12, 1}, CompressedSubDataComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 1})); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedData}, TestSuite::Compare::Container); + } + + CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), {_compressedDataStorage}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 1})); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}.suffix(_compressedDataOffset)), + Containers::ArrayView{CompressedData}, TestSuite::Compare::Container); +} + void CubeMapTextureGLTest::subImageQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); /* I'm too lazy to call setSubImage() six times */ - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); CubeMapTexture texture; @@ -869,21 +1099,57 @@ void CubeMapTextureGLTest::subImageQueryBuffer() { CORRADE_COMPARE(image.size(), Vector3i(2, 2, 1)); CORRADE_COMPARE_AS(imageData.suffix(_dataOffset), Containers::ArrayView{Data}, TestSuite::Compare::Container); } + +void CubeMapTextureGLTest::compressedSubImageQueryBuffer() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + /* I'm too lazy to call setSubImage() six times */ + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::direct_state_access::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + CubeMapTexture texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, Vector2i{12}) + .setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 12, 1}, CompressedSubDataComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), {}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 1})); + CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedData}, TestSuite::Compare::Container); + } + + CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 4, 0}, {4, 4, 1}), {_compressedDataStorage}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 1})); + CORRADE_COMPARE_AS(imageData.suffix(_compressedDataOffset), Containers::ArrayView{CompressedData}, TestSuite::Compare::Container); +} #endif void CubeMapTextureGLTest::generateMipmap() { CubeMapTexture texture; - texture.setImage(CubeMapTexture::Coordinate::PositiveX, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::PositiveX, 0, TextureFormat::RGBA8, ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); - texture.setImage(CubeMapTexture::Coordinate::PositiveY, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::PositiveY, 0, TextureFormat::RGBA8, ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); - texture.setImage(CubeMapTexture::Coordinate::PositiveZ, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::PositiveZ, 0, TextureFormat::RGBA8, ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); - texture.setImage(CubeMapTexture::Coordinate::NegativeX, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::NegativeX, 0, TextureFormat::RGBA8, ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); - texture.setImage(CubeMapTexture::Coordinate::NegativeY, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::NegativeY, 0, TextureFormat::RGBA8, ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); - texture.setImage(CubeMapTexture::Coordinate::NegativeZ, 0, TextureFormat::RGBA8, + texture.setImage(CubeMapCoordinate::NegativeZ, 0, TextureFormat::RGBA8, ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(32))); /** @todo How to test this on ES? */ diff --git a/src/Magnum/Test/DebugOutputGLTest.cpp b/src/Magnum/Test/DebugOutputGLTest.cpp index 370db947d..9af68e779 100644 --- a/src/Magnum/Test/DebugOutputGLTest.cpp +++ b/src/Magnum/Test/DebugOutputGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -61,7 +61,7 @@ DebugOutputGLTest::DebugOutputGLTest() { } void DebugOutputGLTest::setCallback() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::KHR::debug::string() + std::string(" is not supported")); /* Need to be careful, because the test runner is using debug output too */ @@ -71,7 +71,7 @@ void DebugOutputGLTest::setCallback() { } void DebugOutputGLTest::setEnabled() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::KHR::debug::string() + std::string(" is not supported")); /* Try at least some combinations */ @@ -83,10 +83,10 @@ void DebugOutputGLTest::setEnabled() { } void DebugOutputGLTest::messageNoOp() { - if(Context::current()->isExtensionSupported() || - Context::current()->isExtensionSupported() + if(Context::current().isExtensionSupported() || + Context::current().isExtensionSupported() #ifndef MAGNUM_TARGET_GLES - || Context::current()->isExtensionSupported() + || Context::current().isExtensionSupported() #endif ) CORRADE_SKIP("The extensions are supported, cannot test."); @@ -98,12 +98,12 @@ void DebugOutputGLTest::messageNoOp() { } void DebugOutputGLTest::message() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::KHR::debug::string() + std::string(" is not supported")); /* Need to be careful, because the test runner is using debug output too */ std::ostringstream out; - Debug::setOutput(&out); + Debug redirectDebug{&out}; DebugMessage::insert(DebugMessage::Source::Application, DebugMessage::Type::Marker, 1337, DebugOutput::Severity::High, "Hello from OpenGL command stream!"); @@ -113,10 +113,10 @@ void DebugOutputGLTest::message() { } void DebugOutputGLTest::messageFallback() { - if(Context::current()->isExtensionSupported() || - (!Context::current()->isExtensionSupported() + if(Context::current().isExtensionSupported() || + (!Context::current().isExtensionSupported() #ifndef MAGNUM_TARGET_GLES - && !Context::current()->isExtensionSupported() + && !Context::current().isExtensionSupported() #endif )) CORRADE_SKIP("No proper extension is supported"); @@ -128,8 +128,8 @@ void DebugOutputGLTest::messageFallback() { } void DebugOutputGLTest::groupNoOp() { - if(Context::current()->isExtensionSupported() || - Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported() || + Context::current().isExtensionSupported()) CORRADE_SKIP("The extensions are supported, cannot test."); { @@ -140,12 +140,12 @@ void DebugOutputGLTest::groupNoOp() { } void DebugOutputGLTest::group() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::KHR::debug::string() + std::string(" is not supported")); /* Need to be careful, because the test runner is using debug output too */ std::ostringstream out; - Debug::setOutput(&out); + Debug redirectDebug{&out}; { DebugGroup g1{DebugGroup::Source::Application, 42, "Automatic debug group"}; DebugGroup g2; @@ -162,8 +162,8 @@ void DebugOutputGLTest::group() { } void DebugOutputGLTest::groupFallback() { - if(Context::current()->isExtensionSupported() || - !Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported() || + !Context::current().isExtensionSupported()) CORRADE_SKIP("No proper extension is supported"); { diff --git a/src/Magnum/Test/DebugOutputTest.cpp b/src/Magnum/Test/DebugOutputTest.cpp index 26df23359..2d33a04c9 100644 --- a/src/Magnum/Test/DebugOutputTest.cpp +++ b/src/Magnum/Test/DebugOutputTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/DefaultFramebufferTest.cpp b/src/Magnum/Test/DefaultFramebufferTest.cpp index 6121a2f1d..254d5b14c 100644 --- a/src/Magnum/Test/DefaultFramebufferTest.cpp +++ b/src/Magnum/Test/DefaultFramebufferTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/FormatTest.cpp b/src/Magnum/Test/FormatTest.cpp index f29d2c772..0e58cd210 100644 --- a/src/Magnum/Test/FormatTest.cpp +++ b/src/Magnum/Test/FormatTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/FramebufferGLTest.cpp b/src/Magnum/Test/FramebufferGLTest.cpp index 820d9e894..fbe32f287 100644 --- a/src/Magnum/Test/FramebufferGLTest.cpp +++ b/src/Magnum/Test/FramebufferGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -25,6 +25,7 @@ #include "Magnum/configure.h" #include "Magnum/Context.h" +#include "Magnum/CubeMapTexture.h" #include "Magnum/Extensions.h" #include "Magnum/Framebuffer.h" #include "Magnum/Image.h" @@ -177,7 +178,7 @@ FramebufferGLTest::FramebufferGLTest() { &FramebufferGLTest::blit}); #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) { + if(Context::current().isExtensionSupported()) { rgbaFormatES2 = TextureFormat::RGBA8; depthStencilFormatES2 = TextureFormat::Depth24Stencil8; } else { @@ -189,7 +190,7 @@ FramebufferGLTest::FramebufferGLTest() { void FramebufferGLTest::construct() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -222,7 +223,7 @@ void FramebufferGLTest::constructCopy() { void FramebufferGLTest::constructMove() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -251,7 +252,7 @@ void FramebufferGLTest::constructMove() { void FramebufferGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -271,13 +272,13 @@ void FramebufferGLTest::wrap() { void FramebufferGLTest::label() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); Framebuffer framebuffer({{}, Vector2i(32)}); @@ -293,7 +294,7 @@ void FramebufferGLTest::label() { void FramebufferGLTest::attachRenderbuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -308,7 +309,7 @@ void FramebufferGLTest::attachRenderbuffer() { on my NVidia, thus we need to do this juggling with one renderbuffer */ Renderbuffer depthStencil; #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES2 @@ -325,7 +326,7 @@ void FramebufferGLTest::attachRenderbuffer() { .attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil); #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, depthStencil); @@ -338,11 +339,11 @@ void FramebufferGLTest::attachRenderbuffer() { void FramebufferGLTest::attachRenderbufferMultisample() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available."); #endif @@ -376,7 +377,7 @@ void FramebufferGLTest::attachRenderbufferMultisample() { #ifndef MAGNUM_TARGET_GLES void FramebufferGLTest::attachTexture1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); Texture1D color; @@ -397,7 +398,7 @@ void FramebufferGLTest::attachTexture1D() { void FramebufferGLTest::attachTexture2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -421,7 +422,7 @@ void FramebufferGLTest::attachTexture2D() { MAGNUM_VERIFY_NO_ERROR(); #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES2 @@ -441,7 +442,7 @@ void FramebufferGLTest::attachTexture2D() { } #ifdef MAGNUM_TARGET_GLES2 - else if(Context::current()->isExtensionSupported()) { + else if(Context::current().isExtensionSupported()) { Debug() << "Using" << Extensions::GL::OES::depth_texture::string(); Texture2D depth; @@ -457,10 +458,10 @@ void FramebufferGLTest::attachTexture2D() { void FramebufferGLTest::attachTexture3D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not available.")); #endif @@ -481,7 +482,7 @@ void FramebufferGLTest::attachTexture3D() { #ifndef MAGNUM_TARGET_GLES void FramebufferGLTest::attachTexture1DArray() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); Texture1DArray color; @@ -503,9 +504,9 @@ void FramebufferGLTest::attachTexture1DArray() { #ifndef MAGNUM_TARGET_GLES2 void FramebufferGLTest::attachTexture2DArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not available.")); #endif @@ -528,12 +529,12 @@ void FramebufferGLTest::attachTexture2DArray() { #ifndef MAGNUM_TARGET_GLES2 void FramebufferGLTest::attachTexture2DMultisample() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not available.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -556,12 +557,12 @@ void FramebufferGLTest::attachTexture2DMultisample() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void FramebufferGLTest::attachTexture2DMultisampleArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not available.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not available.")); #endif @@ -583,9 +584,9 @@ void FramebufferGLTest::attachTexture2DMultisampleArray() { #ifndef MAGNUM_TARGET_GLES void FramebufferGLTest::attachRectangleTexture() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not available.")); RectangleTexture color; @@ -606,7 +607,7 @@ void FramebufferGLTest::attachRectangleTexture() { void FramebufferGLTest::attachCubeMapTexture() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -618,12 +619,12 @@ void FramebufferGLTest::attachCubeMapTexture() { #else color.setStorage(1, rgbaFormatES2, Vector2i(128)); #endif - framebuffer.attachCubeMapTexture(Framebuffer::ColorAttachment(0), color, CubeMapTexture::Coordinate::NegativeZ, 0); + framebuffer.attachCubeMapTexture(Framebuffer::ColorAttachment(0), color, CubeMapCoordinate::NegativeZ, 0); CubeMapTexture depthStencil; #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES2 @@ -632,20 +633,20 @@ void FramebufferGLTest::attachCubeMapTexture() { #ifndef MAGNUM_TARGET_GLES2 depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); - framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0); + framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, CubeMapCoordinate::NegativeZ, 0); #else depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128)); - framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0) - .attachCubeMapTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0); + framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapCoordinate::NegativeZ, 0) + .attachCubeMapTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, CubeMapCoordinate::NegativeZ, 0); #endif } #ifdef MAGNUM_TARGET_GLES2 - else if(Context::current()->isExtensionSupported()) { + else if(Context::current().isExtensionSupported()) { Debug() << "Using" << Extensions::GL::OES::depth_texture::string(); depthStencil.setStorage(1, TextureFormat::DepthComponent16, Vector2i(128)); - framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapTexture::Coordinate::NegativeZ, 0); + framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapCoordinate::NegativeZ, 0); } #endif @@ -657,12 +658,12 @@ void FramebufferGLTest::attachCubeMapTexture() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void FramebufferGLTest::attachCubeMapTextureArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not available.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not available.")); #endif @@ -685,12 +686,12 @@ void FramebufferGLTest::attachCubeMapTextureArray() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void FramebufferGLTest::attachLayeredTexture3D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available.")); #endif @@ -707,9 +708,9 @@ void FramebufferGLTest::attachLayeredTexture3D() { #ifndef MAGNUM_TARGET_GLES void FramebufferGLTest::attachLayeredTexture1DArray() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available.")); Texture1DArray color; @@ -730,12 +731,12 @@ void FramebufferGLTest::attachLayeredTexture1DArray() { void FramebufferGLTest::attachLayeredTexture2DArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available.")); #endif @@ -756,12 +757,12 @@ void FramebufferGLTest::attachLayeredTexture2DArray() { void FramebufferGLTest::attachLayeredCubeMapTexture() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available.")); #endif @@ -782,16 +783,16 @@ void FramebufferGLTest::attachLayeredCubeMapTexture() { void FramebufferGLTest::attachLayeredCubeMapTextureArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not available.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not available.")); #endif @@ -812,16 +813,16 @@ void FramebufferGLTest::attachLayeredCubeMapTextureArray() { void FramebufferGLTest::attachLayeredTexture2DMultisampleArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not available.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not available.")); #endif @@ -843,7 +844,7 @@ void FramebufferGLTest::attachLayeredTexture2DMultisampleArray() { void FramebufferGLTest::detach() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -857,11 +858,11 @@ void FramebufferGLTest::detach() { void FramebufferGLTest::multipleColorOutputs() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("No required extension available."); #endif @@ -890,7 +891,7 @@ void FramebufferGLTest::multipleColorOutputs() { {1, Framebuffer::ColorAttachment(0)}}); #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES2 @@ -906,7 +907,7 @@ void FramebufferGLTest::multipleColorOutputs() { void FramebufferGLTest::clear() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -921,7 +922,7 @@ void FramebufferGLTest::clear() { on my NVidia, thus we need to do this juggling with one renderbuffer */ Renderbuffer depthStencil; #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES2 @@ -938,7 +939,7 @@ void FramebufferGLTest::clear() { .attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil); #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, depthStencil); @@ -954,7 +955,7 @@ void FramebufferGLTest::clear() { void FramebufferGLTest::invalidate() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -982,7 +983,7 @@ void FramebufferGLTest::invalidate() { #ifndef MAGNUM_TARGET_GLES2 void FramebufferGLTest::invalidateSub() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -1014,7 +1015,7 @@ namespace { void FramebufferGLTest::read() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -1029,7 +1030,7 @@ void FramebufferGLTest::read() { on my NVidia, thus we need to do this juggling with one renderbuffer */ Renderbuffer depthStencil; #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES2 @@ -1046,7 +1047,7 @@ void FramebufferGLTest::read() { .attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil); #ifdef MAGNUM_TARGET_GLES2 - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, depthStencil); @@ -1070,7 +1071,7 @@ void FramebufferGLTest::read() { CORRADE_COMPARE(colorImage.data()[DataOffset], Color4ub(128, 64, 32, 17)); #ifdef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES @@ -1084,7 +1085,7 @@ void FramebufferGLTest::read() { } #ifdef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES @@ -1098,7 +1099,7 @@ void FramebufferGLTest::read() { } #ifdef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { #ifdef MAGNUM_TARGET_GLES @@ -1117,7 +1118,7 @@ void FramebufferGLTest::read() { #ifndef MAGNUM_TARGET_GLES2 void FramebufferGLTest::readBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -1156,11 +1157,11 @@ void FramebufferGLTest::readBuffer() { void FramebufferGLTest::blit() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available."); #endif diff --git a/src/Magnum/Test/FramebufferTest.cpp b/src/Magnum/Test/FramebufferTest.cpp index de85126d9..2229721f5 100644 --- a/src/Magnum/Test/FramebufferTest.cpp +++ b/src/Magnum/Test/FramebufferTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/ImageTest.cpp b/src/Magnum/Test/ImageTest.cpp index f6f85cc4b..224855a2f 100644 --- a/src/Magnum/Test/ImageTest.cpp +++ b/src/Magnum/Test/ImageTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/ImageViewTest.cpp b/src/Magnum/Test/ImageViewTest.cpp index 4ef3cffd2..47074ae7f 100644 --- a/src/Magnum/Test/ImageViewTest.cpp +++ b/src/Magnum/Test/ImageViewTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/MeshGLTest.cpp b/src/Magnum/Test/MeshGLTest.cpp index 784b85124..41b4543cc 100644 --- a/src/Magnum/Test/MeshGLTest.cpp +++ b/src/Magnum/Test/MeshGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -237,9 +237,9 @@ void MeshGLTest::construct() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { CORRADE_VERIFY(mesh.id() > 0); @@ -272,9 +272,9 @@ void MeshGLTest::constructMove() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { CORRADE_VERIFY(id > 0); @@ -292,9 +292,9 @@ void MeshGLTest::constructMove() { MAGNUM_VERIFY_NO_ERROR(); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #elif defined(MAGNUM_TARGET_GLES2) - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) #endif { CORRADE_VERIFY(cId > 0); @@ -306,10 +306,10 @@ void MeshGLTest::constructMove() { void MeshGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_array_object::string() + std::string{" is not supported."}); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::vertex_array_object::string() + std::string{" is not supported."}); #endif @@ -337,8 +337,8 @@ void MeshGLTest::wrap() { void MeshGLTest::label() { /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); Mesh mesh; @@ -384,8 +384,20 @@ FloatShader::FloatShader(const std::string& type, const std::string& conversion) /* We need special version for ES3, because GLSL in ES2 doesn't support rectangle matrices */ #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL210, Shader::Type::Vertex); - Shader frag(Version::GL210, Shader::Type::Fragment); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); + Shader frag( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Fragment); #elif defined(MAGNUM_TARGET_GLES2) Shader vert(Version::GLES200, Shader::Type::Vertex); Shader frag(Version::GLES200, Shader::Type::Fragment); @@ -395,32 +407,32 @@ FloatShader::FloatShader(const std::string& type, const std::string& conversion) #endif vert.addSource( - #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) "#if !defined(GL_ES) && __VERSION__ == 120\n" "#define mediump\n" "#endif\n" - "attribute mediump " + type + " value;\n" - "varying mediump " + type + " valueInterpolated;\n" - #else + "#if defined(GL_ES) || __VERSION__ == 120\n" + "#define in attribute\n" + "#define out varying\n" + "#endif\n" "in mediump " + type + " value;\n" "out mediump " + type + " valueInterpolated;\n" - #endif "void main() {\n" " valueInterpolated = value;\n" " gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n" "}\n"); - - #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) - frag.addSource("#if !defined(GL_ES) && __VERSION__ == 120\n" - "#define mediump\n" - "#endif\n" - "varying mediump " + type + " valueInterpolated;\n" - "void main() { gl_FragColor = " + conversion + "; }\n"); - #else - frag.addSource("in mediump " + type + " valueInterpolated;\n" - "out mediump vec4 result;\n" - "void main() { result = " + conversion + "; }\n"); - #endif + frag.addSource( + "#if !defined(GL_ES) && __VERSION__ == 120\n" + "#define mediump\n" + "#endif\n" + "#if defined(GL_ES) || __VERSION__ == 120\n" + "#define in varying\n" + "#define result gl_FragColor\n" + "#endif\n" + "in mediump " + type + " valueInterpolated;\n" + "#if !defined(GL_ES) && __VERSION__ >= 130\n" + "out mediump vec4 result;\n" + "#endif\n" + "void main() { result = " + conversion + "; }\n"); CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); @@ -434,8 +446,20 @@ FloatShader::FloatShader(const std::string& type, const std::string& conversion) #ifndef MAGNUM_TARGET_GLES2 IntegerShader::IntegerShader(const std::string& type) { #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL300, Shader::Type::Vertex); - Shader frag(Version::GL300, Shader::Type::Fragment); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL300 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); + Shader frag( + #ifndef CORRADE_TARGET_APPLE + Version::GL300 + #else + Version::GL310 + #endif + , Shader::Type::Fragment); #else Shader vert(Version::GLES300, Shader::Type::Vertex); Shader frag(Version::GLES300, Shader::Type::Fragment); @@ -514,7 +538,7 @@ template T Checker::get(PixelFormat format, PixelType type) { #ifndef MAGNUM_TARGET_GLES2 void MeshGLTest::addVertexBufferUnsignedInt() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif @@ -539,7 +563,7 @@ void MeshGLTest::addVertexBufferUnsignedInt() { void MeshGLTest::addVertexBufferInt() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif @@ -590,7 +614,7 @@ void MeshGLTest::addVertexBufferFloat() { #ifndef MAGNUM_TARGET_GLES void MeshGLTest::addVertexBufferDouble() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_attrib_64bit::string() + std::string(" is not available.")); typedef Attribute<0, Double> Attribute; @@ -616,7 +640,7 @@ void MeshGLTest::addVertexBufferDouble() { #ifndef MAGNUM_TARGET_GLES2 void MeshGLTest::addVertexBufferVectorNui() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif @@ -641,7 +665,7 @@ void MeshGLTest::addVertexBufferVectorNui() { void MeshGLTest::addVertexBufferVectorNi() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif @@ -692,7 +716,7 @@ void MeshGLTest::addVertexBufferVectorN() { #ifndef MAGNUM_TARGET_GLES void MeshGLTest::addVertexBufferVectorNd() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_attrib_64bit::string() + std::string(" is not available.")); typedef Attribute<0, Vector4d> Attribute; @@ -745,7 +769,7 @@ void MeshGLTest::addVertexBufferMatrixNxN() { #ifndef MAGNUM_TARGET_GLES void MeshGLTest::addVertexBufferMatrixNxNd() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_attrib_64bit::string() + std::string(" is not available.")); typedef Attribute<0, Matrix3x3d> Attribute; @@ -771,11 +795,14 @@ void MeshGLTest::addVertexBufferMatrixNxNd() { MAGNUM_VERIFY_NO_ERROR(); { - CORRADE_EXPECT_FAIL("Somehow only first two values are extracted"); + CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & (Context::DetectedDriver::AMD|Context::DetectedDriver::NVidia), "Somehow only first two values are extracted"); CORRADE_COMPARE(value, Math::Vector3(315, 65201, 2576)); } - /* This is wrong, but check if it's still the right wrong */ - CORRADE_COMPARE(value, Math::Vector3(315, 65201, 0)); + + /* This is wrong, but check if it's still the right wrong. Fails on AMD + 15.201.1151 but seems to be fixed in 15.300.1025.0 */ + if(Context::current().detectedDriver() & (Context::DetectedDriver::AMD|Context::DetectedDriver::NVidia)) + CORRADE_COMPARE(value, Math::Vector3(315, 65201, 0)); } #endif @@ -808,7 +835,7 @@ void MeshGLTest::addVertexBufferMatrixMxN() { #ifndef MAGNUM_TARGET_GLES void MeshGLTest::addVertexBufferMatrixMxNd() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_attrib_64bit::string() + std::string(" is not available.")); typedef Attribute<0, Matrix3x4d> Attribute; @@ -834,30 +861,33 @@ void MeshGLTest::addVertexBufferMatrixMxNd() { MAGNUM_VERIFY_NO_ERROR(); { - CORRADE_EXPECT_FAIL("Somehow only first two values are extracted"); + CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & (Context::DetectedDriver::AMD|Context::DetectedDriver::NVidia), "Somehow only first two values are extracted"); CORRADE_COMPARE(value, Math::Vector3(315, 65201, 2576)); } - /* This is wrong, but check if it's still the right wrong */ - CORRADE_COMPARE(value, Math::Vector3(315, 65201, 0)); + + /* This is wrong, but check if it's still the right wrong. Fails on AMD + 15.201.1151 but seems to be fixed in 15.300.1025.0 */ + if(Context::current().detectedDriver() & (Context::DetectedDriver::AMD|Context::DetectedDriver::NVidia)) + CORRADE_COMPARE(value, Math::Vector3(315, 65201, 0)); } #endif #ifndef MAGNUM_TARGET_GLES2 void MeshGLTest::addVertexBufferUnsignedIntWithUnsignedShort() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif typedef Attribute<0, UnsignedInt> Attribute; - constexpr UnsignedShort data[] = { 0, 49563, 16583 }; + constexpr UnsignedShort data[] = { 0, 49563, 2128, 3821, 16583 }; Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); Mesh mesh; mesh.setBaseVertex(1) - .addVertexBuffer(buffer, 2, Attribute(Attribute::DataType::UnsignedShort)); + .addVertexBuffer(buffer, 2, 2, Attribute(Attribute::DataType::UnsignedShort)); MAGNUM_VERIFY_NO_ERROR(); @@ -870,19 +900,19 @@ void MeshGLTest::addVertexBufferUnsignedIntWithUnsignedShort() { void MeshGLTest::addVertexBufferUnsignedIntWithShort() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif typedef Attribute<0, UnsignedInt> Attribute; - constexpr Short data[] = { 0, 24563, 16583 }; + constexpr Short data[] = { 0, 24563, 2128, 3821, 16583 }; Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); Mesh mesh; mesh.setBaseVertex(1) - .addVertexBuffer(buffer, 2, Attribute(Attribute::DataType::Short)); + .addVertexBuffer(buffer, 2, 2, Attribute(Attribute::DataType::Short)); MAGNUM_VERIFY_NO_ERROR(); @@ -895,19 +925,19 @@ void MeshGLTest::addVertexBufferUnsignedIntWithShort() { void MeshGLTest::addVertexBufferIntWithUnsignedShort() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif typedef Attribute<0, Int> Attribute; - constexpr UnsignedShort data[] = { 0, 49563, 16583 }; + constexpr UnsignedShort data[] = { 0, 49563, 2128, 3821, 16583 }; Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); Mesh mesh; mesh.setBaseVertex(1) - .addVertexBuffer(buffer, 2, Attribute(Attribute::DataType::UnsignedShort)); + .addVertexBuffer(buffer, 2, 2, Attribute(Attribute::DataType::UnsignedShort)); MAGNUM_VERIFY_NO_ERROR(); @@ -920,19 +950,19 @@ void MeshGLTest::addVertexBufferIntWithUnsignedShort() { void MeshGLTest::addVertexBufferIntWithShort() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif typedef Attribute<0, Int> Attribute; - constexpr Short data[] = { 0, 24563, -16583 }; + constexpr Short data[] = { 0, 24563, 2128, 3821, -16583 }; Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); Mesh mesh; mesh.setBaseVertex(1) - .addVertexBuffer(buffer, 2, Attribute(Attribute::DataType::Short)); + .addVertexBuffer(buffer, 2, 2, Attribute(Attribute::DataType::Short)); MAGNUM_VERIFY_NO_ERROR(); @@ -946,10 +976,10 @@ void MeshGLTest::addVertexBufferIntWithShort() { void MeshGLTest::addVertexBufferFloatWithHalfFloat() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::half_float_vertex::string() + std::string(" is not supported.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::vertex_half_float::string() + std::string(" is not supported.")); #endif @@ -989,7 +1019,7 @@ void MeshGLTest::addVertexBufferFloatWithDouble() { void MeshGLTest::addVertexBufferVector3WithUnsignedInt10f11f11fRev() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_type_10f_11f_11f_rev::string() + std::string(" is not available.")); #endif @@ -1010,7 +1040,7 @@ void MeshGLTest::addVertexBufferVector3WithUnsignedInt10f11f11fRev() { #ifndef MAGNUM_TARGET_GLES2 void MeshGLTest::addVertexBufferVector4WithUnsignedInt2101010Rev() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_type_2_10_10_10_rev::string() + std::string(" is not available.")); #endif @@ -1029,7 +1059,7 @@ void MeshGLTest::addVertexBufferVector4WithUnsignedInt2101010Rev() { void MeshGLTest::addVertexBufferVector4WithInt2101010Rev() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_type_2_10_10_10_rev::string() + std::string(" is not available.")); #endif @@ -1078,13 +1108,13 @@ void MeshGLTest::addVertexBufferLessVectorComponents() { void MeshGLTest::addVertexBufferNormalized() { typedef Attribute<0, Vector3> Attribute; - constexpr Color3ub data[] = { {}, {0, 128, 64}, {32, 156, 228} }; + constexpr Color4ub data[] = { {}, {0, 128, 64}, {32, 156, 228} }; Buffer buffer; buffer.setData(data, BufferUsage::StaticDraw); Mesh mesh; mesh.setBaseVertex(1) - .addVertexBuffer(buffer, 3, Attribute(Attribute::DataType::UnsignedByte, Attribute::DataOption::Normalized)); + .addVertexBuffer(buffer, 4, Attribute(Attribute::DataType::UnsignedByte, Attribute::DataOption::Normalized), 1); MAGNUM_VERIFY_NO_ERROR(); @@ -1103,7 +1133,7 @@ void MeshGLTest::addVertexBufferNormalized() { #ifndef MAGNUM_TARGET_GLES void MeshGLTest::addVertexBufferBGRA() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_array_bgra::string() + std::string(" is not available.")); #endif @@ -1140,29 +1170,54 @@ namespace { #ifndef DOXYGEN_GENERATING_OUTPUT MultipleShader::MultipleShader() { #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL210, Shader::Type::Vertex); - Shader frag(Version::GL210, Shader::Type::Fragment); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); + Shader frag( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Fragment); #else Shader vert(Version::GLES200, Shader::Type::Vertex); Shader frag(Version::GLES200, Shader::Type::Fragment); #endif - vert.addSource("#if !defined(GL_ES) && __VERSION__ == 120\n" - "#define mediump\n" - "#endif\n" - "attribute mediump vec4 position;\n" - "attribute mediump vec3 normal;\n" - "attribute mediump vec2 textureCoordinates;\n" - "varying mediump vec4 valueInterpolated;\n" - "void main() {\n" - " valueInterpolated = position + vec4(normal, 0.0) + vec4(textureCoordinates, 0.0, 0.0);\n" - " gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n" - "}\n"); - frag.addSource("#if !defined(GL_ES) && __VERSION__ == 120\n" - "#define mediump\n" - "#endif\n" - "varying mediump vec4 valueInterpolated;\n" - "void main() { gl_FragColor = valueInterpolated; }\n"); + vert.addSource( + "#if !defined(GL_ES) && __VERSION__ == 120\n" + "#define mediump\n" + "#endif\n" + "#if defined(GL_ES) || __VERSION__ == 120\n" + "#define in attribute\n" + "#define out varying\n" + "#endif\n" + "in mediump vec4 position;\n" + "in mediump vec3 normal;\n" + "in mediump vec2 textureCoordinates;\n" + "out mediump vec4 valueInterpolated;\n" + "void main() {\n" + " valueInterpolated = position + vec4(normal, 0.0) + vec4(textureCoordinates, 0.0, 0.0);\n" + " gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n" + "}\n"); + frag.addSource( + "#if !defined(GL_ES) && __VERSION__ == 120\n" + "#define mediump\n" + "#endif\n" + "#if defined(GL_ES) || __VERSION__ == 120\n" + "#define in varying\n" + "#define result gl_FragColor\n" + "#endif\n" + "in mediump vec4 valueInterpolated;\n" + "#if !defined(GL_ES) && __VERSION__ >= 130\n" + "out mediump vec4 result;\n" + "#endif\n" + "void main() { result = valueInterpolated; }\n"); CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); @@ -1371,7 +1426,7 @@ void MeshGLTest::setIndexBufferRange() { void MeshGLTest::setIndexBufferUnsignedInt() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::element_index_uint::string() + std::string(" is not available.")); #endif @@ -1403,7 +1458,7 @@ void MeshGLTest::setIndexBufferUnsignedInt() { #ifndef MAGNUM_TARGET_GLES void MeshGLTest::setBaseVertex() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_elements_base_vertex::string() + std::string(" is not available.")); Buffer vertices; @@ -1436,10 +1491,12 @@ void MeshGLTest::setInstanceCount() { it didn't generate any error and rendered something */ #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available."); #endif @@ -1475,10 +1532,12 @@ void MeshGLTest::setInstanceCountIndexed() { it didn't generate any error and rendered something */ #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available."); #endif @@ -1516,9 +1575,9 @@ void MeshGLTest::setInstanceCountBaseInstance() { value. I'm too lazy to invent proper test case, so I'll just check that it didn't generate any error and rendered something */ - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::base_instance::string() + std::string(" is not available.")); typedef Attribute<0, Float> Attribute; @@ -1549,9 +1608,9 @@ void MeshGLTest::setInstanceCountBaseInstanceIndexed() { same value. I'm too lazy to invent proper test case, so I'll just check that it didn't generate any error and rendered something */ - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::base_instance::string() + std::string(" is not available.")); Buffer vertices; @@ -1583,9 +1642,9 @@ void MeshGLTest::setInstanceCountBaseVertex() { value. I'm too lazy to invent proper test case, so I'll just check that it didn't generate any error and rendered something */ - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_elements_base_vertex::string() + std::string(" is not available.")); Buffer vertices; @@ -1617,11 +1676,11 @@ void MeshGLTest::setInstanceCountBaseVertexBaseInstance() { value. I'm too lazy to invent proper test case, so I'll just check that it didn't generate any error and rendered something */ - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_elements_base_vertex::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::base_instance::string() + std::string(" is not available.")); Buffer vertices; @@ -1651,14 +1710,18 @@ void MeshGLTest::setInstanceCountBaseVertexBaseInstance() { void MeshGLTest::addVertexBufferInstancedFloat() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::instanced_arrays::string() + std::string(" is not available.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required instancing extension is not available."); - if(!Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported() && !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required drawing extension is not available."); #endif @@ -1695,11 +1758,11 @@ void MeshGLTest::addVertexBufferInstancedFloat() { #ifndef MAGNUM_TARGET_GLES2 void MeshGLTest::addVertexBufferInstancedInteger() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::instanced_arrays::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::gpu_shader4::string() + std::string(" is not available.")); #endif @@ -1731,11 +1794,11 @@ void MeshGLTest::addVertexBufferInstancedInteger() { #ifndef MAGNUM_TARGET_GLES void MeshGLTest::addVertexBufferInstancedDouble() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_instanced::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::instanced_arrays::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::vertex_attrib_64bit::string() + std::string(" is not available.")); typedef Attribute<0, Double> Attribute; @@ -1812,7 +1875,7 @@ template T MultiChecker::get(PixelFormat format, PixelType type) { void MeshGLTest::multiDraw() { #ifdef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) Debug() << Extensions::GL::EXT::multi_draw_arrays::string() << "not supported, using fallback implementation"; #endif @@ -1836,7 +1899,7 @@ void MeshGLTest::multiDraw() { void MeshGLTest::multiDrawIndexed() { #ifdef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) Debug() << Extensions::GL::EXT::multi_draw_arrays::string() << "not supported, using fallback implementation"; #endif @@ -1862,7 +1925,7 @@ void MeshGLTest::multiDrawIndexed() { #ifndef MAGNUM_TARGET_GLES void MeshGLTest::multiDrawBaseVertex() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::draw_elements_base_vertex::string() + std::string(" is not available.")); Buffer vertices; diff --git a/src/Magnum/Test/MeshTest.cpp b/src/Magnum/Test/MeshTest.cpp index 1994bf894..c4c382a05 100644 --- a/src/Magnum/Test/MeshTest.cpp +++ b/src/Magnum/Test/MeshTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/MultisampleTextureGLTest.cpp b/src/Magnum/Test/MultisampleTextureGLTest.cpp index f83f1ff51..979d9bb61 100644 --- a/src/Magnum/Test/MultisampleTextureGLTest.cpp +++ b/src/Magnum/Test/MultisampleTextureGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -26,6 +26,7 @@ #include #include "Magnum/MultisampleTexture.h" +#include "Magnum/ImageFormat.h" #include "Magnum/TextureFormat.h" #include "Magnum/Math/Vector3.h" #include "Magnum/Test/AbstractOpenGLTester.h" @@ -47,6 +48,9 @@ struct MultisampleTextureGLTest: AbstractOpenGLTester { void bind2D(); void bind2DArray(); + void bindImage2D(); + void bindImage2DArray(); + void storage2D(); void storage2DArray(); @@ -70,6 +74,9 @@ MultisampleTextureGLTest::MultisampleTextureGLTest() { &MultisampleTextureGLTest::bind2D, &MultisampleTextureGLTest::bind2DArray, + &MultisampleTextureGLTest::bindImage2D, + &MultisampleTextureGLTest::bindImage2DArray, + &MultisampleTextureGLTest::storage2D, &MultisampleTextureGLTest::storage2DArray, @@ -82,10 +89,10 @@ MultisampleTextureGLTest::MultisampleTextureGLTest() { void MultisampleTextureGLTest::construct2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -112,10 +119,10 @@ void MultisampleTextureGLTest::construct2DNoCreate() { void MultisampleTextureGLTest::construct2DArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); #endif @@ -142,10 +149,10 @@ void MultisampleTextureGLTest::construct2DArrayNoCreate() { void MultisampleTextureGLTest::wrap2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string{" is not supported."}); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -165,10 +172,10 @@ void MultisampleTextureGLTest::wrap2D() { void MultisampleTextureGLTest::wrap2DArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); #endif @@ -188,10 +195,10 @@ void MultisampleTextureGLTest::wrap2DArray() { void MultisampleTextureGLTest::bind2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -215,10 +222,10 @@ void MultisampleTextureGLTest::bind2D() { void MultisampleTextureGLTest::bind2DArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); #endif @@ -240,12 +247,83 @@ void MultisampleTextureGLTest::bind2DArray() { MAGNUM_VERIFY_NO_ERROR(); } +void MultisampleTextureGLTest::bindImage2D() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + #else + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + MultisampleTexture2D texture; + texture.setStorage(4, TextureFormat::RGBA8, Vector2i{32}) + .bindImage(2, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImage(2); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); + #endif +} + +void MultisampleTextureGLTest::bindImage2DArray() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + #else + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + MultisampleTexture2DArray texture; + texture.setStorage(4, TextureFormat::RGBA8, {32, 32, 4}) + .bindImage(2, 1, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + texture.bindImageLayered(3, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + AbstractTexture::unbindImage(2); + AbstractTexture::unbindImage(3); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); + #endif +} + void MultisampleTextureGLTest::storage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -261,10 +339,10 @@ void MultisampleTextureGLTest::storage2D() { void MultisampleTextureGLTest::storage2DArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); #endif @@ -280,10 +358,10 @@ void MultisampleTextureGLTest::storage2DArray() { void MultisampleTextureGLTest::invalidateImage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -296,10 +374,10 @@ void MultisampleTextureGLTest::invalidateImage2D() { void MultisampleTextureGLTest::invalidateImage2DArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); #endif @@ -312,10 +390,10 @@ void MultisampleTextureGLTest::invalidateImage2DArray() { void MultisampleTextureGLTest::invalidateSubImage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -328,10 +406,10 @@ void MultisampleTextureGLTest::invalidateSubImage2D() { void MultisampleTextureGLTest::invalidateSubImage2DArray() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not supported.")); #endif diff --git a/src/Magnum/Test/PixelStorageGLTest.cpp b/src/Magnum/Test/PixelStorageGLTest.cpp index 01c0e6291..abbb6e699 100644 --- a/src/Magnum/Test/PixelStorageGLTest.cpp +++ b/src/Magnum/Test/PixelStorageGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -102,7 +102,7 @@ namespace { void PixelStorageGLTest::unpack2D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::unpack_subimage::string() + std::string(" is not supported.")); #endif @@ -119,7 +119,10 @@ void PixelStorageGLTest::unpack2D() { MAGNUM_VERIFY_NO_ERROR(); - Image2D actual{PixelFormat::RGB, PixelType::UnsignedByte}; + /* Read into zero-initialized array to avoid comparing random memory in + padding bytes (confirmed on NVidia 355.11, AMD 15.300.1025.0) */ + Image2D actual{PixelFormat::RGB, PixelType::UnsignedByte, {}, + Containers::Array{Containers::ValueInit, sizeof(ActualData)}}; #ifndef MAGNUM_TARGET_GLES texture.image(0, actual); @@ -131,18 +134,13 @@ void PixelStorageGLTest::unpack2D() { MAGNUM_VERIFY_NO_ERROR(); - /* Clear padding in the last row (the driver might leave them untouched, - confirmed on NVidia 355.11) */ - CORRADE_VERIFY(actual.data().size() == Containers::ArrayView{ActualData}.size()); - *(actual.data().end() - 1) = *(actual.data().end() - 2) = 0; - CORRADE_COMPARE_AS(actual.data(), Containers::ArrayView{ActualData}, TestSuite::Compare::Container); } void PixelStorageGLTest::pack2D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::NV::pack_subimage::string() + std::string(" is not supported.")); #endif @@ -217,10 +215,20 @@ void PixelStorageGLTest::unpack3D() { /* Testing mainly image height here, which is not available as pack parameter in ES */ #ifndef MAGNUM_TARGET_GLES - Image3D actual = texture.image(0, {PixelFormat::RGB, PixelType::UnsignedByte}); + /* Read into zero-initialized array to avoid comparing random memory in + padding bytes (confirmed on AMD 15.300.1025.0) */ + Image3D actual{PixelFormat::RGB, PixelType::UnsignedByte, {}, + Containers::Array{Containers::ValueInit, sizeof(ActualData)}}; + + texture.image(0, actual); MAGNUM_VERIFY_NO_ERROR(); + /* Clear padding in the last row (the driver might leave them untouched, + confirmed on NVidia 358.16) */ + CORRADE_VERIFY(actual.data().size() == Containers::ArrayView{ActualData}.size()); + *(actual.data().end() - 1) = *(actual.data().end() - 2) = 0; + CORRADE_COMPARE_AS(actual.data(), Containers::ArrayView{ActualData}, TestSuite::Compare::Container); #endif @@ -280,7 +288,7 @@ namespace { } void PixelStorageGLTest::unpackCompressed2D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); CompressedPixelStorage storage; @@ -307,7 +315,7 @@ void PixelStorageGLTest::unpackCompressed2D() { } void PixelStorageGLTest::packCompressed2D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); CompressedImageView2D actual{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4}, ActualCompressedData}; @@ -388,7 +396,7 @@ namespace { } void PixelStorageGLTest::unpackCompressed3D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); CompressedPixelStorage storage; @@ -416,7 +424,7 @@ void PixelStorageGLTest::unpackCompressed3D() { } void PixelStorageGLTest::packCompressed3D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::compressed_texture_pixel_storage::string() + std::string(" is not supported.")); CompressedImageView3D actual{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 1}, ActualCompressedData}; diff --git a/src/Magnum/Test/PixelStorageTest.cpp b/src/Magnum/Test/PixelStorageTest.cpp index 23ef72650..41f96a356 100644 --- a/src/Magnum/Test/PixelStorageTest.cpp +++ b/src/Magnum/Test/PixelStorageTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -50,7 +50,7 @@ struct PixelStorageTest: TestSuite::Tester { void dataPropertiesCompressedRowLength(); void dataPropertiesCompressedImageHeight(); - void dataSizeCompressed(); + void dataOffsetSizeCompressed(); #endif }; @@ -73,7 +73,7 @@ PixelStorageTest::PixelStorageTest() { &PixelStorageTest::dataPropertiesCompressedRowLength, &PixelStorageTest::dataPropertiesCompressedImageHeight, - &PixelStorageTest::dataSizeCompressed + &PixelStorageTest::dataOffsetSizeCompressed #endif }); } @@ -207,11 +207,11 @@ void PixelStorageTest::dataPropertiesCompressedImageHeight() { (std::tuple{(2 + 2 + 9)*16, {1, 3, 3}, 16})); } -void PixelStorageTest::dataSizeCompressed() { - /* Tf the storage doesn't contain any info about block sizes (the default, +void PixelStorageTest::dataOffsetSizeCompressed() { + /* Tf the storage doesn't contain any info about block sizes (the default), using the provided value */ - CORRADE_COMPARE(Implementation::compressedImageDataSizeFor(CompressedImage3D{}, - Vector2i{37, 35}, 1579), 1579); + CORRADE_COMPARE(Implementation::compressedImageDataOffsetSizeFor(CompressedImage3D{}, + Vector2i{37, 35}, 1579), (std::pair{0, 1579})); /* The same parameters as in PixelStorageGLTest 3D case */ const CompressedImage3D image{CompressedPixelStorage{} @@ -220,8 +220,8 @@ void PixelStorageTest::dataSizeCompressed() { .setRowLength(8) .setImageHeight(8) .setSkip({4, 4, 4})}; - CORRADE_COMPARE(Implementation::compressedImageDataSizeFor(image, Vector3i{4, 4, 1}, 1579), - 16*4*4 + 16*4); + CORRADE_COMPARE(Implementation::compressedImageDataOffsetSizeFor(image, Vector3i{4, 4, 1}, 1579), + (std::pair{16*4*4 + 16*2 + 16, 16})); } #endif diff --git a/src/Magnum/Test/PrimitiveQueryGLTest.cpp b/src/Magnum/Test/PrimitiveQueryGLTest.cpp index 4cc974246..3c63d9527 100644 --- a/src/Magnum/Test/PrimitiveQueryGLTest.cpp +++ b/src/Magnum/Test/PrimitiveQueryGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -28,8 +28,11 @@ #include "Magnum/AbstractShaderProgram.h" #include "Magnum/Buffer.h" +#include "Magnum/Framebuffer.h" #include "Magnum/Mesh.h" #include "Magnum/PrimitiveQuery.h" +#include "Magnum/Renderbuffer.h" +#include "Magnum/RenderbufferFormat.h" #include "Magnum/Shader.h" #include "Magnum/TransformFeedback.h" #include "Magnum/Math/Vector2.h" @@ -72,7 +75,7 @@ void PrimitiveQueryGLTest::constructNoCreate() { void PrimitiveQueryGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not available.")); #endif @@ -92,20 +95,33 @@ void PrimitiveQueryGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES void PrimitiveQueryGLTest::primitivesGenerated() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::transform_feedback::string() + std::string(" is not available.")); + /* Bind some FB to avoid errors on contexts w/o default FB */ + Renderbuffer color; + color.setStorage(RenderbufferFormat::RGBA8, Vector2i{32}); + Framebuffer fb{{{}, Vector2i{32}}}; + fb.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color) + .bind(); + struct MyShader: AbstractShaderProgram { typedef Attribute<0, Vector2> Position; explicit MyShader() { - Shader vert(Version::GL210, Shader::Type::Vertex); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); CORRADE_INTERNAL_ASSERT_OUTPUT(vert.addSource( - "#if !defined(GL_ES) && __VERSION__ == 120\n" - "#define lowp\n" + "#if __VERSION__ >= 130\n" + "#define attribute in\n" "#endif\n" - "attribute lowp vec4 position;\n" + "attribute vec4 position;\n" "void main() {\n" " gl_Position = position;\n" "}\n").compile()); @@ -146,14 +162,27 @@ void PrimitiveQueryGLTest::primitivesGenerated() { void PrimitiveQueryGLTest::transformFeedbackPrimitivesWritten() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not available.")); #endif + /* Bind some FB to avoid errors on contexts w/o default FB */ + Renderbuffer color; + color.setStorage(RenderbufferFormat::RGBA8, Vector2i{32}); + Framebuffer fb{{{}, Vector2i{32}}}; + fb.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color) + .bind(); + struct MyShader: AbstractShaderProgram { explicit MyShader() { #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL300, Shader::Type::Vertex); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL300 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); #else Shader vert(Version::GLES300, Shader::Type::Vertex); Shader frag(Version::GLES300, Shader::Type::Fragment); diff --git a/src/Magnum/Test/RectangleTextureGLTest.cpp b/src/Magnum/Test/RectangleTextureGLTest.cpp index e6ea19b7a..8e0d4cfc9 100644 --- a/src/Magnum/Test/RectangleTextureGLTest.cpp +++ b/src/Magnum/Test/RectangleTextureGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -29,6 +29,7 @@ #include "Magnum/configure.h" #include "Magnum/BufferImage.h" #include "Magnum/Image.h" +#include "Magnum/ImageFormat.h" #include "Magnum/PixelFormat.h" #include "Magnum/RectangleTexture.h" #include "Magnum/TextureFormat.h" @@ -46,6 +47,7 @@ struct RectangleTextureGLTest: AbstractOpenGLTester { void wrap(); void bind(); + void bindImage(); void sampling(); void samplingSRGBDecode(); @@ -64,7 +66,9 @@ struct RectangleTextureGLTest: AbstractOpenGLTester { void subImageBuffer(); void compressedSubImageBuffer(); void subImageQuery(); + void compressedSubImageQuery(); void subImageQueryBuffer(); + void compressedSubImageQueryBuffer(); void invalidateImage(); void invalidateSubImage(); @@ -76,6 +80,7 @@ RectangleTextureGLTest::RectangleTextureGLTest() { &RectangleTextureGLTest::wrap, &RectangleTextureGLTest::bind, + &RectangleTextureGLTest::bindImage, &RectangleTextureGLTest::sampling, &RectangleTextureGLTest::samplingSRGBDecode, @@ -95,7 +100,9 @@ RectangleTextureGLTest::RectangleTextureGLTest() { &RectangleTextureGLTest::subImageBuffer, &RectangleTextureGLTest::compressedSubImageBuffer, &RectangleTextureGLTest::subImageQuery, + &RectangleTextureGLTest::compressedSubImageQuery, &RectangleTextureGLTest::subImageQueryBuffer, + &RectangleTextureGLTest::compressedSubImageQueryBuffer, &RectangleTextureGLTest::invalidateImage, &RectangleTextureGLTest::invalidateSubImage}); @@ -109,7 +116,7 @@ namespace { } void RectangleTextureGLTest::construct() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); { @@ -134,7 +141,7 @@ void RectangleTextureGLTest::constructNoCreate() { } void RectangleTextureGLTest::wrap() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); GLuint id; @@ -152,7 +159,7 @@ void RectangleTextureGLTest::wrap() { } void RectangleTextureGLTest::bind() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -173,8 +180,33 @@ void RectangleTextureGLTest::bind() { MAGNUM_VERIFY_NO_ERROR(); } +void RectangleTextureGLTest::bindImage() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + + RectangleTexture texture; + texture.setStorage(TextureFormat::RGBA8, Vector2i{32}) + .bindImage(2, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImage(2); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); +} + void RectangleTextureGLTest::sampling() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -190,9 +222,9 @@ void RectangleTextureGLTest::sampling() { } void RectangleTextureGLTest::samplingSRGBDecode() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -202,9 +234,9 @@ void RectangleTextureGLTest::samplingSRGBDecode() { } void RectangleTextureGLTest::samplingBorderInteger() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); RectangleTexture a; @@ -218,9 +250,9 @@ void RectangleTextureGLTest::samplingBorderInteger() { } void RectangleTextureGLTest::samplingSwizzle() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -230,9 +262,9 @@ void RectangleTextureGLTest::samplingSwizzle() { } void RectangleTextureGLTest::samplingDepthStencilMode() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -242,7 +274,7 @@ void RectangleTextureGLTest::samplingDepthStencilMode() { } void RectangleTextureGLTest::storage() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -266,7 +298,7 @@ namespace { } void RectangleTextureGLTest::image() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -290,7 +322,7 @@ void RectangleTextureGLTest::compressedImage() { } void RectangleTextureGLTest::imageBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -325,7 +357,7 @@ namespace { } void RectangleTextureGLTest::subImage() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -351,7 +383,7 @@ void RectangleTextureGLTest::compressedSubImage() { } void RectangleTextureGLTest::subImageBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -376,9 +408,9 @@ void RectangleTextureGLTest::compressedSubImageBuffer() { } void RectangleTextureGLTest::subImageQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -398,10 +430,14 @@ void RectangleTextureGLTest::subImageQuery() { Containers::ArrayView{Data}, TestSuite::Compare::Container); } +void RectangleTextureGLTest::compressedSubImageQuery() { + CORRADE_SKIP("No rectangle texture compression format exists."); +} + void RectangleTextureGLTest::subImageQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -421,8 +457,12 @@ void RectangleTextureGLTest::subImageQueryBuffer() { Containers::ArrayView{Data}, TestSuite::Compare::Container); } +void RectangleTextureGLTest::compressedSubImageQueryBuffer() { + CORRADE_SKIP("No rectangle texture compression format exists."); +} + void RectangleTextureGLTest::invalidateImage() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; @@ -433,7 +473,7 @@ void RectangleTextureGLTest::invalidateImage() { } void RectangleTextureGLTest::invalidateSubImage() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported.")); RectangleTexture texture; diff --git a/src/Magnum/Test/RenderbufferGLTest.cpp b/src/Magnum/Test/RenderbufferGLTest.cpp index b591879c7..ad6fd4afd 100644 --- a/src/Magnum/Test/RenderbufferGLTest.cpp +++ b/src/Magnum/Test/RenderbufferGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -62,7 +62,7 @@ RenderbufferGLTest::RenderbufferGLTest() { void RenderbufferGLTest::construct() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -94,7 +94,7 @@ void RenderbufferGLTest::constructCopy() { void RenderbufferGLTest::constructMove() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -121,7 +121,7 @@ void RenderbufferGLTest::constructMove() { void RenderbufferGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -141,11 +141,11 @@ void RenderbufferGLTest::wrap() { void RenderbufferGLTest::label() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); Renderbuffer renderbuffer; @@ -161,7 +161,7 @@ void RenderbufferGLTest::label() { void RenderbufferGLTest::setStorage() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #endif @@ -178,11 +178,11 @@ void RenderbufferGLTest::setStorage() { void RenderbufferGLTest::setStorageMultisample() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available."); #endif diff --git a/src/Magnum/Test/RendererTest.cpp b/src/Magnum/Test/RendererTest.cpp index 12e071232..5aaa689c5 100644 --- a/src/Magnum/Test/RendererTest.cpp +++ b/src/Magnum/Test/RendererTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/ResourceManagerLocalInstanceTest.cpp b/src/Magnum/Test/ResourceManagerLocalInstanceTest.cpp index 8efa7f191..61a372177 100644 --- a/src/Magnum/Test/ResourceManagerLocalInstanceTest.cpp +++ b/src/Magnum/Test/ResourceManagerLocalInstanceTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/ResourceManagerLocalInstanceTestLib.cpp b/src/Magnum/Test/ResourceManagerLocalInstanceTestLib.cpp index 08b85ce1b..bdc3db3cb 100644 --- a/src/Magnum/Test/ResourceManagerLocalInstanceTestLib.cpp +++ b/src/Magnum/Test/ResourceManagerLocalInstanceTestLib.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/ResourceManagerLocalInstanceTestLib.h b/src/Magnum/Test/ResourceManagerLocalInstanceTestLib.h index 8b13a6a38..b1595c175 100644 --- a/src/Magnum/Test/ResourceManagerLocalInstanceTestLib.h +++ b/src/Magnum/Test/ResourceManagerLocalInstanceTestLib.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/ResourceManagerTest.cpp b/src/Magnum/Test/ResourceManagerTest.cpp index 2585eb35a..d746901cf 100644 --- a/src/Magnum/Test/ResourceManagerTest.cpp +++ b/src/Magnum/Test/ResourceManagerTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -126,7 +126,7 @@ void ResourceManagerTest::stateDisallowed() { ResourceManager rm; std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; rm.set("data", Data(), ResourceDataState::Loading, ResourcePolicy::Resident); CORRADE_COMPARE(out.str(), "ResourceManager::set(): data should be null if and only if state is NotFound or Loading\n"); @@ -156,7 +156,7 @@ void ResourceManagerTest::basic() { /* Cannot change already final resource */ std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; rm.set(answerKey, 43, ResourceDataState::Mutable, ResourcePolicy::Resident); CORRADE_COMPARE(*theAnswer, 42); CORRADE_COMPARE(out.str(), "ResourceManager::set(): cannot change already final resource " + answerKey.hexString() + '\n'); @@ -256,7 +256,7 @@ void ResourceManagerTest::clearWhileReferenced() { /* Should cover also the destruction case */ std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; ResourceManager rm; rm.set("blah", Int()); diff --git a/src/Magnum/Test/SampleQueryGLTest.cpp b/src/Magnum/Test/SampleQueryGLTest.cpp index 55072128f..37bfcab2b 100644 --- a/src/Magnum/Test/SampleQueryGLTest.cpp +++ b/src/Magnum/Test/SampleQueryGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -74,7 +74,7 @@ void SampleQueryGLTest::constructNoCreate() { void SampleQueryGLTest::wrap() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not available.")); #endif @@ -111,8 +111,20 @@ namespace { #ifndef DOXYGEN_GENERATING_OUTPUT MyShader::MyShader() { #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL210, Shader::Type::Vertex); - Shader frag(Version::GL210, Shader::Type::Fragment); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); + Shader frag( + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + , Shader::Type::Fragment); #else Shader vert(Version::GLES200, Shader::Type::Vertex); Shader frag(Version::GLES200, Shader::Type::Fragment); @@ -122,13 +134,21 @@ MyShader::MyShader() { "#if !defined(GL_ES) && __VERSION__ == 120\n" "#define lowp\n" "#endif\n" - "attribute lowp vec4 position;\n" + "#if defined(GL_ES) || __VERSION__ == 120\n" + "#define in attribute\n" + "#endif\n" + "in lowp vec4 position;\n" "void main() {\n" " gl_Position = position;\n" "}\n"); frag.addSource( + "#if !defined(GL_ES) && __VERSION__ >= 130\n" + "out vec4 color;\n" + "#else\n" + "#define color gl_FragColor\n" + "#endif\n" "void main() {\n" - " gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);\n" + " color = vec4(1.0, 1.0, 1.0, 1.0);\n" "}\n"); CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); @@ -141,7 +161,7 @@ MyShader::MyShader() { void SampleQueryGLTest::querySamplesPassed() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not available.")); #endif @@ -168,6 +188,8 @@ void SampleQueryGLTest::querySamplesPassed() { MAGNUM_VERIFY_NO_ERROR(); + framebuffer.bind(); + #ifndef MAGNUM_TARGET_GLES SampleQuery q{SampleQuery::Target::SamplesPassed}; #else @@ -175,7 +197,6 @@ void SampleQueryGLTest::querySamplesPassed() { #endif q.begin(); - framebuffer.bind(); mesh.draw(shader); q.end(); @@ -195,7 +216,7 @@ void SampleQueryGLTest::querySamplesPassed() { #ifndef MAGNUM_TARGET_GLES void SampleQueryGLTest::conditionalRender() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::NV::conditional_render::string() + std::string(" is not available.")); Renderbuffer renderbuffer; diff --git a/src/Magnum/Test/SamplerTest.cpp b/src/Magnum/Test/SamplerTest.cpp index 89b210752..621edffde 100644 --- a/src/Magnum/Test/SamplerTest.cpp +++ b/src/Magnum/Test/SamplerTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/ShaderGLTest.cpp b/src/Magnum/Test/ShaderGLTest.cpp index 8351123f4..be28f5345 100644 --- a/src/Magnum/Test/ShaderGLTest.cpp +++ b/src/Magnum/Test/ShaderGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -137,8 +137,8 @@ void ShaderGLTest::constructMove() { void ShaderGLTest::label() { /* No-Op version is tested in AbstractObjectGLTest */ - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); #ifndef MAGNUM_TARGET_GLES @@ -209,7 +209,13 @@ void ShaderGLTest::addFile() { void ShaderGLTest::compile() { #ifndef MAGNUM_TARGET_GLES - constexpr Version v = Version::GL210; + constexpr Version v = + #ifndef CORRADE_TARGET_APPLE + Version::GL210 + #else + Version::GL310 + #endif + ; #else constexpr Version v = Version::GLES200; #endif diff --git a/src/Magnum/Test/ShaderTest.cpp b/src/Magnum/Test/ShaderTest.cpp index fbe2e845f..6a1f928e1 100644 --- a/src/Magnum/Test/ShaderTest.cpp +++ b/src/Magnum/Test/ShaderTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/TagsTest.cpp b/src/Magnum/Test/TagsTest.cpp index 48f903c84..7d0e543ee 100644 --- a/src/Magnum/Test/TagsTest.cpp +++ b/src/Magnum/Test/TagsTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Test/TextureArrayGLTest.cpp b/src/Magnum/Test/TextureArrayGLTest.cpp index 61d2976fb..131d03d36 100644 --- a/src/Magnum/Test/TextureArrayGLTest.cpp +++ b/src/Magnum/Test/TextureArrayGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -28,6 +28,7 @@ #include "Magnum/configure.h" #include "Magnum/BufferImage.h" #include "Magnum/Image.h" +#include "Magnum/ImageFormat.h" #include "Magnum/PixelFormat.h" #include "Magnum/TextureArray.h" #include "Magnum/TextureFormat.h" @@ -57,6 +58,13 @@ struct TextureArrayGLTest: AbstractOpenGLTester { #endif void bind2D(); + #ifndef MAGNUM_TARGET_WEBGL + #ifndef MAGNUM_TARGET_GLES + void bindImage1D(); + #endif + void bindImage2D(); + #endif + #ifndef MAGNUM_TARGET_GLES void sampling1D(); #endif @@ -117,7 +125,9 @@ struct TextureArrayGLTest: AbstractOpenGLTester { void subImage1DBuffer(); void compressedSubImage1DBuffer(); void subImage1DQuery(); + void compressedSubImage1DQuery(); void subImage1DQueryBuffer(); + void compressedSubImage1DQueryBuffer(); #endif void subImage2D(); void compressedSubImage2D(); @@ -125,7 +135,9 @@ struct TextureArrayGLTest: AbstractOpenGLTester { void compressedSubImage2DBuffer(); #ifndef MAGNUM_TARGET_GLES void subImage2DQuery(); + void compressedSubImage2DQuery(); void subImage2DQueryBuffer(); + void compressedSubImage2DQueryBuffer(); #endif #ifndef MAGNUM_TARGET_GLES @@ -168,6 +180,13 @@ TextureArrayGLTest::TextureArrayGLTest() { #endif &TextureArrayGLTest::bind2D, + #ifndef MAGNUM_TARGET_WEBGL + #ifndef MAGNUM_TARGET_GLES + &TextureArrayGLTest::bindImage1D, + #endif + &TextureArrayGLTest::bindImage2D, + #endif + #ifndef MAGNUM_TARGET_GLES &TextureArrayGLTest::sampling1D, #endif @@ -225,7 +244,9 @@ TextureArrayGLTest::TextureArrayGLTest() { &TextureArrayGLTest::subImage1DBuffer, &TextureArrayGLTest::compressedSubImage1DBuffer, &TextureArrayGLTest::subImage1DQuery, + &TextureArrayGLTest::compressedSubImage1DQuery, &TextureArrayGLTest::subImage1DQueryBuffer, + &TextureArrayGLTest::compressedSubImage1DQueryBuffer, #endif &TextureArrayGLTest::subImage2D, &TextureArrayGLTest::compressedSubImage2D, @@ -233,7 +254,9 @@ TextureArrayGLTest::TextureArrayGLTest() { &TextureArrayGLTest::compressedSubImage2DBuffer, #ifndef MAGNUM_TARGET_GLES &TextureArrayGLTest::subImage2DQuery, + &TextureArrayGLTest::compressedSubImage2DQuery, &TextureArrayGLTest::subImage2DQueryBuffer, + &TextureArrayGLTest::compressedSubImage2DQueryBuffer, #endif #ifndef MAGNUM_TARGET_GLES @@ -253,7 +276,7 @@ TextureArrayGLTest::TextureArrayGLTest() { }); #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) { _compressedDataStorage2D = CompressedPixelStorage{} .setCompressedBlockSize({4, 4, 1}) @@ -279,7 +302,7 @@ namespace { #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::construct1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); { @@ -306,7 +329,7 @@ void TextureArrayGLTest::construct1DNoCreate() { void TextureArrayGLTest::construct2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -350,7 +373,7 @@ void TextureArrayGLTest::wrap1D() { void TextureArrayGLTest::wrap2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -370,7 +393,7 @@ void TextureArrayGLTest::wrap2D() { #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::bind1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -394,7 +417,7 @@ void TextureArrayGLTest::bind1D() { void TextureArrayGLTest::bind2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -416,9 +439,72 @@ void TextureArrayGLTest::bind2D() { MAGNUM_VERIFY_NO_ERROR(); } +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +#ifndef MAGNUM_TARGET_GLES +void TextureArrayGLTest::bindImage1D() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + + Texture1DArray texture; + texture.setStorage(1, TextureFormat::RGBA8, {32, 4}) + .bindImage(2, 0, 1, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + texture.bindImageLayered(3, 0, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + AbstractTexture::unbindImage(2); + AbstractTexture::unbindImage(3); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); +} +#endif + +void TextureArrayGLTest::bindImage2D() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + #else + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + Texture2DArray texture; + texture.setStorage(1, TextureFormat::RGBA8, {32, 32, 4}) + .bindImage(2, 0, 1, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + texture.bindImageLayered(3, 0, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + AbstractTexture::unbindImage(2); + AbstractTexture::unbindImage(3); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); + #endif +} +#endif + #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::sampling1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -439,9 +525,9 @@ void TextureArrayGLTest::sampling1D() { } void TextureArrayGLTest::samplingSRGBDecode1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -451,9 +537,9 @@ void TextureArrayGLTest::samplingSRGBDecode1D() { } void TextureArrayGLTest::samplingSwizzle1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -463,9 +549,9 @@ void TextureArrayGLTest::samplingSwizzle1D() { } void TextureArrayGLTest::samplingBorderInteger1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); Texture1DArray a; @@ -479,9 +565,9 @@ void TextureArrayGLTest::samplingBorderInteger1D() { } void TextureArrayGLTest::samplingDepthStencilMode1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -493,7 +579,7 @@ void TextureArrayGLTest::samplingDepthStencilMode1D() { void TextureArrayGLTest::sampling2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -527,10 +613,10 @@ void TextureArrayGLTest::sampling2D() { void TextureArrayGLTest::samplingSRGBDecode2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); Texture2DArray texture; @@ -542,9 +628,9 @@ void TextureArrayGLTest::samplingSRGBDecode2D() { #ifndef MAGNUM_TARGET_GLES2 void TextureArrayGLTest::samplingSwizzle2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); #endif @@ -555,7 +641,7 @@ void TextureArrayGLTest::samplingSwizzle2D() { } #else void TextureArrayGLTest::samplingMaxLevel2D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported.")); Texture2DArray texture; @@ -565,8 +651,8 @@ void TextureArrayGLTest::samplingMaxLevel2D() { } void TextureArrayGLTest::samplingCompare2D() { - if(!Context::current()->isExtensionSupported() || - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() || + !Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::NV::shadow_samplers_array::string() + std::string(" is not supported.")); Texture2DArray texture; @@ -580,12 +666,12 @@ void TextureArrayGLTest::samplingCompare2D() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void TextureArrayGLTest::samplingBorderInteger2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_border_clamp::string() + std::string(" is not supported.")); #endif @@ -603,12 +689,12 @@ void TextureArrayGLTest::samplingBorderInteger2D() { #ifndef MAGNUM_TARGET_GLES2 void TextureArrayGLTest::samplingDepthStencilMode2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -621,8 +707,8 @@ void TextureArrayGLTest::samplingDepthStencilMode2D() { #ifdef MAGNUM_TARGET_GLES void TextureArrayGLTest::samplingBorder2D() { - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("No required extension is supported."); Texture2DArray texture; @@ -635,7 +721,7 @@ void TextureArrayGLTest::samplingBorder2D() { #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::storage1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -656,7 +742,7 @@ void TextureArrayGLTest::storage1D() { void TextureArrayGLTest::storage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -667,7 +753,7 @@ void TextureArrayGLTest::storage2D() { #ifndef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing"); #endif @@ -694,7 +780,7 @@ namespace { #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::image1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -718,7 +804,7 @@ void TextureArrayGLTest::compressedImage1D() { } void TextureArrayGLTest::image1DBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -767,7 +853,7 @@ namespace { void TextureArrayGLTest::image2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -792,14 +878,14 @@ void TextureArrayGLTest::image2D() { void TextureArrayGLTest::compressedImage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif @@ -826,7 +912,7 @@ void TextureArrayGLTest::compressedImage2D() { void TextureArrayGLTest::image2DBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -851,14 +937,14 @@ void TextureArrayGLTest::image2DBuffer() { void TextureArrayGLTest::compressedImage2DBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif @@ -895,7 +981,7 @@ namespace { #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::subImage1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -921,7 +1007,7 @@ void TextureArrayGLTest::compressedSubImage1D() { } void TextureArrayGLTest::subImage1DBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -946,9 +1032,9 @@ void TextureArrayGLTest::compressedSubImage1DBuffer() { } void TextureArrayGLTest::subImage1DQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -967,10 +1053,14 @@ void TextureArrayGLTest::subImage1DQuery() { (Containers::ArrayView{image.data(), image.data().size()}.suffix(DataOffset1D)), Containers::ArrayView{Data1D}, TestSuite::Compare::Container); } +void TextureArrayGLTest::compressedSubImage1DQuery() { + CORRADE_SKIP("No 1D texture compression format exists."); +} + void TextureArrayGLTest::subImage1DQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -989,6 +1079,10 @@ void TextureArrayGLTest::subImage1DQueryBuffer() { CORRADE_COMPARE_AS(imageData.suffix(DataOffset1D), Containers::ArrayView{Data1D}, TestSuite::Compare::Container); } + +void TextureArrayGLTest::compressedSubImage1DQueryBuffer() { + CORRADE_SKIP("No 1D texture compression format exists."); +} #endif namespace { @@ -1053,7 +1147,7 @@ namespace { void TextureArrayGLTest::subImage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -1079,17 +1173,39 @@ void TextureArrayGLTest::subImage2D() { void TextureArrayGLTest::compressedSubImage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif + #ifndef MAGNUM_TARGET_GLES + /* Compressed pixel storage for array textures is underspecified. If the + extension is supported, first test with default values to ensure we are + not that far off, then continue as usual */ + if(Context::current().isExtensionSupported()) { + Texture2DArray texture; + texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, + Vector3i{12, 4, 4}, CompressedZero2D}); + texture.setCompressedSubImage(0, {4, 0, 1}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 2}, CompressedData2D}); + + MAGNUM_VERIFY_NO_ERROR(); + + CompressedImage3D image = texture.compressedImage(0, {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4})); + CORRADE_COMPARE_AS( + Containers::ArrayView(image.data(), image.data().size()), Containers::ArrayView{CompressedSubData2DComplete}, TestSuite::Compare::Container); + } + #endif + Texture2DArray texture; texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{12, 4, 4}, CompressedZero2D}); @@ -1107,14 +1223,20 @@ void TextureArrayGLTest::compressedSubImage2D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4})); - CORRADE_COMPARE_AS( - Containers::ArrayView(image.data(), image.data().size()), Containers::ArrayView{CompressedSubData2DComplete}, TestSuite::Compare::Container); + + { + CORRADE_EXPECT_FAIL_IF(Context::current().isExtensionSupported() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), + "Non-default compressed pixel storage for array textures behaves weirdly on NVidia"); + + CORRADE_COMPARE_AS( + Containers::ArrayView(image.data(), image.data().size()), Containers::ArrayView{CompressedSubData2DComplete}, TestSuite::Compare::Container); + } #endif } void TextureArrayGLTest::subImage2DBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -1140,17 +1262,39 @@ void TextureArrayGLTest::subImage2DBuffer() { void TextureArrayGLTest::compressedSubImage2DBuffer() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif + #ifndef MAGNUM_TARGET_GLES + /* Compressed pixel storage for array textures is underspecified. If the + extension is supported, first test with default values to ensure we are + not that far off, then continue as usual */ + if(Context::current().isExtensionSupported()) { + Texture2DArray texture; + texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, + Vector3i{12, 4, 4}, CompressedZero2D}); + texture.setCompressedSubImage(0, {4, 0, 1}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, {4, 4, 2}, CompressedData2D}); + + MAGNUM_VERIFY_NO_ERROR(); + + CompressedBufferImage3D image = texture.compressedImage(0, {}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4})); + CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedSubData2DComplete}, TestSuite::Compare::Container); + } + #endif + Texture2DArray texture; texture.setCompressedImage(0, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, Vector3i{12, 4, 4}, CompressedZero2D}); @@ -1169,15 +1313,21 @@ void TextureArrayGLTest::compressedSubImage2DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4})); - CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedSubData2DComplete}, TestSuite::Compare::Container); + + { + CORRADE_EXPECT_FAIL_IF(Context::current().isExtensionSupported() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), + "Non-default compressed pixel storage for array textures behaves weirdly on NVidia"); + + CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedSubData2DComplete}, TestSuite::Compare::Container); + } #endif } #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::subImage2DQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture2DArray texture; @@ -1196,10 +1346,48 @@ void TextureArrayGLTest::subImage2DQuery() { (Containers::ArrayView{image.data(), image.data().size()}.suffix(DataOffset2D)), Containers::ArrayView{Data2D}, TestSuite::Compare::Container); } +void TextureArrayGLTest::compressedSubImage2DQuery() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + Texture2DArray texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4, 4}) + .setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, + {12, 4, 4}, CompressedSubData2DComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 1}, {4, 4, 2}), {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2})); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedData2D}, TestSuite::Compare::Container); + } + + CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 1}, {4, 4, 2}), {_compressedDataStorage2D}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2})); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}.suffix(_compressedDataOffset2D)), + Containers::ArrayView{CompressedData2D}, TestSuite::Compare::Container); +} + void TextureArrayGLTest::subImage2DQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture2DArray texture; @@ -1219,10 +1407,40 @@ void TextureArrayGLTest::subImage2DQueryBuffer() { Containers::ArrayView{Data2D}, TestSuite::Compare::Container); } +void TextureArrayGLTest::compressedSubImage2DQueryBuffer() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + Texture2DArray texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4, 4}) + .setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBAS3tcDxt3, + {12, 4, 4}, CompressedSubData2DComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 1}, {4, 4, 2}), { + #ifndef MAGNUM_TARGET_GLES + _compressedDataStorage2D + #endif + }, BufferUsage::StaticRead); + + MAGNUM_VERIFY_NO_ERROR(); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4, 4, 2})); + CORRADE_COMPARE_AS(imageData.suffix(_compressedDataOffset2D), Containers::ArrayView{CompressedData2D}, TestSuite::Compare::Container); +} + void TextureArrayGLTest::generateMipmap1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -1249,9 +1467,9 @@ void TextureArrayGLTest::generateMipmap1D() { void TextureArrayGLTest::generateMipmap2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -1283,7 +1501,7 @@ void TextureArrayGLTest::generateMipmap2D() { #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::invalidateImage1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -1296,7 +1514,7 @@ void TextureArrayGLTest::invalidateImage1D() { void TextureArrayGLTest::invalidateImage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif @@ -1309,7 +1527,7 @@ void TextureArrayGLTest::invalidateImage2D() { #ifndef MAGNUM_TARGET_GLES void TextureArrayGLTest::invalidateSubImage1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); Texture1DArray texture; @@ -1322,7 +1540,7 @@ void TextureArrayGLTest::invalidateSubImage1D() { void TextureArrayGLTest::invalidateSubImage2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not supported.")); #endif diff --git a/src/Magnum/Test/TextureGLTest.cpp b/src/Magnum/Test/TextureGLTest.cpp index a3918c200..de6c3b3a5 100644 --- a/src/Magnum/Test/TextureGLTest.cpp +++ b/src/Magnum/Test/TextureGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -30,6 +30,9 @@ #include "Magnum/BufferImage.h" #endif #include "Magnum/Image.h" +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +#include "Magnum/ImageFormat.h" +#endif #include "Magnum/PixelFormat.h" #include "Magnum/Texture.h" #include "Magnum/TextureFormat.h" @@ -63,6 +66,14 @@ struct TextureGLTest: AbstractOpenGLTester { void bind2D(); void bind3D(); + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + #ifndef MAGNUM_TARGET_GLES + void bindImage1D(); + #endif + void bindImage2D(); + void bindImage3D(); + #endif + #ifndef MAGNUM_TARGET_GLES void sampling1D(); #endif @@ -139,7 +150,9 @@ struct TextureGLTest: AbstractOpenGLTester { void subImage1DBuffer(); void compressedSubImage1DBuffer(); void subImage1DQuery(); + void compressedSubImage1DQuery(); void subImage1DQueryBuffer(); + void compressedSubImage1DQueryBuffer(); #endif void subImage2D(); void compressedSubImage2D(); @@ -149,7 +162,9 @@ struct TextureGLTest: AbstractOpenGLTester { #endif #ifndef MAGNUM_TARGET_GLES void subImage2DQuery(); + void compressedSubImage2DQuery(); void subImage2DQueryBuffer(); + void compressedSubImage2DQueryBuffer(); #endif void subImage3D(); void compressedSubImage3D(); @@ -159,7 +174,9 @@ struct TextureGLTest: AbstractOpenGLTester { #endif #ifndef MAGNUM_TARGET_GLES void subImage3DQuery(); + void compressedSubImage3DQuery(); void subImage3DQueryBuffer(); + void compressedSubImage3DQueryBuffer(); #endif #ifndef MAGNUM_TARGET_GLES @@ -212,6 +229,14 @@ TextureGLTest::TextureGLTest() { &TextureGLTest::bind2D, &TextureGLTest::bind3D, + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + #ifndef MAGNUM_TARGET_GLES + &TextureGLTest::bindImage1D, + #endif + &TextureGLTest::bindImage2D, + &TextureGLTest::bindImage3D, + #endif + #ifndef MAGNUM_TARGET_GLES &TextureGLTest::sampling1D, #endif @@ -286,7 +311,9 @@ TextureGLTest::TextureGLTest() { &TextureGLTest::subImage1DBuffer, &TextureGLTest::compressedSubImage1DBuffer, &TextureGLTest::subImage1DQuery, + &TextureGLTest::compressedSubImage1DQuery, &TextureGLTest::subImage1DQueryBuffer, + &TextureGLTest::compressedSubImage1DQueryBuffer, #endif &TextureGLTest::subImage2D, &TextureGLTest::compressedSubImage2D, @@ -296,7 +323,9 @@ TextureGLTest::TextureGLTest() { #endif #ifndef MAGNUM_TARGET_GLES &TextureGLTest::subImage2DQuery, + &TextureGLTest::compressedSubImage2DQuery, &TextureGLTest::subImage2DQueryBuffer, + &TextureGLTest::compressedSubImage2DQueryBuffer, #endif &TextureGLTest::subImage3D, &TextureGLTest::compressedSubImage3D, @@ -306,7 +335,9 @@ TextureGLTest::TextureGLTest() { #endif #ifndef MAGNUM_TARGET_GLES &TextureGLTest::subImage3DQuery, + &TextureGLTest::compressedSubImage3DQuery, &TextureGLTest::subImage3DQueryBuffer, + &TextureGLTest::compressedSubImage3DQueryBuffer, #endif #ifndef MAGNUM_TARGET_GLES @@ -334,7 +365,7 @@ TextureGLTest::TextureGLTest() { _dataOffset3D = 16; #ifdef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #endif { _dataStorage2D = _dataStorage3D = {}; @@ -343,7 +374,7 @@ TextureGLTest::TextureGLTest() { #endif #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) { _compressedDataStorage2D = CompressedPixelStorage{} .setCompressedBlockSize({4, 4, 1}) @@ -420,7 +451,7 @@ void TextureGLTest::construct2DNoCreate() { void TextureGLTest::construct3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -479,7 +510,7 @@ void TextureGLTest::wrap2D() { void TextureGLTest::wrap3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -539,7 +570,7 @@ void TextureGLTest::bind2D() { void TextureGLTest::bind3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -561,6 +592,96 @@ void TextureGLTest::bind3D() { MAGNUM_VERIFY_NO_ERROR(); } +#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) +#ifndef MAGNUM_TARGET_GLES +void TextureGLTest::bindImage1D() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + + Texture1D texture; + texture.setStorage(1, TextureFormat::RGBA8, 32) + .bindImage(2, 0, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImage(2); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); +} +#endif + +void TextureGLTest::bindImage2D() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + #else + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + Texture2D texture; + texture.setStorage(1, TextureFormat::RGBA8, Vector2i{32}) + .bindImage(2, 0, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImage(2); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); + #endif +} + +void TextureGLTest::bindImage3D() { + #ifndef MAGNUM_TARGET_GLES + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported.")); + #else + if(!Context::current().isVersionSupported(Version::GLES310)) + CORRADE_SKIP("OpenGL ES 3.1 is not supported."); + #endif + + Texture3D texture; + texture.setStorage(1, TextureFormat::RGBA8, {32, 32, 4}) + .bindImage(2, 0, 1, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + MAGNUM_VERIFY_NO_ERROR(); + + texture.bindImageLayered(3, 0, ImageAccess::ReadWrite, ImageFormat::RGBA8); + + AbstractTexture::unbindImage(2); + AbstractTexture::unbindImage(3); + + MAGNUM_VERIFY_NO_ERROR(); + + #ifndef MAGNUM_TARGET_GLES + AbstractTexture::bindImages(1, {&texture, nullptr, &texture}); + + MAGNUM_VERIFY_NO_ERROR(); + + AbstractTexture::unbindImages(1, 3); + + MAGNUM_VERIFY_NO_ERROR(); + #endif +} +#endif + #ifndef MAGNUM_TARGET_GLES void TextureGLTest::sampling1D() { Texture1D texture; @@ -581,7 +702,7 @@ void TextureGLTest::sampling1D() { } void TextureGLTest::samplingSRGBDecode1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); Texture1D texture; @@ -591,7 +712,7 @@ void TextureGLTest::samplingSRGBDecode1D() { } void TextureGLTest::samplingSwizzle1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); Texture1D texture; @@ -601,7 +722,7 @@ void TextureGLTest::samplingSwizzle1D() { } void TextureGLTest::samplingBorderInteger1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); Texture1D a; @@ -615,7 +736,7 @@ void TextureGLTest::samplingBorderInteger1D() { } void TextureGLTest::samplingDepthStencilMode1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); Texture1D texture; @@ -653,10 +774,10 @@ void TextureGLTest::sampling2D() { void TextureGLTest::samplingSRGBDecode2D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::sRGB::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); Texture2D texture; @@ -668,7 +789,7 @@ void TextureGLTest::samplingSRGBDecode2D() { #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::samplingSwizzle2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); #endif @@ -679,7 +800,7 @@ void TextureGLTest::samplingSwizzle2D() { } #else void TextureGLTest::samplingMaxLevel2D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported.")); Texture2D texture; @@ -689,7 +810,7 @@ void TextureGLTest::samplingMaxLevel2D() { } void TextureGLTest::samplingCompare2D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::shadow_samplers::string() + std::string(" is not supported.")); Texture2D texture; @@ -703,10 +824,10 @@ void TextureGLTest::samplingCompare2D() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void TextureGLTest::samplingBorderInteger2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_border_clamp::string() + std::string(" is not supported.")); #endif @@ -724,10 +845,10 @@ void TextureGLTest::samplingBorderInteger2D() { #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::samplingDepthStencilMode2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -740,8 +861,8 @@ void TextureGLTest::samplingDepthStencilMode2D() { #ifdef MAGNUM_TARGET_GLES void TextureGLTest::samplingBorder2D() { - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("No required extension is supported."); Texture2D texture; @@ -754,7 +875,7 @@ void TextureGLTest::samplingBorder2D() { void TextureGLTest::sampling3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -783,12 +904,12 @@ void TextureGLTest::sampling3D() { void TextureGLTest::samplingSRGBDecode3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::sRGB::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported.")); Texture3D texture; @@ -800,7 +921,7 @@ void TextureGLTest::samplingSRGBDecode3D() { #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::samplingSwizzle3D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported.")); #endif @@ -811,9 +932,9 @@ void TextureGLTest::samplingSwizzle3D() { } #else void TextureGLTest::samplingMaxLevel3D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::APPLE::texture_max_level::string() + std::string(" is not supported.")); Texture3D texture; @@ -826,10 +947,10 @@ void TextureGLTest::samplingMaxLevel3D() { #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) void TextureGLTest::samplingBorderInteger3D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_border_clamp::string() + std::string(" is not supported.")); #endif @@ -847,10 +968,10 @@ void TextureGLTest::samplingBorderInteger3D() { #ifndef MAGNUM_TARGET_GLES2 void TextureGLTest::samplingDepthStencilMode3D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported.")); #else - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 is not supported."); #endif @@ -864,12 +985,12 @@ void TextureGLTest::samplingDepthStencilMode3D() { #ifdef MAGNUM_TARGET_GLES void TextureGLTest::samplingBorder3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("No required extension is supported."); Texture3D texture; @@ -906,7 +1027,7 @@ void TextureGLTest::storage2D() { #ifndef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing."); #endif @@ -923,7 +1044,7 @@ void TextureGLTest::storage2D() { void TextureGLTest::storage3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -934,7 +1055,7 @@ void TextureGLTest::storage3D() { #ifndef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GLES310)) + if(!Context::current().isVersionSupported(Version::GLES310)) CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing."); #endif @@ -1037,10 +1158,10 @@ void TextureGLTest::image2D() { void TextureGLTest::compressedImage2D() { #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif @@ -1090,10 +1211,10 @@ void TextureGLTest::image2DBuffer() { void TextureGLTest::compressedImage2DBuffer() { #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif @@ -1146,7 +1267,7 @@ namespace { void TextureGLTest::image3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -1174,7 +1295,7 @@ void TextureGLTest::compressedImage3D() { /** @todo ASTC HDR, when available on any ES driver */ CORRADE_SKIP("No 3D texture compression format available on OpenGL ES."); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_compression_bptc::string() + std::string(" is not supported.")); Texture3D texture; @@ -1221,7 +1342,7 @@ void TextureGLTest::compressedImage3DBuffer() { /** @todo ASTC HDR, when available on any ES driver */ CORRADE_SKIP("No 3D texture compression format available on OpenGL ES."); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_compression_bptc::string() + std::string(" is not supported.")); Texture3D texture; @@ -1297,7 +1418,7 @@ void TextureGLTest::compressedSubImage1DBuffer() { } void TextureGLTest::subImage1DQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture1D texture; @@ -1316,8 +1437,12 @@ void TextureGLTest::subImage1DQuery() { (Containers::ArrayView{image.data(), image.data().size()}.suffix(DataOffset1D)), Containers::ArrayView{Data1D}, TestSuite::Compare::Container); } +void TextureGLTest::compressedSubImage1DQuery() { + CORRADE_SKIP("No 1D texture compression format exists."); +} + void TextureGLTest::subImage1DQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture1D texture; @@ -1336,6 +1461,10 @@ void TextureGLTest::subImage1DQueryBuffer() { CORRADE_COMPARE_AS(imageData.suffix(DataOffset1D), Containers::ArrayView{Data1D}, TestSuite::Compare::Container); } + +void TextureGLTest::compressedSubImage1DQueryBuffer() { + CORRADE_SKIP("No 1D texture compression format exists."); +} #endif namespace { @@ -1386,10 +1515,10 @@ void TextureGLTest::subImage2D() { void TextureGLTest::compressedSubImage2D() { #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif @@ -1440,10 +1569,10 @@ void TextureGLTest::subImage2DBuffer() { void TextureGLTest::compressedSubImage2DBuffer() { #ifndef MAGNUM_TARGET_WEBGL - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::WEBGL::compressed_texture_s3tc::string() + std::string(" is not supported.")); #endif @@ -1472,7 +1601,7 @@ void TextureGLTest::compressedSubImage2DBuffer() { #ifndef MAGNUM_TARGET_GLES void TextureGLTest::subImage2DQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture2D texture; @@ -1491,8 +1620,43 @@ void TextureGLTest::subImage2DQuery() { (Containers::ArrayView{image.data(), image.data().size()}.suffix(_dataOffset2D)), Containers::ArrayView{Data2D}, TestSuite::Compare::Container); } +void TextureGLTest::compressedSubImage2DQuery() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + Texture2D texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4}) + .setCompressedSubImage(0, {}, CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 4}, CompressedSubData2DComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedImage2D image = texture.compressedSubImage(0, Range2Di::fromSize({4, 0}, Vector2i{4}), {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector2i{4}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedData2D}, TestSuite::Compare::Container); + } + + CompressedImage2D image = texture.compressedSubImage(0, Range2Di::fromSize({4, 0}, Vector2i{4}), {_compressedDataStorage2D}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector2i{4}); + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}.suffix(_compressedDataOffset2D)), + Containers::ArrayView{CompressedData2D}, TestSuite::Compare::Container); +} + void TextureGLTest::subImage2DQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture2D texture; @@ -1511,6 +1675,39 @@ void TextureGLTest::subImage2DQueryBuffer() { CORRADE_COMPARE_AS(imageData.suffix(_dataOffset2D), Containers::ArrayView{Data2D}, TestSuite::Compare::Container); } + +void TextureGLTest::compressedSubImage2DQueryBuffer() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_compression_s3tc::string() + std::string(" is not supported.")); + + Texture2D texture; + texture.setStorage(1, TextureFormat::CompressedRGBAS3tcDxt3, {12, 4}) + .setCompressedSubImage(0, {}, CompressedImageView2D{CompressedPixelFormat::RGBAS3tcDxt3, {12, 4}, CompressedSubData2DComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedBufferImage2D image = texture.compressedSubImage(0, Range2Di::fromSize({4, 0}, Vector2i{4}), {}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector2i{4}); + CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedData2D}, TestSuite::Compare::Container); + } + + CompressedBufferImage2D image = texture.compressedSubImage(0, Range2Di::fromSize({4, 0}, Vector2i{4}), {_compressedDataStorage2D}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector2i{4}); + CORRADE_COMPARE_AS(imageData.suffix(_compressedDataOffset2D), Containers::ArrayView{CompressedData2D}, TestSuite::Compare::Container); +} #endif namespace { @@ -1585,7 +1782,7 @@ namespace { void TextureGLTest::subImage3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -1615,7 +1812,7 @@ void TextureGLTest::compressedSubImage3D() { /** @todo ASTC HDR, when available on any ES driver */ CORRADE_SKIP("No 3D texture compression format available on OpenGL ES."); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_compression_bptc::string() + std::string(" is not supported.")); Texture3D texture; @@ -1631,9 +1828,15 @@ void TextureGLTest::compressedSubImage3D() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4})); - CORRADE_COMPARE_AS( - (Containers::ArrayView{image.data(), image.data().size()}), - Containers::ArrayView{CompressedSubData3DComplete}, TestSuite::Compare::Container); + + { + CORRADE_EXPECT_FAIL_IF(!Context::current().isExtensionSupported() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), + "Default compressed pixel storage behaves weirdly with BPTC compression on NVidia"); + + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedSubData3DComplete}, TestSuite::Compare::Container); + } #endif } @@ -1664,7 +1867,7 @@ void TextureGLTest::compressedSubImage3DBuffer() { /** @todo ASTC HDR, when available on any ES driver */ CORRADE_SKIP("No 3D texture compression format available on OpenGL ES."); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_compression_bptc::string() + std::string(" is not supported.")); Texture3D texture; @@ -1681,14 +1884,20 @@ void TextureGLTest::compressedSubImage3DBuffer() { MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(image.size(), (Vector3i{12, 4, 4})); - CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedSubData3DComplete}, TestSuite::Compare::Container); + + { + CORRADE_EXPECT_FAIL_IF(!Context::current().isExtensionSupported() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), + "Default compressed pixel storage behaves weirdly with BPTC compression on NVidia"); + + CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedSubData3DComplete}, TestSuite::Compare::Container); + } #endif } #endif #ifndef MAGNUM_TARGET_GLES void TextureGLTest::subImage3DQuery() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture3D texture; @@ -1707,8 +1916,53 @@ void TextureGLTest::subImage3DQuery() { (Containers::ArrayView{image.data(), image.data().size()}.suffix(_dataOffset3D)), Containers::ArrayView{Data3D}, TestSuite::Compare::Container); } +void TextureGLTest::compressedSubImage3DQuery() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_compression_bptc::string() + std::string(" is not supported.")); + + Texture3D texture; + texture.setStorage(1, TextureFormat::CompressedRGBABptcUnorm, {12, 4, 4}) + .setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBABptcUnorm, {12, 4, 4}, CompressedSubData3DComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 0}, Vector3i{4}), {}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4})); + + CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & Context::DetectedDriver::NVidia, + "Default compressed pixel storage behaves weirdly with BPTC compression on NVidia"); + + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}), + Containers::ArrayView{CompressedData3D}, TestSuite::Compare::Container); + } + + CompressedImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 0}, Vector3i{4}), {_compressedDataStorage3D}); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), (Vector3i{4})); + + { + CORRADE_EXPECT_FAIL_IF(!Context::current().isExtensionSupported() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), + "Default compressed pixel storage behaves weirdly with BPTC compression on NVidia"); + + CORRADE_COMPARE_AS( + (Containers::ArrayView{image.data(), image.data().size()}.suffix(_compressedDataOffset3D)), + Containers::ArrayView{CompressedData3D}, TestSuite::Compare::Container); + } +} + void TextureGLTest::subImage3DQueryBuffer() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); Texture3D texture; @@ -1728,8 +1982,51 @@ void TextureGLTest::subImage3DQueryBuffer() { Containers::ArrayView{Data3D}, TestSuite::Compare::Container); } +void TextureGLTest::compressedSubImage3DQueryBuffer() { + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported.")); + if(!Context::current().isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_compression_bptc::string() + std::string(" is not supported.")); + + Texture3D texture; + texture.setStorage(1, TextureFormat::CompressedRGBABptcUnorm, {12, 4, 4}) + .setCompressedSubImage(0, {}, CompressedImageView3D{CompressedPixelFormat::RGBABptcUnorm, {12, 4, 4}, CompressedSubData3DComplete}); + + MAGNUM_VERIFY_NO_ERROR(); + + /* Test also without compressed pixel storage to ensure that both size + computations work */ + if(Context::current().isExtensionSupported()) { + CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 0}, Vector3i{4}), {}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector3i{4}); + + CORRADE_EXPECT_FAIL_IF(Context::current().detectedDriver() & Context::DetectedDriver::NVidia, + "Default compressed pixel storage behaves weirdly with BPTC compression on NVidia"); + + CORRADE_COMPARE_AS(imageData, Containers::ArrayView{CompressedData3D}, TestSuite::Compare::Container); + } + + CompressedBufferImage3D image = texture.compressedSubImage(0, Range3Di::fromSize({4, 0, 0}, Vector3i{4}), {_compressedDataStorage3D}, BufferUsage::StaticRead); + const auto imageData = image.buffer().data(); + + MAGNUM_VERIFY_NO_ERROR(); + + CORRADE_COMPARE(image.size(), Vector3i{4}); + + { + CORRADE_EXPECT_FAIL_IF(!Context::current().isExtensionSupported() && (Context::current().detectedDriver() & Context::DetectedDriver::NVidia), + "Default compressed pixel storage behaves weirdly with BPTC compression on NVidia"); + + CORRADE_COMPARE_AS(imageData.suffix(_compressedDataOffset3D), Containers::ArrayView{CompressedData3D}, TestSuite::Compare::Container); + } +} + void TextureGLTest::generateMipmap1D() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not supported.")); Texture1D texture; @@ -1756,7 +2053,7 @@ void TextureGLTest::generateMipmap1D() { void TextureGLTest::generateMipmap2D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not supported.")); #endif @@ -1789,10 +2086,10 @@ void TextureGLTest::generateMipmap2D() { void TextureGLTest::generateMipmap3D() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not supported.")); #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -1843,7 +2140,7 @@ void TextureGLTest::invalidateImage2D() { void TextureGLTest::invalidateImage3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif @@ -1874,7 +2171,7 @@ void TextureGLTest::invalidateSubImage2D() { void TextureGLTest::invalidateSubImage3D() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not supported.")); #endif diff --git a/src/Magnum/Test/TimeQueryGLTest.cpp b/src/Magnum/Test/TimeQueryGLTest.cpp index f14ea888a..4860ccc16 100644 --- a/src/Magnum/Test/TimeQueryGLTest.cpp +++ b/src/Magnum/Test/TimeQueryGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -59,10 +59,10 @@ void TimeQueryGLTest::constructNoCreate() { void TimeQueryGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::timer_query::string() + std::string(" is not available")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::disjoint_timer_query::string() + std::string(" is not available")); #endif @@ -90,10 +90,10 @@ void TimeQueryGLTest::wrap() { void TimeQueryGLTest::queryTime() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::timer_query::string() + std::string(" is not available")); #else - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::disjoint_timer_query::string() + std::string(" is not available")); #endif @@ -117,7 +117,7 @@ void TimeQueryGLTest::queryTime() { void TimeQueryGLTest::queryTimestamp() { #ifdef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::EXT::disjoint_timer_query::string() + std::string(" is not available")); #endif diff --git a/src/Magnum/Test/TransformFeedbackGLTest.cpp b/src/Magnum/Test/TransformFeedbackGLTest.cpp index 9c41bdd04..396ef680e 100644 --- a/src/Magnum/Test/TransformFeedbackGLTest.cpp +++ b/src/Magnum/Test/TransformFeedbackGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -25,7 +25,10 @@ #include "Magnum/AbstractShaderProgram.h" #include "Magnum/Buffer.h" +#include "Magnum/Framebuffer.h" #include "Magnum/Mesh.h" +#include "Magnum/Renderbuffer.h" +#include "Magnum/RenderbufferFormat.h" #include "Magnum/Shader.h" #include "Magnum/TransformFeedback.h" #include "Magnum/Math/Vector2.h" @@ -76,7 +79,7 @@ TransformFeedbackGLTest::TransformFeedbackGLTest() { void TransformFeedbackGLTest::construct() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not supported.")); #endif @@ -108,7 +111,7 @@ void TransformFeedbackGLTest::constructCopy() { void TransformFeedbackGLTest::constructMove() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not supported.")); #endif @@ -135,7 +138,7 @@ void TransformFeedbackGLTest::constructMove() { void TransformFeedbackGLTest::wrap() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not supported.")); #endif @@ -156,11 +159,11 @@ void TransformFeedbackGLTest::wrap() { void TransformFeedbackGLTest::label() { /* No-Op version is tested in AbstractObjectGLTest */ #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not supported.")); #endif - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); TransformFeedback feedback; @@ -189,7 +192,13 @@ struct XfbShader: AbstractShaderProgram { XfbShader::XfbShader() { #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL300, Shader::Type::Vertex); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL300 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); #else Shader vert(Version::GLES300, Shader::Type::Vertex); Shader frag(Version::GLES300, Shader::Type::Fragment); @@ -219,10 +228,17 @@ XfbShader::XfbShader() { void TransformFeedbackGLTest::attachBase() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not supported.")); #endif + /* Bind some FB to avoid errors on contexts w/o default FB */ + Renderbuffer color; + color.setStorage(RenderbufferFormat::RGBA8, Vector2i{32}); + Framebuffer fb{{{}, Vector2i{32}}}; + fb.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color) + .bind(); + XfbShader shader; Buffer input; @@ -255,10 +271,17 @@ void TransformFeedbackGLTest::attachBase() { void TransformFeedbackGLTest::attachRange() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not supported.")); #endif + /* Bind some FB to avoid errors on contexts w/o default FB */ + Renderbuffer color; + color.setStorage(RenderbufferFormat::RGBA8, Vector2i{32}); + Framebuffer fb{{{}, Vector2i{32}}}; + fb.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color) + .bind(); + XfbShader shader; Buffer input; @@ -299,7 +322,13 @@ struct XfbMultiShader: AbstractShaderProgram { XfbMultiShader::XfbMultiShader() { #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL300, Shader::Type::Vertex); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL300 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); #else Shader vert(Version::GLES300, Shader::Type::Vertex); Shader frag(Version::GLES300, Shader::Type::Fragment); @@ -331,10 +360,17 @@ XfbMultiShader::XfbMultiShader() { void TransformFeedbackGLTest::attachBases() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not supported.")); #endif + /* Bind some FB to avoid errors on contexts w/o default FB */ + Renderbuffer color; + color.setStorage(RenderbufferFormat::RGBA8, Vector2i{32}); + Framebuffer fb{{{}, Vector2i{32}}}; + fb.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color) + .bind(); + XfbMultiShader shader; Buffer input; @@ -373,10 +409,17 @@ void TransformFeedbackGLTest::attachBases() { void TransformFeedbackGLTest::attachRanges() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback2::string() + std::string(" is not supported.")); #endif + /* Bind some FB to avoid errors on contexts w/o default FB */ + Renderbuffer color; + color.setStorage(RenderbufferFormat::RGBA8, Vector2i{32}); + Framebuffer fb{{{}, Vector2i{32}}}; + fb.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color) + .bind(); + Buffer input; input.setData(inputData, BufferUsage::StaticDraw); Buffer output1, output2; @@ -419,14 +462,27 @@ void TransformFeedbackGLTest::attachRanges() { #ifndef MAGNUM_TARGET_GLES void TransformFeedbackGLTest::interleaved() { /* ARB_transform_feedback3 needed for gl_SkipComponents1 */ - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::transform_feedback3::string() + std::string(" is not supported.")); + /* Bind some FB to avoid errors on contexts w/o default FB */ + Renderbuffer color; + color.setStorage(RenderbufferFormat::RGBA8, Vector2i{32}); + Framebuffer fb{{{}, Vector2i{32}}}; + fb.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color) + .bind(); + struct XfbInterleavedShader: AbstractShaderProgram { typedef Attribute<0, Vector2> Input; explicit XfbInterleavedShader() { - Shader vert(Version::GL300, Shader::Type::Vertex); + Shader vert( + #ifndef CORRADE_TARGET_APPLE + Version::GL300 + #else + Version::GL310 + #endif + , Shader::Type::Vertex); CORRADE_INTERNAL_ASSERT_OUTPUT(vert.addSource( "in mediump vec2 inputData;\n" "out mediump vec2 output1;\n" diff --git a/src/Magnum/Test/VersionTest.cpp b/src/Magnum/Test/VersionTest.cpp index a27596c67..d439b7b02 100644 --- a/src/Magnum/Test/VersionTest.cpp +++ b/src/Magnum/Test/VersionTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -35,24 +35,41 @@ struct VersionTest: TestSuite::Tester { void fromNumber(); void toNumber(); + #ifndef MAGNUM_TARGET_GLES + void toNumberES(); + #endif + void isES(); void compare(); void debug(); + #ifndef MAGNUM_TARGET_GLES + void debugES(); + #endif }; VersionTest::VersionTest() { addTests({&VersionTest::fromNumber, &VersionTest::toNumber, + #ifndef MAGNUM_TARGET_GLES + &VersionTest::toNumberES, + #endif + &VersionTest::isES, &VersionTest::compare, - &VersionTest::debug}); + &VersionTest::debug, + #ifndef MAGNUM_TARGET_GLES + &VersionTest::debugES + #endif + }); } void VersionTest::fromNumber() { #ifndef MAGNUM_TARGET_GLES - CORRADE_COMPARE(version(4, 3), Version::GL430); + constexpr const Version v = version(4, 3); + CORRADE_COMPARE(v, Version::GL430); #else - CORRADE_COMPARE(version(3, 0), Version::GLES300); + constexpr const Version v = version(3, 0); + CORRADE_COMPARE(v, Version::GLES300); #endif } @@ -64,6 +81,16 @@ void VersionTest::toNumber() { #endif } +#ifndef MAGNUM_TARGET_GLES +void VersionTest::toNumberES() { + CORRADE_COMPARE(version(Version::GLES310), std::make_pair(3, 1)); +} +#endif + +void VersionTest::isES() { + CORRADE_VERIFY(isVersionES(Version::GLES200)); +} + void VersionTest::compare() { #ifndef MAGNUM_TARGET_GLES CORRADE_VERIFY(version(1, 1) < Version::GL210); @@ -88,6 +115,15 @@ void VersionTest::debug() { #endif } +#ifndef MAGNUM_TARGET_GLES +void VersionTest::debugES() { + std::ostringstream out; + + Debug{&out} << Version::GLES310; + CORRADE_COMPARE(out.str(), "OpenGL ES 3.1\n"); +} +#endif + }} CORRADE_TEST_MAIN(Magnum::Test::VersionTest) diff --git a/src/Magnum/Test/configure.h.cmake b/src/Magnum/Test/configure.h.cmake index af1f028a6..96fcde21b 100644 --- a/src/Magnum/Test/configure.h.cmake +++ b/src/Magnum/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index 1eabeeba8..d0cc4fd44 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -45,12 +45,16 @@ bool AbstractFont::openData(const std::vector AbstractFont::doOpenData(const std::vector>>& data, const Float size) { +auto AbstractFont::doOpenData(const std::vector>>& data, const Float size) -> Metrics { CORRADE_ASSERT(!(features() & Feature::MultiFile), "Text::AbstractFont::openData(): feature advertised but not implemented", {}); CORRADE_ASSERT(data.size() == 1, @@ -67,24 +71,32 @@ bool AbstractFont::openSingleData(const Containers::ArrayView data, "Text::AbstractFont::openSingleData(): the format is not single-file", false); close(); - std::tie(_size, _lineHeight) = doOpenSingleData(data, size); - CORRADE_INTERNAL_ASSERT(isOpened() || (_size == 0.0f && _lineHeight == 0.0f)); + const Metrics metrics = doOpenSingleData(data, size); + _size = metrics.size; + _ascent = metrics.ascent; + _descent = metrics.descent; + _lineHeight = metrics.lineHeight; + CORRADE_INTERNAL_ASSERT(isOpened() || (!_size && !_ascent && !_descent && !_lineHeight)); return isOpened(); } -std::pair AbstractFont::doOpenSingleData(Containers::ArrayView, Float) { +auto AbstractFont::doOpenSingleData(Containers::ArrayView, Float) -> Metrics { CORRADE_ASSERT(false, "Text::AbstractFont::openSingleData(): feature advertised but not implemented", {}); return {}; } bool AbstractFont::openFile(const std::string& filename, const Float size) { close(); - std::tie(_size, _lineHeight) = doOpenFile(filename, size); - CORRADE_INTERNAL_ASSERT(isOpened() || (_size == 0.0f && _lineHeight == 0.0f)); + const Metrics metrics = doOpenFile(filename, size); + _size = metrics.size; + _ascent = metrics.ascent; + _descent = metrics.descent; + _lineHeight = metrics.lineHeight; + CORRADE_INTERNAL_ASSERT(isOpened() || (!_size && !_ascent && !_descent && !_lineHeight)); return isOpened(); } -std::pair AbstractFont::doOpenFile(const std::string& filename, const Float size) { +auto AbstractFont::doOpenFile(const std::string& filename, const Float size) -> Metrics { CORRADE_ASSERT(features() & Feature::OpenData && !(features() & Feature::MultiFile), "Text::AbstractFont::openFile(): not implemented", {}); diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index ce9ed573f..3af3f3ddc 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -72,10 +72,10 @@ checked by the implementation: - All `do*()` implementations working on opened file are called only if there is any file opened. -Plugin interface string is `"cz.mosra.magnum.Text.AbstractFont/0.2.3"`. +Plugin interface string is `"cz.mosra.magnum.Text.AbstractFont/0.2.4"`. */ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { - CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Text.AbstractFont/0.2.3") + CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Text.AbstractFont/0.2.4") public: /** @@ -158,16 +158,33 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { /** * @brief Font size * - * Returns scale in which @ref lineHeight() and @ref glyphAdvance() is - * returned. + * Returns scale in which @ref lineHeight(), @ref ascent(), + * @ref descent() and @ref glyphAdvance() is returned. */ Float size() const { return _size; } + /** + * @brief Font ascent + * + * Distance from baseline to top, scaled to font size. Positive value. + * @see @ref size(), @ref descent(), @ref lineHeight() + */ + Float ascent() const { return _ascent; } + + /** + * @brief Font descent + * + * Distance from baseline to bottom, scalled to font size. Negative + * value. + * @see @ref size(), @ref ascent(), @ref lineHeight() + */ + Float descent() const { return _descent; } + /** * @brief Line height * * Returns line height scaled to font size. - * @see @ref size() + * @see @ref size(), @ref ascent(), @ref descent() */ Float lineHeight() const { return _lineHeight; } @@ -225,6 +242,38 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { */ std::unique_ptr layout(const GlyphCache& cache, Float size, const std::string& text); + protected: + /** + * @brief Font metrics + * + * @see @ref doOpenFile(), @ref doOpenData(), @ref doOpenSingleData() + */ + struct Metrics { + /** + * Font size + * @see @ref size() + */ + Float size; + + /** + * Font ascent + * @see @ref ascent() + */ + Float ascent; + + /** + * Font descent + * @see @ref descent() + */ + Float descent; + + /** + * Line height + * @see @ref lineHeight() + */ + Float lineHeight; + }; + #ifdef DOXYGEN_GENERATING_OUTPUT protected: #else @@ -239,29 +288,29 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { /** * @brief Implementation for @ref openData() * - * Return size and line height of opened font on successful opening, - * zeros otherwise. If the plugin doesn't have @ref Feature::MultiFile, + * Return metrics of opened font on successful opening, zeros + * otherwise. If the plugin doesn't have @ref Feature::MultiFile, * default implementation calls @ref doOpenSingleData(). */ - virtual std::pair doOpenData(const std::vector>>& data, Float size); + virtual Metrics doOpenData(const std::vector>>& data, Float size); /** * @brief Implementation for @ref openSingleData() * - * Return size and line height of opened font on successful opening, - * zeros otherwise. + * Return metrics of opened font on successful opening, zeros + * otherwise. */ - virtual std::pair doOpenSingleData(Containers::ArrayView data, Float size); + virtual Metrics doOpenSingleData(Containers::ArrayView data, Float size); /** * @brief Implementation for @ref openFile() * - * Return size and line height of opened font on successful opening, - * zeros otherwise. If @ref Feature::OpenData is supported and the - * plugin doesn't have @ref Feature::MultiFile, default implementation - * opens the file and calls @ref doOpenSingleData() with its contents. + * Return metrics of opened font on successful opening, zeros + * otherwise. If @ref Feature::OpenData is supported and the plugin + * doesn't have @ref Feature::MultiFile, default implementation opens + * the file and calls @ref doOpenSingleData() with its contents. */ - virtual std::pair doOpenFile(const std::string& filename, Float size); + virtual Metrics doOpenFile(const std::string& filename, Float size); /** @brief Implementation for @ref close() */ virtual void doClose() = 0; @@ -289,7 +338,7 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { #ifdef DOXYGEN_GENERATING_OUTPUT private: #endif - Float _size, _lineHeight; + Float _size, _ascent, _descent, _lineHeight; }; CORRADE_ENUMSET_OPERATORS(AbstractFont::Features) diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index b744bd8eb..f47462665 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index f9e715916..22c4c264c 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -68,10 +68,10 @@ checked by the implementation: - Function `doImport*FromData()` is called only if there is at least one data array passed. -Plugin interface string is `"cz.mosra.magnum.Text.AbstractFontConverter/0.1.1"`. +Plugin interface string is `"cz.mosra.magnum.Text.AbstractFontConverter/0.1.2"`. */ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPlugin { - CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Text.AbstractFontConverter/0.1.1") + CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Text.AbstractFontConverter/0.1.2") public: /** diff --git a/src/Magnum/Text/Alignment.h b/src/Magnum/Text/Alignment.h index c2e0b1365..c6c76a5ec 100644 --- a/src/Magnum/Text/Alignment.h +++ b/src/Magnum/Text/Alignment.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/CMakeLists.txt b/src/Magnum/Text/CMakeLists.txt index 0efac50ba..0f97736d9 100644 --- a/src/Magnum/Text/CMakeLists.txt +++ b/src/Magnum/Text/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -48,7 +48,6 @@ set_target_properties(MagnumText PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumText PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(MagnumText Magnum MagnumTextureTools) install(TARGETS MagnumText @@ -61,26 +60,30 @@ if(WITH_FONTCONVERTER) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fontconverterConfigure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/fontconverterConfigure.h) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) - add_executable(magnum-fontconverter fontconverter.cpp) - - if(CORRADE_TARGET_APPLE) - target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessCglApplication) + target_include_directories(magnum-fontconverter PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_link_libraries(magnum-fontconverter Magnum MagnumText) + if(MAGNUM_TARGET_HEADLESS) + target_link_libraries(magnum-fontconverter MagnumWindowlessEglApplication) + elseif(CORRADE_TARGET_APPLE) + target_link_libraries(magnum-fontconverter MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES) - target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessGlxApplication) + target_link_libraries(magnum-fontconverter MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS AND NOT TARGET_GLES) - target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessWglApplication) + target_link_libraries(magnum-fontconverter MagnumWindowlessWglApplication) else() message(FATAL_ERROR "magnum-fontconverter is not available on this platform. Set WITH_FONTCONVERTER to OFF to suppress this warning.") endif() install(TARGETS magnum-fontconverter DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}) + + # Magnum fontconverter target alias for superprojects + add_executable(Magnum::fontconverter ALIAS magnum-fontconverter) endif() if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum Text library for superprojects -set(MAGNUM_TEXT_LIBRARY MagnumText CACHE INTERNAL "") +# Magnum Text target alias for superprojects +add_library(Magnum::Text ALIAS MagnumText) diff --git a/src/Magnum/Text/DistanceFieldGlyphCache.cpp b/src/Magnum/Text/DistanceFieldGlyphCache.cpp index 0fbd1984c..89b21d2ea 100644 --- a/src/Magnum/Text/DistanceFieldGlyphCache.cpp +++ b/src/Magnum/Text/DistanceFieldGlyphCache.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -41,7 +41,7 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c GlyphCache(TextureFormat::R8, originalSize, size, Vector2i(radius)), #elif !defined(MAGNUM_TARGET_WEBGL) /* Luminance is not renderable in most cases */ - GlyphCache(Context::current()->isExtensionSupported() ? + GlyphCache(Context::current().isExtensionSupported() ? TextureFormat::Red : TextureFormat::RGB, originalSize, size, Vector2i(radius)), #else GlyphCache(TextureFormat::RGB, originalSize, size, Vector2i(radius)), @@ -54,7 +54,7 @@ DistanceFieldGlyphCache::DistanceFieldGlyphCache(const Vector2i& originalSize, c #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) /* Luminance is not renderable in most cases */ - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) Warning() << "Text::DistanceFieldGlyphCache:" << Extensions::GL::EXT::texture_rg::string() << "not supported, using inefficient RGB format for glyph cache texture"; #endif } @@ -67,7 +67,7 @@ void DistanceFieldGlyphCache::setImage(const Vector2i& offset, const ImageView2D #else TextureFormat internalFormat; #ifndef MAGNUM_TARGET_WEBGL - if(Context::current()->isExtensionSupported()) { + if(Context::current().isExtensionSupported()) { internalFormat = TextureFormat::Red; CORRADE_ASSERT(image.format() == PixelFormat::Red, "Text::DistanceFieldGlyphCache::setImage(): expected" << PixelFormat::Red << "but got" << image.format(), ); @@ -96,7 +96,7 @@ void DistanceFieldGlyphCache::setDistanceFieldImage(const Vector2i& offset, cons "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << PixelFormat::Red << "but got" << image.format(), ); #else #ifndef MAGNUM_TARGET_WEBGL - if(Context::current()->isExtensionSupported()) + if(Context::current().isExtensionSupported()) CORRADE_ASSERT(image.format() == PixelFormat::Red, "Text::DistanceFieldGlyphCache::setDistanceFieldImage(): expected" << PixelFormat::Red << "but got" << image.format(), ); else diff --git a/src/Magnum/Text/DistanceFieldGlyphCache.h b/src/Magnum/Text/DistanceFieldGlyphCache.h index 580bc77d5..aeecb36c1 100644 --- a/src/Magnum/Text/DistanceFieldGlyphCache.h +++ b/src/Magnum/Text/DistanceFieldGlyphCache.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/GlyphCache.cpp b/src/Magnum/Text/GlyphCache.cpp index 5ef9a4fcd..72a676cad 100644 --- a/src/Magnum/Text/GlyphCache.cpp +++ b/src/Magnum/Text/GlyphCache.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -51,8 +51,8 @@ GlyphCache::GlyphCache(const Vector2i& originalSize, const Vector2i& size, const const TextureFormat internalFormat = TextureFormat::R8; #elif !defined(MAGNUM_TARGET_WEBGL) TextureFormat internalFormat; - if(Context::current()->isExtensionSupported()) { - internalFormat = Context::current()->isExtensionSupported() ? + if(Context::current().isExtensionSupported()) { + internalFormat = Context::current().isExtensionSupported() ? TextureFormat::R8 : TextureFormat::Red; } else internalFormat = TextureFormat::Luminance; #else diff --git a/src/Magnum/Text/GlyphCache.h b/src/Magnum/Text/GlyphCache.h index 08848d83e..27b321a4a 100644 --- a/src/Magnum/Text/GlyphCache.h +++ b/src/Magnum/Text/GlyphCache.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/Renderer.cpp b/src/Magnum/Text/Renderer.cpp index 3d13faa72..fe1cce3b7 100644 --- a/src/Magnum/Text/Renderer.cpp +++ b/src/Magnum/Text/Renderer.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -93,13 +93,12 @@ std::tuple, Range2D> renderVerticesInternal(AbstractFont& fo /* Layout the line */ const auto layouter = font.layout(cache, size, line); - const UnsignedInt vertexCount = layouter->glyphCount()*4; /* Verify that we don't reallocate anything. The only problem might arise when the layouter decides to compose one character from more than one glyph (i.e. accents). Will remove the assert when this issue arises. */ - CORRADE_INTERNAL_ASSERT(vertices.size()+vertexCount <= vertices.capacity()); + CORRADE_INTERNAL_ASSERT(vertices.size() + layouter->glyphCount()*4 <= vertices.capacity()); /* Bounds of rendered line */ Range2D lineRectangle; @@ -307,11 +306,11 @@ AbstractRenderer::AbstractRenderer(AbstractFont& font, const GlyphCache& cache, #ifndef MAGNUM_TARGET_GLES MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::map_buffer_range); #elif defined(MAGNUM_TARGET_GLES2) && !defined(CORRADE_TARGET_EMSCRIPTEN) - if(Context::current()->isExtensionSupported()) { + if(Context::current().isExtensionSupported()) { bufferMapImplementation = &AbstractRenderer::bufferMapImplementationRange; } #ifdef CORRADE_TARGET_NACL - else if(Context::current()->isExtensionSupported()) { + else if(Context::current().isExtensionSupported()) { bufferMapImplementation = &AbstractRenderer::bufferMapImplementationSub; bufferUnmapImplementation = &AbstractRenderer::bufferUnmapImplementationSub; } diff --git a/src/Magnum/Text/Renderer.h b/src/Magnum/Text/Renderer.h index a1e49c0db..a9dc65d57 100644 --- a/src/Magnum/Text/Renderer.h +++ b/src/Magnum/Text/Renderer.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp index ec2e29d44..3cca1727e 100644 --- a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/Test/AbstractFontTest.cpp b/src/Magnum/Text/Test/AbstractFontTest.cpp index 0d8632eab..fbda4f7ce 100644 --- a/src/Magnum/Text/Test/AbstractFontTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -56,7 +56,7 @@ class SingleDataFont: public Text::AbstractFont { bool doIsOpened() const override { return opened; } void doClose() override {} - std::pair doOpenSingleData(const Containers::ArrayView data, Float) override { + Metrics doOpenSingleData(const Containers::ArrayView data, Float) override { opened = (data.size() == 1 && data[0] == '\xa5'); return {}; } diff --git a/src/Magnum/Text/Test/AbstractLayouterTest.cpp b/src/Magnum/Text/Test/AbstractLayouterTest.cpp index 9f0d3450a..7410e4d24 100644 --- a/src/Magnum/Text/Test/AbstractLayouterTest.cpp +++ b/src/Magnum/Text/Test/AbstractLayouterTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/Test/CMakeLists.txt b/src/Magnum/Text/Test/CMakeLists.txt index c90206ac7..1fe654601 100644 --- a/src/Magnum/Text/Test/CMakeLists.txt +++ b/src/Magnum/Text/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,10 +26,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(TextAbstractFontTest AbstractFontTest.cpp LIBRARIES Magnum MagnumText) +target_include_directories(TextAbstractFontTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(TextAbstractFontConverterTest AbstractFontConverterTest.cpp LIBRARIES Magnum MagnumText) +target_include_directories(TextAbstractFontConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(TextAbstractLayouterTest AbstractLayouterTest.cpp LIBRARIES Magnum MagnumText) if(BUILD_GL_TESTS) diff --git a/src/Magnum/Text/Test/GlyphCacheGLTest.cpp b/src/Magnum/Text/Test/GlyphCacheGLTest.cpp index b860849ec..682d1f20c 100644 --- a/src/Magnum/Text/Test/GlyphCacheGLTest.cpp +++ b/src/Magnum/Text/Test/GlyphCacheGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/Test/RendererGLTest.cpp b/src/Magnum/Text/Test/RendererGLTest.cpp index 012930460..51afbc7e7 100644 --- a/src/Magnum/Text/Test/RendererGLTest.cpp +++ b/src/Magnum/Text/Test/RendererGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -258,13 +258,13 @@ void RendererGLTest::renderMeshIndexType() { void RendererGLTest::mutableText() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::map_buffer_range::string() + std::string(" is not supported")); #elif defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_EMSCRIPTEN) - if(!Context::current()->isExtensionSupported() && - !Context::current()->isExtensionSupported() + if(!Context::current().isExtensionSupported() && + !Context::current().isExtensionSupported() #ifdef CORRADE_TARGET_NACL - && !Context::current()->isExtensionSupported() + && !Context::current().isExtensionSupported() #endif ) { CORRADE_SKIP("No required extension is supported"); @@ -344,9 +344,9 @@ void RendererGLTest::multiline() { bool doIsOpened() const override { return _opened; } void doClose() override { _opened = false; } - std::pair doOpenFile(const std::string&, Float) override { + Metrics doOpenFile(const std::string&, Float) override { _opened = true; - return {0.5f, 0.75f}; + return {0.5f, 0.45f, -0.25f, 0.75f}; } UnsignedInt doGlyphId(char32_t) override { return 0; } @@ -370,6 +370,8 @@ void RendererGLTest::multiline() { /* We're rendering text at 2.0f size and the font is scaled to 0.3f, so the line advance should be 0.75f*2.0f/0.5f = 3.0f */ CORRADE_COMPARE(font.size(), 0.5f); + CORRADE_COMPARE(font.ascent(), 0.45f); + CORRADE_COMPARE(font.descent(), -0.25f); CORRADE_COMPARE(font.lineHeight(), 0.75f); /* Bounds */ diff --git a/src/Magnum/Text/Test/configure.h.cmake b/src/Magnum/Text/Test/configure.h.cmake index 0221eb5ec..96f3e6a59 100644 --- a/src/Magnum/Text/Test/configure.h.cmake +++ b/src/Magnum/Text/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/Text.h b/src/Magnum/Text/Text.h index 5d1a31a44..4bfde1277 100644 --- a/src/Magnum/Text/Text.h +++ b/src/Magnum/Text/Text.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/fontconverter.cpp b/src/Magnum/Text/fontconverter.cpp index 01d1e1870..78a90dbf4 100644 --- a/src/Magnum/Text/fontconverter.cpp +++ b/src/Magnum/Text/fontconverter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -32,7 +32,9 @@ #include "Magnum/Text/DistanceFieldGlyphCache.h" #include "Magnum/Trade/AbstractImageConverter.h" -#ifdef CORRADE_TARGET_APPLE +#ifdef MAGNUM_TARGET_HEADLESS +#include "Magnum/Platform/WindowlessEglApplication.h" +#elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) #include "Magnum/Platform/WindowlessGlxApplication.h" @@ -104,14 +106,14 @@ FontConverter::FontConverter(const Arguments& arguments): Platform::WindowlessAp .addArgument("output").setHelp("output", "output filename prefix") .addNamedArgument("font").setHelp("font", "font plugin") .addNamedArgument("converter").setHelp("converter", "font converter plugin") - .addOption("plugin-dir", MAGNUM_PLUGINS_DIR).setHelpKey("plugin-dir", "DIR").setHelp("plugin-dir", "base plugin dir") + .addOption("plugin-dir", MAGNUM_PLUGINS_DIR).setHelp("plugin-dir", "base plugin dir", "DIR") .addOption("characters", "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789?!:;,. ").setHelp("characters", "characters to include in the output") - .addOption("font-size", "128").setHelpKey("font-size", "N").setHelp("font-size", "input font size") - .addOption("atlas-size", "2048 2048").setHelpKey("atlas-size", "\"X Y\"").setHelp("atlas-size", "glyph atlas size") - .addOption("output-size", "256 256").setHelpKey("output-size", "\"X Y\"").setHelp("output-size", "output atlas size. If set to zero size, distance field computation will not be used.") - .addOption("radius", "24").setHelpKey("radius", "N").setHelp("radius", "distance field computation radius") + .addOption("font-size", "128").setHelp("font-size", "input font size", "N") + .addOption("atlas-size", "2048 2048").setHelp("atlas-size", "glyph atlas size", "\"X Y\"") + .addOption("output-size", "256 256").setHelp("output-size", "output atlas size. If set to zero size, distance field computation will not be used.", "\"X Y\"") + .addOption("radius", "24").setHelp("radius", "distance field computation radius", "N") .addSkippedPrefix("magnum", "engine-specific options") .setHelp("Converts font to raster one of given atlas size.") .parse(arguments.argc, arguments.argv); diff --git a/src/Magnum/Text/fontconverterConfigure.h.cmake b/src/Magnum/Text/fontconverterConfigure.h.cmake index 1464161ef..895e33c28 100644 --- a/src/Magnum/Text/fontconverterConfigure.h.cmake +++ b/src/Magnum/Text/fontconverterConfigure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Text/visibility.h b/src/Magnum/Text/visibility.h index 61677ce2e..3ce04bd44 100644 --- a/src/Magnum/Text/visibility.h +++ b/src/Magnum/Text/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Texture.cpp b/src/Magnum/Texture.cpp index 018d8084b..28a11f493 100644 --- a/src/Magnum/Texture.cpp +++ b/src/Magnum/Texture.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -53,7 +53,7 @@ template MAGNUM_EXPORT Vector2i maxTextureSize<2>(); #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) template<> MAGNUM_EXPORT Vector3i maxTextureSize<3>() { #ifdef MAGNUM_TARGET_GLES2 - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return {}; #endif return {Vector2i(Implementation::maxTextureSideSize()), Implementation::max3DTextureDepth()}; @@ -93,6 +93,16 @@ template BufferImage Texture::su return std::move(image); } +template CompressedImage Texture::compressedSubImage(const Int level, const RangeTypeFor& range, CompressedImage&& image) { + compressedSubImage(level, range, image); + return std::move(image); +} + +template CompressedBufferImage Texture::compressedSubImage(const Int level, const RangeTypeFor& range, CompressedBufferImage&& image, const BufferUsage usage) { + compressedSubImage(level, range, image, usage); + return std::move(image); +} + template class MAGNUM_EXPORT Texture<1>; template class MAGNUM_EXPORT Texture<2>; template class MAGNUM_EXPORT Texture<3>; diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 3d274b4be..d33498c42 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -123,6 +123,39 @@ template class Texture: public AbstractTexture { return Implementation::maxTextureSize(); } + #ifndef MAGNUM_TARGET_GLES + /** + * @brief Compressed block size + * + * If @p format is compressed, returns compressed block size (in + * pixels). For uncompressed formats returns zero vector. + * @see @ref compressedBlockDataSize(), @fn_gl{Getinternalformat} with + * @def_gl{TEXTURE_COMPRESSED_BLOCK_WIDTH}, + * @def_gl{TEXTURE_COMPRESSED_BLOCK_HEIGHT} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @requires_gl Compressed texture queries are not available in OpenGL + * ES. + */ + static VectorTypeFor compressedBlockSize(TextureFormat format) { + return DataHelper::compressedBlockSize(Implementation::textureTarget(), format); + } + + /** + * @brief Compressed block data size + * + * If @p format is compressed, returns compressed block data size (in + * bytes). For uncompressed formats returns zero. + * @see @ref compressedBlockSize(), @fn_gl{Getinternalformat} with + * @def_gl{TEXTURE_COMPRESSED_BLOCK_SIZE} + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @requires_gl Compressed texture queries are not available in OpenGL + * ES. + */ + static Int compressedBlockDataSize(TextureFormat format) { + return AbstractTexture::compressedBlockDataSize(Implementation::textureTarget(), format); + } + #endif + /** * @brief Wrap existing OpenGL texture object * @param id OpenGL texture ID @@ -161,6 +194,90 @@ template class Texture: public AbstractTexture { */ explicit Texture(NoCreateT) noexcept: AbstractTexture{NoCreate, Implementation::textureTarget()} {} + #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) + /** + * @brief Bind level of texture to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param access Image access + * @param format Image format + * + * Available only on 1D and 2D textures. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + template::type> + #endif + void bindImage(Int imageUnit, Int level, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, false, 0, access, format); + } + + /** + * @brief Bind level of given texture layer to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param layer Texture layer + * @param access Image access + * @param format Image format + * + * Available only on 3D textures. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + template::type> + #endif + void bindImage(Int imageUnit, Int level, Int layer, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, false, layer, access, format); + } + + /** + * @brief Bind level of layered texture to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param access Image access + * @param format Image format + * + * Available only on 3D textures. + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImage(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + #ifndef DOXYGEN_GENERATING_OUTPUT + template::type> + #endif + void bindImageLayered(Int imageUnit, Int level, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, true, 0, access, format); + } + #endif + #ifndef MAGNUM_TARGET_GLES2 /** * @brief Set base mip level @@ -625,7 +742,7 @@ template class Texture: public AbstractTexture { * WebGL. */ VectorTypeFor imageSize(Int level) { - return DataHelper::imageSize(*this, _target, level); + return DataHelper::imageSize(*this, level); } #endif @@ -827,6 +944,61 @@ template class Texture: public AbstractTexture { * @endcode */ BufferImage subImage(Int level, const RangeTypeFor& range, BufferImage&& image, BufferUsage usage); + + /** + * @brief Read range of given compressed texture mip level to image + * @param level Mip level + * @param range Range to read + * @param image Image where to put the compressed data + * + * Compression format and data size are taken from the texture. + * @see @fn_gl2{GetTextureLevelParameter,GetTexLevelParameter}, + * @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access}, + * eventually @fn_gl{GetTexLevelParameter} with + * @def_gl{TEXTURE_COMPRESSED_IMAGE_SIZE}, @def_gl{TEXTURE_INTERNAL_FORMAT}, + * then @fn_gl{GetCompressedTextureSubImage} + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. + */ + void compressedSubImage(Int level, const RangeTypeFor& range, CompressedImage& image) { + AbstractTexture::compressedSubImage(level, range, image); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedImage2D image = texture.compressedSubImage(0, rect, {}); + * @endcode + */ + CompressedImage compressedSubImage(Int level, const RangeTypeFor& range, CompressedImage&& image); + + /** + * @brief Read range of given compressed texture mip level to buffer image + * @param level Mip level + * @param range Range to read + * @param image Buffer image where to put the compressed data + * @param usage Buffer usage + * + * See @ref compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. + */ + void compressedSubImage(Int level, const RangeTypeFor& range, CompressedBufferImage& image, BufferUsage usage) { + AbstractTexture::compressedSubImage(level, range, image, usage); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedBufferImage2D image = texture.compressedSubImage(0, rect, {}, BufferUsage::StaticRead); + * @endcode + */ + CompressedBufferImage compressedSubImage(Int level, const RangeTypeFor& range, CompressedBufferImage&& image, BufferUsage usage); #endif /** diff --git a/src/Magnum/TextureArray.cpp b/src/Magnum/TextureArray.cpp index de611004f..8818c633a 100644 --- a/src/Magnum/TextureArray.cpp +++ b/src/Magnum/TextureArray.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -46,7 +46,7 @@ namespace { template VectorTypeFor TextureArray::maxSize() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return {}; #endif @@ -84,6 +84,16 @@ template BufferImage TextureArraysubImage(level, range, image, usage); return std::move(image); } + +template CompressedImage TextureArray::compressedSubImage(const Int level, const RangeTypeFor& range, CompressedImage&& image) { + compressedSubImage(level, range, image); + return std::move(image); +} + +template CompressedBufferImage TextureArray::compressedSubImage(const Int level, const RangeTypeFor& range, CompressedBufferImage&& image, const BufferUsage usage) { + compressedSubImage(level, range, image, usage); + return std::move(image); +} #endif #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index 00867ac36..5e9d364a6 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -111,6 +111,34 @@ template class TextureArray: public AbstractTexture { */ static VectorTypeFor maxSize(); + #ifndef MAGNUM_TARGET_GLES + /** + * @copybrief Texture::compressedBlockSize() + * + * See @ref Texture::compressedBlockSize() for more information. + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @requires_gl Compressed texture queries are not available in OpenGL + * ES. + */ + static VectorTypeFor compressedBlockSize(TextureFormat format) { + return DataHelper::compressedBlockSize(Implementation::textureArrayTarget(), format); + } + + /** + * @copybrief Texture::compressedBlockDataSize() + * + * See @ref Texture::compressedBlockDataSize() for more information. + * @requires_gl43 Extension @extension{ARB,internalformat_query2} + * @requires_gl Compressed texture queries are not available in OpenGL + * ES. + * @see @ref compressedBlockSize(), @fn_gl{Getinternalformat} with + * @def_gl{TEXTURE_COMPRESSED_BLOCK_SIZE} + */ + static Int compressedBlockDataSize(TextureFormat format) { + return AbstractTexture::compressedBlockDataSize(Implementation::textureArrayTarget(), format); + } + #endif + /** * @brief Wrap existing OpenGL texture array object * @param id OpenGL texture array ID @@ -149,6 +177,55 @@ template class TextureArray: public AbstractTexture { */ explicit TextureArray(NoCreateT) noexcept: AbstractTexture{NoCreate, Implementation::textureArrayTarget()} {} + #ifndef MAGNUM_TARGET_WEBGL + /** + * @brief Bind level of given texture layer to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param layer Texture layer + * @param access Image access + * @param format Image format + * + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + void bindImage(Int imageUnit, Int level, Int layer, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, false, layer, access, format); + } + + /** + * @brief Bind level of layered texture to given image unit + * @param imageUnit Image unit + * @param level Texture level + * @param access Image access + * @param format Image format + * + * @note This function is meant to be used only internally from + * @ref AbstractShaderProgram subclasses. See its documentation + * for more information. + * @see @ref bindImages(Int, std::initializer_list), + * @ref bindImage(), @ref unbindImage(), @ref unbindImages(), + * @ref AbstractShaderProgram::maxImageUnits(), + * @fn_gl{BindImageTexture} + * @requires_gl42 Extension @extension{ARB,shader_image_load_store} + * @requires_gles31 Shader image load/store is not available in OpenGL + * ES 3.0 and older. + * @requires_gles Shader image load/store is not available in WebGL. + */ + void bindImageLayered(Int imageUnit, Int level, ImageAccess access, ImageFormat format) { + bindImageInternal(imageUnit, level, true, 0, access, format); + } + #endif + /** * @copybrief Texture::setBaseLevel() * @return Reference to self (for method chaining) @@ -388,7 +465,7 @@ template class TextureArray: public AbstractTexture { * WebGL. */ VectorTypeFor imageSize(Int level) { - return DataHelper::imageSize(*this, _target, level); + return DataHelper::imageSize(*this, level); } #endif @@ -523,6 +600,50 @@ template class TextureArray: public AbstractTexture { * @endcode */ BufferImage subImage(Int level, const RangeTypeFor& range, BufferImage&& image, BufferUsage usage); + + /** + * @copybrief Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) + * + * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedImage&) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. + */ + void compressedSubImage(Int level, const RangeTypeFor& range, CompressedImage& image) { + AbstractTexture::compressedSubImage(level, range, image); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedImage3D image = texture.compressedSubImage(0, range, {}); + * @endcode + */ + CompressedImage compressedSubImage(Int level, const RangeTypeFor& range, CompressedImage&& image); + + /** + * @copybrief Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * + * See @ref Texture::compressedSubImage(Int, const RangeTypeFor&, CompressedBufferImage&, BufferUsage) + * for more information. + * @requires_gl45 Extension @extension{ARB,get_texture_sub_image} + * @requires_gl Texture image queries are not available in OpenGL ES or + * WebGL. See @ref Framebuffer::read() for possible workaround. + */ + void compressedSubImage(Int level, const RangeTypeFor& range, CompressedBufferImage& image, BufferUsage usage) { + AbstractTexture::compressedSubImage(level, range, image, usage); + } + + /** @overload + * + * Convenience alternative to the above, example usage: + * @code + * CompressedBufferImage3D image = texture.compressedSubImage(0, range, {}, BufferUsage::StaticRead); + * @endcode + */ + CompressedBufferImage compressedSubImage(Int level, const RangeTypeFor& range, CompressedBufferImage&& image, BufferUsage usage); #endif /** diff --git a/src/Magnum/TextureFormat.h b/src/Magnum/TextureFormat.h index 32de31dbc..b0c9f9929 100644 --- a/src/Magnum/TextureFormat.h +++ b/src/Magnum/TextureFormat.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TextureTools/Atlas.cpp b/src/Magnum/TextureTools/Atlas.cpp index 449bb21a2..7994e6f7a 100644 --- a/src/Magnum/TextureTools/Atlas.cpp +++ b/src/Magnum/TextureTools/Atlas.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TextureTools/Atlas.h b/src/Magnum/TextureTools/Atlas.h index a1c409b8f..4b8ecf28d 100644 --- a/src/Magnum/TextureTools/Atlas.h +++ b/src/Magnum/TextureTools/Atlas.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TextureTools/CMakeLists.txt b/src/Magnum/TextureTools/CMakeLists.txt index acbcf7afa..e93c999c6 100644 --- a/src/Magnum/TextureTools/CMakeLists.txt +++ b/src/Magnum/TextureTools/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -44,28 +44,31 @@ set_target_properties(MagnumTextureTools PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) set_target_properties(MagnumTextureTools PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(MagnumTextureTools Magnum) if(WITH_DISTANCEFIELDCONVERTER) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/distancefieldconverterConfigure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/distancefieldconverterConfigure.h) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) - add_executable(magnum-distancefieldconverter distancefieldconverter.cpp) - - if(CORRADE_TARGET_APPLE) - target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessCglApplication) + target_include_directories(magnum-distancefieldconverter PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_link_libraries(magnum-distancefieldconverter Magnum MagnumTextureTools) + if(MAGNUM_TARGET_HEADLESS) + target_link_libraries(magnum-distancefieldconverter MagnumWindowlessEglApplication) + elseif(CORRADE_TARGET_APPLE) + target_link_libraries(magnum-distancefieldconverter MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES) - target_link_libraries(magnum-distancefieldconverter MagnumTextureTools Magnum MagnumWindowlessGlxApplication) + target_link_libraries(magnum-distancefieldconverter MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS AND NOT TARGET_GLES) - target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessWglApplication) + target_link_libraries(magnum-distancefieldconverter MagnumWindowlessWglApplication) else() message(FATAL_ERROR "magnum-distancefieldconverter is not available on this platform. Set WITH_DISTANCEFIELDCONVERTER to OFF to suppress this warning.") endif() install(TARGETS magnum-distancefieldconverter DESTINATION ${MAGNUM_BINARY_INSTALL_DIR}) + + # Magnum distancefieldconverter target alias for superprojects + add_executable(Magnum::distancefieldconverter ALIAS magnum-distancefieldconverter) endif() install(TARGETS MagnumTextureTools @@ -78,5 +81,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum TextureTools library for superprojects -set(MAGNUM_TEXTURETOOLS_LIBRARY MagnumTextureTools CACHE INTERNAL "") +# Magnum TextureTools target alias for superprojects +add_library(Magnum::TextureTools ALIAS MagnumTextureTools) diff --git a/src/Magnum/TextureTools/DistanceField.cpp b/src/Magnum/TextureTools/DistanceField.cpp index 55a049470..5d97417c3 100644 --- a/src/Magnum/TextureTools/DistanceField.cpp +++ b/src/Magnum/TextureTools/DistanceField.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -91,9 +91,9 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1) Utility::Resource rs("MagnumTextureTools"); #ifndef MAGNUM_TARGET_GLES - const Version v = Context::current()->supportedVersion({Version::GL320, Version::GL300, Version::GL210}); + const Version v = Context::current().supportedVersion({Version::GL320, Version::GL300, Version::GL210}); #else - const Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); + const Version v = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert = Shaders::Implementation::createCompatibilityShader(rs, v, Shader::Type::Vertex); @@ -109,9 +109,9 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1) /* Older GLSL doesn't have gl_VertexID, vertices must be supplied explicitly */ #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GL300)) + if(!Context::current().isVersionSupported(Version::GL300)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); @@ -120,16 +120,16 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1) CORRADE_INTERNAL_ASSERT_OUTPUT(link()); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #endif { radiusUniform = uniformLocation("radius"); scalingUniform = uniformLocation("scaling"); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GL320)) + if(!Context::current().isVersionSupported(Version::GL320)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { imageSizeInvertedUniform = uniformLocation("imageSizeInverted"); @@ -137,7 +137,7 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1) } #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) #endif { setUniform(uniformLocation("textureData"), TextureUnit); @@ -179,9 +179,9 @@ void distanceField(Texture2D& input, Texture2D& output, const Range2Di& rectangl .setTexture(input); #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GL320)) + if(!Context::current().isVersionSupported(Version::GL320)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { shader.setImageSizeInverted(1.0f/Vector2(imageSize)); @@ -194,9 +194,9 @@ void distanceField(Texture2D& input, Texture2D& output, const Range2Di& rectangl /* Older GLSL doesn't have gl_VertexID, vertices must be supplied explicitly */ Buffer buffer; #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isVersionSupported(Version::GL300)) + if(!Context::current().isVersionSupported(Version::GL300)) #else - if(!Context::current()->isVersionSupported(Version::GLES300)) + if(!Context::current().isVersionSupported(Version::GLES300)) #endif { constexpr Vector2 triangle[] = { diff --git a/src/Magnum/TextureTools/DistanceField.h b/src/Magnum/TextureTools/DistanceField.h index 2df3fd9ea..da512c3a5 100644 --- a/src/Magnum/TextureTools/DistanceField.h +++ b/src/Magnum/TextureTools/DistanceField.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TextureTools/DistanceFieldShader.frag b/src/Magnum/TextureTools/DistanceFieldShader.frag index 4088e55d5..448213855 100644 --- a/src/Magnum/TextureTools/DistanceFieldShader.frag +++ b/src/Magnum/TextureTools/DistanceFieldShader.frag @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -52,7 +52,9 @@ uniform lowp sampler2D textureData; #endif #ifdef TEXELFETCH_USABLE +#ifndef GL_ES layout(pixel_center_integer) in mediump vec4 gl_FragCoord; +#endif #else #ifdef EXPLICIT_UNIFORM_LOCATION layout(location = 2) uniform vec2 imageSizeInverted; @@ -85,8 +87,12 @@ bool hasValue(const mediump vec2 position, const mediump vec2 offset) { void main() { #ifdef TEXELFETCH_USABLE + #ifndef GL_ES const mediump ivec2 position = ivec2(gl_FragCoord.xy*scaling); #else + const mediump ivec2 position = ivec2((gl_FragCoord.xy - vec2(0.5))*scaling); + #endif + #else const mediump vec2 position = (gl_FragCoord.xy - vec2(0.5))*scaling*imageSizeInverted; #endif diff --git a/src/Magnum/TextureTools/DistanceFieldShader.vert b/src/Magnum/TextureTools/DistanceFieldShader.vert index bb8637604..85ddd7bbf 100644 --- a/src/Magnum/TextureTools/DistanceFieldShader.vert +++ b/src/Magnum/TextureTools/DistanceFieldShader.vert @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TextureTools/Test/AtlasTest.cpp b/src/Magnum/TextureTools/Test/AtlasTest.cpp index 8ba7ce764..82c96b8a0 100644 --- a/src/Magnum/TextureTools/Test/AtlasTest.cpp +++ b/src/Magnum/TextureTools/Test/AtlasTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -82,7 +82,7 @@ void AtlasTest::createEmpty() { void AtlasTest::createTooSmall() { std::ostringstream o; - Error::setOutput(&o); + Error redirectError{&o}; std::vector atlas = TextureTools::atlas({64, 32}, { {8, 16}, diff --git a/src/Magnum/TextureTools/Test/CMakeLists.txt b/src/Magnum/TextureTools/Test/CMakeLists.txt index 1c42d070d..bcbb445e0 100644 --- a/src/Magnum/TextureTools/Test/CMakeLists.txt +++ b/src/Magnum/TextureTools/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TextureTools/distancefieldconverter.cpp b/src/Magnum/TextureTools/distancefieldconverter.cpp index 606c2eda1..bded817b8 100644 --- a/src/Magnum/TextureTools/distancefieldconverter.cpp +++ b/src/Magnum/TextureTools/distancefieldconverter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -38,7 +38,9 @@ #include "Magnum/Trade/AbstractImageConverter.h" #include "Magnum/Trade/ImageData.h" -#ifdef CORRADE_TARGET_APPLE +#ifdef MAGNUM_TARGET_HEADLESS +#include "Magnum/Platform/WindowlessEglApplication.h" +#elif defined(CORRADE_TARGET_APPLE) #include "Magnum/Platform/WindowlessCglApplication.h" #elif defined(CORRADE_TARGET_UNIX) #include "Magnum/Platform/WindowlessGlxApplication.h" @@ -105,9 +107,9 @@ DistanceFieldConverter::DistanceFieldConverter(const Arguments& arguments): Plat .addArgument("output").setHelp("output", "output image") .addOption("importer", "AnyImageImporter").setHelp("importer", "image importer plugin") .addOption("converter", "AnyImageConverter").setHelp("converter", "image converter plugin") - .addOption("plugin-dir", MAGNUM_PLUGINS_DIR).setHelpKey("plugin-dir", "DIR").setHelp("plugin-dir", "base plugin dir") - .addNamedArgument("output-size").setHelpKey("output-size", "\"X Y\"").setHelp("output-size", "size of output image") - .addNamedArgument("radius").setHelpKey("radius", "N").setHelp("radius", "distance field computation radius") + .addOption("plugin-dir", MAGNUM_PLUGINS_DIR).setHelp("plugin-dir", "base plugin dir", "DIR") + .addNamedArgument("output-size").setHelp("output-size", "size of output image", "\"X Y\"") + .addNamedArgument("radius").setHelp("radius", "distance field computation radius", "N") .addSkippedPrefix("magnum", "engine-specific options") .setHelp("Converts red channel of an image to distance field representation.") .parse(arguments.argc, arguments.argv); diff --git a/src/Magnum/TextureTools/distancefieldconverterConfigure.h.cmake b/src/Magnum/TextureTools/distancefieldconverterConfigure.h.cmake index 1464161ef..895e33c28 100644 --- a/src/Magnum/TextureTools/distancefieldconverterConfigure.h.cmake +++ b/src/Magnum/TextureTools/distancefieldconverterConfigure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TextureTools/visibility.h b/src/Magnum/TextureTools/visibility.h index 8d9aec05a..8fae5b679 100644 --- a/src/Magnum/TextureTools/visibility.h +++ b/src/Magnum/TextureTools/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TimeQuery.h b/src/Magnum/TimeQuery.h index 309e33aee..4d5b7e068 100644 --- a/src/Magnum/TimeQuery.h +++ b/src/Magnum/TimeQuery.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Timeline.cpp b/src/Magnum/Timeline.cpp index 3122e468a..a05790bc5 100644 --- a/src/Magnum/Timeline.cpp +++ b/src/Magnum/Timeline.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Timeline.h b/src/Magnum/Timeline.h index 9db373caa..d35442a6f 100644 --- a/src/Magnum/Timeline.h +++ b/src/Magnum/Timeline.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index c3341a78a..d3589bf7d 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index 8879d272a..b5215f60d 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index 808748006..21e76c3ac 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index 8011a799b..f0bf089e3 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/AbstractMaterialData.cpp b/src/Magnum/Trade/AbstractMaterialData.cpp index ba2cf200e..c60d10001 100644 --- a/src/Magnum/Trade/AbstractMaterialData.cpp +++ b/src/Magnum/Trade/AbstractMaterialData.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/AbstractMaterialData.h b/src/Magnum/Trade/AbstractMaterialData.h index 0ac57ab4d..894d10ea2 100644 --- a/src/Magnum/Trade/AbstractMaterialData.h +++ b/src/Magnum/Trade/AbstractMaterialData.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/CMakeLists.txt b/src/Magnum/Trade/CMakeLists.txt index 0e20dd89c..59f0b8d44 100644 --- a/src/Magnum/Trade/CMakeLists.txt +++ b/src/Magnum/Trade/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/CameraData.h b/src/Magnum/Trade/CameraData.h index 045fc36da..7daa4acd2 100644 --- a/src/Magnum/Trade/CameraData.h +++ b/src/Magnum/Trade/CameraData.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -77,7 +77,7 @@ class CameraData { }; inline CameraData::CameraData(const Rad fov, const Float near, const Float far, const void* const importerState) noexcept: - _fov{fov != fov ? Rad{35.0_degf} : fov}, + _fov{fov != fov ? Rad{Deg{35.0f}} : fov}, _near{near != near ? 0.01f : near}, _far{far != far ? 100.0f : far}, _importerState{importerState} {} diff --git a/src/Magnum/Trade/ImageData.cpp b/src/Magnum/Trade/ImageData.cpp index 16303a39a..e4d1f3a87 100644 --- a/src/Magnum/Trade/ImageData.cpp +++ b/src/Magnum/Trade/ImageData.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index 1071fed2a..7ff2e5561 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/LightData.h b/src/Magnum/Trade/LightData.h index e9a6057c9..3a8163f6d 100644 --- a/src/Magnum/Trade/LightData.h +++ b/src/Magnum/Trade/LightData.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/MeshData2D.cpp b/src/Magnum/Trade/MeshData2D.cpp index 1fab7b45a..0793d63a3 100644 --- a/src/Magnum/Trade/MeshData2D.cpp +++ b/src/Magnum/Trade/MeshData2D.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/MeshData2D.h b/src/Magnum/Trade/MeshData2D.h index a58f5685f..69946251f 100644 --- a/src/Magnum/Trade/MeshData2D.h +++ b/src/Magnum/Trade/MeshData2D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/MeshData3D.cpp b/src/Magnum/Trade/MeshData3D.cpp index 76b3f04dd..393584993 100644 --- a/src/Magnum/Trade/MeshData3D.cpp +++ b/src/Magnum/Trade/MeshData3D.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/MeshData3D.h b/src/Magnum/Trade/MeshData3D.h index 64a5ca02d..060f78bdd 100644 --- a/src/Magnum/Trade/MeshData3D.h +++ b/src/Magnum/Trade/MeshData3D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/MeshObjectData2D.cpp b/src/Magnum/Trade/MeshObjectData2D.cpp index c3e94271f..5dcb9c03c 100644 --- a/src/Magnum/Trade/MeshObjectData2D.cpp +++ b/src/Magnum/Trade/MeshObjectData2D.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/MeshObjectData2D.h b/src/Magnum/Trade/MeshObjectData2D.h index 39c349593..26dad47c5 100644 --- a/src/Magnum/Trade/MeshObjectData2D.h +++ b/src/Magnum/Trade/MeshObjectData2D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/MeshObjectData3D.cpp b/src/Magnum/Trade/MeshObjectData3D.cpp index 76f51d2bc..135f4ee0f 100644 --- a/src/Magnum/Trade/MeshObjectData3D.cpp +++ b/src/Magnum/Trade/MeshObjectData3D.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/MeshObjectData3D.h b/src/Magnum/Trade/MeshObjectData3D.h index d536e208b..305b74d36 100644 --- a/src/Magnum/Trade/MeshObjectData3D.h +++ b/src/Magnum/Trade/MeshObjectData3D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/ObjectData2D.cpp b/src/Magnum/Trade/ObjectData2D.cpp index a11327c66..4ea19c029 100644 --- a/src/Magnum/Trade/ObjectData2D.cpp +++ b/src/Magnum/Trade/ObjectData2D.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/ObjectData2D.h b/src/Magnum/Trade/ObjectData2D.h index d2b952e0d..01b3cd2b2 100644 --- a/src/Magnum/Trade/ObjectData2D.h +++ b/src/Magnum/Trade/ObjectData2D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/ObjectData3D.cpp b/src/Magnum/Trade/ObjectData3D.cpp index 3afcb99fa..c0e0cfc94 100644 --- a/src/Magnum/Trade/ObjectData3D.cpp +++ b/src/Magnum/Trade/ObjectData3D.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/ObjectData3D.h b/src/Magnum/Trade/ObjectData3D.h index 05f71dbf2..382615bc1 100644 --- a/src/Magnum/Trade/ObjectData3D.h +++ b/src/Magnum/Trade/ObjectData3D.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/PhongMaterialData.cpp b/src/Magnum/Trade/PhongMaterialData.cpp index 06d2d948e..ff427d677 100644 --- a/src/Magnum/Trade/PhongMaterialData.cpp +++ b/src/Magnum/Trade/PhongMaterialData.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/PhongMaterialData.h b/src/Magnum/Trade/PhongMaterialData.h index 2e0451056..dee266602 100644 --- a/src/Magnum/Trade/PhongMaterialData.h +++ b/src/Magnum/Trade/PhongMaterialData.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/SceneData.cpp b/src/Magnum/Trade/SceneData.cpp index b66b55a55..f00726a0b 100644 --- a/src/Magnum/Trade/SceneData.cpp +++ b/src/Magnum/Trade/SceneData.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/SceneData.h b/src/Magnum/Trade/SceneData.h index 799c3c051..0c12bb7f0 100644 --- a/src/Magnum/Trade/SceneData.h +++ b/src/Magnum/Trade/SceneData.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp index 439e1c621..fc2b86f2e 100644 --- a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Test/AbstractImporterTest.cpp b/src/Magnum/Trade/Test/AbstractImporterTest.cpp index 332720801..099e71d51 100644 --- a/src/Magnum/Trade/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImporterTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Test/AbstractMaterialDataTest.cpp b/src/Magnum/Trade/Test/AbstractMaterialDataTest.cpp index a5c8890b9..7d4054031 100644 --- a/src/Magnum/Trade/Test/AbstractMaterialDataTest.cpp +++ b/src/Magnum/Trade/Test/AbstractMaterialDataTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Test/CMakeLists.txt b/src/Magnum/Trade/Test/CMakeLists.txt index 73aca1c1b..ffe52e9c9 100644 --- a/src/Magnum/Trade/Test/CMakeLists.txt +++ b/src/Magnum/Trade/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,10 +26,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(TradeAbstractImageConverterTest AbstractImageConverterTest.cpp LIBRARIES Magnum) +target_include_directories(TradeAbstractImageConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(TradeAbstractImporterTest AbstractImporterTest.cpp LIBRARIES Magnum) +target_include_directories(TradeAbstractImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) corrade_add_test(TradeAbstractMaterialDataTest AbstractMaterialDataTest.cpp LIBRARIES Magnum) corrade_add_test(TradeImageDataTest ImageDataTest.cpp LIBRARIES Magnum) corrade_add_test(TradeObjectData2DTest ObjectData2DTest.cpp LIBRARIES Magnum) diff --git a/src/Magnum/Trade/Test/ImageDataTest.cpp b/src/Magnum/Trade/Test/ImageDataTest.cpp index d27e424fa..f56132e60 100644 --- a/src/Magnum/Trade/Test/ImageDataTest.cpp +++ b/src/Magnum/Trade/Test/ImageDataTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Test/ObjectData2DTest.cpp b/src/Magnum/Trade/Test/ObjectData2DTest.cpp index b914ee27e..fa65e8e78 100644 --- a/src/Magnum/Trade/Test/ObjectData2DTest.cpp +++ b/src/Magnum/Trade/Test/ObjectData2DTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Test/ObjectData3DTest.cpp b/src/Magnum/Trade/Test/ObjectData3DTest.cpp index f11624aa7..4f5a0d674 100644 --- a/src/Magnum/Trade/Test/ObjectData3DTest.cpp +++ b/src/Magnum/Trade/Test/ObjectData3DTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Test/TextureDataTest.cpp b/src/Magnum/Trade/Test/TextureDataTest.cpp index 1e27b528b..30c0050c1 100644 --- a/src/Magnum/Trade/Test/TextureDataTest.cpp +++ b/src/Magnum/Trade/Test/TextureDataTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Test/configure.h.cmake b/src/Magnum/Trade/Test/configure.h.cmake index 51b292ac3..d39dc3cdf 100644 --- a/src/Magnum/Trade/Test/configure.h.cmake +++ b/src/Magnum/Trade/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/TextureData.cpp b/src/Magnum/Trade/TextureData.cpp index 4120e99ac..d0be1a163 100644 --- a/src/Magnum/Trade/TextureData.cpp +++ b/src/Magnum/Trade/TextureData.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/TextureData.h b/src/Magnum/Trade/TextureData.h index 0b83c07b8..23cfe3071 100644 --- a/src/Magnum/Trade/TextureData.h +++ b/src/Magnum/Trade/TextureData.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Trade/Trade.h b/src/Magnum/Trade/Trade.h index 0371ddce8..85d791a2b 100644 --- a/src/Magnum/Trade/Trade.h +++ b/src/Magnum/Trade/Trade.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/TransformFeedback.cpp b/src/Magnum/TransformFeedback.cpp index 8be2f5588..1ec6160c0 100644 --- a/src/Magnum/TransformFeedback.cpp +++ b/src/Magnum/TransformFeedback.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -42,11 +42,11 @@ namespace Magnum { Int TransformFeedback::maxInterleavedComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().transformFeedback->maxInterleavedComponents; + GLint& value = Context::current().state().transformFeedback->maxInterleavedComponents; if(value == 0) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, &value); @@ -56,11 +56,11 @@ Int TransformFeedback::maxInterleavedComponents() { Int TransformFeedback::maxSeparateAttributes() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().transformFeedback->maxSeparateAttributes; + GLint& value = Context::current().state().transformFeedback->maxSeparateAttributes; if(value == 0) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &value); @@ -70,11 +70,11 @@ Int TransformFeedback::maxSeparateAttributes() { Int TransformFeedback::maxSeparateComponents() { #ifndef MAGNUM_TARGET_GLES - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return 0; #endif - GLint& value = Context::current()->state().transformFeedback->maxSeparateComponents; + GLint& value = Context::current().state().transformFeedback->maxSeparateComponents; if(value == 0) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, &value); @@ -84,10 +84,10 @@ Int TransformFeedback::maxSeparateComponents() { #ifndef MAGNUM_TARGET_GLES Int TransformFeedback::maxBuffers() { - if(!Context::current()->isExtensionSupported()) + if(!Context::current().isExtensionSupported()) return maxSeparateAttributes(); - GLint& value = Context::current()->state().transformFeedback->maxBuffers; + GLint& value = Context::current().state().transformFeedback->maxBuffers; if(value == 0) glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, &value); @@ -97,7 +97,7 @@ Int TransformFeedback::maxBuffers() { #endif TransformFeedback::TransformFeedback(): _flags{ObjectFlag::DeleteOnDestruction} { - (this->*Context::current()->state().transformFeedback->createImplementation)(); + (this->*Context::current().state().transformFeedback->createImplementation)(); CORRADE_INTERNAL_ASSERT(_id != Implementation::State::DisengagedBinding); } @@ -117,14 +117,14 @@ TransformFeedback::~TransformFeedback() { if(!_id || !(_flags & ObjectFlag::DeleteOnDestruction)) return; /* If bound, remove itself from state */ - GLuint& binding = Context::current()->state().transformFeedback->binding; + GLuint& binding = Context::current().state().transformFeedback->binding; if(binding == _id) binding = 0; glDeleteTransformFeedbacks(1, &_id); } void TransformFeedback::bindInternal() { - GLuint& bound = Context::current()->state().transformFeedback->binding; + GLuint& bound = Context::current().state().transformFeedback->binding; /* Already bound, nothing to do */ if(bound == _id) return; @@ -149,23 +149,23 @@ inline void TransformFeedback::createIfNotAlready() { #ifndef MAGNUM_TARGET_WEBGL std::string TransformFeedback::label() { createIfNotAlready(); - return Context::current()->state().debug->getLabelImplementation(GL_TRANSFORM_FEEDBACK, _id); + return Context::current().state().debug->getLabelImplementation(GL_TRANSFORM_FEEDBACK, _id); } TransformFeedback& TransformFeedback::setLabelInternal(const Containers::ArrayView label) { createIfNotAlready(); - Context::current()->state().debug->labelImplementation(GL_TRANSFORM_FEEDBACK, _id, label); + Context::current().state().debug->labelImplementation(GL_TRANSFORM_FEEDBACK, _id, label); return *this; } #endif TransformFeedback& TransformFeedback::attachBuffer(const UnsignedInt index, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) { - (this->*Context::current()->state().transformFeedback->attachRangeImplementation)(index, buffer, offset, size); + (this->*Context::current().state().transformFeedback->attachRangeImplementation)(index, buffer, offset, size); return *this; } TransformFeedback& TransformFeedback::attachBuffer(const UnsignedInt index, Buffer& buffer) { - (this->*Context::current()->state().transformFeedback->attachBaseImplementation)(index, buffer); + (this->*Context::current().state().transformFeedback->attachBaseImplementation)(index, buffer); return *this; } @@ -193,13 +193,13 @@ void TransformFeedback::attachImplementationDSA(const GLuint index, Buffer& buff /** @todoc const std::initializer_list makes Doxygen grumpy */ TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list> buffers) { - (this->*Context::current()->state().transformFeedback->attachRangesImplementation)(firstIndex, buffers); + (this->*Context::current().state().transformFeedback->attachRangesImplementation)(firstIndex, buffers); return *this; } /** @todoc const std::initializer_list makes Doxygen grumpy */ TransformFeedback& TransformFeedback::attachBuffers(const UnsignedInt firstIndex, std::initializer_list buffers) { - (this->*Context::current()->state().transformFeedback->attachBasesImplementation)(firstIndex, buffers); + (this->*Context::current().state().transformFeedback->attachBasesImplementation)(firstIndex, buffers); return *this; } diff --git a/src/Magnum/TransformFeedback.h b/src/Magnum/TransformFeedback.h index 8c398f967..602d3ba2a 100644 --- a/src/Magnum/TransformFeedback.h +++ b/src/Magnum/TransformFeedback.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Types.h b/src/Magnum/Types.h index 7da8730a8..0b73e006e 100644 --- a/src/Magnum/Types.h +++ b/src/Magnum/Types.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/Magnum/Version.cpp b/src/Magnum/Version.cpp index ca4ff2696..c0853dff7 100644 --- a/src/Magnum/Version.cpp +++ b/src/Magnum/Version.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -46,7 +46,8 @@ Debug& operator<<(Debug& debug, Version value) { _c(GL430, "OpenGL 4.3") _c(GL440, "OpenGL 4.4") _c(GL450, "OpenGL 4.5") - #elif defined(MAGNUM_TARGET_WEBGL) + #endif + #ifdef MAGNUM_TARGET_WEBGL _c(GLES200, "WebGL 1.0") _c(GLES300, "WebGL 2.0") #else diff --git a/src/Magnum/Version.h b/src/Magnum/Version.h index 37515ae12..a329c43f7 100644 --- a/src/Magnum/Version.h +++ b/src/Magnum/Version.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -36,6 +36,12 @@ namespace Magnum { +#ifndef MAGNUM_TARGET_GLES +namespace Implementation { + enum: Int { VersionESMask = 0x10000 }; +} +#endif + /** @brief OpenGL version @@ -60,12 +66,13 @@ enum class Version: Int { /** * @brief OpenGL ES 2.0 or WebGL 1.0, GLSL ES 1.00 * - * All the functionality is present in OpenGL 4.2 (extension - * @extension{ARB,ES2_compatibility}), so on desktop OpenGL this is - * equivalent to @ref Version::GL410. + * On desktop OpenGL, all related functionality is present in extension + * @extension{ARB,ES2_compatibility} (OpenGL 4.1), so testing for this + * version using @ref Context::isVersionSupported() is equivalent to + * testing for availability of that extension. */ #ifndef MAGNUM_TARGET_GLES - GLES200 = 410, + GLES200 = Implementation::VersionESMask|200, #else GLES200 = 200, #endif @@ -73,12 +80,13 @@ enum class Version: Int { /** * @brief OpenGL ES 3.0 or WebGL 2.0, GLSL ES 3.00 * - * All the functionality is present in OpenGL 4.3 (extension - * @extension{ARB,ES3_compatibility}), so on desktop OpenGL this is the - * equivalent to @ref Version::GL430. + * On desktop OpenGL, all related functionality is present in extension + * @extension{ARB,ES3_compatibility} (OpenGL 4.3), so testing for this + * version using @ref Context::isVersionSupported() is equivalent to + * testing for availability of that extension. */ #ifndef MAGNUM_TARGET_GLES - GLES300 = 430, + GLES300 = Implementation::VersionESMask|300, #else GLES300 = 300, #endif @@ -87,12 +95,13 @@ enum class Version: Int { /** * @brief OpenGL ES 3.1, GLSL ES 3.10 * - * All the functionality is present in OpenGL 4.5 (extension - * @extension{ARB,ES3_1_compatibility}), so on desktop OpenGL this is the - * equivalent to @ref Version::GL450. + * On desktop OpenGL, all related functionality is present in extension + * @extension{ARB,ES3_1_compatibility} (OpenGL 4.5), so testing for this + * version using @ref Context::isVersionSupported() is equivalent to + * testing for availability of that extension. */ #ifndef MAGNUM_TARGET_GLES - GLES310 = 450 + GLES310 = Implementation::VersionESMask|310, #else GLES310 = 310 #endif @@ -100,15 +109,37 @@ enum class Version: Int { }; /** @brief Enum value from major and minor version number */ -inline Version version(Int major, Int minor) { +constexpr Version version(Int major, Int minor) { return Version(major*100 + minor*10); } -/** @brief Major and minor version number from enum value */ +/** +@brief Major and minor version number from enum value + +@see @ref isVersionES() +*/ inline std::pair version(Version version) { - return {Int(version)/100, (Int(version)%100)/10}; + const Int v = Int(version) + #ifndef MAGNUM_TARGET_GLES + & ~Implementation::VersionESMask + #endif + ; + return {v/100, (v%100)/10}; } +/** +@brief Whether given version is OpenGL ES or WebGL + +Always `true` on @ref MAGNUM_TARGET_GLES "OpenGL ES" and WebGL build. +*/ +#ifndef MAGNUM_TARGET_GLES +constexpr bool isVersionES(Version version) { + return Int(version) & Implementation::VersionESMask; +} +#else +constexpr bool isVersionES(Version) { return true; } +#endif + /** @debugoperatorenum{Magnum::Version} */ MAGNUM_EXPORT Debug& operator<<(Debug& debug, Version value); diff --git a/src/Magnum/configure.h.cmake b/src/Magnum/configure.h.cmake index 2f7d74c0a..54abfa21d 100644 --- a/src/Magnum/configure.h.cmake +++ b/src/Magnum/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -30,3 +30,4 @@ #cmakedefine MAGNUM_TARGET_GLES3 #cmakedefine MAGNUM_TARGET_DESKTOP_GLES #cmakedefine MAGNUM_TARGET_WEBGL +#cmakedefine MAGNUM_TARGET_HEADLESS diff --git a/src/Magnum/dummy.cpp b/src/Magnum/dummy.cpp new file mode 100644 index 000000000..02a434d1f --- /dev/null +++ b/src/Magnum/dummy.cpp @@ -0,0 +1,30 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +/* XCode-generated project files have a limitation that you can't create a + library target from OBJECT sources only and you have to provide at least one + file. Otherwise the generated library gets replaced with self-pointing + symlink and the build then obviously fails with "File not found" error. + Related: http://public.kitware.com/pipermail/cmake/2016-April/063178.html */ diff --git a/src/Magnum/visibility.h b/src/Magnum/visibility.h index 771f6ea34..eac214616 100644 --- a/src/Magnum/visibility.h +++ b/src/Magnum/visibility.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumExternal/CMakeLists.txt b/src/MagnumExternal/CMakeLists.txt index 550c057bc..63db16444 100644 --- a/src/MagnumExternal/CMakeLists.txt +++ b/src/MagnumExternal/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumExternal/OpenAL/CMakeLists.txt b/src/MagnumExternal/OpenAL/CMakeLists.txt index 2076113e4..0da1c4b3f 100644 --- a/src/MagnumExternal/OpenAL/CMakeLists.txt +++ b/src/MagnumExternal/OpenAL/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # Copyright © 2015 Jonathan Hale # diff --git a/src/MagnumExternal/OpenAL/extensions.h b/src/MagnumExternal/OpenAL/extensions.h index bae6dd256..c0c60c30a 100644 --- a/src/MagnumExternal/OpenAL/extensions.h +++ b/src/MagnumExternal/OpenAL/extensions.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Copyright © 2015 Jonathan Hale diff --git a/src/MagnumExternal/OpenGL/CMakeLists.txt b/src/MagnumExternal/OpenGL/CMakeLists.txt index 2a95c3225..85c1067c7 100644 --- a/src/MagnumExternal/OpenGL/CMakeLists.txt +++ b/src/MagnumExternal/OpenGL/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumExternal/OpenGL/GL/CMakeLists.txt b/src/MagnumExternal/OpenGL/GL/CMakeLists.txt index 0009c0fb1..045c58921 100644 --- a/src/MagnumExternal/OpenGL/GL/CMakeLists.txt +++ b/src/MagnumExternal/OpenGL/GL/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -25,11 +25,10 @@ # flextGLPlatform.cpp is compiled as part of Magnum*Context libraries in Platform add_library(MagnumFlextGLObjects OBJECT flextGL.cpp) +target_include_directories(MagnumFlextGLObjects PUBLIC $) -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang") - set_target_properties(MagnumFlextGLObjects PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -DFlextGL_EXPORTS") -else() - set_target_properties(MagnumFlextGLObjects PROPERTIES COMPILE_FLAGS "-DFlextGL_EXPORTS") +if(NOT BUILD_STATIC) + target_compile_definitions(MagnumFlextGLObjects PRIVATE "FlextGL_EXPORTS") endif() if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumFlextGLObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/src/MagnumExternal/OpenGL/GL/extensions.txt b/src/MagnumExternal/OpenGL/GL/extensions.txt index 035c3e478..82b268d8b 100644 --- a/src/MagnumExternal/OpenGL/GL/extensions.txt +++ b/src/MagnumExternal/OpenGL/GL/extensions.txt @@ -33,3 +33,4 @@ extension KHR_texture_compression_astc_ldr optional extension KHR_texture_compression_astc_hdr optional extension KHR_blend_equation_advanced optional extension KHR_blend_equation_advanced_coherent optional +extension KHR_no_error optional diff --git a/src/MagnumExternal/OpenGL/GL/flextGL.cpp b/src/MagnumExternal/OpenGL/GL/flextGL.cpp index 1d7a507d8..80f2cfc35 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGL.cpp +++ b/src/MagnumExternal/OpenGL/GL/flextGL.cpp @@ -837,7 +837,7 @@ FLEXTGL_EXPORT void(APIENTRY *flextglBlitNamedFramebuffer)(GLuint, GLuint, GLint FLEXTGL_EXPORT GLenum(APIENTRY *flextglCheckNamedFramebufferStatus)(GLuint, GLenum) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedBufferData)(GLuint, GLenum, GLenum, GLenum, const void *) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedBufferSubData)(GLuint, GLenum, GLintptr, GLsizeiptr, GLenum, GLenum, const void *) = nullptr; -FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfi)(GLuint, GLenum, const GLfloat, GLint) = nullptr; +FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfi)(GLuint, GLenum, GLint, GLfloat, GLint) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfv)(GLuint, GLenum, GLint, const GLfloat *) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferiv)(GLuint, GLenum, GLint, const GLint *) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferuiv)(GLuint, GLenum, GLint, const GLuint *) = nullptr; diff --git a/src/MagnumExternal/OpenGL/GL/flextGL.h b/src/MagnumExternal/OpenGL/GL/flextGL.h index 8771bddfd..92148bc94 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGL.h +++ b/src/MagnumExternal/OpenGL/GL/flextGL.h @@ -1749,6 +1749,10 @@ typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum #define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +/* GL_KHR_no_error */ + +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 + /* Function prototypes */ /* GL_ARB_bindless_texture */ @@ -3458,7 +3462,7 @@ GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedBufferData)(GLuint, GLenum, #define glClearNamedBufferData flextglClearNamedBufferData GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedBufferSubData)(GLuint, GLenum, GLintptr, GLsizeiptr, GLenum, GLenum, const void *); #define glClearNamedBufferSubData flextglClearNamedBufferSubData -GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfi)(GLuint, GLenum, const GLfloat, GLint); +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfi)(GLuint, GLenum, GLint, GLfloat, GLint); #define glClearNamedFramebufferfi flextglClearNamedFramebufferfi GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglClearNamedFramebufferfv)(GLuint, GLenum, GLint, const GLfloat *); #define glClearNamedFramebufferfv flextglClearNamedFramebufferfv diff --git a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp index 49c91d3a9..9396c4a2b 100644 --- a/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp +++ b/src/MagnumExternal/OpenGL/GL/flextGLPlatform.cpp @@ -841,7 +841,7 @@ void flextGLInit() { flextglCheckNamedFramebufferStatus = reinterpret_cast(loader.load("glCheckNamedFramebufferStatus")); flextglClearNamedBufferData = reinterpret_cast(loader.load("glClearNamedBufferData")); flextglClearNamedBufferSubData = reinterpret_cast(loader.load("glClearNamedBufferSubData")); - flextglClearNamedFramebufferfi = reinterpret_cast(loader.load("glClearNamedFramebufferfi")); + flextglClearNamedFramebufferfi = reinterpret_cast(loader.load("glClearNamedFramebufferfi")); flextglClearNamedFramebufferfv = reinterpret_cast(loader.load("glClearNamedFramebufferfv")); flextglClearNamedFramebufferiv = reinterpret_cast(loader.load("glClearNamedFramebufferiv")); flextglClearNamedFramebufferuiv = reinterpret_cast(loader.load("glClearNamedFramebufferuiv")); diff --git a/src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt b/src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt index b9482f594..56d3cb0fd 100644 --- a/src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt +++ b/src/MagnumExternal/OpenGL/GLES2/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -27,11 +27,10 @@ if(NOT CORRADE_TARGET_NACL AND NOT CORRADE_TARGET_EMSCRIPTEN) # flextGLPlatform.cpp is compiled as part of Magnum*Context libraries in Platform add_library(MagnumFlextGLObjects OBJECT flextGL.cpp) + target_include_directories(MagnumFlextGLObjects PUBLIC $) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang") - set_target_properties(MagnumFlextGLObjects PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -DFlextGL_EXPORTS") - else() - set_target_properties(MagnumFlextGLObjects PROPERTIES COMPILE_FLAGS "-DFlextGL_EXPORTS") + if(NOT BUILD_STATIC) + target_compile_definitions(MagnumFlextGLObjects PRIVATE "FlextGL_EXPORTS") endif() if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumFlextGLObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/src/MagnumExternal/OpenGL/GLES2/README.md b/src/MagnumExternal/OpenGL/GLES2/README.md index fb7ce33a1..b4f73b127 100644 --- a/src/MagnumExternal/OpenGL/GLES2/README.md +++ b/src/MagnumExternal/OpenGL/GLES2/README.md @@ -7,7 +7,8 @@ files for generic GLES2 implementations: .../flextGLgen.py -D . -t . extensions.txt -It will generate `flextGL.h` and `flextGL.cpp` files. +It will generate `flextGL.h`, `flextGL.cpp`, `flextGLPlatform.cpp` and +`flextGLPlatformIOS.cpp` files. NaCl and Emscripten don't have the ability to manually load extension pointers, thus they have only header files: diff --git a/src/MagnumExternal/OpenGL/GLES2/extensions.txt b/src/MagnumExternal/OpenGL/GLES2/extensions.txt index 7fdaedd20..9abbd3b66 100644 --- a/src/MagnumExternal/OpenGL/GLES2/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES2/extensions.txt @@ -51,12 +51,15 @@ extension OES_required_internalformat optional extension OES_surfaceless_context optional extension APPLE_texture_format_BGRA8888 optional +extension ARM_shader_framebuffer_fetch optional +extension ARM_shader_framebuffer_fetch_depth_stencil optional extension EXT_texture_filter_anisotropic optional extension EXT_texture_format_BGRA8888 optional extension EXT_read_format_bgra optional extension EXT_multi_draw_arrays optional extension EXT_debug_label optional extension EXT_debug_marker optional +extension EXT_shader_framebuffer_fetch optional extension EXT_disjoint_timer_query optional extension EXT_texture_sRGB_decode optional extension EXT_sRGB_write_control optional @@ -74,6 +77,7 @@ extension KHR_blend_equation_advanced_coherent optional extension KHR_robustness optional extension KHR_robust_buffer_access_behavior optional extension KHR_context_flush_control optional +extension KHR_no_error optional extension NV_read_buffer_front optional extension NV_read_depth optional extension NV_read_stencil optional diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGL.h b/src/MagnumExternal/OpenGL/GLES2/flextGL.h index b7162711e..606c85332 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGL.h +++ b/src/MagnumExternal/OpenGL/GLES2/flextGL.h @@ -720,6 +720,11 @@ typedef khronos_ssize_t GLsizeiptr; #define GL_BGRA_EXT 0x80E1 #define GL_BGRA8_EXT 0x93A1 +/* GL_ARM_shader_framebuffer_fetch */ + +#define GL_FETCH_PER_SAMPLE_ARM 0x8F65 +#define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66 + /* GL_EXT_texture_filter_anisotropic */ #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE @@ -746,6 +751,10 @@ typedef khronos_ssize_t GLsizeiptr; #define GL_SAMPLER 0x82E6 #define GL_TRANSFORM_FEEDBACK 0x8E22 +/* GL_EXT_shader_framebuffer_fetch */ + +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 + /* GL_EXT_disjoint_timer_query */ #define GL_QUERY_COUNTER_BITS_EXT 0x8864 @@ -981,6 +990,10 @@ typedef khronos_ssize_t GLsizeiptr; #define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC #define GL_NONE 0 +/* GL_KHR_no_error */ + +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 + /* GL_NV_texture_border_clamp */ #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp new file mode 100644 index 000000000..d94dd06d4 --- /dev/null +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp @@ -0,0 +1,419 @@ +#include "flextGL.h" + +#undef glBlitFramebufferANGLE +#undef glRenderbufferStorageMultisampleANGLE +#undef glDrawArraysInstancedANGLE +#undef glDrawElementsInstancedANGLE +#undef glVertexAttribDivisorANGLE +#undef glRenderbufferStorageMultisampleAPPLE +#undef glResolveMultisampleFramebufferAPPLE +#undef glGetObjectLabelEXT +#undef glLabelObjectEXT +#undef glInsertEventMarkerEXT +#undef glPopGroupMarkerEXT +#undef glPushGroupMarkerEXT +#undef glDiscardFramebufferEXT +#undef glGetQueryObjecti64vEXT +#undef glGetQueryObjectivEXT +#undef glGetQueryObjectui64vEXT +#undef glQueryCounterEXT +#undef glDrawBuffersEXT +#undef glBlendEquationSeparateiEXT +#undef glBlendEquationiEXT +#undef glBlendFuncSeparateiEXT +#undef glBlendFunciEXT +#undef glColorMaskiEXT +#undef glDisableiEXT +#undef glEnableiEXT +#undef glIsEnablediEXT +#undef glDrawArraysInstancedEXT +#undef glDrawElementsInstancedEXT +#undef glVertexAttribDivisorEXT +#undef glFlushMappedBufferRangeEXT +#undef glMapBufferRangeEXT +#undef glMultiDrawArraysEXT +#undef glMultiDrawElementsEXT +#undef glFramebufferTexture2DMultisampleEXT +#undef glRenderbufferStorageMultisampleEXT +#undef glBeginQueryEXT +#undef glDeleteQueriesEXT +#undef glEndQueryEXT +#undef glGenQueriesEXT +#undef glGetQueryObjectuivEXT +#undef glGetQueryivEXT +#undef glIsQueryEXT +#undef glGetGraphicsResetStatusEXT +#undef glGetnUniformfvEXT +#undef glGetnUniformivEXT +#undef glReadnPixelsEXT +#undef glActiveShaderProgramEXT +#undef glBindProgramPipelineEXT +#undef glCreateShaderProgramvEXT +#undef glDeleteProgramPipelinesEXT +#undef glGenProgramPipelinesEXT +#undef glGetProgramPipelineInfoLogEXT +#undef glGetProgramPipelineivEXT +#undef glIsProgramPipelineEXT +#undef glProgramParameteriEXT +#undef glProgramUniform1fEXT +#undef glProgramUniform1fvEXT +#undef glProgramUniform1iEXT +#undef glProgramUniform1ivEXT +#undef glProgramUniform1uiEXT +#undef glProgramUniform1uivEXT +#undef glProgramUniform2fEXT +#undef glProgramUniform2fvEXT +#undef glProgramUniform2iEXT +#undef glProgramUniform2ivEXT +#undef glProgramUniform2uiEXT +#undef glProgramUniform2uivEXT +#undef glProgramUniform3fEXT +#undef glProgramUniform3fvEXT +#undef glProgramUniform3iEXT +#undef glProgramUniform3ivEXT +#undef glProgramUniform3uiEXT +#undef glProgramUniform3uivEXT +#undef glProgramUniform4fEXT +#undef glProgramUniform4fvEXT +#undef glProgramUniform4iEXT +#undef glProgramUniform4ivEXT +#undef glProgramUniform4uiEXT +#undef glProgramUniform4uivEXT +#undef glProgramUniformMatrix2fvEXT +#undef glProgramUniformMatrix2x3fvEXT +#undef glProgramUniformMatrix2x4fvEXT +#undef glProgramUniformMatrix3fvEXT +#undef glProgramUniformMatrix3x2fvEXT +#undef glProgramUniformMatrix3x4fvEXT +#undef glProgramUniformMatrix4fvEXT +#undef glProgramUniformMatrix4x2fvEXT +#undef glProgramUniformMatrix4x3fvEXT +#undef glUseProgramStagesEXT +#undef glValidateProgramPipelineEXT +#undef glGetSamplerParameterIivEXT +#undef glGetSamplerParameterIuivEXT +#undef glGetTexParameterIivEXT +#undef glGetTexParameterIuivEXT +#undef glSamplerParameterIivEXT +#undef glSamplerParameterIuivEXT +#undef glTexParameterIivEXT +#undef glTexParameterIuivEXT +#undef glTexStorage1DEXT +#undef glTexStorage2DEXT +#undef glTexStorage3DEXT +#undef glTextureStorage1DEXT +#undef glTextureStorage2DEXT +#undef glTextureStorage3DEXT +#undef glBlendBarrierKHR +#undef glDebugMessageCallbackKHR +#undef glDebugMessageControlKHR +#undef glDebugMessageInsertKHR +#undef glGetDebugMessageLogKHR +#undef glGetObjectLabelKHR +#undef glGetObjectPtrLabelKHR +#undef glGetPointervKHR +#undef glObjectLabelKHR +#undef glObjectPtrLabelKHR +#undef glPopDebugGroupKHR +#undef glPushDebugGroupKHR +#undef glGetGraphicsResetStatusKHR +#undef glGetnUniformfvKHR +#undef glGetnUniformivKHR +#undef glGetnUniformuivKHR +#undef glReadnPixelsKHR +#undef glDrawBuffersNV +#undef glDrawArraysInstancedNV +#undef glDrawElementsInstancedNV +#undef glBlitFramebufferNV +#undef glRenderbufferStorageMultisampleNV +#undef glVertexAttribDivisorNV +#undef glPolygonModeNV +#undef glReadBufferNV +#undef glGetBufferPointervOES +#undef glMapBufferOES +#undef glUnmapBufferOES +#undef glCompressedTexImage3DOES +#undef glCompressedTexSubImage3DOES +#undef glCopyTexSubImage3DOES +#undef glFramebufferTexture3DOES +#undef glTexImage3DOES +#undef glTexSubImage3DOES +#undef glBindVertexArrayOES +#undef glDeleteVertexArraysOES +#undef glGenVertexArraysOES +#undef glIsVertexArrayOES + +#include + +void flextGLInit() { + + /* GL_ANGLE_framebuffer_blit */ + #if GL_ANGLE_framebuffer_blit + flextglBlitFramebufferANGLE = reinterpret_cast(glBlitFramebufferANGLE); + #endif + + /* GL_ANGLE_framebuffer_multisample */ + #if GL_ANGLE_framebuffer_multisample + flextglRenderbufferStorageMultisampleANGLE = reinterpret_cast(glRenderbufferStorageMultisampleANGLE); + #endif + + /* GL_ANGLE_instanced_arrays */ + #if GL_ANGLE_instanced_arrays + flextglDrawArraysInstancedANGLE = reinterpret_cast(glDrawArraysInstancedANGLE); + flextglDrawElementsInstancedANGLE = reinterpret_cast(glDrawElementsInstancedANGLE); + flextglVertexAttribDivisorANGLE = reinterpret_cast(glVertexAttribDivisorANGLE); + #endif + + /* GL_APPLE_framebuffer_multisample */ + #if GL_APPLE_framebuffer_multisample + flextglRenderbufferStorageMultisampleAPPLE = reinterpret_cast(glRenderbufferStorageMultisampleAPPLE); + flextglResolveMultisampleFramebufferAPPLE = reinterpret_cast(glResolveMultisampleFramebufferAPPLE); + #endif + + /* GL_EXT_debug_label */ + #if GL_EXT_debug_label + flextglGetObjectLabelEXT = reinterpret_cast(glGetObjectLabelEXT); + flextglLabelObjectEXT = reinterpret_cast(glLabelObjectEXT); + #endif + + /* GL_EXT_debug_marker */ + #if GL_EXT_debug_marker + flextglInsertEventMarkerEXT = reinterpret_cast(glInsertEventMarkerEXT); + flextglPopGroupMarkerEXT = reinterpret_cast(glPopGroupMarkerEXT); + flextglPushGroupMarkerEXT = reinterpret_cast(glPushGroupMarkerEXT); + #endif + + /* GL_EXT_discard_framebuffer */ + #if GL_EXT_discard_framebuffer + flextglDiscardFramebufferEXT = reinterpret_cast(glDiscardFramebufferEXT); + #endif + + /* GL_EXT_disjoint_timer_query */ + #if GL_EXT_disjoint_timer_query + flextglGetQueryObjecti64vEXT = reinterpret_cast(glGetQueryObjecti64vEXT); + flextglGetQueryObjectivEXT = reinterpret_cast(glGetQueryObjectivEXT); + flextglGetQueryObjectui64vEXT = reinterpret_cast(glGetQueryObjectui64vEXT); + flextglQueryCounterEXT = reinterpret_cast(glQueryCounterEXT); + #endif + + /* GL_EXT_draw_buffers */ + #if GL_EXT_draw_buffers + flextglDrawBuffersEXT = reinterpret_cast(glDrawBuffersEXT); + #endif + + /* GL_EXT_draw_buffers_indexed */ + #if GL_EXT_draw_buffers_indexed + flextglBlendEquationSeparateiEXT = reinterpret_cast(glBlendEquationSeparateiEXT); + flextglBlendEquationiEXT = reinterpret_cast(glBlendEquationiEXT); + flextglBlendFuncSeparateiEXT = reinterpret_cast(glBlendFuncSeparateiEXT); + flextglBlendFunciEXT = reinterpret_cast(glBlendFunciEXT); + flextglColorMaskiEXT = reinterpret_cast(glColorMaskiEXT); + flextglDisableiEXT = reinterpret_cast(glDisableiEXT); + flextglEnableiEXT = reinterpret_cast(glEnableiEXT); + flextglIsEnablediEXT = reinterpret_cast(glIsEnablediEXT); + #endif + + /* GL_EXT_instanced_arrays */ + #if GL_EXT_instanced_arrays + flextglDrawArraysInstancedEXT = reinterpret_cast(glDrawArraysInstancedEXT); + flextglDrawElementsInstancedEXT = reinterpret_cast(glDrawElementsInstancedEXT); + flextglVertexAttribDivisorEXT = reinterpret_cast(glVertexAttribDivisorEXT); + #endif + + /* GL_EXT_map_buffer_range */ + #if GL_EXT_map_buffer_range + flextglFlushMappedBufferRangeEXT = reinterpret_cast(glFlushMappedBufferRangeEXT); + flextglMapBufferRangeEXT = reinterpret_cast(glMapBufferRangeEXT); + #endif + + /* GL_EXT_multi_draw_arrays */ + #if GL_EXT_multi_draw_arrays + flextglMultiDrawArraysEXT = reinterpret_cast(glMultiDrawArraysEXT); + flextglMultiDrawElementsEXT = reinterpret_cast(glMultiDrawElementsEXT); + #endif + + /* GL_EXT_multisampled_render_to_texture */ + #if GL_EXT_multisampled_render_to_texture + flextglFramebufferTexture2DMultisampleEXT = reinterpret_cast(glFramebufferTexture2DMultisampleEXT); + flextglRenderbufferStorageMultisampleEXT = reinterpret_cast(glRenderbufferStorageMultisampleEXT); + #endif + + /* GL_EXT_occlusion_query_boolean */ + #if GL_EXT_occlusion_query_boolean + flextglBeginQueryEXT = reinterpret_cast(glBeginQueryEXT); + flextglDeleteQueriesEXT = reinterpret_cast(glDeleteQueriesEXT); + flextglEndQueryEXT = reinterpret_cast(glEndQueryEXT); + flextglGenQueriesEXT = reinterpret_cast(glGenQueriesEXT); + flextglGetQueryObjectuivEXT = reinterpret_cast(glGetQueryObjectuivEXT); + flextglGetQueryivEXT = reinterpret_cast(glGetQueryivEXT); + flextglIsQueryEXT = reinterpret_cast(glIsQueryEXT); + #endif + + /* GL_EXT_robustness */ + #if GL_EXT_robustness + flextglGetGraphicsResetStatusEXT = reinterpret_cast(glGetGraphicsResetStatusEXT); + flextglGetnUniformfvEXT = reinterpret_cast(glGetnUniformfvEXT); + flextglGetnUniformivEXT = reinterpret_cast(glGetnUniformivEXT); + flextglReadnPixelsEXT = reinterpret_cast(glReadnPixelsEXT); + #endif + + /* GL_EXT_separate_shader_objects */ + #if GL_EXT_separate_shader_objects + flextglActiveShaderProgramEXT = reinterpret_cast(glActiveShaderProgramEXT); + flextglBindProgramPipelineEXT = reinterpret_cast(glBindProgramPipelineEXT); + flextglCreateShaderProgramvEXT = reinterpret_cast(glCreateShaderProgramvEXT); + flextglDeleteProgramPipelinesEXT = reinterpret_cast(glDeleteProgramPipelinesEXT); + flextglGenProgramPipelinesEXT = reinterpret_cast(glGenProgramPipelinesEXT); + flextglGetProgramPipelineInfoLogEXT = reinterpret_cast(glGetProgramPipelineInfoLogEXT); + flextglGetProgramPipelineivEXT = reinterpret_cast(glGetProgramPipelineivEXT); + flextglIsProgramPipelineEXT = reinterpret_cast(glIsProgramPipelineEXT); + flextglProgramParameteriEXT = reinterpret_cast(glProgramParameteriEXT); + flextglProgramUniform1fEXT = reinterpret_cast(glProgramUniform1fEXT); + flextglProgramUniform1fvEXT = reinterpret_cast(glProgramUniform1fvEXT); + flextglProgramUniform1iEXT = reinterpret_cast(glProgramUniform1iEXT); + flextglProgramUniform1ivEXT = reinterpret_cast(glProgramUniform1ivEXT); + flextglProgramUniform1uiEXT = reinterpret_cast(glProgramUniform1uiEXT); + flextglProgramUniform1uivEXT = reinterpret_cast(glProgramUniform1uivEXT); + flextglProgramUniform2fEXT = reinterpret_cast(glProgramUniform2fEXT); + flextglProgramUniform2fvEXT = reinterpret_cast(glProgramUniform2fvEXT); + flextglProgramUniform2iEXT = reinterpret_cast(glProgramUniform2iEXT); + flextglProgramUniform2ivEXT = reinterpret_cast(glProgramUniform2ivEXT); + flextglProgramUniform2uiEXT = reinterpret_cast(glProgramUniform2uiEXT); + flextglProgramUniform2uivEXT = reinterpret_cast(glProgramUniform2uivEXT); + flextglProgramUniform3fEXT = reinterpret_cast(glProgramUniform3fEXT); + flextglProgramUniform3fvEXT = reinterpret_cast(glProgramUniform3fvEXT); + flextglProgramUniform3iEXT = reinterpret_cast(glProgramUniform3iEXT); + flextglProgramUniform3ivEXT = reinterpret_cast(glProgramUniform3ivEXT); + flextglProgramUniform3uiEXT = reinterpret_cast(glProgramUniform3uiEXT); + flextglProgramUniform3uivEXT = reinterpret_cast(glProgramUniform3uivEXT); + flextglProgramUniform4fEXT = reinterpret_cast(glProgramUniform4fEXT); + flextglProgramUniform4fvEXT = reinterpret_cast(glProgramUniform4fvEXT); + flextglProgramUniform4iEXT = reinterpret_cast(glProgramUniform4iEXT); + flextglProgramUniform4ivEXT = reinterpret_cast(glProgramUniform4ivEXT); + flextglProgramUniform4uiEXT = reinterpret_cast(glProgramUniform4uiEXT); + flextglProgramUniform4uivEXT = reinterpret_cast(glProgramUniform4uivEXT); + flextglProgramUniformMatrix2fvEXT = reinterpret_cast(glProgramUniformMatrix2fvEXT); + flextglProgramUniformMatrix2x3fvEXT = reinterpret_cast(glProgramUniformMatrix2x3fvEXT); + flextglProgramUniformMatrix2x4fvEXT = reinterpret_cast(glProgramUniformMatrix2x4fvEXT); + flextglProgramUniformMatrix3fvEXT = reinterpret_cast(glProgramUniformMatrix3fvEXT); + flextglProgramUniformMatrix3x2fvEXT = reinterpret_cast(glProgramUniformMatrix3x2fvEXT); + flextglProgramUniformMatrix3x4fvEXT = reinterpret_cast(glProgramUniformMatrix3x4fvEXT); + flextglProgramUniformMatrix4fvEXT = reinterpret_cast(glProgramUniformMatrix4fvEXT); + flextglProgramUniformMatrix4x2fvEXT = reinterpret_cast(glProgramUniformMatrix4x2fvEXT); + flextglProgramUniformMatrix4x3fvEXT = reinterpret_cast(glProgramUniformMatrix4x3fvEXT); + flextglUseProgramStagesEXT = reinterpret_cast(glUseProgramStagesEXT); + flextglValidateProgramPipelineEXT = reinterpret_cast(glValidateProgramPipelineEXT); + #endif + + /* GL_EXT_texture_border_clamp */ + #if GL_EXT_texture_border_clamp + flextglGetSamplerParameterIivEXT = reinterpret_cast(glGetSamplerParameterIivEXT); + flextglGetSamplerParameterIuivEXT = reinterpret_cast(glGetSamplerParameterIuivEXT); + flextglGetTexParameterIivEXT = reinterpret_cast(glGetTexParameterIivEXT); + flextglGetTexParameterIuivEXT = reinterpret_cast(glGetTexParameterIuivEXT); + flextglSamplerParameterIivEXT = reinterpret_cast(glSamplerParameterIivEXT); + flextglSamplerParameterIuivEXT = reinterpret_cast(glSamplerParameterIuivEXT); + flextglTexParameterIivEXT = reinterpret_cast(glTexParameterIivEXT); + flextglTexParameterIuivEXT = reinterpret_cast(glTexParameterIuivEXT); + #endif + + /* GL_EXT_texture_storage */ + #if GL_EXT_texture_storage + flextglTexStorage1DEXT = reinterpret_cast(glTexStorage1DEXT); + flextglTexStorage2DEXT = reinterpret_cast(glTexStorage2DEXT); + flextglTexStorage3DEXT = reinterpret_cast(glTexStorage3DEXT); + flextglTextureStorage1DEXT = reinterpret_cast(glTextureStorage1DEXT); + flextglTextureStorage2DEXT = reinterpret_cast(glTextureStorage2DEXT); + flextglTextureStorage3DEXT = reinterpret_cast(glTextureStorage3DEXT); + #endif + + /* GL_KHR_blend_equation_advanced */ + #if GL_KHR_blend_equation_advanced + flextglBlendBarrierKHR = reinterpret_cast(glBlendBarrierKHR); + #endif + + /* GL_KHR_debug */ + #if GL_KHR_debug + flextglDebugMessageCallbackKHR = reinterpret_cast(glDebugMessageCallbackKHR); + flextglDebugMessageControlKHR = reinterpret_cast(glDebugMessageControlKHR); + flextglDebugMessageInsertKHR = reinterpret_cast(glDebugMessageInsertKHR); + flextglGetDebugMessageLogKHR = reinterpret_cast(glGetDebugMessageLogKHR); + flextglGetObjectLabelKHR = reinterpret_cast(glGetObjectLabelKHR); + flextglGetObjectPtrLabelKHR = reinterpret_cast(glGetObjectPtrLabelKHR); + flextglGetPointervKHR = reinterpret_cast(glGetPointervKHR); + flextglObjectLabelKHR = reinterpret_cast(glObjectLabelKHR); + flextglObjectPtrLabelKHR = reinterpret_cast(glObjectPtrLabelKHR); + flextglPopDebugGroupKHR = reinterpret_cast(glPopDebugGroupKHR); + flextglPushDebugGroupKHR = reinterpret_cast(glPushDebugGroupKHR); + #endif + + /* GL_KHR_robustness */ + #if GL_KHR_robustness + flextglGetGraphicsResetStatusKHR = reinterpret_cast(glGetGraphicsResetStatusKHR); + flextglGetnUniformfvKHR = reinterpret_cast(glGetnUniformfvKHR); + flextglGetnUniformivKHR = reinterpret_cast(glGetnUniformivKHR); + flextglGetnUniformuivKHR = reinterpret_cast(glGetnUniformuivKHR); + flextglReadnPixelsKHR = reinterpret_cast(glReadnPixelsKHR); + #endif + + /* GL_NV_draw_buffers */ + #if GL_NV_draw_buffers + flextglDrawBuffersNV = reinterpret_cast(glDrawBuffersNV); + #endif + + /* GL_NV_draw_instanced */ + #if GL_NV_draw_instanced + flextglDrawArraysInstancedNV = reinterpret_cast(glDrawArraysInstancedNV); + flextglDrawElementsInstancedNV = reinterpret_cast(glDrawElementsInstancedNV); + #endif + + /* GL_NV_framebuffer_blit */ + #if GL_NV_framebuffer_blit + flextglBlitFramebufferNV = reinterpret_cast(glBlitFramebufferNV); + #endif + + /* GL_NV_framebuffer_multisample */ + #if GL_NV_framebuffer_multisample + flextglRenderbufferStorageMultisampleNV = reinterpret_cast(glRenderbufferStorageMultisampleNV); + #endif + + /* GL_NV_instanced_arrays */ + #if GL_NV_instanced_arrays + flextglVertexAttribDivisorNV = reinterpret_cast(glVertexAttribDivisorNV); + #endif + + /* GL_NV_polygon_mode */ + #if GL_NV_polygon_mode + flextglPolygonModeNV = reinterpret_cast(glPolygonModeNV); + #endif + + /* GL_NV_read_buffer */ + #if GL_NV_read_buffer + flextglReadBufferNV = reinterpret_cast(glReadBufferNV); + #endif + + /* GL_OES_mapbuffer */ + #if GL_OES_mapbuffer + flextglGetBufferPointervOES = reinterpret_cast(glGetBufferPointervOES); + flextglMapBufferOES = reinterpret_cast(glMapBufferOES); + flextglUnmapBufferOES = reinterpret_cast(glUnmapBufferOES); + #endif + + /* GL_OES_texture_3D */ + #if GL_OES_texture_3D + flextglCompressedTexImage3DOES = reinterpret_cast(glCompressedTexImage3DOES); + flextglCompressedTexSubImage3DOES = reinterpret_cast(glCompressedTexSubImage3DOES); + flextglCopyTexSubImage3DOES = reinterpret_cast(glCopyTexSubImage3DOES); + flextglFramebufferTexture3DOES = reinterpret_cast(glFramebufferTexture3DOES); + flextglTexImage3DOES = reinterpret_cast(glTexImage3DOES); + flextglTexSubImage3DOES = reinterpret_cast(glTexSubImage3DOES); + #endif + + /* GL_OES_vertex_array_object */ + #if GL_OES_vertex_array_object + flextglBindVertexArrayOES = reinterpret_cast(glBindVertexArrayOES); + flextglDeleteVertexArraysOES = reinterpret_cast(glDeleteVertexArraysOES); + flextglGenVertexArraysOES = reinterpret_cast(glGenVertexArraysOES); + flextglIsVertexArrayOES = reinterpret_cast(glIsVertexArrayOES); + #endif +} diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp.template b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp.template new file mode 100644 index 000000000..2d5982016 --- /dev/null +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatformIOS.cpp.template @@ -0,0 +1,27 @@ +@require(passthru, functions, enums, options, version, extensions) +#include "flextGL.h" + +@for category,funcs in functions: +@if funcs and category not in ['ES_VERSION_2_0']: +@for f in funcs: +#undef gl@f.name +@end +@end +@end + +#include + +void flextGLInit() { + @for category,funcs in functions: + @if funcs and category not in ['ES_VERSION_2_0']: + + /* GL_@category */ + #if GL_@category + @for f in funcs: + flextgl@f.name = reinterpret_cast<@f.returntype\ +(APIENTRY*)(@f.param_type_list_string())>(gl@f.name); + @end + #endif + @end + @end +} diff --git a/src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt b/src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt index 26f645a83..0cd6050e3 100644 --- a/src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt +++ b/src/MagnumExternal/OpenGL/GLES3/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -25,11 +25,10 @@ # flextGLPlatform.cpp is compiled as part of Magnum*Context libraries in Platform add_library(MagnumFlextGLObjects OBJECT flextGL.cpp) +target_include_directories(MagnumFlextGLObjects PUBLIC $) -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang") - set_target_properties(MagnumFlextGLObjects PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -DFlextGL_EXPORTS") -else() - set_target_properties(MagnumFlextGLObjects PROPERTIES COMPILE_FLAGS "-DFlextGL_EXPORTS") +if(NOT BUILD_STATIC) + target_compile_definitions(MagnumFlextGLObjects PRIVATE "FlextGL_EXPORTS") endif() if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumFlextGLObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/src/MagnumExternal/OpenGL/GLES3/README.md b/src/MagnumExternal/OpenGL/GLES3/README.md index 4ab311da7..680618870 100644 --- a/src/MagnumExternal/OpenGL/GLES3/README.md +++ b/src/MagnumExternal/OpenGL/GLES3/README.md @@ -6,7 +6,8 @@ Call `flextGLgen.py` in this directory with the following arguments: .../flextGLgen.py -D . -t . extensions.txt -It will generate `flextGL.h` and `flextGL.cpp` files. +It will generate `flextGL.h`, `flextGL.cpp`, `flextGLPlatform.cpp` and +`flextGLPlatformIOS.cpp` files. Emscripten doesn't have the ability to manually load extension pointers, thus it has only header files: diff --git a/src/MagnumExternal/OpenGL/GLES3/extensions.txt b/src/MagnumExternal/OpenGL/GLES3/extensions.txt index f07c7bb94..8b56b0b6a 100644 --- a/src/MagnumExternal/OpenGL/GLES3/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES3/extensions.txt @@ -4,12 +4,15 @@ version 3.1 es extension ANDROID_extension_pack_es31a optional extension APPLE_texture_format_BGRA8888 optional +extension ARM_shader_framebuffer_fetch optional +extension ARM_shader_framebuffer_fetch_depth_stencil optional extension EXT_texture_filter_anisotropic optional extension EXT_texture_format_BGRA8888 optional extension EXT_read_format_bgra optional extension EXT_multi_draw_arrays optional extension EXT_debug_label optional extension EXT_debug_marker optional +extension EXT_shader_framebuffer_fetch optional extension EXT_disjoint_timer_query optional extension EXT_texture_sRGB_decode optional extension EXT_sRGB_write_control optional @@ -36,6 +39,7 @@ extension KHR_blend_equation_advanced_coherent optional extension KHR_robustness optional extension KHR_robust_buffer_access_behavior optional extension KHR_context_flush_control optional +extension KHR_no_error optional extension NV_read_buffer_front optional extension NV_read_depth optional extension NV_read_stencil optional diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGL.h b/src/MagnumExternal/OpenGL/GLES3/flextGL.h index 53fc2d6a5..865dfd90c 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGL.h +++ b/src/MagnumExternal/OpenGL/GLES3/flextGL.h @@ -900,6 +900,11 @@ typedef khronos_ssize_t GLsizeiptr; #define GL_BGRA_EXT 0x80E1 #define GL_BGRA8_EXT 0x93A1 +/* GL_ARM_shader_framebuffer_fetch */ + +#define GL_FETCH_PER_SAMPLE_ARM 0x8F65 +#define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66 + /* GL_EXT_texture_filter_anisotropic */ #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE @@ -926,6 +931,10 @@ typedef khronos_ssize_t GLsizeiptr; #define GL_SAMPLER 0x82E6 #define GL_TRANSFORM_FEEDBACK 0x8E22 +/* GL_EXT_shader_framebuffer_fetch */ + +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 + /* GL_EXT_disjoint_timer_query */ #define GL_QUERY_COUNTER_BITS_EXT 0x8864 @@ -1280,6 +1289,10 @@ typedef khronos_ssize_t GLsizeiptr; #define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC #define GL_NONE 0 +/* GL_KHR_no_error */ + +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 + /* GL_NV_texture_border_clamp */ #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp new file mode 100644 index 000000000..ae8d7f1dd --- /dev/null +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp @@ -0,0 +1,457 @@ +#include "flextGL.h" + +#undef glActiveShaderProgram +#undef glBindImageTexture +#undef glBindProgramPipeline +#undef glBindVertexBuffer +#undef glCreateShaderProgramv +#undef glDeleteProgramPipelines +#undef glDispatchCompute +#undef glDispatchComputeIndirect +#undef glDrawArraysIndirect +#undef glDrawElementsIndirect +#undef glFramebufferParameteri +#undef glGenProgramPipelines +#undef glGetBooleani_v +#undef glGetFramebufferParameteriv +#undef glGetMultisamplefv +#undef glGetProgramInterfaceiv +#undef glGetProgramPipelineInfoLog +#undef glGetProgramPipelineiv +#undef glGetProgramResourceIndex +#undef glGetProgramResourceLocation +#undef glGetProgramResourceName +#undef glGetProgramResourceiv +#undef glGetTexLevelParameterfv +#undef glGetTexLevelParameteriv +#undef glIsProgramPipeline +#undef glMemoryBarrier +#undef glMemoryBarrierByRegion +#undef glProgramUniform1f +#undef glProgramUniform1fv +#undef glProgramUniform1i +#undef glProgramUniform1iv +#undef glProgramUniform1ui +#undef glProgramUniform1uiv +#undef glProgramUniform2f +#undef glProgramUniform2fv +#undef glProgramUniform2i +#undef glProgramUniform2iv +#undef glProgramUniform2ui +#undef glProgramUniform2uiv +#undef glProgramUniform3f +#undef glProgramUniform3fv +#undef glProgramUniform3i +#undef glProgramUniform3iv +#undef glProgramUniform3ui +#undef glProgramUniform3uiv +#undef glProgramUniform4f +#undef glProgramUniform4fv +#undef glProgramUniform4i +#undef glProgramUniform4iv +#undef glProgramUniform4ui +#undef glProgramUniform4uiv +#undef glProgramUniformMatrix2fv +#undef glProgramUniformMatrix2x3fv +#undef glProgramUniformMatrix2x4fv +#undef glProgramUniformMatrix3fv +#undef glProgramUniformMatrix3x2fv +#undef glProgramUniformMatrix3x4fv +#undef glProgramUniformMatrix4fv +#undef glProgramUniformMatrix4x2fv +#undef glProgramUniformMatrix4x3fv +#undef glSampleMaski +#undef glTexStorage2DMultisample +#undef glUseProgramStages +#undef glValidateProgramPipeline +#undef glVertexAttribBinding +#undef glVertexAttribFormat +#undef glVertexAttribIFormat +#undef glVertexBindingDivisor +#undef glCopyImageSubDataEXT +#undef glGetObjectLabelEXT +#undef glLabelObjectEXT +#undef glInsertEventMarkerEXT +#undef glPopGroupMarkerEXT +#undef glPushGroupMarkerEXT +#undef glBeginQueryEXT +#undef glDeleteQueriesEXT +#undef glEndQueryEXT +#undef glGenQueriesEXT +#undef glGetQueryObjecti64vEXT +#undef glGetQueryObjectivEXT +#undef glGetQueryObjectui64vEXT +#undef glGetQueryObjectuivEXT +#undef glGetQueryivEXT +#undef glIsQueryEXT +#undef glQueryCounterEXT +#undef glBlendEquationSeparateiEXT +#undef glBlendEquationiEXT +#undef glBlendFuncSeparateiEXT +#undef glBlendFunciEXT +#undef glColorMaskiEXT +#undef glDisableiEXT +#undef glEnableiEXT +#undef glIsEnablediEXT +#undef glFramebufferTextureEXT +#undef glMultiDrawArraysEXT +#undef glMultiDrawElementsEXT +#undef glFramebufferTexture2DMultisampleEXT +#undef glRenderbufferStorageMultisampleEXT +#undef glPrimitiveBoundingBoxEXT +#undef glGetGraphicsResetStatusEXT +#undef glGetnUniformfvEXT +#undef glGetnUniformivEXT +#undef glReadnPixelsEXT +#undef glActiveShaderProgramEXT +#undef glBindProgramPipelineEXT +#undef glCreateShaderProgramvEXT +#undef glDeleteProgramPipelinesEXT +#undef glGenProgramPipelinesEXT +#undef glGetProgramPipelineInfoLogEXT +#undef glGetProgramPipelineivEXT +#undef glIsProgramPipelineEXT +#undef glProgramParameteriEXT +#undef glProgramUniform1fEXT +#undef glProgramUniform1fvEXT +#undef glProgramUniform1iEXT +#undef glProgramUniform1ivEXT +#undef glProgramUniform1uiEXT +#undef glProgramUniform1uivEXT +#undef glProgramUniform2fEXT +#undef glProgramUniform2fvEXT +#undef glProgramUniform2iEXT +#undef glProgramUniform2ivEXT +#undef glProgramUniform2uiEXT +#undef glProgramUniform2uivEXT +#undef glProgramUniform3fEXT +#undef glProgramUniform3fvEXT +#undef glProgramUniform3iEXT +#undef glProgramUniform3ivEXT +#undef glProgramUniform3uiEXT +#undef glProgramUniform3uivEXT +#undef glProgramUniform4fEXT +#undef glProgramUniform4fvEXT +#undef glProgramUniform4iEXT +#undef glProgramUniform4ivEXT +#undef glProgramUniform4uiEXT +#undef glProgramUniform4uivEXT +#undef glProgramUniformMatrix2fvEXT +#undef glProgramUniformMatrix2x3fvEXT +#undef glProgramUniformMatrix2x4fvEXT +#undef glProgramUniformMatrix3fvEXT +#undef glProgramUniformMatrix3x2fvEXT +#undef glProgramUniformMatrix3x4fvEXT +#undef glProgramUniformMatrix4fvEXT +#undef glProgramUniformMatrix4x2fvEXT +#undef glProgramUniformMatrix4x3fvEXT +#undef glUseProgramStagesEXT +#undef glValidateProgramPipelineEXT +#undef glPatchParameteriEXT +#undef glGetSamplerParameterIivEXT +#undef glGetSamplerParameterIuivEXT +#undef glGetTexParameterIivEXT +#undef glGetTexParameterIuivEXT +#undef glSamplerParameterIivEXT +#undef glSamplerParameterIuivEXT +#undef glTexParameterIivEXT +#undef glTexParameterIuivEXT +#undef glTexBufferEXT +#undef glTexBufferRangeEXT +#undef glBlendBarrierKHR +#undef glDebugMessageCallbackKHR +#undef glDebugMessageControlKHR +#undef glDebugMessageInsertKHR +#undef glGetDebugMessageLogKHR +#undef glGetObjectLabelKHR +#undef glGetObjectPtrLabelKHR +#undef glGetPointervKHR +#undef glObjectLabelKHR +#undef glObjectPtrLabelKHR +#undef glPopDebugGroupKHR +#undef glPushDebugGroupKHR +#undef glGetGraphicsResetStatusKHR +#undef glGetnUniformfvKHR +#undef glGetnUniformivKHR +#undef glGetnUniformuivKHR +#undef glReadnPixelsKHR +#undef glPolygonModeNV +#undef glGetBufferPointervOES +#undef glMapBufferOES +#undef glUnmapBufferOES +#undef glMinSampleShadingOES +#undef glTexStorage3DMultisampleOES + +#include + +void flextGLInit() { + + /* GL_ES_VERSION_3_1 */ + #if GL_ES_VERSION_3_1 + flextglActiveShaderProgram = reinterpret_cast(glActiveShaderProgram); + flextglBindImageTexture = reinterpret_cast(glBindImageTexture); + flextglBindProgramPipeline = reinterpret_cast(glBindProgramPipeline); + flextglBindVertexBuffer = reinterpret_cast(glBindVertexBuffer); + flextglCreateShaderProgramv = reinterpret_cast(glCreateShaderProgramv); + flextglDeleteProgramPipelines = reinterpret_cast(glDeleteProgramPipelines); + flextglDispatchCompute = reinterpret_cast(glDispatchCompute); + flextglDispatchComputeIndirect = reinterpret_cast(glDispatchComputeIndirect); + flextglDrawArraysIndirect = reinterpret_cast(glDrawArraysIndirect); + flextglDrawElementsIndirect = reinterpret_cast(glDrawElementsIndirect); + flextglFramebufferParameteri = reinterpret_cast(glFramebufferParameteri); + flextglGenProgramPipelines = reinterpret_cast(glGenProgramPipelines); + flextglGetBooleani_v = reinterpret_cast(glGetBooleani_v); + flextglGetFramebufferParameteriv = reinterpret_cast(glGetFramebufferParameteriv); + flextglGetMultisamplefv = reinterpret_cast(glGetMultisamplefv); + flextglGetProgramInterfaceiv = reinterpret_cast(glGetProgramInterfaceiv); + flextglGetProgramPipelineInfoLog = reinterpret_cast(glGetProgramPipelineInfoLog); + flextglGetProgramPipelineiv = reinterpret_cast(glGetProgramPipelineiv); + flextglGetProgramResourceIndex = reinterpret_cast(glGetProgramResourceIndex); + flextglGetProgramResourceLocation = reinterpret_cast(glGetProgramResourceLocation); + flextglGetProgramResourceName = reinterpret_cast(glGetProgramResourceName); + flextglGetProgramResourceiv = reinterpret_cast(glGetProgramResourceiv); + flextglGetTexLevelParameterfv = reinterpret_cast(glGetTexLevelParameterfv); + flextglGetTexLevelParameteriv = reinterpret_cast(glGetTexLevelParameteriv); + flextglIsProgramPipeline = reinterpret_cast(glIsProgramPipeline); + flextglMemoryBarrier = reinterpret_cast(glMemoryBarrier); + flextglMemoryBarrierByRegion = reinterpret_cast(glMemoryBarrierByRegion); + flextglProgramUniform1f = reinterpret_cast(glProgramUniform1f); + flextglProgramUniform1fv = reinterpret_cast(glProgramUniform1fv); + flextglProgramUniform1i = reinterpret_cast(glProgramUniform1i); + flextglProgramUniform1iv = reinterpret_cast(glProgramUniform1iv); + flextglProgramUniform1ui = reinterpret_cast(glProgramUniform1ui); + flextglProgramUniform1uiv = reinterpret_cast(glProgramUniform1uiv); + flextglProgramUniform2f = reinterpret_cast(glProgramUniform2f); + flextglProgramUniform2fv = reinterpret_cast(glProgramUniform2fv); + flextglProgramUniform2i = reinterpret_cast(glProgramUniform2i); + flextglProgramUniform2iv = reinterpret_cast(glProgramUniform2iv); + flextglProgramUniform2ui = reinterpret_cast(glProgramUniform2ui); + flextglProgramUniform2uiv = reinterpret_cast(glProgramUniform2uiv); + flextglProgramUniform3f = reinterpret_cast(glProgramUniform3f); + flextglProgramUniform3fv = reinterpret_cast(glProgramUniform3fv); + flextglProgramUniform3i = reinterpret_cast(glProgramUniform3i); + flextglProgramUniform3iv = reinterpret_cast(glProgramUniform3iv); + flextglProgramUniform3ui = reinterpret_cast(glProgramUniform3ui); + flextglProgramUniform3uiv = reinterpret_cast(glProgramUniform3uiv); + flextglProgramUniform4f = reinterpret_cast(glProgramUniform4f); + flextglProgramUniform4fv = reinterpret_cast(glProgramUniform4fv); + flextglProgramUniform4i = reinterpret_cast(glProgramUniform4i); + flextglProgramUniform4iv = reinterpret_cast(glProgramUniform4iv); + flextglProgramUniform4ui = reinterpret_cast(glProgramUniform4ui); + flextglProgramUniform4uiv = reinterpret_cast(glProgramUniform4uiv); + flextglProgramUniformMatrix2fv = reinterpret_cast(glProgramUniformMatrix2fv); + flextglProgramUniformMatrix2x3fv = reinterpret_cast(glProgramUniformMatrix2x3fv); + flextglProgramUniformMatrix2x4fv = reinterpret_cast(glProgramUniformMatrix2x4fv); + flextglProgramUniformMatrix3fv = reinterpret_cast(glProgramUniformMatrix3fv); + flextglProgramUniformMatrix3x2fv = reinterpret_cast(glProgramUniformMatrix3x2fv); + flextglProgramUniformMatrix3x4fv = reinterpret_cast(glProgramUniformMatrix3x4fv); + flextglProgramUniformMatrix4fv = reinterpret_cast(glProgramUniformMatrix4fv); + flextglProgramUniformMatrix4x2fv = reinterpret_cast(glProgramUniformMatrix4x2fv); + flextglProgramUniformMatrix4x3fv = reinterpret_cast(glProgramUniformMatrix4x3fv); + flextglSampleMaski = reinterpret_cast(glSampleMaski); + flextglTexStorage2DMultisample = reinterpret_cast(glTexStorage2DMultisample); + flextglUseProgramStages = reinterpret_cast(glUseProgramStages); + flextglValidateProgramPipeline = reinterpret_cast(glValidateProgramPipeline); + flextglVertexAttribBinding = reinterpret_cast(glVertexAttribBinding); + flextglVertexAttribFormat = reinterpret_cast(glVertexAttribFormat); + flextglVertexAttribIFormat = reinterpret_cast(glVertexAttribIFormat); + flextglVertexBindingDivisor = reinterpret_cast(glVertexBindingDivisor); + #endif + + /* GL_EXT_copy_image */ + #if GL_EXT_copy_image + flextglCopyImageSubDataEXT = reinterpret_cast(glCopyImageSubDataEXT); + #endif + + /* GL_EXT_debug_label */ + #if GL_EXT_debug_label + flextglGetObjectLabelEXT = reinterpret_cast(glGetObjectLabelEXT); + flextglLabelObjectEXT = reinterpret_cast(glLabelObjectEXT); + #endif + + /* GL_EXT_debug_marker */ + #if GL_EXT_debug_marker + flextglInsertEventMarkerEXT = reinterpret_cast(glInsertEventMarkerEXT); + flextglPopGroupMarkerEXT = reinterpret_cast(glPopGroupMarkerEXT); + flextglPushGroupMarkerEXT = reinterpret_cast(glPushGroupMarkerEXT); + #endif + + /* GL_EXT_disjoint_timer_query */ + #if GL_EXT_disjoint_timer_query + flextglBeginQueryEXT = reinterpret_cast(glBeginQueryEXT); + flextglDeleteQueriesEXT = reinterpret_cast(glDeleteQueriesEXT); + flextglEndQueryEXT = reinterpret_cast(glEndQueryEXT); + flextglGenQueriesEXT = reinterpret_cast(glGenQueriesEXT); + flextglGetQueryObjecti64vEXT = reinterpret_cast(glGetQueryObjecti64vEXT); + flextglGetQueryObjectivEXT = reinterpret_cast(glGetQueryObjectivEXT); + flextglGetQueryObjectui64vEXT = reinterpret_cast(glGetQueryObjectui64vEXT); + flextglGetQueryObjectuivEXT = reinterpret_cast(glGetQueryObjectuivEXT); + flextglGetQueryivEXT = reinterpret_cast(glGetQueryivEXT); + flextglIsQueryEXT = reinterpret_cast(glIsQueryEXT); + flextglQueryCounterEXT = reinterpret_cast(glQueryCounterEXT); + #endif + + /* GL_EXT_draw_buffers_indexed */ + #if GL_EXT_draw_buffers_indexed + flextglBlendEquationSeparateiEXT = reinterpret_cast(glBlendEquationSeparateiEXT); + flextglBlendEquationiEXT = reinterpret_cast(glBlendEquationiEXT); + flextglBlendFuncSeparateiEXT = reinterpret_cast(glBlendFuncSeparateiEXT); + flextglBlendFunciEXT = reinterpret_cast(glBlendFunciEXT); + flextglColorMaskiEXT = reinterpret_cast(glColorMaskiEXT); + flextglDisableiEXT = reinterpret_cast(glDisableiEXT); + flextglEnableiEXT = reinterpret_cast(glEnableiEXT); + flextglIsEnablediEXT = reinterpret_cast(glIsEnablediEXT); + #endif + + /* GL_EXT_geometry_shader */ + #if GL_EXT_geometry_shader + flextglFramebufferTextureEXT = reinterpret_cast(glFramebufferTextureEXT); + #endif + + /* GL_EXT_multi_draw_arrays */ + #if GL_EXT_multi_draw_arrays + flextglMultiDrawArraysEXT = reinterpret_cast(glMultiDrawArraysEXT); + flextglMultiDrawElementsEXT = reinterpret_cast(glMultiDrawElementsEXT); + #endif + + /* GL_EXT_multisampled_render_to_texture */ + #if GL_EXT_multisampled_render_to_texture + flextglFramebufferTexture2DMultisampleEXT = reinterpret_cast(glFramebufferTexture2DMultisampleEXT); + flextglRenderbufferStorageMultisampleEXT = reinterpret_cast(glRenderbufferStorageMultisampleEXT); + #endif + + /* GL_EXT_primitive_bounding_box */ + #if GL_EXT_primitive_bounding_box + flextglPrimitiveBoundingBoxEXT = reinterpret_cast(glPrimitiveBoundingBoxEXT); + #endif + + /* GL_EXT_robustness */ + #if GL_EXT_robustness + flextglGetGraphicsResetStatusEXT = reinterpret_cast(glGetGraphicsResetStatusEXT); + flextglGetnUniformfvEXT = reinterpret_cast(glGetnUniformfvEXT); + flextglGetnUniformivEXT = reinterpret_cast(glGetnUniformivEXT); + flextglReadnPixelsEXT = reinterpret_cast(glReadnPixelsEXT); + #endif + + /* GL_EXT_separate_shader_objects */ + #if GL_EXT_separate_shader_objects + flextglActiveShaderProgramEXT = reinterpret_cast(glActiveShaderProgramEXT); + flextglBindProgramPipelineEXT = reinterpret_cast(glBindProgramPipelineEXT); + flextglCreateShaderProgramvEXT = reinterpret_cast(glCreateShaderProgramvEXT); + flextglDeleteProgramPipelinesEXT = reinterpret_cast(glDeleteProgramPipelinesEXT); + flextglGenProgramPipelinesEXT = reinterpret_cast(glGenProgramPipelinesEXT); + flextglGetProgramPipelineInfoLogEXT = reinterpret_cast(glGetProgramPipelineInfoLogEXT); + flextglGetProgramPipelineivEXT = reinterpret_cast(glGetProgramPipelineivEXT); + flextglIsProgramPipelineEXT = reinterpret_cast(glIsProgramPipelineEXT); + flextglProgramParameteriEXT = reinterpret_cast(glProgramParameteriEXT); + flextglProgramUniform1fEXT = reinterpret_cast(glProgramUniform1fEXT); + flextglProgramUniform1fvEXT = reinterpret_cast(glProgramUniform1fvEXT); + flextglProgramUniform1iEXT = reinterpret_cast(glProgramUniform1iEXT); + flextglProgramUniform1ivEXT = reinterpret_cast(glProgramUniform1ivEXT); + flextglProgramUniform1uiEXT = reinterpret_cast(glProgramUniform1uiEXT); + flextglProgramUniform1uivEXT = reinterpret_cast(glProgramUniform1uivEXT); + flextglProgramUniform2fEXT = reinterpret_cast(glProgramUniform2fEXT); + flextglProgramUniform2fvEXT = reinterpret_cast(glProgramUniform2fvEXT); + flextglProgramUniform2iEXT = reinterpret_cast(glProgramUniform2iEXT); + flextglProgramUniform2ivEXT = reinterpret_cast(glProgramUniform2ivEXT); + flextglProgramUniform2uiEXT = reinterpret_cast(glProgramUniform2uiEXT); + flextglProgramUniform2uivEXT = reinterpret_cast(glProgramUniform2uivEXT); + flextglProgramUniform3fEXT = reinterpret_cast(glProgramUniform3fEXT); + flextglProgramUniform3fvEXT = reinterpret_cast(glProgramUniform3fvEXT); + flextglProgramUniform3iEXT = reinterpret_cast(glProgramUniform3iEXT); + flextglProgramUniform3ivEXT = reinterpret_cast(glProgramUniform3ivEXT); + flextglProgramUniform3uiEXT = reinterpret_cast(glProgramUniform3uiEXT); + flextglProgramUniform3uivEXT = reinterpret_cast(glProgramUniform3uivEXT); + flextglProgramUniform4fEXT = reinterpret_cast(glProgramUniform4fEXT); + flextglProgramUniform4fvEXT = reinterpret_cast(glProgramUniform4fvEXT); + flextglProgramUniform4iEXT = reinterpret_cast(glProgramUniform4iEXT); + flextglProgramUniform4ivEXT = reinterpret_cast(glProgramUniform4ivEXT); + flextglProgramUniform4uiEXT = reinterpret_cast(glProgramUniform4uiEXT); + flextglProgramUniform4uivEXT = reinterpret_cast(glProgramUniform4uivEXT); + flextglProgramUniformMatrix2fvEXT = reinterpret_cast(glProgramUniformMatrix2fvEXT); + flextglProgramUniformMatrix2x3fvEXT = reinterpret_cast(glProgramUniformMatrix2x3fvEXT); + flextglProgramUniformMatrix2x4fvEXT = reinterpret_cast(glProgramUniformMatrix2x4fvEXT); + flextglProgramUniformMatrix3fvEXT = reinterpret_cast(glProgramUniformMatrix3fvEXT); + flextglProgramUniformMatrix3x2fvEXT = reinterpret_cast(glProgramUniformMatrix3x2fvEXT); + flextglProgramUniformMatrix3x4fvEXT = reinterpret_cast(glProgramUniformMatrix3x4fvEXT); + flextglProgramUniformMatrix4fvEXT = reinterpret_cast(glProgramUniformMatrix4fvEXT); + flextglProgramUniformMatrix4x2fvEXT = reinterpret_cast(glProgramUniformMatrix4x2fvEXT); + flextglProgramUniformMatrix4x3fvEXT = reinterpret_cast(glProgramUniformMatrix4x3fvEXT); + flextglUseProgramStagesEXT = reinterpret_cast(glUseProgramStagesEXT); + flextglValidateProgramPipelineEXT = reinterpret_cast(glValidateProgramPipelineEXT); + #endif + + /* GL_EXT_tessellation_shader */ + #if GL_EXT_tessellation_shader + flextglPatchParameteriEXT = reinterpret_cast(glPatchParameteriEXT); + #endif + + /* GL_EXT_texture_border_clamp */ + #if GL_EXT_texture_border_clamp + flextglGetSamplerParameterIivEXT = reinterpret_cast(glGetSamplerParameterIivEXT); + flextglGetSamplerParameterIuivEXT = reinterpret_cast(glGetSamplerParameterIuivEXT); + flextglGetTexParameterIivEXT = reinterpret_cast(glGetTexParameterIivEXT); + flextglGetTexParameterIuivEXT = reinterpret_cast(glGetTexParameterIuivEXT); + flextglSamplerParameterIivEXT = reinterpret_cast(glSamplerParameterIivEXT); + flextglSamplerParameterIuivEXT = reinterpret_cast(glSamplerParameterIuivEXT); + flextglTexParameterIivEXT = reinterpret_cast(glTexParameterIivEXT); + flextglTexParameterIuivEXT = reinterpret_cast(glTexParameterIuivEXT); + #endif + + /* GL_EXT_texture_buffer */ + #if GL_EXT_texture_buffer + flextglTexBufferEXT = reinterpret_cast(glTexBufferEXT); + flextglTexBufferRangeEXT = reinterpret_cast(glTexBufferRangeEXT); + #endif + + /* GL_KHR_blend_equation_advanced */ + #if GL_KHR_blend_equation_advanced + flextglBlendBarrierKHR = reinterpret_cast(glBlendBarrierKHR); + #endif + + /* GL_KHR_debug */ + #if GL_KHR_debug + flextglDebugMessageCallbackKHR = reinterpret_cast(glDebugMessageCallbackKHR); + flextglDebugMessageControlKHR = reinterpret_cast(glDebugMessageControlKHR); + flextglDebugMessageInsertKHR = reinterpret_cast(glDebugMessageInsertKHR); + flextglGetDebugMessageLogKHR = reinterpret_cast(glGetDebugMessageLogKHR); + flextglGetObjectLabelKHR = reinterpret_cast(glGetObjectLabelKHR); + flextglGetObjectPtrLabelKHR = reinterpret_cast(glGetObjectPtrLabelKHR); + flextglGetPointervKHR = reinterpret_cast(glGetPointervKHR); + flextglObjectLabelKHR = reinterpret_cast(glObjectLabelKHR); + flextglObjectPtrLabelKHR = reinterpret_cast(glObjectPtrLabelKHR); + flextglPopDebugGroupKHR = reinterpret_cast(glPopDebugGroupKHR); + flextglPushDebugGroupKHR = reinterpret_cast(glPushDebugGroupKHR); + #endif + + /* GL_KHR_robustness */ + #if GL_KHR_robustness + flextglGetGraphicsResetStatusKHR = reinterpret_cast(glGetGraphicsResetStatusKHR); + flextglGetnUniformfvKHR = reinterpret_cast(glGetnUniformfvKHR); + flextglGetnUniformivKHR = reinterpret_cast(glGetnUniformivKHR); + flextglGetnUniformuivKHR = reinterpret_cast(glGetnUniformuivKHR); + flextglReadnPixelsKHR = reinterpret_cast(glReadnPixelsKHR); + #endif + + /* GL_NV_polygon_mode */ + #if GL_NV_polygon_mode + flextglPolygonModeNV = reinterpret_cast(glPolygonModeNV); + #endif + + /* GL_OES_mapbuffer */ + #if GL_OES_mapbuffer + flextglGetBufferPointervOES = reinterpret_cast(glGetBufferPointervOES); + flextglMapBufferOES = reinterpret_cast(glMapBufferOES); + flextglUnmapBufferOES = reinterpret_cast(glUnmapBufferOES); + #endif + + /* GL_OES_sample_shading */ + #if GL_OES_sample_shading + flextglMinSampleShadingOES = reinterpret_cast(glMinSampleShadingOES); + #endif + + /* GL_OES_texture_storage_multisample_2d_array */ + #if GL_OES_texture_storage_multisample_2d_array + flextglTexStorage3DMultisampleOES = reinterpret_cast(glTexStorage3DMultisampleOES); + #endif +} diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp.template b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp.template new file mode 100644 index 000000000..98a29513b --- /dev/null +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatformIOS.cpp.template @@ -0,0 +1,27 @@ +@require(passthru, functions, enums, options, version, extensions) +#include "flextGL.h" + +@for category,funcs in functions: +@if funcs and category not in ['ES_VERSION_2_0', 'ES_VERSION_3_0']: +@for f in funcs: +#undef gl@f.name +@end +@end +@end + +#include + +void flextGLInit() { + @for category,funcs in functions: + @if funcs and category not in ['ES_VERSION_2_0', 'ES_VERSION_3_0']: + + /* GL_@category */ + #if GL_@category + @for f in funcs: + flextgl@f.name = reinterpret_cast<@f.returntype\ +(APIENTRY*)(@f.param_type_list_string())>(gl@f.name); + @end + #endif + @end + @end +} diff --git a/src/MagnumExternal/OpenGL/KHR/CMakeLists.txt b/src/MagnumExternal/OpenGL/KHR/CMakeLists.txt index d4c06d3c7..b237f4be6 100644 --- a/src/MagnumExternal/OpenGL/KHR/CMakeLists.txt +++ b/src/MagnumExternal/OpenGL/KHR/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumExternal/Optional/CMakeLists.txt b/src/MagnumExternal/Optional/CMakeLists.txt index c92bd42e0..06c3b1955 100644 --- a/src/MagnumExternal/Optional/CMakeLists.txt +++ b/src/MagnumExternal/Optional/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/CMakeLists.txt b/src/MagnumPlugins/CMakeLists.txt index c5c617fc3..13b85f2f9 100644 --- a/src/MagnumPlugins/CMakeLists.txt +++ b/src/MagnumPlugins/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/MagnumFont/CMakeLists.txt b/src/MagnumPlugins/MagnumFont/CMakeLists.txt index bd367aef3..a5cab2251 100644 --- a/src/MagnumPlugins/MagnumFont/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFont/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -33,6 +33,7 @@ set(MagnumFont_HEADERS add_library(MagnumFontObjects OBJECT ${MagnumFont_SRCS} ${MagnumFont_HEADERS}) +target_include_directories(MagnumFontObjects PUBLIC $) if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumFontObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -62,7 +63,7 @@ if(BUILD_GL_TESTS) add_library(MagnumMagnumFontTestLib STATIC ${MagnumFont_SRCS} ${MagnumFont_HEADERS}) - set_target_properties(MagnumMagnumFontTestLib PROPERTIES COMPILE_FLAGS "-DMAGNUM_TGAIMPORTER_BUILD_STATIC") + target_compile_definitions(MagnumMagnumFontTestLib PRIVATE "MAGNUM_TGAIMPORTER_BUILD_STATIC") else() add_library(MagnumMagnumFontTestLib STATIC $) endif() @@ -71,5 +72,5 @@ if(BUILD_GL_TESTS) add_subdirectory(Test) endif() -# Magnum MagnumFont library for superprojects -set(MAGNUM_MAGNUMFONT_LIBRARY MagnumFont CACHE INTERNAL "") +# Magnum MagnumFont target alias for superprojects +add_library(Magnum::MagnumFont ALIAS MagnumFont) diff --git a/src/MagnumPlugins/MagnumFont/MagnumFont.cpp b/src/MagnumPlugins/MagnumFont/MagnumFont.cpp index 2295cbd00..6f1bb04e1 100644 --- a/src/MagnumPlugins/MagnumFont/MagnumFont.cpp +++ b/src/MagnumPlugins/MagnumFont/MagnumFont.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -68,7 +68,7 @@ auto MagnumFont::doFeatures() const -> Features { return Feature::OpenData|Featu bool MagnumFont::doIsOpened() const { return _opened; } -std::pair MagnumFont::doOpenData(const std::vector>>& data, const Float) { +auto MagnumFont::doOpenData(const std::vector>>& data, const Float) -> Metrics { /* We need just the configuration file and image file */ if(data.size() != 2) { Error() << "Text::MagnumFont::openData(): wanted two files, got" << data.size(); @@ -112,7 +112,7 @@ std::pair MagnumFont::doOpenData(const std::vector MagnumFont::doOpenFile(const std::string& filename, Float) { +auto MagnumFont::doOpenFile(const std::string& filename, Float) -> Metrics { /* Open the configuration file */ Utility::Configuration conf(filename, Utility::Configuration::Flag::ReadOnly|Utility::Configuration::Flag::SkipComments); if(!conf.isValid() || conf.isEmpty()) { @@ -143,7 +143,7 @@ std::pair MagnumFont::doOpenFile(const std::string& filename, Floa return openInternal(std::move(conf), std::move(*image)); } -std::pair MagnumFont::openInternal(Utility::Configuration&& conf, Trade::ImageData2D&& image) { +auto MagnumFont::openInternal(Utility::Configuration&& conf, Trade::ImageData2D&& image) -> Metrics { /* Everything okay, save the data internally */ _opened = new Data{std::move(conf), std::move(image), std::unordered_map{}, {}}; @@ -161,7 +161,10 @@ std::pair MagnumFont::openInternal(Utility::Configuration&& conf, _opened->glyphId.emplace(c->value("unicode"), glyphId); } - return {_opened->conf.value("fontSize"), _opened->conf.value("lineHeight")}; + return {_opened->conf.value("fontSize"), + _opened->conf.value("ascent"), + _opened->conf.value("descent"), + _opened->conf.value("lineHeight")}; } void MagnumFont::doClose() { diff --git a/src/MagnumPlugins/MagnumFont/MagnumFont.h b/src/MagnumPlugins/MagnumFont/MagnumFont.h index 957c81de5..0496e64a3 100644 --- a/src/MagnumPlugins/MagnumFont/MagnumFont.h +++ b/src/MagnumPlugins/MagnumFont/MagnumFont.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -42,8 +42,8 @@ built if `WITH_MAGNUMFONT` is enabled when building Magnum. To use dynamic plugin, you need to load `MagnumFont` plugin from `MAGNUM_PLUGINS_FONT_DIR`. To use static plugin or use this as a dependency of another plugin, you need to request `MagnumFont` component of `Magnum` package in CMake and link to -`${MAGNUM_MAGNUMFONT_LIBRARIES}`. See @ref building, @ref cmake and -@ref plugins for more information. +`Magnum::MagnumFont` target. See @ref building, @ref cmake and @ref plugins for +more information. The font consists of two files, one text file containing character and glyph info and one TGA file containing the glyphs in distance field format. The font @@ -120,9 +120,9 @@ class MagnumFont: public AbstractFont { bool doIsOpened() const override; - std::pair doOpenData(const std::vector>>& data, Float) override; + Metrics doOpenData(const std::vector>>& data, Float) override; - std::pair doOpenFile(const std::string& filename, Float) override; + Metrics doOpenFile(const std::string& filename, Float) override; void doClose() override; @@ -134,7 +134,7 @@ class MagnumFont: public AbstractFont { std::unique_ptr doLayout(const GlyphCache& cache, Float size, const std::string& text) override; - std::pair openInternal(Utility::Configuration&& conf, Trade::ImageData2D&& image); + Metrics openInternal(Utility::Configuration&& conf, Trade::ImageData2D&& image); Data* _opened; }; diff --git a/src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt b/src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt index f73da3d62..3b0a411d9 100644 --- a/src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFont/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,6 +26,5 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(MagnumFontGLTest MagnumFontGLTest.cpp LIBRARIES MagnumMagnumFontTestLib ${GL_TEST_LIBRARIES}) +target_include_directories(MagnumFontGLTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp b/src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp index 3a3818fca..36226d297 100644 --- a/src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp +++ b/src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -52,6 +52,8 @@ void MagnumFontGLTest::properties() { MagnumFont font; CORRADE_VERIFY(font.openFile(Utility::Directory::join(MAGNUMFONT_TEST_DIR, "font.conf"), 0.0f)); CORRADE_COMPARE(font.size(), 16.0f); + CORRADE_COMPARE(font.ascent(), 25.0f); + CORRADE_COMPARE(font.descent(), -10.0f); CORRADE_COMPARE(font.lineHeight(), 39.7333f); CORRADE_COMPARE(font.glyphAdvance(font.glyphId(U'W')), Vector2(23.0f, 0.0f)); } diff --git a/src/MagnumPlugins/MagnumFont/Test/configure.h.cmake b/src/MagnumPlugins/MagnumFont/Test/configure.h.cmake index 9284dbef6..e84b90d3d 100644 --- a/src/MagnumPlugins/MagnumFont/Test/configure.h.cmake +++ b/src/MagnumPlugins/MagnumFont/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/MagnumFont/Test/font.conf b/src/MagnumPlugins/MagnumFont/Test/font.conf index 7cf2c7b9b..b305ba032 100644 --- a/src/MagnumPlugins/MagnumFont/Test/font.conf +++ b/src/MagnumPlugins/MagnumFont/Test/font.conf @@ -3,6 +3,8 @@ image=font.tga originalImageSize=1536 1536 padding=24 24 fontSize=16 +ascent=25 +descent=-10 lineHeight=39.7333 [char] unicode=57 diff --git a/src/MagnumPlugins/MagnumFont/pluginRegistration.cpp b/src/MagnumPlugins/MagnumFont/pluginRegistration.cpp index 5d121821d..b7c2ccc55 100644 --- a/src/MagnumPlugins/MagnumFont/pluginRegistration.cpp +++ b/src/MagnumPlugins/MagnumFont/pluginRegistration.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -26,4 +26,4 @@ #include "MagnumPlugins/MagnumFont/MagnumFont.h" CORRADE_PLUGIN_REGISTER(MagnumFont, Magnum::Text::MagnumFont, - "cz.mosra.magnum.Text.AbstractFont/0.2.3") + "cz.mosra.magnum.Text.AbstractFont/0.2.4") diff --git a/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt b/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt index 184a4d386..7f2a5661b 100644 --- a/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -33,6 +33,7 @@ set(MagnumFontConverter_HEADERS add_library(MagnumFontConverterObjects OBJECT ${MagnumFontConverter_SRCS} ${MagnumFontConverter_HEADERS}) +target_include_directories(MagnumFontConverterObjects PUBLIC $) if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumFontConverterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -62,7 +63,7 @@ if(BUILD_GL_TESTS) add_library(MagnumMagnumFontConverterTestLib STATIC ${MagnumFontConverter_SRCS} ${MagnumFontConverter_HEADERS}) - set_target_properties(MagnumMagnumFontConverterTestLib PROPERTIES COMPILE_FLAGS "-DMAGNUM_TGAIMAGECONVERTER_BUILD_STATIC") + target_compile_definitions(MagnumMagnumFontConverterTestLib PRIVATE "MAGNUM_TGAIMAGECONVERTER_BUILD_STATIC") else() add_library(MagnumMagnumFontConverterTestLib STATIC $) endif() @@ -71,5 +72,5 @@ if(BUILD_GL_TESTS) add_subdirectory(Test) endif() -# Magnum MagnumFontConverter library for superprojects -set(MAGNUM_MAGNUMFONTCONVERTER_LIBRARY MagnumFontConverter CACHE INTERNAL "") +# Magnum MagnumFontConverter target alias for superprojects +add_library(Magnum::MagnumFontConverter ALIAS MagnumFontConverter) diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp index a961e754e..ff56e2fe5 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -53,6 +53,8 @@ std::vector>> MagnumFontConverter configuration.setValue("originalImageSize", cache.textureSize()); configuration.setValue("padding", cache.padding()); configuration.setValue("fontSize", font.size()); + configuration.setValue("ascent", font.ascent()); + configuration.setValue("descent", font.descent()); configuration.setValue("lineHeight", font.lineHeight()); /* Compress glyph IDs so the glyphs are in consecutive array, glyph 0 diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h index b98957ec1..4f6595db2 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -46,9 +46,8 @@ to read back the generated data. It depends on plugin, you need to load `MagnumFontConverter` plugin from `MAGNUM_PLUGINS_FONTCONVERTER_DIR`. To use static plugin or use this as a dependency of another plugin, you need to request `MagnumFontConverter` -component of `Magnum` package in CMake and link to -`${MAGNUM_MAGNUMFONTCONVERTER_LIBRARIES}`. See @ref building, @ref cmake and -@ref plugins for more information. +component of `Magnum` package in CMake and link to `Magnum::MagnumFontConverter` +target. See @ref building, @ref cmake and @ref plugins for more information. */ class MagnumFontConverter: public Text::AbstractFontConverter { public: diff --git a/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt b/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt index 6e97d3ad3..2e859b71b 100644 --- a/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,17 +26,16 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(MagnumFontConverterGLTest MagnumFontConverterGLTest.cpp LIBRARIES MagnumMagnumFontConverterTestLib MagnumTgaImporterTestLib ${GL_TEST_LIBRARIES}) +target_include_directories(MagnumFontConverterGLTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # On Win32 we need to avoid dllimporting TgaImporter symbols, because it would # search for the symbols in some DLL even though they were linked statically. # However it apparently doesn't matter that they were dllexported when building # the static library. EH. if(WIN32) - set_target_properties(MagnumFontConverterGLTest PROPERTIES COMPILE_FLAGS "-DMAGNUM_TGAIMPORTER_BUILD_STATIC") + target_compile_definitions(MagnumFontConverterGLTest PRIVATE "MAGNUM_TGAIMPORTER_BUILD_STATIC") endif() diff --git a/src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterGLTest.cpp b/src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterGLTest.cpp index 7db3ff572..6c34c61aa 100644 --- a/src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterGLTest.cpp +++ b/src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterGLTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -65,9 +65,9 @@ void MagnumFontConverterGLTest::exportFont() { private: void doClose() { _opened = false; } bool doIsOpened() const { return _opened; } - std::pair doOpenFile(const std::string&, Float) { + Metrics doOpenFile(const std::string&, Float) { _opened = true; - return {16.0f, 39.7333f}; + return {16.0f, 25.0f, -10.0f, 39.7333f}; } Features doFeatures() const { return {}; } std::unique_ptr doLayout(const GlyphCache&, Float, const std::string&) { return nullptr; } diff --git a/src/MagnumPlugins/MagnumFontConverter/Test/configure.h.cmake b/src/MagnumPlugins/MagnumFontConverter/Test/configure.h.cmake index 84061f8ce..37e4d1df6 100644 --- a/src/MagnumPlugins/MagnumFontConverter/Test/configure.h.cmake +++ b/src/MagnumPlugins/MagnumFontConverter/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/MagnumFontConverter/pluginRegistration.cpp b/src/MagnumPlugins/MagnumFontConverter/pluginRegistration.cpp index 01390adf4..dfdca3e24 100644 --- a/src/MagnumPlugins/MagnumFontConverter/pluginRegistration.cpp +++ b/src/MagnumPlugins/MagnumFontConverter/pluginRegistration.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -26,4 +26,4 @@ #include "MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h" CORRADE_PLUGIN_REGISTER(MagnumFontConverter, Magnum::Text::MagnumFontConverter, - "cz.mosra.magnum.Text.AbstractFontConverter/0.1.1") + "cz.mosra.magnum.Text.AbstractFontConverter/0.1.2") diff --git a/src/MagnumPlugins/ObjImporter/CMakeLists.txt b/src/MagnumPlugins/ObjImporter/CMakeLists.txt index a4d8e9d3b..8973e22c2 100644 --- a/src/MagnumPlugins/ObjImporter/CMakeLists.txt +++ b/src/MagnumPlugins/ObjImporter/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -33,6 +33,7 @@ set(ObjImporter_HEADERS add_library(ObjImporterObjects OBJECT ${ObjImporter_SRCS} ${ObjImporter_HEADERS}) +target_include_directories(ObjImporterObjects PUBLIC $) if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(ObjImporterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -45,7 +46,6 @@ add_plugin(ObjImporter ${MAGNUM_PLUGINS_IMPORTER_DEBUG_INSTALL_DIR} ${MAGNUM_PLU if(BUILD_STATIC_PIC) set_target_properties(ObjImporter PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(ObjImporter Magnum MagnumMeshTools) install(FILES ${ObjImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/ObjImporter) @@ -57,4 +57,4 @@ if(BUILD_TESTS) endif() # Magnum ObjImporter library for superprojects -set(MAGNUM_OBJIMPORTER_LIBRARY ObjImporter CACHE INTERNAL "") +add_library(Magnum:::ObjImporter ALIAS ObjImporter) diff --git a/src/MagnumPlugins/ObjImporter/ObjImporter.cpp b/src/MagnumPlugins/ObjImporter/ObjImporter.cpp index 0ca0b581b..125237f54 100644 --- a/src/MagnumPlugins/ObjImporter/ObjImporter.cpp +++ b/src/MagnumPlugins/ObjImporter/ObjImporter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/ObjImporter/ObjImporter.h b/src/MagnumPlugins/ObjImporter/ObjImporter.h index 14d2a7d78..29d150f16 100644 --- a/src/MagnumPlugins/ObjImporter/ObjImporter.h +++ b/src/MagnumPlugins/ObjImporter/ObjImporter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -48,8 +48,8 @@ This plugin is built if `WITH_OBJIMPORTER` is enabled when building Magnum. To use dynamic plugin, you need to load `ObjImporter` plugin from `MAGNUM_PLUGINS_IMPORTER_DIR`. To use static plugin or use this as a dependency of another plugin, you need to request `ObjImporter` component of `Magnum` -package in CMake and link to `${MAGNUM_OBJIMPORTER_LIBRARIES}`. See -@ref building, @ref cmake and @ref plugins for more information. +package in CMake and link to `Magnum::ObjImporter` target. See @ref building, +@ref cmake and @ref plugins for more information. */ class ObjImporter: public AbstractImporter { public: diff --git a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt index ecbd0e1a6..134e83d4d 100644 --- a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,6 +26,5 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(ObjImporterTest Test.cpp LIBRARIES MagnumObjImporterTestLib) +target_include_directories(ObjImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/MagnumPlugins/ObjImporter/Test/Test.cpp b/src/MagnumPlugins/ObjImporter/Test/Test.cpp index d307464be..df1bc8e21 100644 --- a/src/MagnumPlugins/ObjImporter/Test/Test.cpp +++ b/src/MagnumPlugins/ObjImporter/Test/Test.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -206,7 +206,7 @@ void ObjImporterTest::mixedPrimitives() { CORRADE_COMPARE(importer.mesh3DCount(), 1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(0)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): mixed primitive MeshPrimitive::Points and MeshPrimitive::Lines\n"); } @@ -406,7 +406,7 @@ void ObjImporterTest::wrongFloat() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): error while converting numeric data\n"); } @@ -418,7 +418,7 @@ void ObjImporterTest::wrongInteger() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): error while converting numeric data\n"); } @@ -430,7 +430,7 @@ void ObjImporterTest::unmergedIndexOutOfRange() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): index out of range\n"); } @@ -442,7 +442,7 @@ void ObjImporterTest::mergedIndexOutOfRange() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): index out of range\n"); } @@ -454,7 +454,7 @@ void ObjImporterTest::zeroIndex() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): index out of range\n"); } @@ -494,7 +494,7 @@ void ObjImporterTest::unsupportedOptionalPositionCoordinate() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): homogeneous coordinates are not supported\n"); } @@ -506,7 +506,7 @@ void ObjImporterTest::unsupportedOptionalTextureCoordinate() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): 3D texture coordinates are not supported\n"); } @@ -518,7 +518,7 @@ void ObjImporterTest::shortFloatData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): invalid float array size\n"); } @@ -530,7 +530,7 @@ void ObjImporterTest::longFloatData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): invalid float array size\n"); } @@ -542,7 +542,7 @@ void ObjImporterTest::longOptionalFloatData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): invalid float array size\n"); } @@ -554,7 +554,7 @@ void ObjImporterTest::longIndexData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): invalid index data\n"); } @@ -566,7 +566,7 @@ void ObjImporterTest::wrongPointIndexData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): wrong index count for point\n"); } @@ -578,7 +578,7 @@ void ObjImporterTest::wrongLineIndexData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): wrong index count for line\n"); } @@ -590,7 +590,7 @@ void ObjImporterTest::wrongTriangleIndexData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): wrong index count for triangle\n"); } @@ -602,7 +602,7 @@ void ObjImporterTest::polygonIndexData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): polygons are not supported\n"); } @@ -614,7 +614,7 @@ void ObjImporterTest::missingPositionData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): incomplete position data\n"); } @@ -626,7 +626,7 @@ void ObjImporterTest::missingPositionIndices() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): incomplete position data\n"); } @@ -638,7 +638,7 @@ void ObjImporterTest::missingNormalData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): incomplete normal data\n"); } @@ -650,7 +650,7 @@ void ObjImporterTest::missingNormalIndices() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): incomplete normal data\n"); } @@ -662,7 +662,7 @@ void ObjImporterTest::missingTextureCoordinateData() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): incomplete texture coordinate data\n"); } @@ -674,7 +674,7 @@ void ObjImporterTest::missingTextureCoordinateIndices() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): incomplete texture coordinate data\n"); } @@ -686,7 +686,7 @@ void ObjImporterTest::wrongNormalIndexCount() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): some normal indices are missing\n"); } @@ -698,7 +698,7 @@ void ObjImporterTest::wrongTextureCoordinateIndexCount() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): some texture coordinate indices are missing\n"); } @@ -727,7 +727,7 @@ void ObjImporterTest::unknownKeyword() { CORRADE_VERIFY(id > -1); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; CORRADE_VERIFY(!importer.mesh3D(id)); CORRADE_COMPARE(out.str(), "Trade::ObjImporter::mesh3D(): unknown keyword bleh\n"); } diff --git a/src/MagnumPlugins/ObjImporter/Test/configure.h.cmake b/src/MagnumPlugins/ObjImporter/Test/configure.h.cmake index c0f82e29a..459564c9c 100644 --- a/src/MagnumPlugins/ObjImporter/Test/configure.h.cmake +++ b/src/MagnumPlugins/ObjImporter/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/ObjImporter/pluginRegistration.cpp b/src/MagnumPlugins/ObjImporter/pluginRegistration.cpp index ba5190e6a..41fef90b1 100644 --- a/src/MagnumPlugins/ObjImporter/pluginRegistration.cpp +++ b/src/MagnumPlugins/ObjImporter/pluginRegistration.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt b/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt index 092b4b850..2895f4618 100644 --- a/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -40,8 +40,9 @@ set(TgaImageConverter_HEADERS add_library(TgaImageConverterObjects OBJECT ${TgaImageConverter_SRCS} ${TgaImageConverter_HEADERS}) +target_include_directories(TgaImageConverterObjects PUBLIC $) if(NOT BUILD_PLUGINS_STATIC) - set_target_properties(TgaImageConverterObjects PROPERTIES COMPILE_FLAGS "-DTgaImageConverterObjects_EXPORTS") + target_compile_definitions(TgaImageConverterObjects PRIVATE "TgaImageConverterObjects_EXPORTS") endif() if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(TgaImageConverterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -55,7 +56,6 @@ add_plugin(TgaImageConverter ${MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_INSTALL_DIR} if(BUILD_STATIC_PIC) set_target_properties(TgaImageConverter PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(TgaImageConverter Magnum) install(FILES ${TgaImageConverter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/TgaImageConverter) @@ -68,5 +68,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum TgaImageConverter library for superprojects -set(MAGNUM_TGAIMAGECONVERTER_LIBRARY TgaImageConverter CACHE INTERNAL "") +# Magnum TgaImageConverter target alias for superprojects +add_library(Magnum::TgaImageConverter ALIAS TgaImageConverter) diff --git a/src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt b/src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt index ac043ba78..aa1cb434a 100644 --- a/src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImageConverter/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,14 +26,14 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(TgaImageConverterTest TgaImageConverterTest.cpp LIBRARIES MagnumTgaImageConverterTestLib MagnumTgaImporterTestLib) +target_include_directories(TgaImageConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # On Win32 we need to avoid dllimporting TgaImporter and TgaImageConverterTest # symbols, because it would search for the symbols in some DLL even though they # were linked statically. However it apparently doesn't matter that they were # dllexported when building the static library. EH. if(WIN32) - set_target_properties(TgaImageConverterTest PROPERTIES COMPILE_FLAGS - "-DMAGNUM_TGAIMAGECONVERTER_BUILD_STATIC -DMAGNUM_TGAIMPORTER_BUILD_STATIC") + target_compile_definitions(TgaImageConverterTest PRIVATE + "MAGNUM_TGAIMAGECONVERTER_BUILD_STATIC" + "MAGNUM_TGAIMPORTER_BUILD_STATIC") endif() diff --git a/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp b/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp index b71bfaa1e..52b003d27 100644 --- a/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp +++ b/src/MagnumPlugins/TgaImageConverter/Test/TgaImageConverterTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -90,7 +90,7 @@ void TgaImageConverterTest::wrongFormat() { ImageView2D image(PixelFormat::RG, PixelType::UnsignedByte, {}, nullptr); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; const auto data = TgaImageConverter().exportToData(image); CORRADE_VERIFY(!data); @@ -101,7 +101,7 @@ void TgaImageConverterTest::wrongType() { ImageView2D image(PixelFormat::Red, PixelType::Float, {}, nullptr); std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; const auto data = TgaImageConverter().exportToData(image); CORRADE_VERIFY(!data); diff --git a/src/MagnumPlugins/TgaImageConverter/Test/configure.h.cmake b/src/MagnumPlugins/TgaImageConverter/Test/configure.h.cmake index 1489956ed..c2d991989 100644 --- a/src/MagnumPlugins/TgaImageConverter/Test/configure.h.cmake +++ b/src/MagnumPlugins/TgaImageConverter/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp index 752efccfa..af9817c0f 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h index 62965f476..90a51fdea 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -60,9 +60,8 @@ This plugin is built if `WITH_TGAIMAGECONVERTER` is enabled when building Magnum. To use dynamic plugin, you need to load `TgaImageConverter` plugin from `MAGNUM_PLUGINS_IMAGECONVERTER_DIR`. To use static plugin or use this as a dependency of another plugin, you need to request `TgaImageConverter` -component of `Magnum` package in CMake and link to -`${MAGNUM_TGAIMAGECONVERTER_LIBRARIES}`. See @ref building, @ref cmake and -@ref plugins for more information. +component of `Magnum` package in CMake and link to `Magnum::TgaImageConverter` +target. See @ref building, @ref cmake and @ref plugins for more information. */ class MAGNUM_TGAIMAGECONVERTER_EXPORT TgaImageConverter: public AbstractImageConverter { public: diff --git a/src/MagnumPlugins/TgaImageConverter/configure.h.cmake b/src/MagnumPlugins/TgaImageConverter/configure.h.cmake index d0c23cf82..34bdda52e 100644 --- a/src/MagnumPlugins/TgaImageConverter/configure.h.cmake +++ b/src/MagnumPlugins/TgaImageConverter/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/TgaImageConverter/pluginRegistration.cpp b/src/MagnumPlugins/TgaImageConverter/pluginRegistration.cpp index 341cc233e..f52316869 100644 --- a/src/MagnumPlugins/TgaImageConverter/pluginRegistration.cpp +++ b/src/MagnumPlugins/TgaImageConverter/pluginRegistration.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/TgaImporter/CMakeLists.txt b/src/MagnumPlugins/TgaImporter/CMakeLists.txt index 0be16ad88..b2ebfb43e 100644 --- a/src/MagnumPlugins/TgaImporter/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImporter/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -41,8 +41,9 @@ set(TgaImporter_HEADERS add_library(TgaImporterObjects OBJECT ${TgaImporter_SRCS} ${TgaImporter_HEADERS}) +target_include_directories(TgaImporterObjects PUBLIC $) if(NOT BUILD_PLUGINS_STATIC) - set_target_properties(TgaImporterObjects PROPERTIES COMPILE_FLAGS "-DTgaImporterObjects_EXPORTS") + target_compile_definitions(TgaImporterObjects PRIVATE "TgaImporterObjects_EXPORTS") endif() if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(TgaImporterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) @@ -56,7 +57,6 @@ add_plugin(TgaImporter ${MAGNUM_PLUGINS_IMPORTER_DEBUG_INSTALL_DIR} ${MAGNUM_PLU if(BUILD_STATIC_PIC) set_target_properties(TgaImporter PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(TgaImporter Magnum) install(FILES ${TgaImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/TgaImporter) @@ -69,5 +69,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum TgaImporter library for superprojects -set(MAGNUM_TGAIMPORTER_LIBRARY TgaImporter CACHE INTERNAL "") +# Magnum TgaImporter target alias for superprojects +add_library(Magnum::TgaImporter ALIAS TgaImporter) diff --git a/src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt b/src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt index a20229b2a..e3499dd25 100644 --- a/src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImporter/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,13 +26,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(TgaImporterTest TgaImporterTest.cpp LIBRARIES MagnumTgaImporterTestLib) +target_include_directories(TgaImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # On Win32 we need to avoid dllimporting TgaImporter symbols, because it would # search for the symbols in some DLL even though they were linked statically. # However it apparently doesn't matter that they were dllexported when building # the static library. EH. if(WIN32) - set_target_properties(TgaImporterTest PROPERTIES COMPILE_FLAGS "-DMAGNUM_TGAIMPORTER_BUILD_STATIC") + target_compile_definitions(TgaImporterTest PRIVATE "MAGNUM_TGAIMPORTER_BUILD_STATIC") endif() diff --git a/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp b/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp index 1cc780cc6..e4e823d05 100644 --- a/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp +++ b/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -77,7 +77,7 @@ void TgaImporterTest::openShort() { CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; - Error::setOutput(&debug); + Error redirectError{&debug}; CORRADE_VERIFY(!importer.image2D(0)); CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): the file is too short: 17 bytes\n"); } @@ -88,7 +88,7 @@ void TgaImporterTest::paletted() { CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; - Error::setOutput(&debug); + Error redirectError{&debug}; CORRADE_VERIFY(!importer.image2D(0)); CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): paletted files are not supported\n"); } @@ -99,7 +99,7 @@ void TgaImporterTest::compressed() { CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; - Error::setOutput(&debug); + Error redirectError{&debug}; CORRADE_VERIFY(!importer.image2D(0)); CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): unsupported (compressed?) image type: 9\n"); } @@ -110,7 +110,7 @@ void TgaImporterTest::colorBits16() { CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; - Error::setOutput(&debug); + Error redirectError{&debug}; CORRADE_VERIFY(!importer.image2D(0)); CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): unsupported color bits-per-pixel: 16\n"); } @@ -195,7 +195,7 @@ void TgaImporterTest::grayscaleBits16() { CORRADE_VERIFY(importer.openData(data)); std::ostringstream debug; - Error::setOutput(&debug); + Error redirectError{&debug}; CORRADE_VERIFY(!importer.image2D(0)); CORRADE_COMPARE(debug.str(), "Trade::TgaImporter::image2D(): unsupported grayscale bits-per-pixel: 16\n"); } diff --git a/src/MagnumPlugins/TgaImporter/Test/configure.h.cmake b/src/MagnumPlugins/TgaImporter/Test/configure.h.cmake index 20b731aa2..cb625138d 100644 --- a/src/MagnumPlugins/TgaImporter/Test/configure.h.cmake +++ b/src/MagnumPlugins/TgaImporter/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/TgaImporter/TgaHeader.h b/src/MagnumPlugins/TgaImporter/TgaHeader.h index 0ccb681fd..641b2b263 100644 --- a/src/MagnumPlugins/TgaImporter/TgaHeader.h +++ b/src/MagnumPlugins/TgaImporter/TgaHeader.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp index e09fb1b77..2923e0a86 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -100,7 +100,7 @@ std::optional TgaImporter::doImage2D(UnsignedInt) { /* Grayscale */ } else if(header.imageType == 3) { #if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) - format = Context::current() && Context::current()->isExtensionSupported() ? + format = Context::hasCurrent() && Context::current().isExtensionSupported() ? PixelFormat::Red : PixelFormat::Luminance; #elif !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) format = PixelFormat::Red; diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.h b/src/MagnumPlugins/TgaImporter/TgaImporter.h index 14ac168ac..e18c2c917 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.h +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -60,8 +60,8 @@ This plugin is built if `WITH_TGAIMPORTER` is enabled when building Magnum. To use dynamic plugin, you need to load `TgaImporter` plugin from `MAGNUM_PLUGINS_IMPORTER_DIR`. To use static plugin or use this as a dependency of another plugin, you need to request `TgaImporter` component of `Magnum` -package in CMake and link to `${MAGNUM_TGAIMPORTER_LIBRARIES}`. See -@ref building, @ref cmake and @ref plugins for more information. +package in CMake and link to `Magnum::TgaImporter` target. See @ref building, +@ref cmake and @ref plugins for more information. The images are imported with @ref PixelType::UnsignedByte and @ref PixelFormat::RGB, @ref PixelFormat::RGBA or @ref PixelFormat::Red, respectively. Grayscale images diff --git a/src/MagnumPlugins/TgaImporter/configure.h.cmake b/src/MagnumPlugins/TgaImporter/configure.h.cmake index aea9ee97c..a890086b2 100644 --- a/src/MagnumPlugins/TgaImporter/configure.h.cmake +++ b/src/MagnumPlugins/TgaImporter/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/TgaImporter/pluginRegistration.cpp b/src/MagnumPlugins/TgaImporter/pluginRegistration.cpp index 03e613f66..a7a112b71 100644 --- a/src/MagnumPlugins/TgaImporter/pluginRegistration.cpp +++ b/src/MagnumPlugins/TgaImporter/pluginRegistration.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt b/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt index db0bd771a..adb4a558d 100644 --- a/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt +++ b/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -23,10 +23,6 @@ # DEALINGS IN THE SOFTWARE. # -find_package(OpenAL REQUIRED) - -include_directories(${OPENAL_INCLUDE_DIR}) - set(WavAudioImporter_SRCS WavImporter.cpp) @@ -38,6 +34,9 @@ set(WavAudioImporter_HEADERS add_library(WavAudioImporterObjects OBJECT ${WavAudioImporter_SRCS} ${WavAudioImporter_HEADERS}) +target_include_directories(WavAudioImporterObjects PUBLIC + $ + $) if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(WavAudioImporterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -50,7 +49,6 @@ add_plugin(WavAudioImporter ${MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_INSTALL_DIR} ${ if(BUILD_STATIC_PIC) set_target_properties(WavAudioImporter PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() - target_link_libraries(WavAudioImporter Magnum MagnumAudio) install(FILES ${WavAudioImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/WavAudioImporter) @@ -61,5 +59,5 @@ if(BUILD_TESTS) add_subdirectory(Test) endif() -# Magnum WavAudioImporter library for superprojects -set(MAGNUM_WAVAUDIOIMPORTER_LIBRARY WavAudioImporter CACHE INTERNAL "") +# Magnum WavAudioImporter target alias for superprojects +add_library(Magnum::WavAudioImporter ALIAS WavAudioImporter) diff --git a/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt b/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt index dfdc7c078..ec775d9e4 100644 --- a/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt @@ -1,7 +1,7 @@ # # This file is part of Magnum. # -# Copyright © 2010, 2011, 2012, 2013, 2014, 2015 +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 # Vladimír Vondruš # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,6 +26,5 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) - corrade_add_test(WavAudioImporterTest WavImporterTest.cpp LIBRARIES MagnumWavAudioImporterTestLib) +target_include_directories(WavAudioImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp b/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp index 6d6d03b57..3896c67e2 100644 --- a/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp +++ b/src/MagnumPlugins/WavAudioImporter/Test/WavImporterTest.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -58,7 +58,7 @@ WavImporterTest::WavImporterTest() { void WavImporterTest::wrongSize() { std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; WavImporter importer; CORRADE_VERIFY(!importer.openData(Containers::Array(43))); @@ -67,7 +67,7 @@ void WavImporterTest::wrongSize() { void WavImporterTest::wrongSignature() { std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; WavImporter importer; CORRADE_VERIFY(!importer.openFile(Utility::Directory::join(WAVAUDIOIMPORTER_TEST_DIR, "wrongSignature.wav"))); @@ -76,7 +76,7 @@ void WavImporterTest::wrongSignature() { void WavImporterTest::unsupportedFormat() { std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; WavImporter importer; CORRADE_VERIFY(!importer.openFile(Utility::Directory::join(WAVAUDIOIMPORTER_TEST_DIR, "unsupportedFormat.wav"))); @@ -85,7 +85,7 @@ void WavImporterTest::unsupportedFormat() { void WavImporterTest::unsupportedChannelCount() { std::ostringstream out; - Error::setOutput(&out); + Error redirectError{&out}; WavImporter importer; CORRADE_VERIFY(!importer.openFile(Utility::Directory::join(WAVAUDIOIMPORTER_TEST_DIR, "unsupportedChannelCount.wav"))); diff --git a/src/MagnumPlugins/WavAudioImporter/Test/configure.h.cmake b/src/MagnumPlugins/WavAudioImporter/Test/configure.h.cmake index ca489a0fe..8bcf9cc77 100644 --- a/src/MagnumPlugins/WavAudioImporter/Test/configure.h.cmake +++ b/src/MagnumPlugins/WavAudioImporter/Test/configure.h.cmake @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/WavAudioImporter/WavHeader.h b/src/MagnumPlugins/WavAudioImporter/WavHeader.h index 9b368a982..4948fea35 100644 --- a/src/MagnumPlugins/WavAudioImporter/WavHeader.h +++ b/src/MagnumPlugins/WavAudioImporter/WavHeader.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/WavAudioImporter/WavImporter.cpp b/src/MagnumPlugins/WavAudioImporter/WavImporter.cpp index dd55be188..aa001e105 100644 --- a/src/MagnumPlugins/WavAudioImporter/WavImporter.cpp +++ b/src/MagnumPlugins/WavAudioImporter/WavImporter.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/src/MagnumPlugins/WavAudioImporter/WavImporter.h b/src/MagnumPlugins/WavAudioImporter/WavImporter.h index 0a4d233e3..3300821e9 100644 --- a/src/MagnumPlugins/WavAudioImporter/WavImporter.h +++ b/src/MagnumPlugins/WavAudioImporter/WavImporter.h @@ -3,7 +3,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a @@ -46,8 +46,8 @@ This plugin is built if `WITH_WAVAUDIOIMPORTER` is enabled when building Magnum. To use dynamic plugin, you need to load `WavAudioImporter` plugin from `MAGNUM_PLUGINS_AUDIOIMPORTER_DIR`. To use static plugin or use this as a dependency of another plugin, you need to request `WavAudioImporter` component -of `Magnum` package in CMake and link to `${MAGNUM_WAVAUDIOIMPORTER_LIBRARIES}`. -See @ref building, @ref cmake and @ref plugins for more information. +of `Magnum` package in CMake and link to `Magnum::WavAudioImporter` target. See +@ref building, @ref cmake and @ref plugins for more information. */ class WavImporter: public AbstractImporter { public: diff --git a/src/MagnumPlugins/WavAudioImporter/pluginRegistration.cpp b/src/MagnumPlugins/WavAudioImporter/pluginRegistration.cpp index 514228b8c..76c942633 100644 --- a/src/MagnumPlugins/WavAudioImporter/pluginRegistration.cpp +++ b/src/MagnumPlugins/WavAudioImporter/pluginRegistration.cpp @@ -1,7 +1,7 @@ /* This file is part of Magnum. - Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš Permission is hereby granted, free of charge, to any person obtaining a diff --git a/toolchains b/toolchains index a4683ed56..db1c8163e 160000 --- a/toolchains +++ b/toolchains @@ -1 +1 @@ -Subproject commit a4683ed5662754a6498e64f30064b9f118f78285 +Subproject commit db1c8163e6a43bd8a77029b7080d3a802870b57d