You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.8 KiB

#include <Corrade/PluginManager/Manager.h>
#include <Corrade/Utility/ConfigurationGroup.h>
#include "Magnum/Text/AbstractFont.h"
#include "Magnum/Trade/AbstractImporter.h"
/* [static-import] */
/* No need to do this if you use CMake */
#include <MagnumPlugins/TgaImporter/importStaticPlugin.cpp>
/* [static-import] */
using namespace Magnum;
int main() {
/* [loading] */
{
PluginManager::Manager<Trade::AbstractImporter> manager;
std::unique_ptr<Trade::AbstractImporter> importer =
manager.loadAndInstantiate("TgaImporter");
if(!importer) Fatal{} << "Cannot load the TgaImporter plugin";
// Use the plugin...
/* At the end of the scope the importer instance gets deleted and then
the manager automatically unloads the plugin on destruction */
}
/* [loading] */
{
/* [dependencies] */
PluginManager::Manager<Trade::AbstractImporter> importerManager;
PluginManager::Manager<Text::AbstractFont> fontManager;
// As a side effect TgaImporter is loaded by importerManager
fontManager.load("MagnumFont");
/* [dependencies] */
}
{
/* [aliases] */
PluginManager::Manager<Text::AbstractFont> fontManager;
fontManager.setPreferredPlugins("TrueTypeFont", {"HarfBuzzFont", "FreeTypeFont"});
/* [aliases] */
}
{
PluginManager::Manager<Trade::AbstractImporter> manager;
/* [anyimporter] */
std::unique_ptr<Trade::AbstractImporter> importer =
manager.instantiate("AnyImageImporter");
importer->openFile("texture.dds"); /* Delegates to the DdsImporter plugin */
/* [anyimporter] */
}
{
PluginManager::Manager<Trade::AbstractImporter> manager;
/* [configuration] */
std::unique_ptr<Trade::AbstractImporter> importer =
manager.instantiate("AssimpImporter");
importer->configuration().group("postprocess")->setValue("PreTransformVertices", true);
/* [configuration] */
}
}