Commit Graph

10 Commits

Author SHA1 Message Date
Robert Osfield
dd996a3289 Introduced CMake option OSG_PROVIDE_READFILE option that defaults to ON, but when switched to OFF disables the building of the osgDB::read*File() methods,
forcing users to use osgDB::readRef*File() methods.  The later is preferable as it closes a potential threading bug when using paging databases in conjunction
with the osgDB::Registry Object Cache.  This threading bug occurs when one thread gets an object from the Cache via an osgDB::read*File() call where only
a pointer to the object is passed back, so taking a reference to the object is delayed till it gets reassigned to a ref_ptr<>, but at the same time another
thread calls a flush of the Object Cache deleting this object as it's referenceCount is now zero.  Using osgDB::readREf*File() makes sure the a ref_ptr<> is
passed back and the referenceCount never goes to zero.

To ensure the OSG builds when OSG_PROVIDE_READFILE is to OFF the many cases of osgDB::read*File() usage had to be replaced with a ref_ptr<> osgDB::readRef*File()
usage.  The avoid this change causing lots of other client code to be rewritten to handle the use of ref_ptr<> in place of C pointer I introduced a serious of
templte methods in various class to adapt ref_ptr<> to the underly C pointer to be passed to old OSG API's, example of this is found in include/osg/Group:

    bool addChild(Node* child); // old method which can only be used with a Node*

    tempalte<class T> bool addChild(const osg::ref_ptr<T>& child) { return addChild(child.get()); } // adapter template method

These changes together cover 149 modified files, so it's a large submission. This extent of changes are warrent to make use of the Object Cache
and multi-threaded loaded more robust.



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@15164 16af8721-9629-0410-8352-f15c8da7e697
2015-10-22 13:42:19 +00:00
Robert Osfield
0a1db3d6fc From Jannik Heller, typo fixes
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14832 16af8721-9629-0410-8352-f15c8da7e697
2015-04-13 10:43:56 +00:00
Robert Osfield
b41e5ccc77 Changed the default directory for the output files to be the current working directory,
with the --write-to-source-file-directory added to allow one to have the original behaviour
of writing to the same directory as the original source file.
2014-01-20 17:03:29 +00:00
Robert Osfield
981182fb01 From Kim Bale, "The application description for osg2cpp was cut and pasted from osgconv and not changed.
I've added a more relevant description."
2012-02-17 16:51:10 +00:00
Robert Osfield
960f20fe1e Fixed the searchAndReplace function so that it correctly skips over the newly inserted replacement strings. 2011-05-27 11:07:04 +00:00
Robert Osfield
9bbf71b53a From Wang Rui, "A Chinese engineer (named Beilei Geng) reports a possible bug in the
osg2cpp application to me today. The conversion result may become
incorrect if there are quotation marks ( " ) in the shader file, which
will mostly appear in comment lines.

Replace all " into \" before writing to cpp files will solve the
problem, as the attached file shows."
2011-05-12 12:28:43 +00:00
Robert Osfield
b4562b0393 From Jean-Sebastien Guay, Explanation:
Currently osg2cpp removes "\n" line endings to replace them with a textual equivalent ("\\n") in order for the string representing the shader to contain line endings in the string. But if the file that was read contained Windows line endings ("\r\n"), the resulting file looked really weird (the \r were left there and editors interpreted that as an additional newline). Also, I can imagine that if the shader file that was read had Mac line endings ("\r") then the output shader would all end up in one long line since there are no "\n"...

What I've done:

I've added a search and replace of "\r\n" to "\n", and then "\r" to "\n" (note that the order is important).

I've also changed the filename handling so that the output file will be put in the same directory as the input file in case it was specified with a path. Previous functionality is retained for files specified with the filename only.""
2009-11-27 15:39:07 +00:00
Robert Osfield
22e4e63060 From Gary Quinn, spelling fixes 2009-02-06 15:17:49 +00:00
Robert Osfield
720551d549 From Michael Platings, Converted std::fstream/ifstream/ofstream to osgDB::fstream/ifstream/ofstream and
fopen to osgDB::fopen to facilitate support for wide character filenames using UT8 encoding.
2008-11-07 15:08:08 +00:00
Robert Osfield
8c276a0b5e Created new osg2cpp utility that creates .cpp files from source shaders that can be included directly in application code, see osgvolume for an example. 2008-09-25 14:39:57 +00:00