On Wed, 2004-04-28 at 16:55, Allen Bierbaum wrote:
> Is it reasonable and safe to repetitively call osgInit() then osgExit()
> in a single application?
>
> The code I am working on is not an OpenSG application, but is a plugin
> routine for another application that allows it to create an opensg graph
> and then save it out.
>
> Right now I am looking at code that would be something like this:
>
> void exportGraph()
> {
> osgInit(0,NULL);
> .... do the export ....
> osgExit();
> }
>
> Is this a "good" way to do this from the OpenSG standpoint?
If you expect to be able to call exportGraph multiple times probably
not.
I would use something like this:
void exportGraph()
{
static bool isInited = false;
if (!isInited)
{
isInited = true;
osgInit(0,NULL);
}
.... do the export ....
}
osgExit is called automatically using atexit anyway, so that's not a
problem I hope. It might not be called if this is done as a plugin, but
I would expect there to be a service function that is called when a
plugin is unloaded, and put it in there.
On Wed, 2004-04-28 at 17:34, Chad Austin wrote:
> I've wondered about this too... More specifically, I was wondering if
> osgInit
> and osgExit could be called multiple times in a row, as long as there
> is one
> exit for each init:
>
> osgInit(...)
> osgInit(...)
> ...
> osgExit()
> osgExit()
>
> The code didn't look like it could handle that, but it would really
> come in
> handy... (Ideally, it would be nice if there was no such thing as
> osgInit and
> osgExit, but it doesn't seem like that's feasible :)
No, that's not going to work, init and exit are one-shot things. Where
would it come in handy? I can't really imagine what you'd need this for
right now. ;)
And unless we get more influence on the startup sequence of C++, we will
need osgInit. The primary use is to call the initialize functions of the
type system. Given that we store the complete list of fields in each
type, all the base types have to be initialized before that, and the
undefined initialization order f static C++ instances makes that a
little hard. Exit is probably not as critical, but init is hard to get
around.
Yours
Dirk
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users