From 7421bf045dfe37b77cdc7302d138c6854609676c Mon Sep 17 00:00:00 2001 From: Squareys Date: Sun, 6 Sep 2015 12:09:37 +0200 Subject: [PATCH] Audio: Add Extensions.h Analog to Magnum::Extensions, but without Version, since OpenAL has only one Version which is in use (OpenAL 1.1). Signed-off-by: Squareys --- src/Magnum/Audio/CMakeLists.txt | 1 + src/Magnum/Audio/Extensions.h | 89 +++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/Magnum/Audio/Extensions.h diff --git a/src/Magnum/Audio/CMakeLists.txt b/src/Magnum/Audio/CMakeLists.txt index af4034e2d..7b5a93943 100644 --- a/src/Magnum/Audio/CMakeLists.txt +++ b/src/Magnum/Audio/CMakeLists.txt @@ -40,6 +40,7 @@ set(MagnumAudio_HEADERS Audio.h Buffer.h Context.h + Extensions.h Renderer.h Source.h diff --git a/src/Magnum/Audio/Extensions.h b/src/Magnum/Audio/Extensions.h new file mode 100644 index 000000000..f752a26cb --- /dev/null +++ b/src/Magnum/Audio/Extensions.h @@ -0,0 +1,89 @@ +#ifndef Magnum_Audio_Extensions_h +#define Magnum_Audio_Extensions_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + Vladimír Vondruš + Copyright © 2015 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 Namespace @ref Magnum::Audio::Extensions + */ + +#include "MagnumExternal/OpenAL/extensions.h" + +namespace Magnum { namespace Audio { + +/** +@brief Compile-time information about OpenAL extensions + +Each extension is `struct` named hierarchically by prefix, vendor and +extension name taken from list at @ref openal-support, for example +`ALC::SOFTX::HRTF`. + +Each struct has the same public methods as @ref Extension class +(@ref Extension::requiredVersion() "requiredVersion()", +@ref Extension::coreVersion() "coreVersion()" and @ref Extension::string() "string()"), +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 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. +@see @ref MAGNUM_ASSERT_AUDIO_EXTENSION_SUPPORTED() +@todo Manual indices for extensions, this has gaps +*/ +namespace Extensions { + +#ifndef DOXYGEN_GENERATING_OUTPUT +#define _extension(prefix, vendor, extension) \ + struct extension { \ + enum: std::size_t { Index = __LINE__-1 }; \ + constexpr static const char* string() { return #prefix "_" #vendor "_" #extension; } \ + }; + +/* IMPORTANT: don't forget to add new extensions also in Context.cpp */ +namespace AL { + #line 1 + namespace EXT { + _extension(AL,EXT,FLOAT32) // #??? + _extension(AL,EXT,DOUBLE) // #??? + } +} namespace ALC { + namespace SOFTX { + _extension(ALC,SOFTX,HRTF) // #??? + } +} +#undef _extension +#endif + +} + +}} + +#endif