Browse Source

Merge various Any* plugins extracted from magnum-plugins repository.

Will be integrated to the buildsystem and documentation in later
commits.
pull/205/head
Vladimír Vondruš 8 years ago
parent
commit
2732658254
  1. 0
      src/MagnumPlugins/AnyAudioImporter/AnyAudioImporter.conf
  2. 84
      src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp
  3. 105
      src/MagnumPlugins/AnyAudioImporter/AnyImporter.h
  4. 86
      src/MagnumPlugins/AnyAudioImporter/CMakeLists.txt
  5. 50
      src/MagnumPlugins/AnyAudioImporter/Test/CMakeLists.txt
  6. 91
      src/MagnumPlugins/AnyAudioImporter/Test/Test.cpp
  7. 33
      src/MagnumPlugins/AnyAudioImporter/Test/configure.h.cmake
  8. 26
      src/MagnumPlugins/AnyAudioImporter/configure.h.cmake
  9. 29
      src/MagnumPlugins/AnyAudioImporter/pluginRegistration.cpp
  10. 0
      src/MagnumPlugins/AnyImageConverter/AnyImageConverter.conf
  11. 88
      src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp
  12. 104
      src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h
  13. 84
      src/MagnumPlugins/AnyImageConverter/CMakeLists.txt
  14. 45
      src/MagnumPlugins/AnyImageConverter/Test/CMakeLists.txt
  15. 93
      src/MagnumPlugins/AnyImageConverter/Test/Test.cpp
  16. 32
      src/MagnumPlugins/AnyImageConverter/Test/configure.h.cmake
  17. 26
      src/MagnumPlugins/AnyImageConverter/configure.h.cmake
  18. 29
      src/MagnumPlugins/AnyImageConverter/pluginRegistration.cpp
  19. 0
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.conf
  20. 125
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp
  21. 128
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h
  22. 84
      src/MagnumPlugins/AnyImageImporter/CMakeLists.txt
  23. 53
      src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt
  24. 109
      src/MagnumPlugins/AnyImageImporter/Test/Test.cpp
  25. 34
      src/MagnumPlugins/AnyImageImporter/Test/configure.h.cmake
  26. 26
      src/MagnumPlugins/AnyImageImporter/configure.h.cmake
  27. 29
      src/MagnumPlugins/AnyImageImporter/pluginRegistration.cpp
  28. 0
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.conf
  29. 200
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp
  30. 196
      src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h
  31. 84
      src/MagnumPlugins/AnySceneImporter/CMakeLists.txt
  32. 50
      src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt
  33. 95
      src/MagnumPlugins/AnySceneImporter/Test/Test.cpp
  34. 33
      src/MagnumPlugins/AnySceneImporter/Test/configure.h.cmake
  35. 10
      src/MagnumPlugins/AnySceneImporter/Test/mesh.obj
  36. 26
      src/MagnumPlugins/AnySceneImporter/configure.h.cmake
  37. 29
      src/MagnumPlugins/AnySceneImporter/pluginRegistration.cpp

0
src/MagnumPlugins/AnyAudioImporter/AnyAudioImporter.conf

84
src/MagnumPlugins/AnyAudioImporter/AnyImporter.cpp

@ -0,0 +1,84 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "AnyImporter.h"
#include <Corrade/Containers/Array.h>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/String.h>
namespace Magnum { namespace Audio {
AnyImporter::AnyImporter(PluginManager::Manager<AbstractImporter>& manager): AbstractImporter{manager} {}
AnyImporter::AnyImporter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractImporter{manager, plugin} {}
AnyImporter::~AnyImporter() = default;
auto AnyImporter::doFeatures() const -> Features { return {}; }
bool AnyImporter::doIsOpened() const { return !!_in; }
void AnyImporter::doClose() { _in = nullptr; }
void AnyImporter::doOpenFile(const std::string& filename) {
CORRADE_INTERNAL_ASSERT(manager());
/* Detect type from extension */
std::string plugin;
if(Utility::String::endsWith(filename, ".ogg"))
plugin = "VorbisAudioImporter";
else if(Utility::String::endsWith(filename, ".wav"))
plugin = "WavAudioImporter";
else if(Utility::String::endsWith(filename, ".flac"))
plugin = "FlacAudioImporter";
else {
Error() << "Audio::AnyImporter::openFile(): cannot determine type of file" << filename;
return;
}
/* Try to load the plugin */
if(!(manager()->load(plugin) & PluginManager::LoadState::Loaded)) {
Error() << "Audio::AnyImporter::openFile(): cannot load" << plugin << "plugin";
return;
}
/* Try to open the file (error output should be printed by the plugin
itself) */
std::unique_ptr<AbstractImporter> importer = static_cast<PluginManager::Manager<AbstractImporter>*>(manager())->instance(plugin);
if(!importer->openFile(filename)) return;
/* Success, save the instance */
_in = std::move(importer);
}
Buffer::Format AnyImporter::doFormat() const { return _in->format(); }
UnsignedInt AnyImporter::doFrequency() const { return _in->frequency(); }
Containers::Array<char> AnyImporter::doData() { return _in->data(); }
}}

105
src/MagnumPlugins/AnyAudioImporter/AnyImporter.h

@ -0,0 +1,105 @@
#ifndef Magnum_Trade_AnyImporter_h
#define Magnum_Trade_AnyImporter_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Class @ref Magnum::Audio::AnyImporter
*/
#include <memory>
#include <Magnum/Audio/AbstractImporter.h>
#include "MagnumPlugins/AnyAudioImporter/configure.h"
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_ANYAUDIOIMPORTER_BUILD_STATIC
#if defined(AnyAudioImporter_EXPORTS) || defined(AnyAudioImporterObjects_EXPORTS)
#define MAGNUM_ANYAUDIOIMPORTER_EXPORT CORRADE_VISIBILITY_EXPORT
#else
#define MAGNUM_ANYAUDIOIMPORTER_EXPORT CORRADE_VISIBILITY_IMPORT
#endif
#else
#define MAGNUM_ANYAUDIOIMPORTER_EXPORT CORRADE_VISIBILITY_STATIC
#endif
#define MAGNUM_ANYAUDIOIMPORTER_LOCAL CORRADE_VISIBILITY_LOCAL
#else
#define MAGNUM_ANYAUDIOIMPORTER_EXPORT
#define MAGNUM_ANYAUDIOIMPORTER_LOCAL
#endif
namespace Magnum { namespace Audio {
/**
@brief Any audio importer plugin
Detects file type based on file extension, loads corresponding plugin and then
tries to open the file with it.
This plugin depends on the @ref Audio library and is built if
`WITH_ANYAUDIOIMPORTER` is enabled when building Magnum Plugins. To use as a
dynamic plugin, you need to load the @cpp "AnyAudioImporter" @ce plugin from
`MAGNUM_PLUGINS_IMPORTER_DIR`. To use as a static plugin or as a dependency of
another plugin with CMake, you need to request the `AnyAudioImporter` component
of the `MagnumPlugins` package and link to the
`MagnumPlugins::AnyAudioImporter` target. See @ref building-plugins,
@ref cmake-plugins and @ref plugins for more information.
Supported formats:
- OGG Vorbis (`*.ogg`), loaded with any plugin that provides
`VorbisAudioImporter`
- WAV (`*.wav`), loaded with @ref WavImporter "WavAudioImporter" or any other
plugin that provides it
- FLAC (`*.flac`), loaded with any plugin that provides `FlacAudioImporter`
Only loading from files is supported.
*/
class MAGNUM_ANYAUDIOIMPORTER_EXPORT AnyImporter: public AbstractImporter {
public:
/** @brief Constructor with access to plugin manager */
explicit AnyImporter(PluginManager::Manager<AbstractImporter>& manager);
/** @brief Plugin manager constructor */
explicit AnyImporter(PluginManager::AbstractManager& manager, const std::string& plugin);
~AnyImporter();
private:
MAGNUM_ANYAUDIOIMPORTER_LOCAL Features doFeatures() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL void doClose() override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL void doOpenFile(const std::string& filename) override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL Buffer::Format doFormat() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL UnsignedInt doFrequency() const override;
MAGNUM_ANYAUDIOIMPORTER_LOCAL Containers::Array<char> doData() override;
std::unique_ptr<AbstractImporter> _in;
};
}}
#endif

86
src/MagnumPlugins/AnyAudioImporter/CMakeLists.txt

@ -0,0 +1,86 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
find_package(Magnum REQUIRED Audio)
if(BUILD_STATIC)
set(MAGNUM_ANYAUDIOIMPORTER_BUILD_STATIC 1)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
set(AnyAudioImporter_SRCS
AnyImporter.cpp)
set(AnyAudioImporter_HEADERS
AnyImporter.h)
# Objects shared between plugin and test library
add_library(AnyAudioImporterObjects OBJECT
${AnyAudioImporter_SRCS}
${AnyAudioImporter_HEADERS})
target_include_directories(AnyAudioImporterObjects PUBLIC
$<TARGET_PROPERTY:Magnum::Audio,INTERFACE_INCLUDE_DIRECTORIES>
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
target_compile_definitions(AnyAudioImporterObjects PRIVATE "AnyAudioImporterObjects_EXPORTS")
if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(AnyAudioImporterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
set_target_properties(AnyAudioImporterObjects PROPERTIES FOLDER "MagnumPlugins/AnyAudioImporter")
# AnyAudioImporter plugin
add_plugin(AnyAudioImporter
"${MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_LIBRARY_INSTALL_DIR}"
"${MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_LIBRARY_INSTALL_DIR}"
AnyAudioImporter.conf
$<TARGET_OBJECTS:AnyAudioImporterObjects>
pluginRegistration.cpp)
if(BUILD_STATIC_PIC)
set_target_properties(AnyAudioImporter PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
target_include_directories(AnyAudioImporter PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
target_link_libraries(AnyAudioImporter Magnum::Magnum Magnum::Audio)
install(FILES ${AnyAudioImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnyAudioImporter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnyAudioImporter)
if(BUILD_TESTS)
add_library(MagnumAnyAudioImporterTestLib STATIC
$<TARGET_OBJECTS:AnyAudioImporterObjects>
${PROJECT_SOURCE_DIR}/src/dummy.cpp) # XCode workaround, see file comment for details
target_include_directories(MagnumAnyAudioImporterTestLib PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
set_target_properties(MagnumAnyAudioImporterTestLib PROPERTIES FOLDER "MagnumPlugins/AnyAudioImporter")
target_link_libraries(MagnumAnyAudioImporterTestLib Magnum::Magnum Magnum::Audio)
add_subdirectory(Test)
endif()
# MagnumPlugins AnyAudioImporter target alias for superprojects
add_library(MagnumPlugins::AnyAudioImporter ALIAS AnyAudioImporter)

50
src/MagnumPlugins/AnyAudioImporter/Test/CMakeLists.txt

@ -0,0 +1,50 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
set(WAV_FILE stereo8.wav)
set(OGG_FILE mono16.ogg)
else()
set(WAV_FILE ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/DrWavAudioImporter/Test/stereo8.wav)
set(OGG_FILE ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/StbVorbisAudioImporter/Test/mono16.ogg)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
corrade_add_test(AnyAudioImporterTest Test.cpp
LIBRARIES MagnumAnyAudioImporterTestLib
FILES
../../DrWavAudioImporter/Test/stereo8.wav
../../StbVorbisAudioImporter/Test/mono16.ogg)
target_include_directories(AnyAudioImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
# On Win32 we need to avoid dllimporting AnyAudioImporter symbols, because it
# would search for the symbols in some DLL even when they were linked
# statically. However it apparently doesn't matter that they were dllexported
# when building the static library. EH.
if(WIN32)
target_compile_definitions(AnyAudioImporterTest PRIVATE "MAGNUM_ANYAUDIOIMPORTER_BUILD_STATIC")
endif()
set_target_properties(AnyAudioImporterTest PROPERTIES FOLDER "MagnumPlugins/AnyAudioImporter/Test")

91
src/MagnumPlugins/AnyAudioImporter/Test/Test.cpp

@ -0,0 +1,91 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/TestSuite/Tester.h>
#include "MagnumPlugins/AnyAudioImporter/AnyImporter.h"
#include "configure.h"
namespace Magnum { namespace Audio { namespace Test {
struct AnyImporterTest: TestSuite::Tester {
explicit AnyImporterTest();
void wav();
void ogg();
void unknown();
private:
PluginManager::Manager<AbstractImporter> _manager;
};
AnyImporterTest::AnyImporterTest(): _manager{MAGNUM_PLUGINS_AUDIOIMPORTER_DIR} {
addTests({&AnyImporterTest::wav,
&AnyImporterTest::ogg,
&AnyImporterTest::unknown});
}
void AnyImporterTest::wav() {
if(_manager.loadState("WavAudioImporter") == PluginManager::LoadState::NotFound)
CORRADE_SKIP("WavAudioImporter plugin not found, cannot test");
AnyImporter importer{_manager};
CORRADE_VERIFY(importer.openFile(WAV_FILE));
/* Check only parameters, as it is good enough proof that it is working */
CORRADE_COMPARE(importer.format(), Buffer::Format::Stereo8);
CORRADE_COMPARE(importer.frequency(), 96000);
}
void AnyImporterTest::ogg() {
if(_manager.loadState("VorbisAudioImporter") == PluginManager::LoadState::NotFound)
CORRADE_SKIP("VorbisAudioImporter plugin not found, cannot test");
AnyImporter importer{_manager};
CORRADE_VERIFY(importer.openFile(OGG_FILE));
/* Check only parameters, as it is good enough proof that it is working */
CORRADE_COMPARE(importer.format(), Buffer::Format::Mono16);
CORRADE_COMPARE(importer.frequency(), 96000);
}
void AnyImporterTest::unknown() {
std::ostringstream output;
Error redirectError{&output};
AnyImporter importer{_manager};
CORRADE_VERIFY(!importer.openFile("sound.mid"));
CORRADE_COMPARE(output.str(), "Audio::AnyImporter::openFile(): cannot determine type of file sound.mid\n");
}
}}}
CORRADE_TEST_MAIN(Magnum::Audio::Test::AnyImporterTest)

33
src/MagnumPlugins/AnyAudioImporter/Test/configure.h.cmake

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

26
src/MagnumPlugins/AnyAudioImporter/configure.h.cmake

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

29
src/MagnumPlugins/AnyAudioImporter/pluginRegistration.cpp

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

0
src/MagnumPlugins/AnyImageConverter/AnyImageConverter.conf

88
src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp

@ -0,0 +1,88 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "AnyImageConverter.h"
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/String.h>
#include <Magnum/Trade/ImageData.h>
namespace Magnum { namespace Trade {
AnyImageConverter::AnyImageConverter(PluginManager::Manager<AbstractImageConverter>& manager): AbstractImageConverter{manager} {}
AnyImageConverter::AnyImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractImageConverter{manager, plugin} {}
AnyImageConverter::~AnyImageConverter() = default;
auto AnyImageConverter::doFeatures() const -> Features {
return Feature::ConvertFile|Feature::ConvertCompressedFile;
}
bool AnyImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) {
CORRADE_INTERNAL_ASSERT(manager());
/* Detect type from extension */
std::string plugin;
if(Utility::String::endsWith(filename, ".bmp"))
plugin = "BmpImageConverter";
else if(Utility::String::endsWith(filename, ".exr"))
plugin = "OpenExrImageConverter";
else if(Utility::String::endsWith(filename, ".hdr"))
plugin = "HdrImageConverter";
else if(Utility::String::endsWith(filename, ".png"))
plugin = "PngImageConverter";
else if(Utility::String::endsWith(filename, ".tga") ||
Utility::String::endsWith(filename, ".vda") ||
Utility::String::endsWith(filename, ".icb") ||
Utility::String::endsWith(filename, ".vst"))
plugin = "TgaImageConverter";
else {
Error() << "Trade::AnyImageConverter::exportToFile(): cannot determine type of file" << filename;
return false;
}
/* Try to load the plugin */
if(!(manager()->load(plugin) & PluginManager::LoadState::Loaded)) {
Error() << "Trade::AnyImageConverter::exportToFile(): cannot load" << plugin << "plugin";
return false;
}
/* Try to convert the file (error output should be printed by the plugin
itself) */
return static_cast<PluginManager::Manager<AbstractImageConverter>*>(manager())->instance(plugin)->exportToFile(image, filename);
}
bool AnyImageConverter::doExportToFile(const CompressedImageView2D&, const std::string& filename) {
CORRADE_INTERNAL_ASSERT(manager());
/* No file formats to store compressed data yet */
Error() << "Trade::AnyImageConverter::exportToFile(): cannot determine type of file" << filename << "to store compressed data";
return false;
}
}}

104
src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h

@ -0,0 +1,104 @@
#ifndef Magnum_Trade_AnyImageConverter_h
#define Magnum_Trade_AnyImageConverter_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Class @ref Magnum::Trade::AnyImageConverter
*/
#include <Magnum/Trade/AbstractImageConverter.h>
#include "MagnumPlugins/AnyImageConverter/configure.h"
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_ANYIMAGECONVERTER_BUILD_STATIC
#if defined(AnyImageConverter_EXPORTS) || defined(AnyImageConverterObjects_EXPORTS)
#define MAGNUM_ANYIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_EXPORT
#else
#define MAGNUM_ANYIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_IMPORT
#endif
#else
#define MAGNUM_ANYIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_STATIC
#endif
#define MAGNUM_ANYIMAGECONVERTER_LOCAL CORRADE_VISIBILITY_LOCAL
#else
#define MAGNUM_ANYIMAGECONVERTER_EXPORT
#define MAGNUM_ANYIMAGECONVERTER_LOCAL
#endif
namespace Magnum { namespace Trade {
/**
@brief Any image converter plugin
Detects file type based on file extension, loads corresponding plugin and then
tries to convert the file with it.
This plugin depends on the @ref Trade library and is built if
`WITH_ANYIMAGECONVERTER` is enabled when building Magnum Plugins. To use as a
dynamic plugin, you need to load the @cpp "AnyImageConverter" @ce plugin from
`MAGNUM_PLUGINS_IMPORTER_DIR`. To use as a static plugin or as a dependency of
another plugin with CMake, you need to request the `AnyImageConverter`
component of the `MagnumPlugins` package and link to the
`MagnumPlugins::AnyImageConverter` target. See @ref building-plugins,
@ref cmake-plugins and @ref plugins for more information.
Supported formats for uncompressed data:
- OpenEXR (`*.exr`), converted with any plugin that provides
`OpenExrImageConverter`
- Windows Bitmap (`*.bmp`), converted with any plugin that provides
`BmpImageConverter`
- Radiance HDR (`*.hdr`), converted with any plugin that provides
`HdrImageConverter`
- Portable Network Graphics (`*.png`), converted with @ref PngImageConverter
or any other plugin that provides it
- Truevision TGA (`*.tga`, `*.vda`, `*.icb`, `*.vst`), converted with
@ref TgaImageConverter or any other plugin that provides it
No supported formats for compressed data yet.
Only exporting to files is supported.
*/
class MAGNUM_ANYIMAGECONVERTER_EXPORT AnyImageConverter: public AbstractImageConverter {
public:
/** @brief Constructor with access to plugin manager */
explicit AnyImageConverter(PluginManager::Manager<AbstractImageConverter>& manager);
/** @brief Plugin manager constructor */
explicit AnyImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin);
~AnyImageConverter();
private:
MAGNUM_ANYIMAGECONVERTER_LOCAL Features doFeatures() const override;
MAGNUM_ANYIMAGECONVERTER_LOCAL bool doExportToFile(const ImageView2D& image, const std::string& filename) override;
MAGNUM_ANYIMAGECONVERTER_LOCAL bool doExportToFile(const CompressedImageView2D& image, const std::string& filename) override;
};
}}
#endif

84
src/MagnumPlugins/AnyImageConverter/CMakeLists.txt

@ -0,0 +1,84 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
if(BUILD_STATIC)
set(MAGNUM_ANYIMAGECONVERTER_BUILD_STATIC 1)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
set(AnyImageConverter_SRCS
AnyImageConverter.cpp)
set(AnyImageConverter_HEADERS
AnyImageConverter.h)
# Objects shared between plugin and test library
add_library(AnyImageConverterObjects OBJECT
${AnyImageConverter_SRCS}
${AnyImageConverter_HEADERS})
target_include_directories(AnyImageConverterObjects PUBLIC
$<TARGET_PROPERTY:Magnum::Magnum,INTERFACE_INCLUDE_DIRECTORIES>
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
target_compile_definitions(AnyImageConverterObjects PRIVATE "AnyImageConverterObjects_EXPORTS")
if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(AnyImageConverterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
set_target_properties(AnyImageConverterObjects PROPERTIES FOLDER "MagnumPlugins/AnyImageConverter")
# AnyImageConverter plugin
add_plugin(AnyImageConverter
"${MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_LIBRARY_INSTALL_DIR}"
"${MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_LIBRARY_INSTALL_DIR}"
AnyImageConverter.conf
$<TARGET_OBJECTS:AnyImageConverterObjects>
pluginRegistration.cpp)
if(BUILD_STATIC_PIC)
set_target_properties(AnyImageConverter PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
target_include_directories(AnyImageConverter PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
target_link_libraries(AnyImageConverter Magnum::Magnum)
install(FILES ${AnyImageConverter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnyImageConverter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnyImageConverter)
if(BUILD_TESTS)
add_library(MagnumAnyImageConverterTestLib STATIC
$<TARGET_OBJECTS:AnyImageConverterObjects>
${PROJECT_SOURCE_DIR}/src/dummy.cpp) # XCode workaround, see file comment for details
target_include_directories(MagnumAnyImageConverterTestLib PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
set_target_properties(MagnumAnyImageConverterTestLib PROPERTIES FOLDER "MagnumPlugins/AnyImageConverter")
target_link_libraries(MagnumAnyImageConverterTestLib Magnum::Magnum)
add_subdirectory(Test)
endif()
# MagnumPlugins AnyImageConverter target alias for superprojects
add_library(MagnumPlugins::AnyImageConverter ALIAS AnyImageConverter)

45
src/MagnumPlugins/AnyImageConverter/Test/CMakeLists.txt

@ -0,0 +1,45 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
set(ANYIMAGECONVERTER_TEST_DIR "write")
else()
set(ANYIMAGECONVERTER_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
corrade_add_test(AnyImageConverterTest Test.cpp
LIBRARIES MagnumAnyImageConverterTestLib)
target_include_directories(AnyImageConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
# On Win32 we need to avoid dllimporting AnyImageConverter symbols, because it
# would search for the symbols in some DLL even when they were linked
# statically. However it apparently doesn't matter that they were dllexported
# when building the static library. EH.
if(WIN32)
target_compile_definitions(AnyImageConverterTest PRIVATE "MAGNUM_ANYIMAGECONVERTER_BUILD_STATIC")
endif()
set_target_properties(AnyImageConverterTest PROPERTIES FOLDER "MagnumPlugins/AnyImageConverter/Test")

93
src/MagnumPlugins/AnyImageConverter/Test/Test.cpp

@ -0,0 +1,93 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/Utility/Directory.h>
#include <Corrade/PluginManager/Manager.h>
#include <Magnum/PixelFormat.h>
#include <Magnum/Trade/ImageData.h>
#include "MagnumPlugins/AnyImageConverter/AnyImageConverter.h"
#include "configure.h"
namespace Magnum { namespace Trade { namespace Test {
struct AnyImageConverterTest: TestSuite::Tester {
explicit AnyImageConverterTest();
void png();
void unknown();
private:
PluginManager::Manager<AbstractImageConverter> _manager;
};
AnyImageConverterTest::AnyImageConverterTest(): _manager{MAGNUM_PLUGINS_IMAGECONVERTER_DIR} {
addTests({&AnyImageConverterTest::png,
&AnyImageConverterTest::unknown});
}
namespace {
constexpr const char Data[] = {
1, 2, 3, 2, 3, 4, 0, 0,
3, 4, 5, 4, 5, 6, 0, 0,
5, 6, 7, 6, 7, 8, 0, 0
};
const ImageView2D Image{PixelFormat::RGB, PixelType::UnsignedByte, {2, 3}, Data};
}
void AnyImageConverterTest::png() {
if(_manager.loadState("PngImageConverter") == PluginManager::LoadState::NotFound)
CORRADE_SKIP("PngImageConverter plugin not found, cannot test");
const std::string filename = Utility::Directory::join(ANYIMAGECONVERTER_TEST_DIR, "output.png");
if(Utility::Directory::fileExists(filename))
CORRADE_VERIFY(Utility::Directory::rm(filename));
/* Just test that the exported file exists */
AnyImageConverter converter{_manager};
CORRADE_VERIFY(converter.exportToFile(Image, filename));
CORRADE_VERIFY(Utility::Directory::fileExists(filename));
}
void AnyImageConverterTest::unknown() {
std::ostringstream output;
Error redirectError{&output};
AnyImageConverter converter{_manager};
CORRADE_VERIFY(!converter.exportToFile(Image, "image.xcf"));
CORRADE_COMPARE(output.str(), "Trade::AnyImageConverter::exportToFile(): cannot determine type of file image.xcf\n");
}
}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::AnyImageConverterTest)

32
src/MagnumPlugins/AnyImageConverter/Test/configure.h.cmake

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

26
src/MagnumPlugins/AnyImageConverter/configure.h.cmake

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

29
src/MagnumPlugins/AnyImageConverter/pluginRegistration.cpp

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

0
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.conf

125
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp

@ -0,0 +1,125 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "AnyImageImporter.h"
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/String.h>
#include <Magnum/Trade/ImageData.h>
namespace Magnum { namespace Trade {
AnyImageImporter::AnyImageImporter(PluginManager::Manager<AbstractImporter>& manager): AbstractImporter{manager} {}
AnyImageImporter::AnyImageImporter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractImporter{manager, plugin} {}
AnyImageImporter::~AnyImageImporter() = default;
auto AnyImageImporter::doFeatures() const -> Features { return {}; }
bool AnyImageImporter::doIsOpened() const { return !!_in; }
void AnyImageImporter::doClose() {
_in = nullptr;
}
void AnyImageImporter::doOpenFile(const std::string& filename) {
CORRADE_INTERNAL_ASSERT(manager());
/* Detect type from extension */
std::string plugin;
if(Utility::String::endsWith(filename, ".bmp"))
plugin = "BmpImporter";
else if(Utility::String::endsWith(filename, ".dds"))
plugin = "DdsImporter";
else if(Utility::String::endsWith(filename, ".exr"))
plugin = "OpenExrImporter";
else if(Utility::String::endsWith(filename, ".gif"))
plugin = "GifImporter";
else if(Utility::String::endsWith(filename, ".hdr"))
plugin = "HdrImporter";
else if(Utility::String::endsWith(filename, ".jpg") ||
Utility::String::endsWith(filename, ".jpeg") ||
Utility::String::endsWith(filename, ".jpe") )
plugin = "JpegImporter";
else if(Utility::String::endsWith(filename, ".jp2"))
plugin = "Jpeg2000Importer";
else if(Utility::String::endsWith(filename, ".mng"))
plugin = "MngImporter";
else if(Utility::String::endsWith(filename, ".pbm"))
plugin = "PbmImporter";
else if(Utility::String::endsWith(filename, ".pcx"))
plugin = "PcxImporter";
else if(Utility::String::endsWith(filename, ".pgm"))
plugin = "PgmImporter";
else if(Utility::String::endsWith(filename, ".pic"))
plugin = "PicImporter";
else if(Utility::String::endsWith(filename, ".pnm"))
plugin = "PnmImporter";
else if(Utility::String::endsWith(filename, ".png"))
plugin = "PngImporter";
else if(Utility::String::endsWith(filename, ".ppm"))
plugin = "PpmImporter";
else if(Utility::String::endsWith(filename, ".psd"))
plugin = "PsdImporter";
else if(Utility::String::endsWith(filename, ".sgi") ||
Utility::String::endsWith(filename, ".bw") ||
Utility::String::endsWith(filename, ".rgb") ||
Utility::String::endsWith(filename, ".rgba"))
plugin = "SgiImporter";
else if(Utility::String::endsWith(filename, ".tif") ||
Utility::String::endsWith(filename, ".tiff"))
plugin = "TiffImporter";
else if(Utility::String::endsWith(filename, ".tga") ||
Utility::String::endsWith(filename, ".vda") ||
Utility::String::endsWith(filename, ".icb") ||
Utility::String::endsWith(filename, ".vst"))
plugin = "TgaImporter";
else {
Error() << "Trade::AnyImageImporter::openFile(): cannot determine type of file" << filename;
return;
}
/* Try to load the plugin */
if(!(manager()->load(plugin) & PluginManager::LoadState::Loaded)) {
Error() << "Trade::AnyImageImporter::openFile(): cannot load" << plugin << "plugin";
return;
}
/* Try to open the file (error output should be printed by the plugin
itself) */
std::unique_ptr<AbstractImporter> importer = static_cast<PluginManager::Manager<AbstractImporter>*>(manager())->instance(plugin);
if(!importer->openFile(filename)) return;
/* Success, save the instance */
_in = std::move(importer);
}
UnsignedInt AnyImageImporter::doImage2DCount() const { return _in->image2DCount(); }
Containers::Optional<ImageData2D> AnyImageImporter::doImage2D(const UnsignedInt id) { return _in->image2D(id); }
}}

128
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h

@ -0,0 +1,128 @@
#ifndef Magnum_Trade_AnyImageImporter_h
#define Magnum_Trade_AnyImageImporter_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Class @ref Magnum::Trade::AnyImageImporter
*/
#include <Magnum/Trade/AbstractImporter.h>
#include "MagnumPlugins/AnyImageImporter/configure.h"
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_ANYIMAGEIMPORTER_BUILD_STATIC
#if defined(AnyImageImporter_EXPORTS) || defined(AnyImageImporterObjects_EXPORTS)
#define MAGNUM_ANYIMAGEIMPORTER_EXPORT CORRADE_VISIBILITY_EXPORT
#else
#define MAGNUM_ANYIMAGEIMPORTER_EXPORT CORRADE_VISIBILITY_IMPORT
#endif
#else
#define MAGNUM_ANYIMAGEIMPORTER_EXPORT CORRADE_VISIBILITY_STATIC
#endif
#define MAGNUM_ANYIMAGEIMPORTER_LOCAL CORRADE_VISIBILITY_LOCAL
#else
#define MAGNUM_ANYIMAGEIMPORTER_EXPORT
#define MAGNUM_ANYIMAGEIMPORTER_LOCAL
#endif
namespace Magnum { namespace Trade {
/**
@brief Any image importer plugin
Detects file type based on file extension, loads corresponding plugin and then
tries to open the file with it.
This plugin depends on the @ref Trade library and is built if
`WITH_ANYIMAGEIMPORTER` is enabled when building Magnum Plugins. To use as a
dynamic plugin, you need to load the @cpp "AnyImageImporter" @ce plugin from
`MAGNUM_PLUGINS_IMPORTER_DIR`. To use as a static plugin or as a dependency of
another plugin with CMake, you need to request the `AnyImageImporter` component
of the `MagnumPlugins` package and link to the
`MagnumPlugins::AnyImageImporter` target. See @ref building-plugins,
@ref cmake-plugins and @ref plugins for more information.
Supported formats:
- Windows Bitmap (`*.bmp`), loaded with any plugin that provides `BmpImporter`
- DirectDraw Surface (`*.dds`), loaded with @ref DdsImporter or any other
plugin that provides it
- Graphics Interchange Format (`*.gif`), loaded with any plugin that provides
`GifImporter`
- OpenEXR (`*.exr`), loaded with any plugin that provides `OpenExrImporter`
- Radiance HDR (`*.hdr`), loaded with any plugin that provides `HdrImporter`
- JPEG (`*.jpg`, `*.jpe`, `*.jpeg`), loaded with @ref JpegImporter or any
other plugin that provides it
- JPEG 2000 (`*.jp2`), loaded with any plugin that provides
`Jpeg2000Importer`
- Multiple-image Network Graphics (`*.mng`), loaded with any plugin that
provides `MngImporter`
- Portable Bitmap (`*.pbm`), loaded with any plugin that provides `PbmImporter`
- ZSoft PCX (`*.pcx`), loaded with any plugin that provides `PcxImporter`
- Portable Graymap (`*.pgm`), loaded with any plugin that provides
`PgmImporter`
- Softimage PIC (`*.pic`), loaded with any plugin that provides `PicImporter`
- Portable Anymap (`*.pnm`), loaded with any plugin that provides
`PnmImporter`
- Portable Network Graphics (`*.png`), loaded with @ref PngImporter or any
other plugin that provides it
- Portable Pixmap (`*.ppm`), loaded with any plugin that provides `PpmImporter`
- Adobe Photoshop (`*.psd`), loaded with any plugin that provides `PsdImporter`
- Silicon Graphics (`*.sgi`, `*.bw`, `*.rgb`, `*.rgba`), loaded with any
plugin that provides `SgiImporter`
- Tagged Image File Format (`*.tif`, `*.tiff`), loaded with any plugin that
provides `TiffImporter`
- Truevision TGA (`*.tga`, `*.vda`, `*.icb`, `*.vst`), loaded with
@ref TgaImporter or any other plugin that provides it
Only loading from files is supported.
*/
class MAGNUM_ANYIMAGEIMPORTER_EXPORT AnyImageImporter: public AbstractImporter {
public:
/** @brief Constructor with access to plugin manager */
explicit AnyImageImporter(PluginManager::Manager<AbstractImporter>& manager);
/** @brief Plugin manager constructor */
explicit AnyImageImporter(PluginManager::AbstractManager& manager, const std::string& plugin);
~AnyImageImporter();
private:
MAGNUM_ANYIMAGEIMPORTER_LOCAL Features doFeatures() const override;
MAGNUM_ANYIMAGEIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_ANYIMAGEIMPORTER_LOCAL void doClose() override;
MAGNUM_ANYIMAGEIMPORTER_LOCAL void doOpenFile(const std::string& filename) override;
MAGNUM_ANYIMAGEIMPORTER_LOCAL UnsignedInt doImage2DCount() const override;
MAGNUM_ANYIMAGEIMPORTER_LOCAL Containers::Optional<ImageData2D> doImage2D(UnsignedInt id) override;
std::unique_ptr<AbstractImporter> _in;
};
}}
#endif

84
src/MagnumPlugins/AnyImageImporter/CMakeLists.txt

@ -0,0 +1,84 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
if(BUILD_STATIC)
set(MAGNUM_ANYIMAGEIMPORTER_BUILD_STATIC 1)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
set(AnyImageImporter_SRCS
AnyImageImporter.cpp)
set(AnyImageImporter_HEADERS
AnyImageImporter.h)
# Objects shared between plugin and test library
add_library(AnyImageImporterObjects OBJECT
${AnyImageImporter_SRCS}
${AnyImageImporter_HEADERS})
target_include_directories(AnyImageImporterObjects PUBLIC
$<TARGET_PROPERTY:Magnum::Magnum,INTERFACE_INCLUDE_DIRECTORIES>
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
target_compile_definitions(AnyImageImporterObjects PRIVATE "AnyImageImporterObjects_EXPORTS")
if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(AnyImageImporterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
set_target_properties(AnyImageImporterObjects PROPERTIES FOLDER "MagnumPlugins/AnyImageImporter")
# AnyImageImporter plugin
add_plugin(AnyImageImporter
"${MAGNUM_PLUGINS_IMPORTER_DEBUG_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_IMPORTER_DEBUG_LIBRARY_INSTALL_DIR}"
"${MAGNUM_PLUGINS_IMPORTER_RELEASE_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_IMPORTER_RELEASE_LIBRARY_INSTALL_DIR}"
AnyImageImporter.conf
$<TARGET_OBJECTS:AnyImageImporterObjects>
pluginRegistration.cpp)
if(BUILD_STATIC_PIC)
set_target_properties(AnyImageImporter PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
target_include_directories(AnyImageImporter PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
target_link_libraries(AnyImageImporter Magnum::Magnum)
install(FILES ${AnyImageImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnyImageImporter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnyImageImporter)
if(BUILD_TESTS)
add_library(MagnumAnyImageImporterTestLib STATIC
$<TARGET_OBJECTS:AnyImageImporterObjects>
${PROJECT_SOURCE_DIR}/src/dummy.cpp) # XCode workaround, see file comment for details
target_include_directories(MagnumAnyImageImporterTestLib PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
set_target_properties(MagnumAnyImageImporterTestLib PROPERTIES FOLDER "MagnumPlugins/AnyImageImporter")
target_link_libraries(MagnumAnyImageImporterTestLib Magnum::Magnum)
add_subdirectory(Test)
endif()
# MagnumPlugins AnyImageImporter target alias for superprojects
add_library(MagnumPlugins::AnyImageImporter ALIAS AnyImageImporter)

53
src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt

@ -0,0 +1,53 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
set(TGA_FILE image.tga)
set(JPEG_FILE rgb.jpg)
set(PNG_FILE rgb.png)
else()
set(TGA_FILE ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/ColladaImporter/Test/ColladaImporterTestFiles/image.tga)
set(JPEG_FILE ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/JpegImporter/Test/rgb.jpg)
set(PNG_FILE ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/PngImporter/Test/rgb.png)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
corrade_add_test(AnyImageImporterTest Test.cpp
LIBRARIES MagnumAnyImageImporterTestLib
FILES
../../ColladaImporter/Test/ColladaImporterTestFiles/image.tga
../../JpegImporter/Test/rgb.jpg
../../PngImporter/Test/rgb.png)
target_include_directories(AnyImageImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
# On Win32 we need to avoid dllimporting AnyImageImporter symbols, because it
# would search for the symbols in some DLL even when they were linked
# statically. However it apparently doesn't matter that they were dllexported
# when building the static library. EH.
if(WIN32)
target_compile_definitions(AnyImageImporterTest PRIVATE "MAGNUM_ANYIMAGEIMPORTER_BUILD_STATIC")
endif()
set_target_properties(AnyImageImporterTest PROPERTIES FOLDER "MagnumPlugins/AnyImageImporter/Test")

109
src/MagnumPlugins/AnyImageImporter/Test/Test.cpp

@ -0,0 +1,109 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/TestSuite/Tester.h>
#include <Magnum/Trade/ImageData.h>
#include "MagnumPlugins/AnyImageImporter/AnyImageImporter.h"
#include "configure.h"
namespace Magnum { namespace Trade { namespace Test {
struct AnyImageImporterTest: TestSuite::Tester {
explicit AnyImageImporterTest();
void tga();
void jpeg();
void png();
void unknown();
private:
PluginManager::Manager<AbstractImporter> _manager;
};
AnyImageImporterTest::AnyImageImporterTest(): _manager{MAGNUM_PLUGINS_IMPORTER_DIR} {
addTests({&AnyImageImporterTest::tga,
&AnyImageImporterTest::jpeg,
&AnyImageImporterTest::png,
&AnyImageImporterTest::unknown});
}
void AnyImageImporterTest::tga() {
if(_manager.loadState("TgaImporter") == PluginManager::LoadState::NotFound)
CORRADE_SKIP("TgaImporter plugin not found, cannot test");
AnyImageImporter importer{_manager};
CORRADE_VERIFY(importer.openFile(TGA_FILE));
/* Check only size, as it is good enough proof that it is working */
Containers::Optional<ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->size(), Vector2i(2, 3));
}
void AnyImageImporterTest::jpeg() {
if(_manager.loadState("JpegImporter") == PluginManager::LoadState::NotFound)
CORRADE_SKIP("JpegImporter plugin not found, cannot test");
AnyImageImporter importer{_manager};
CORRADE_VERIFY(importer.openFile(JPEG_FILE));
/* Check only size, as it is good enough proof that it is working */
Containers::Optional<ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->size(), Vector2i(3, 2));
}
void AnyImageImporterTest::png() {
if(_manager.loadState("PngImporter") == PluginManager::LoadState::NotFound)
CORRADE_SKIP("PngImporter plugin not found, cannot test");
AnyImageImporter importer{_manager};
CORRADE_VERIFY(importer.openFile(PNG_FILE));
/* Check only size, as it is good enough proof that it is working */
Containers::Optional<ImageData2D> image = importer.image2D(0);
CORRADE_VERIFY(image);
CORRADE_COMPARE(image->size(), Vector2i(3, 2));
}
void AnyImageImporterTest::unknown() {
std::ostringstream output;
Error redirectError{&output};
AnyImageImporter importer{_manager};
CORRADE_VERIFY(!importer.openFile("image.xcf"));
CORRADE_COMPARE(output.str(), "Trade::AnyImageImporter::openFile(): cannot determine type of file image.xcf\n");
}
}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::AnyImageImporterTest)

34
src/MagnumPlugins/AnyImageImporter/Test/configure.h.cmake

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

26
src/MagnumPlugins/AnyImageImporter/configure.h.cmake

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

29
src/MagnumPlugins/AnyImageImporter/pluginRegistration.cpp

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

0
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.conf

200
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.cpp

@ -0,0 +1,200 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "AnySceneImporter.h"
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/String.h>
#include <Magnum/Trade/AbstractMaterialData.h>
#include <Magnum/Trade/CameraData.h>
#include <Magnum/Trade/ImageData.h>
#include <Magnum/Trade/LightData.h>
#include <Magnum/Trade/MeshData2D.h>
#include <Magnum/Trade/MeshData3D.h>
#include <Magnum/Trade/ObjectData2D.h>
#include <Magnum/Trade/ObjectData3D.h>
#include <Magnum/Trade/SceneData.h>
#include <Magnum/Trade/TextureData.h>
namespace Magnum { namespace Trade {
AnySceneImporter::AnySceneImporter(PluginManager::Manager<AbstractImporter>& manager): AbstractImporter{manager} {}
AnySceneImporter::AnySceneImporter(PluginManager::AbstractManager& manager, const std::string& plugin): AbstractImporter{manager, plugin} {}
AnySceneImporter::~AnySceneImporter() = default;
auto AnySceneImporter::doFeatures() const -> Features { return {}; }
bool AnySceneImporter::doIsOpened() const { return !!_in; }
void AnySceneImporter::doClose() {
_in = nullptr;
}
void AnySceneImporter::doOpenFile(const std::string& filename) {
CORRADE_INTERNAL_ASSERT(manager());
/* Detect type from extension */
std::string plugin;
if(Utility::String::endsWith(filename, ".3ds") ||
Utility::String::endsWith(filename, ".ase"))
plugin = "3dsImporter";
else if(Utility::String::endsWith(filename, ".ac"))
plugin = "Ac3dImporter";
else if(Utility::String::endsWith(filename, ".blend"))
plugin = "BlenderImporter";
else if(Utility::String::endsWith(filename, ".bvh"))
plugin = "BvhImporter";
else if(Utility::String::endsWith(filename, ".csm"))
plugin = "CsmImporter";
else if(Utility::String::endsWith(filename, ".dae"))
plugin = "ColladaImporter";
else if(Utility::String::endsWith(filename, ".x"))
plugin = "DirectXImporter";
else if(Utility::String::endsWith(filename, ".dxf"))
plugin = "DxfImporter";
else if(Utility::String::endsWith(filename, ".fbx"))
plugin = "FbxImporter";
else if(Utility::String::endsWith(filename, ".gltf") ||
Utility::String::endsWith(filename, ".glb"))
plugin = "GltfImporter";
else if(Utility::String::endsWith(filename, ".ifc"))
plugin = "IfcImporter";
else if(Utility::String::endsWith(filename, ".irrmesh") ||
Utility::String::endsWith(filename, ".irr"))
plugin = "IrrlichtImporter";
else if(Utility::String::endsWith(filename, ".lwo") ||
Utility::String::endsWith(filename, ".lws"))
plugin = "LightWaveImporter";
else if(Utility::String::endsWith(filename, ".lxo"))
plugin = "ModoImporter";
else if(Utility::String::endsWith(filename, ".ms3d"))
plugin = "MilkshapeImporter";
else if(Utility::String::endsWith(filename, ".obj"))
plugin = "ObjImporter";
else if(Utility::String::endsWith(filename, ".xml"))
plugin = "OgreImporter";
else if(Utility::String::endsWith(filename, ".ogex"))
plugin = "OpenGexImporter";
else if(Utility::String::endsWith(filename, ".ply"))
plugin = "StanfordImporter";
else if(Utility::String::endsWith(filename, ".stl"))
plugin = "StlImporter";
else if(Utility::String::endsWith(filename, ".cob") ||
Utility::String::endsWith(filename, ".scn"))
plugin = "TrueSpaceImporter";
else if(Utility::String::endsWith(filename, ".3d"))
plugin = "UnrealImporter";
else if(Utility::String::endsWith(filename, ".smd") ||
Utility::String::endsWith(filename, ".vta"))
plugin = "ValveImporter";
else if(Utility::String::endsWith(filename, ".xgl") ||
Utility::String::endsWith(filename, ".zgl"))
plugin = "XglImporter";
else {
Error() << "Trade::AnySceneImporter::openFile(): cannot determine type of file" << filename;
return;
}
/* Try to load the plugin */
if(!(manager()->load(plugin) & PluginManager::LoadState::Loaded)) {
Error() << "Trade::AnySceneImporter::openFile(): cannot load" << plugin << "plugin";
return;
}
/* Try to open the file (error output should be printed by the plugin
itself) */
std::unique_ptr<AbstractImporter> importer = static_cast<PluginManager::Manager<AbstractImporter>*>(manager())->instance(plugin);
if(!importer->openFile(filename)) return;
/* Success, save the instance */
_in = std::move(importer);
}
Int AnySceneImporter::doDefaultScene() { return _in->defaultScene(); }
UnsignedInt AnySceneImporter::doSceneCount() const { return _in->sceneCount(); }
Int AnySceneImporter::doSceneForName(const std::string& name) { return _in->sceneForName(name); }
std::string AnySceneImporter::doSceneName(const UnsignedInt id) { return _in->sceneName(id); }
Containers::Optional<SceneData> AnySceneImporter::doScene(const UnsignedInt id) { return _in->scene(id); }
UnsignedInt AnySceneImporter::doLightCount() const { return _in->lightCount(); }
Int AnySceneImporter::doLightForName(const std::string& name) { return _in->lightForName(name); }
std::string AnySceneImporter::doLightName(const UnsignedInt id) { return _in->lightName(id); }
Containers::Optional<LightData> AnySceneImporter::doLight(const UnsignedInt id) { return _in->light(id); }
UnsignedInt AnySceneImporter::doCameraCount() const { return _in->cameraCount(); }
Int AnySceneImporter::doCameraForName(const std::string& name) { return _in->cameraForName(name); }
std::string AnySceneImporter::doCameraName(const UnsignedInt id) { return _in->cameraName(id); }
Containers::Optional<CameraData> AnySceneImporter::doCamera(const UnsignedInt id) { return _in->camera(id); }
UnsignedInt AnySceneImporter::doObject2DCount() const { return _in->object2DCount(); }
Int AnySceneImporter::doObject2DForName(const std::string& name) { return _in->object2DForName(name); }
std::string AnySceneImporter::doObject2DName(const UnsignedInt id) { return _in->object2DName(id); }
std::unique_ptr<ObjectData2D> AnySceneImporter::doObject2D(const UnsignedInt id) { return _in->object2D(id); }
UnsignedInt AnySceneImporter::doObject3DCount() const { return _in->object3DCount(); }
Int AnySceneImporter::doObject3DForName(const std::string& name) { return _in->object3DForName(name); }
std::string AnySceneImporter::doObject3DName(const UnsignedInt id) { return _in->object3DName(id); }
std::unique_ptr<ObjectData3D> AnySceneImporter::doObject3D(const UnsignedInt id) { return _in->object3D(id); }
UnsignedInt AnySceneImporter::doMesh2DCount() const { return _in->mesh2DCount(); }
Int AnySceneImporter::doMesh2DForName(const std::string& name) { return _in->mesh2DForName(name); }
std::string AnySceneImporter::doMesh2DName(const UnsignedInt id) { return _in->mesh2DName(id); }
Containers::Optional<MeshData2D> AnySceneImporter::doMesh2D(const UnsignedInt id) { return _in->mesh2D(id); }
UnsignedInt AnySceneImporter::doMesh3DCount() const { return _in->mesh3DCount(); }
Int AnySceneImporter::doMesh3DForName(const std::string& name) { return _in->mesh3DForName(name); }
std::string AnySceneImporter::doMesh3DName(const UnsignedInt id) { return _in->mesh3DName(id); }
Containers::Optional<MeshData3D> AnySceneImporter::doMesh3D(const UnsignedInt id) { return _in->mesh3D(id); }
UnsignedInt AnySceneImporter::doMaterialCount() const { return _in->materialCount(); }
Int AnySceneImporter::doMaterialForName(const std::string& name) { return _in->materialForName(name); }
std::string AnySceneImporter::doMaterialName(const UnsignedInt id) { return _in->materialName(id); }
std::unique_ptr<AbstractMaterialData> AnySceneImporter::doMaterial(const UnsignedInt id) { return _in->material(id); }
UnsignedInt AnySceneImporter::doTextureCount() const { return _in->textureCount(); }
Int AnySceneImporter::doTextureForName(const std::string& name) { return _in->textureForName(name); }
std::string AnySceneImporter::doTextureName(const UnsignedInt id) { return _in->textureName(id); }
Containers::Optional<TextureData> AnySceneImporter::doTexture(const UnsignedInt id) { return _in->texture(id); }
UnsignedInt AnySceneImporter::doImage1DCount() const { return _in->image1DCount(); }
Int AnySceneImporter::doImage1DForName(const std::string& name) { return _in->image1DForName(name); }
std::string AnySceneImporter::doImage1DName(const UnsignedInt id) { return _in->image1DName(id); }
Containers::Optional<ImageData1D> AnySceneImporter::doImage1D(const UnsignedInt id) { return _in->image1D(id); }
UnsignedInt AnySceneImporter::doImage2DCount() const { return _in->image2DCount(); }
Int AnySceneImporter::doImage2DForName(const std::string& name) { return _in->image2DForName(name); }
std::string AnySceneImporter::doImage2DName(const UnsignedInt id) { return _in->image2DName(id); }
Containers::Optional<ImageData2D> AnySceneImporter::doImage2D(const UnsignedInt id) { return _in->image2D(id); }
UnsignedInt AnySceneImporter::doImage3DCount() const { return _in->image3DCount(); }
Int AnySceneImporter::doImage3DForName(const std::string& name) { return _in->image3DForName(name); }
std::string AnySceneImporter::doImage3DName(const UnsignedInt id) { return _in->image3DName(id); }
Containers::Optional<ImageData3D> AnySceneImporter::doImage3D(const UnsignedInt id) { return _in->image3D(id); }
}}

196
src/MagnumPlugins/AnySceneImporter/AnySceneImporter.h

@ -0,0 +1,196 @@
#ifndef Magnum_Trade_AnySceneImporter_h
#define Magnum_Trade_AnySceneImporter_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Class @ref Magnum::Trade::AnySceneImporter
*/
#include <Magnum/Trade/AbstractImporter.h>
#include "MagnumPlugins/AnySceneImporter/configure.h"
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_ANYSCENEIMPORTER_BUILD_STATIC
#if defined(AnySceneImporter_EXPORTS) || defined(AnySceneImporterObjects_EXPORTS)
#define MAGNUM_ANYSCENEIMPORTER_EXPORT CORRADE_VISIBILITY_EXPORT
#else
#define MAGNUM_ANYSCENEIMPORTER_EXPORT CORRADE_VISIBILITY_IMPORT
#endif
#else
#define MAGNUM_ANYSCENEIMPORTER_EXPORT CORRADE_VISIBILITY_STATIC
#endif
#define MAGNUM_ANYSCENEIMPORTER_LOCAL CORRADE_VISIBILITY_LOCAL
#else
#define MAGNUM_ANYSCENEIMPORTER_EXPORT
#define MAGNUM_ANYSCENEIMPORTER_LOCAL
#endif
namespace Magnum { namespace Trade {
/**
@brief Any scene importer plugin
Detects file type based on file extension, loads corresponding plugin and then
tries to open the file with it.
This plugin depends on the @ref Trade library and is built if
`WITH_ANYSCENEIMPORTER` is enabled when building Magnum Plugins. To use as a
dynamic plugin, you need to load the @cpp "AnySceneImporter" @ce plugin from
`MAGNUM_PLUGINS_IMPORTER_DIR`. To use as a static plugin or as a dependency of
another plugin with CMake, you need to request the `AnySceneImporter` component
of the `MagnumPlugins` package in CMake and link to the
`MagnumPlugins::AnySceneImporter` target. See @ref building-plugins,
@ref cmake-plugins and @ref plugins for more information.
Supported formats:
- 3ds Max 3DS and ASE (`*.3ds`, `*.ase`), loaded with any plugin that
provides `3dsImporter`
- AC3D (`*.ac`), loaded with any plugin that provides `Ac3dImporter`
- Blender 3D (`*.blend`), loaded with any plugin that provides
`BlenderImporter`
- Biovision BVH (`*.bvh`), loaded with any plugin that provides `BvhImporter`
- CharacterStudio Motion (`*.csm`), loaded with any plugin that provides
`CsmImporter`
- COLLADA (`*.dae`), loaded with @ref ColladaImporter or any other plugin
that provides it
- DirectX X (`*.x`), loaded with any plugin that provides `DirectXImporter`
- AutoCAD DXF (`*.dxf`), loaded with any plugin that provides `DxfImporter`
- Autodesk FBX (`*.fbx`), loaded with any plugin that provides `FbxImporter`
- glTF (`*.gltf`, `*.glb`), loaded with any plugin that provides
`GltfImporter`
- Industry Foundation Classes (IFC/Step) (`*.ifc`), loaded with any plugin
that provides `IfcImporter`
- Irrlicht Mesh and Scene (`*.irrmesh`, `*.irr`), loaded with any plugin that
provides `IrrlichtImporter`
- LightWave, LightWave Scene (`*.lwo`, `*.lws`), loaded with any plugin that
provides `LightWaveImporter`
- Modo (`*.lxo`), loaded with any plugin that provides `ModoImporter`
- Milkshape 3D (`*.ms3d`), loaded with any plugin that provides
`MilkshapeImporter`
- Wavefront OBJ (`*.obj`), loaded with @ref ObjImporter or any other plugin
that provides it
- Ogre XML (`*.xml`), loaded with any plugin that provides `OgreImporter`
- OpenGEX (`*.ogex`), loaded with @ref OpenGexImporter or any other plugin
that provides it
- Stanford (`*.ply`), loaded with @ref StanfordImporter or any other plugin
that provides it
- Stereolitography (`*.stl`), loaded with any plugin that provides
`StlImporter`
- TrueSpace (`*.cob`, `*.scn`), loaded with any plugin that provides
`TrueSpaceImporter`
- Unreal (`*.3d`), loaded with any plugin that provides `UnrealImporter`
- Valve Model (`*.smd`, `*.vta`), loaded with any plugin that provides
`ValveImporter`
- XGL (`*.xgl`, `*.zgl`), loaded with any plugin that provides `XglImporter`
Only loading from files is supported.
*/
class MAGNUM_ANYSCENEIMPORTER_EXPORT AnySceneImporter: public AbstractImporter {
public:
/** @brief Constructor with access to plugin manager */
explicit AnySceneImporter(PluginManager::Manager<AbstractImporter>& manager);
/** @brief Plugin manager constructor */
explicit AnySceneImporter(PluginManager::AbstractManager& manager, const std::string& plugin);
~AnySceneImporter();
private:
MAGNUM_ANYSCENEIMPORTER_LOCAL Features doFeatures() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL bool doIsOpened() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL void doClose() override;
MAGNUM_ANYSCENEIMPORTER_LOCAL void doOpenFile(const std::string& filename) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doDefaultScene() override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doSceneCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doSceneForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doSceneName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<SceneData> doScene(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doLightCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doLightForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doLightName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<LightData> doLight(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doCameraCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doCameraForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doCameraName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<CameraData> doCamera(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doObject2DCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doObject2DForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doObject2DName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::unique_ptr<ObjectData2D> doObject2D(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doObject3DCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doObject3DForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doObject3DName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::unique_ptr<ObjectData3D> doObject3D(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doMesh2DCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doMesh2DForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doMesh2DName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<MeshData2D> doMesh2D(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doMesh3DCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doMesh3DForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doMesh3DName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<MeshData3D> doMesh3D(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doMaterialCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doMaterialForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doMaterialName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::unique_ptr<AbstractMaterialData> doMaterial(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doTextureCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doTextureForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doTextureName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<TextureData> doTexture(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doImage1DCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doImage1DForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doImage1DName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<ImageData1D> doImage1D(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doImage2DCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doImage2DForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doImage2DName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<ImageData2D> doImage2D(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL UnsignedInt doImage3DCount() const override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Int doImage3DForName(const std::string& name) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL std::string doImage3DName(UnsignedInt id) override;
MAGNUM_ANYSCENEIMPORTER_LOCAL Containers::Optional<ImageData3D> doImage3D(UnsignedInt id) override;
std::unique_ptr<AbstractImporter> _in;
};
}}
#endif

84
src/MagnumPlugins/AnySceneImporter/CMakeLists.txt

@ -0,0 +1,84 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
if(BUILD_STATIC)
set(MAGNUM_ANYSCENEIMPORTER_BUILD_STATIC 1)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
set(AnySceneImporter_SRCS
AnySceneImporter.cpp)
set(AnySceneImporter_HEADERS
AnySceneImporter.h)
# Objects shared between plugin and test library
add_library(AnySceneImporterObjects OBJECT
${AnySceneImporter_SRCS}
${AnySceneImporter_HEADERS})
target_include_directories(AnySceneImporterObjects PUBLIC
$<TARGET_PROPERTY:Magnum::Magnum,INTERFACE_INCLUDE_DIRECTORIES>
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
target_compile_definitions(AnySceneImporterObjects PRIVATE "AnySceneImporterObjects_EXPORTS")
if(NOT BUILD_STATIC OR BUILD_STATIC_PIC)
set_target_properties(AnySceneImporterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
set_target_properties(AnySceneImporterObjects PROPERTIES FOLDER "MagnumPlugins/AnySceneImporter")
# AnySceneImporter plugin
add_plugin(AnySceneImporter
"${MAGNUM_PLUGINS_IMPORTER_DEBUG_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_IMPORTER_DEBUG_LIBRARY_INSTALL_DIR}"
"${MAGNUM_PLUGINS_IMPORTER_RELEASE_BINARY_INSTALL_DIR};${MAGNUM_PLUGINS_IMPORTER_RELEASE_LIBRARY_INSTALL_DIR}"
AnySceneImporter.conf
$<TARGET_OBJECTS:AnySceneImporterObjects>
pluginRegistration.cpp)
if(BUILD_STATIC_PIC)
set_target_properties(AnySceneImporter PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
target_include_directories(AnySceneImporter PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
target_link_libraries(AnySceneImporter Magnum::Magnum)
install(FILES ${AnySceneImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnySceneImporter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/AnySceneImporter)
if(BUILD_TESTS)
add_library(MagnumAnySceneImporterTestLib STATIC
$<TARGET_OBJECTS:AnySceneImporterObjects>
${PROJECT_SOURCE_DIR}/src/dummy.cpp) # XCode workaround, see file comment for details
target_include_directories(MagnumAnySceneImporterTestLib PUBLIC
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src)
set_target_properties(MagnumAnySceneImporterTestLib PROPERTIES FOLDER "MagnumPlugins/AnySceneImporter")
target_link_libraries(MagnumAnySceneImporterTestLib Magnum::Magnum)
add_subdirectory(Test)
endif()
# MagnumPlugins AnySceneImporter target alias for superprojects
add_library(MagnumPlugins::AnySceneImporter ALIAS AnySceneImporter)

50
src/MagnumPlugins/AnySceneImporter/Test/CMakeLists.txt

@ -0,0 +1,50 @@
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
# Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
if(CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID)
set(OBJ_FILE mesh.obj)
set(PLY_FILE common.ply)
else()
set(OBJ_FILE ${CMAKE_CURRENT_SOURCE_DIR}/mesh.obj)
set(PLY_FILE ${PROJECT_SOURCE_DIR}/src/MagnumPlugins/StanfordImporter/Test/common.ply)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
corrade_add_test(AnySceneImporterTest Test.cpp
LIBRARIES MagnumAnySceneImporterTestLib
FILES
mesh.obj
../../StanfordImporter/Test/common.ply)
target_include_directories(AnySceneImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
# On Win32 we need to avoid dllimporting AnySceneImporter symbols, because it
# would search for the symbols in some DLL even when they were linked
# statically. However it apparently doesn't matter that they were dllexported
# when building the static library. EH.
if(WIN32)
target_compile_definitions(AnySceneImporterTest PRIVATE "MAGNUM_ANYSCENEIMPORTER_BUILD_STATIC")
endif()
set_target_properties(AnySceneImporterTest PROPERTIES FOLDER "MagnumPlugins/AnySceneImporter/Test")

95
src/MagnumPlugins/AnySceneImporter/Test/Test.cpp

@ -0,0 +1,95 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include <sstream>
#include <Corrade/PluginManager/Manager.h>
#include <Corrade/TestSuite/Tester.h>
#include <Magnum/Math/Vector3.h>
#include <Magnum/Trade/MeshData3D.h>
#include "MagnumPlugins/AnySceneImporter/AnySceneImporter.h"
#include "configure.h"
namespace Magnum { namespace Trade { namespace Test {
struct AnySceneImporterTest: TestSuite::Tester {
explicit AnySceneImporterTest();
void obj();
void ply();
void unknown();
private:
PluginManager::Manager<AbstractImporter> _manager;
};
AnySceneImporterTest::AnySceneImporterTest(): _manager{MAGNUM_PLUGINS_IMPORTER_DIR} {
addTests({&AnySceneImporterTest::obj,
&AnySceneImporterTest::ply,
&AnySceneImporterTest::unknown});
}
void AnySceneImporterTest::obj() {
if(_manager.loadState("ObjImporter") == PluginManager::LoadState::NotFound)
CORRADE_SKIP("ObjImporter plugin not found, cannot test");
AnySceneImporter importer{_manager};
CORRADE_VERIFY(importer.openFile(OBJ_FILE));
/* Check only size, as it is good enough proof that it is working */
Containers::Optional<MeshData3D> mesh = importer.mesh3D(0);
CORRADE_VERIFY(mesh);
CORRADE_COMPARE(mesh->positions(0).size(), 3);
}
void AnySceneImporterTest::ply() {
if(_manager.loadState("StanfordImporter") == PluginManager::LoadState::NotFound)
CORRADE_SKIP("StanfordImporter plugin not found, cannot test");
AnySceneImporter importer{_manager};
CORRADE_VERIFY(importer.openFile(PLY_FILE));
/* Check only size, as it is good enough proof that it is working */
Containers::Optional<MeshData3D> mesh = importer.mesh3D(0);
CORRADE_VERIFY(mesh);
CORRADE_COMPARE(mesh->positions(0).size(), 5);
}
void AnySceneImporterTest::unknown() {
std::ostringstream output;
Error redirectError{&output};
AnySceneImporter importer{_manager};
CORRADE_VERIFY(!importer.openFile("mesh.wtf"));
CORRADE_COMPARE(output.str(), "Trade::AnySceneImporter::openFile(): cannot determine type of file mesh.wtf\n");
}
}}}
CORRADE_TEST_MAIN(Magnum::Trade::Test::AnySceneImporterTest)

33
src/MagnumPlugins/AnySceneImporter/Test/configure.h.cmake

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

10
src/MagnumPlugins/AnySceneImporter/Test/mesh.obj

@ -0,0 +1,10 @@
# Positions
v 0.5 2 3
v 0 1.5 1
v 2 3 5.0
# Points
p 1
p 3
p 2
p 1

26
src/MagnumPlugins/AnySceneImporter/configure.h.cmake

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

29
src/MagnumPlugins/AnySceneImporter/pluginRegistration.cpp

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