Hi Wang Rui, Having a more formal ReaderWriter option control would be a good thing, the current osgDB::Option::OptionString usage is rather overstretched and inflexible. The already exists the Options::PluginStringData which is newer and more flexible but not used extensively, making more use of this for this type of control would be sensible.
Inheritance of settings is something that is something that would need to be handled, we already have a default osgDB::Options object in osgDB::Registry. Could one also have an optional Options object defined per ReaderWriter? Which would take precedence? If we are using the PluginStringData might it be enough just to stick with the Registry::Options object? Perhaps as a simple step we could put options for the "dds" plugin into PluginStringData fields as "dds" i.e. osgDB::Options::setPluginStringData("dds","flip_dds=true") or better simplified osgDB::Options::setPluginStringData("dds","flip") Thoughts? Robert. On Sun, Oct 17, 2010 at 10:04 AM, Wang Rui <wangra...@gmail.com> wrote: > Hi all, > I just encountered an annoying problem that DDS images should be flipped for > correct rendering if generated by DirectDraw-based tools. The images are > already included in scene files (like osg, ive, obj, etc.) so osgdb_dds's > "flip_dds" option cannot be used directly. Of course making own plugins, > altering texture coordinates and using node visitors are all possible > solutions. But I'm wondering if there is some other way to handle such > problems, for example, set a plugin's global state and then change > its behaviors on the fly. > My plan is to modify the osgDB::ReaderWriter interface and add a new virtual > method setGlobalOption(), which does nothing by default. Specific plugins > can override this method to realize certain functionalities accordingly; and > other plugins' code will not be broken any more. For example, assuming we > have got the dds reader writer: > rwDDS->setGlobalOption("flip_dds=true"); // Ready to read flipped DDS > images > rwDDS->readImage("directdraw_image1.dds"); > rwDDS->readImage("directdraw_image2.dds"); > ... > rwDDS->readImage("directdraw_imagen.dds"); > rwDDS->setGlobalOption("flip_dds=false"); // OK, reset the behavior > rwDDS->readImage("opengl_image.dds"); > It can also work for other types of plugins (if corresponding method is > implemented), for instance, to force compressing data when saving next few > files: > rwIVE->setGlobalOption("compressed=true") > rwIVE->writeNodeFile(...); > We can even have a convenient method like > Registry::setGlobalOptionForExtension(). Then, when reading scene files with > flipped dds files, we will have: > osgDB::instance()->setGlobalOptionForExtension("dds", "flip_dds=true"); > osgDB::readNodeFile("directdraw_image.dds"); > So is this necessary to be added to current osgDB functionalities? (I'd like > to code if necessary) Any opinions or better ideas about this? Or have we > already had too much discussions about this? :-) > Cheers, > Wang Rui > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org