Comments (3)
Hi,
sorry, should have told you about this limitation sooner -- I completely forgot that this would hit you very early in the process of creating the converter plugin. It's on my TODO list (and currently also part of mosra/magnum#108). Yes, you are basically on the right path, there's unfortunately some missing parts that I need to put into the plugin manager in order for it to work. The workflow should be then like this (in case of the stb_image_write
plugin):
- There's just one plugin binary, named
StbImageConverter
, and it has aliases likeStbPngImageConverter
,StbTgaImageConverter
etc.- For the general "any converter" case it would of course also provide aliases like
PngImageConverter
etc. TheStbPngImageConverter
alias is there in case you want to explicitly use this plugin without any other aliases mixing in (more on that in my reply to #25).
- For the general "any converter" case it would of course also provide aliases like
- The
StbImageConverter
class has a constructor that takes either astd::string
(in case the plugin is loaded through plugin manager) or some enum that specifies which format the plugin should convert to (in case the plugin is linked in the executable and instantiated directly). - The enum constructor is obvious, the
std::string
constructor gets a name under which the plugin was instantiated viaPluginManager::Manager::instance()
/PluginManager::Manager::loadAndInstantiate()
. So in case it was instantiated asStbPngImageConverter
orPngImageConverter
, it would provide conversion to PNG. - In order to output to a different type than PNG, you would load another instance with another alias name.
I think this design is pretty usable, though it has a limitation that you need to have different plugin instances in order to output to different file types. But on the other hand this could be exploited to squeeze some additional performance out (for example precalculating some compressor state in the constructor and then reusing it for the whole plugin lifetime instead of recreating it from scratch in every doConvert*()
implementation). So I would keep it this way.
What needs to be done in the plugin manager is:
- The
std::string
passed to the constructor is currently the real name of the plugin, not the alias. It should be the alias in order to make this feature work, but I have to check that this doesn't clash with any other use case. - It should be also possible to create every instance with a different alias passed to the constructor. Also not sure, maybe there is something that prevents this.
- For convenience the alias name should be available through some function. The plugin manager code dates back to 2007 and I have a blurry memory that there once was such function, but then I removed it because (as you discovered) it was also available through the metadata and thus seemed redundant. Now it wouldn't be redundant anymore.
Another thing is -- the user might want to specify some options to the converters (such as compression quality). I have an idea how that could be done in a general way, I'll open another issue for that in the corrade repo.
Will keep you updated on the progress (though as I said in other place, I don't have much time right now).
from magnum-plugins.
Okay. Done! Sorry it took so long.
The required change in the PluginManager library is done in mosra/corrade@834ea41 and the StbImageImporter plugin was reworked to handle also other formats in 332ba6c, you can look there to see how I tried to handle the format distinction. Nothing (except time, hah) should prevent creating the DevIL image converter now :)
from magnum-plugins.
@mosra I'll probably get to it in due time, maybe closer to Valentines day or something. Thanks a lot!
from magnum-plugins.
Related Issues (20)
- AssimpImporter: Should normalize filepaths for external image paths HOT 1
- Static analyzer warning about variable used before initialization in TinyGltfImporter HOT 2
- Unable to install magnum-plugins.deb on Linux Mint 20.2 HOT 3
- KTX2 + Basis Universal HOT 4
- Attentuation for Directional/Sun Lights when importing Blender files HOT 3
- Wrong line ending normalization under Windows due to typo in .gitattributes HOT 1
- AssimpImporter: Embedded textures fail to load with FBX HOT 2
- meshoptimizersceneconverter build failed because meshoptimizer has updated HOT 1
- GltfImporter: spot light with outer angle of 90° produces error HOT 4
- Build Server Configuration Issue. HOT 10
- DrWavAudioImporterTest: cmake error when CORRADE_BUILD_STATIC=ON and BUILD_PLUGINS_STATIC=OFF HOT 2
- vcpkg does not work properly due to lib files not copied to the installed folder HOT 2
- CMake error (missing: AnyImageImporter) HOT 6
- Update Basis Universal plugin for UASTC HOT 4
- FindMagnumPlugins.cmake interaction with Assimp HOT 4
- AssimpImporter crashes on gltf/glb in wasm builds HOT 9
- Updating the basis plugin importer HOT 1
- Compile issues on osx HOT 4
- Expose Configuration Value implementation for Trade::BasisImporter::TargetFormat HOT 4
- Find modules have issues with paths containing spaces HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magnum-plugins.