Wang,

I was wondering how you would keep this information resident in the Registry.  
From your first example it seems like you are setting an option that would 
attempt to be applied to ALL ReaderWriter transactions, regardless of 
extension.  In this case, some general types of options could be agreed upon 
and used by many different plugins.  In your second example it looks like you 
want to create a specific option map for a single ReaderWriter.  In this case 
the option would ONLY be applied to the dds plugin.  So are you thinking about 
having both cases handled with your implementation - both multi-plugin as well 
as single-plugin options?

Chuck Seberino

On Oct 17, 2010, at 2:04 AM, Wang Rui 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
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to