Hi JS, I don't believe removing newlines that exist in strings from Ouput::wrapString() is appropriate. If a newlines are in a string it really should be honored.
I believe we need to get to the bottom of what you are seeing at your end and see if we can reproduce it elsewhere. I've tried a couple of experiments using osgconv on .osg files with shaders with newlines and it all works correctly. Perhaps it's a windows issue? Could you provide some guidance on how to reproduce the problem? Robert. On Fri, Mar 12, 2010 at 4:57 PM, Jean-Sébastien Guay <jean-sebastien.g...@cm-labs.com> wrote: > Hi Robert, > > This fixes a small problem in .osg files, where inline shaders would have an > extra newline per line: > > Shader { > type VERTEX > code { > "#version 120 > " > "#extension GL_EXT_geometry_shader4 : enable > " > "uniform mat4 osg_ViewMatrixInverse; > " > " > " > > ... > > This is because the shader is being written directly from the string > (_shaderSource) to the .osg file, and that string contains newlines. > > osgDB::Output::wrapString() is called from > src/osgWrappers/deprecated-dotosg/osg/Shader.cpp : Shader_writeLocalData(). > I made the change to osgDB::Output::wrapString() because I think in no case > would we want to keep those newlines when writing a wrapped string, because > the wrapping itself adds a newline after each closing quote of each line > anyways. So the same shader above now looks like: > > Shader { > type VERTEX > code { > "#version 120" > "#extension GL_EXT_geometry_shader4 : enable" > "uniform mat4 osg_ViewMatrixInverse;" > "" > > ... > > I also made the corresponding change for the new .osgt plugin. > AsciiOutputIterator::writeWrappedString() is called from > src/osgWrappers/serializers/osg/Shader.cpp : writeShaderSource(). Again the > change will take effect for any wrapped string. I have tested this and it > fixes it too. > > The reading already adds a newline to each line of code read from the > .osg/.osgt file, so the shader code we read will be what we want. The only > thing that didn't work on reading was that empty lines were discarded in the > old deprecated .osg plugin. The change to > src/osgWrappers/deprecated-dotosg/osg/Shader.cpp fixes that. > > So Output.cpp goes in src/osgDB, AsciiStreamOperator.h goes in > src/osgPlugins/osg, and Shader.cpp goes in > src/osgWrappers/deprecated-dotosg/osg/ > > By the way, is there a way of commenting out lines in the old or new > .osg/.osgt formats? > > Thanks, and sorry for being verbose. > > J-S > > -- > ______________________________________________________ > Jean-Sebastien Guay jean-sebastien.g...@cm-labs.com > http://www.cm-labs.com/ > http://whitestar02.webhop.org/ > > _______________________________________________ > 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