[osg-users] Cannot save osgText::Text when statically linking OSG

12 views
Skip to first unread message

Iñaki García

unread,
Nov 19, 2010, 5:13:03 AM11/19/10
to OSG Users
Hi all,

When I save my scene to a "file.osg", osgText::Text nodes are not saved
into the file. This happens only when I statically link OSG to my
application, when I use the DLLs everything is OK. So I suppose that the
"Plugins osgText" is not being registered/linked to my app. I have tried
to use the macro USE_OSGPLUGIN(x), but it only works to link
ReaderWriters of "x" extension.

Is there any different way to instruct the compiler to link
osgdb_osgtext.lib code, and tell the osgDB::Registry to use those
functions to save Text nodes?

Thanks in advance
--
*Iñaki García
*
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Nov 19, 2010, 10:38:20 AM11/19/10
to OpenSceneGraph Users
Hi Iñaki,

You'll need to include both the osg plugin and the osgText plugin.
What USE_OSGPLUGIN lines are you using right now?

Robert.

Chris 'Xenon' Hanson

unread,
Nov 19, 2010, 10:54:53 AM11/19/10
to OpenSceneGraph Users
On 11/19/2010 3:13 AM, Iñaki García wrote:
> When I save my scene to a "file.osg", osgText::Text nodes are not saved into the file.
> This happens only when I statically link OSG to my application, when I use the DLLs
> everything is OK. So I suppose that the "Plugins osgText" is not being registered/linked
> to my app. I have tried to use the macro USE_OSGPLUGIN(x), but it only works to link
> ReaderWriters of "x" extension.
> Is there any different way to instruct the compiler to link osgdb_osgtext.lib code, and
> tell the osgDB::Registry to use those functions to save Text nodes?

Basically, you need to have a reference in your main code to some data or code object in
the desired plugin code, so the linker doesn't optimize out the plugin during linking. The
USE_OSGPLUGIN() macro does this for you, but it probably uses some magic that isn't right
for the osgText plugin. I'd look at the macro and see what it's doing, and then go look at
the text plugin and see what you have to do manually (without the macro) to get
approximately the same result.

--
Chris 'Xenon' Hanson, omo sanza lettere. Xe...@AlphaPixel.com http://www.alphapixel.com/
Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen

Iñaki García

unread,
Nov 22, 2010, 4:24:32 AM11/22/10
to OpenSceneGraph Users
Hi Robert,

I am using the following lines in my app for static linking (besides the
full osg built into static libraries):
USE_OSGPLUGIN(ive)
USE_OSGPLUGIN(freetype)
USE_OSGPLUGIN(osg)
USE_OSGPLUGIN(bmp)
USE_GRAPHICSWINDOW()

I've tried an "USE_OSGPLUGIN(osgtext)", but it does not work, as nobody
has ever registered that plugin. When I do that I receive:
error LNK2001: unresolved external symbol _osgdb_osgtext

That means to me that osgdb_osgtext function does not exist, and those
osgdb_[plugin] functions are created in the REGISTER_OSGPLUGIN macro, in
order to associate an "extension" to a ReaderWriter (for example osg to
OSGReaderWriter).
But no ReaderWriter[osgText] exists in the "Plugins osgtext".

The list of registered plugins includes osgShadow, osgTerrain (named
just as "terrain"), osgTgz and osgViewer, but not osgText (neither
osgfx, osgparticle, osgsim and some others). Any reason for that, or
it's just that nobody has needed it until myself?

Iñaki

Robert Osfield

unread,
Nov 22, 2010, 4:40:07 AM11/22/10
to OpenSceneGraph Users
Hi Iñaki,

I've just had a look at the OpenSceneGraph-2.8 branch and the osgText
plugin doesn't use the REGISTER_DOTOSGWRAPPER for the Text classes.
Unfortunately, this will mean that OpenSceneGraph-2.8.x and prior
versions won't be able to statically link the osgText. Two things
would need adding, first the REGISTER_DOTOSGWRAPPER and second the use
of USE_DOTOSGWRAPPER(Text) for all the classes you wish to use from
the osgText plugin. If you have a look at
src/osgPlugins/osg/ReaderWriterOSG.cpp you'll see lots of the
USE_DOTOSGWRAPPER.

The other alternative is to try out OpenSceneGraph from svn/trunk as
the .osg format and the new .osgx, .osgt and .osgb formats are now
supported in a bit of different way. The osg plugin you'll include
using OSG_OSGPLUGIN(osg) and then the wrappers that provide the
implementation of the IO/serializer support you'll include for each
core library/NodeKit. For instance it'll look like:

// pull in the osg plugin
USE_OSGPLUGIN(osg)

// pull in the old sytle .osg support
USE_DOTOSGWRAPPER_LIBRARY(osg)
USE_DOTOSGWRAPPER_LIBRARY(osgFX)
USE_DOTOSGWRAPPER_LIBRARY(osgParticle)
USE_DOTOSGWRAPPER_LIBRARY(osgShadow)
USE_DOTOSGWRAPPER_LIBRARY(osgSim)
USE_DOTOSGWRAPPER_LIBRARY(osgTerrain)
USE_DOTOSGWRAPPER_LIBRARY(osgText)
USE_DOTOSGWRAPPER_LIBRARY(osgViewer)
USE_DOTOSGWRAPPER_LIBRARY(osgVolume)
USE_DOTOSGWRAPPER_LIBRARY(osgWidget)

// pull in the serializers for the new .osgt, .osgb and .osgx formats
USE_SERIALIZER_WRAPPER_LIBRARY(osg)
USE_SERIALIZER_WRAPPER_LIBRARY(osgAnimation)
USE_SERIALIZER_WRAPPER_LIBRARY(osgFX)
USE_SERIALIZER_WRAPPER_LIBRARY(osgManipulator)
USE_SERIALIZER_WRAPPER_LIBRARY(osgParticle)
USE_SERIALIZER_WRAPPER_LIBRARY(osgShadow)
USE_SERIALIZER_WRAPPER_LIBRARY(osgSim)
USE_SERIALIZER_WRAPPER_LIBRARY(osgTerrain)
USE_SERIALIZER_WRAPPER_LIBRARY(osgText)
USE_SERIALIZER_WRAPPER_LIBRARY(osgVolume)

I'll be making a dev release this week that will wrap this up as well.

Robert.

Iñaki García

unread,
Nov 22, 2010, 6:38:16 AM11/22/10
to OpenSceneGraph Users
Hi Robert,

So, if I understood correctly, even in last dev release (2.9.9) the
problem may persist, but it will be solved in next one (2.9.10?). My
question is because building OSG statically under Windows takes a time I
would prefer not to waste in 2.9.9 if it may not solve the issue.

Thanks

Iñaki

Iñaki García

unread,
Nov 24, 2010, 11:46:28 AM11/24/10
to OpenSceneGraph Users
Hi Robert,

I've tried with dev release 2.9.9, and the USE_DOTOSGWRAPPER did work:

USE_OSGPLUGIN(osg);

USE_DOTOSGWRAPPER(AlphaFunc)
USE_DOTOSGWRAPPER(AnimationPath)
...
USE_DOTOSGWRAPPER(VertexProgram)
USE_DOTOSGWRAPPER(Viewport)

USE_DOTOSGWRAPPER(Text_Proxy)
USE_DOTOSGWRAPPER(TextBase_Proxy)

The last two ones made the difference, now it reads .osg files with the
osgText::Text nodes in them.

Thank you very much

Iñaki

_______________________________________________

Reply all
Reply to author
Forward
0 new messages