Browse Source

Doc++

pull/205/merge
Vladimír Vondruš 8 years ago
parent
commit
1491415379
  1. 2
      doc/getting-started.dox
  2. 1
      doc/platforms-windows.dox
  3. 37
      doc/plugins.dox
  4. 12
      doc/snippets/plugins.cpp
  5. 2
      src/Magnum/Trade/AbstractImporter.h

2
doc/getting-started.dox

@ -138,7 +138,7 @@ find_package(Magnum REQUIRED Sdl2Application)
set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS ON)
add_executable(MyApplication MyApplication.cpp)
target_link_libraries(MyApplication
target_link_libraries(MyApplication PRIVATE
Magnum::Magnum
Magnum::Application)
@endcode

1
doc/platforms-windows.dox

@ -39,6 +39,7 @@ See @ref Platform::Sdl2Application for more information about WinRT.
@todoc mingw, clang, clang/c2...
@todoc "unicode"
@todoc colored console output
@todoc lcov on mingw (ugh)
*/
}

37
doc/plugins.dox

@ -116,10 +116,14 @@ explicitly find the plugin and link it into the executable. If you use CMake,
it would look like this:
@code{.cmake}
find_package(MagnumPlugins REQUIRED PngImporter)
add_executable(MyApp ...)
target_link_libraries(MyApp ... MagnumPlugins::PngImporter)
find_package(MagnumPlugins REQUIRED
TinyGltfImporter
StbTrueTypeFont)
add_executable(my-app my-app.cpp)
target_link_libraries(my-app PRIVATE
MagnumPlugins::TinyGltfImporter
MagnumPlugins::StbTrueTypeFont)
@endcode
The only user-visible behavioral change in the code will be that
@ -141,20 +145,20 @@ application. The static import file contains just a simple call to
@section plugins-aliases Plugin aliases and "any" plugins
There's usually more than one plugin available to achieve a particular thing
--- for example in order to open a PNG file, you can choose among
There's usually more than one plugin available to achieve a particular goal ---
for example in order to open a PNG file, you can choose among
@ref Trade::PngImporter "PngImporter", @ref Trade::StbImageImporter "StbImageImporter"
or @ref Trade::DevIlImageImporter "DevIlImageImporter" plugins. Rather than
this being an unnecessary redundancy, it allows you to choose among different
performance / portability / feature tradeoffs --- choose a plugin with no
external dependencies or on the other hand pick the fastest possible
implementation.
this being an unnecessary redundancy, it allows you to pick a particular
performance / portability / feature tradeoff --- a plugin with no external
dependencies for a web build or, on the other hand, the fastest possible
implementation for a tool that does heavy image processing.
The decision what plugin to use is usually done in the buildsystem or during
the deploy. To make this simpler in the code itself, all plugins that support a
particular format provide a common *alias*. In the case of PNG images, you can
just load a @cpp "PngImporter" @ce plugin and if @ref Trade::PngImporter "PngImporter"
is not available, it will pick up any of the other candidates.
To make this simpler in the code and defer the decision to the buildsystem or
app deployment, all plugins that support a particular format provide a common
*alias* --- in case of PNG images, you can just load a @cpp "PngImporter" @ce
plugin and if @ref Trade::PngImporter "PngImporter" is not available, it will
pick up any of the other candidates.
For greater control you can also use
@ref Corrade::PluginManager::AbstractManager::setPreferredPlugins() "setPreferredPlugins()",
@ -196,7 +200,8 @@ all possible knobs and switches that a file format could support, the plugins
have a possibility to supply additional configuration via the
@ref Corrade::PluginManager::AbstractPlugin::configuration() "configuration()"
function. For example, in the @ref Trade-AssimpImporter-configuration "AssimpImporter"
plugin you can toggle various postprocessing modules:
plugin you can toggle various postprocessing steps that are applied to loaded
scene files:
@snippet plugins.cpp configuration

12
doc/snippets/plugins.cpp

@ -4,10 +4,16 @@
#include "Magnum/Text/AbstractFont.h"
#include "Magnum/Trade/AbstractImporter.h"
#ifdef __has_include
#if __has_include(<MagnumPlugins/TinyGltfImporter/importStaticPlugin.cpp>) && \
__has_include(<MagnumPlugins/StbTrueTypeFont/importStaticPlugin.cpp>)
/* [static-import] */
/* No need to do this if you use CMake */
#include <MagnumPlugins/TgaImporter/importStaticPlugin.cpp>
#include <MagnumPlugins/TinyGltfImporter/importStaticPlugin.cpp>
#include <MagnumPlugins/StbTrueTypeFont/importStaticPlugin.cpp>
/* [static-import] */
#endif
#endif
using namespace Magnum;
@ -39,8 +45,8 @@ fontManager.load("MagnumFont");
{
/* [aliases] */
PluginManager::Manager<Text::AbstractFont> fontManager;
fontManager.setPreferredPlugins("TrueTypeFont", {"HarfBuzzFont", "FreeTypeFont"});
PluginManager::Manager<Text::AbstractFont> manager;
manager.setPreferredPlugins("TrueTypeFont", {"HarfBuzzFont", "FreeTypeFont"});
/* [aliases] */
}

2
src/Magnum/Trade/AbstractImporter.h

@ -54,7 +54,7 @@ data. See @ref plugins for more information and `*Importer` classes in
@section Trade-AbstractImporter-subclassing Subclassing
The plugin needs to implement the @ref doFeatures(), @ref doIsOpened()
functions, at least one of @ref doOpenData() / @ref doOpenFile() @ref doOpenState()
functions, at least one of @ref doOpenData() / @ref doOpenFile() / @ref doOpenState()
functions, function @ref doClose() and one or more tuples of data access
functions, based on what features are supported in given format.

Loading…
Cancel
Save