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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to