Carsten Neumann wrote: > Hello Marcus, > > Marcus Lindblom wrote: >> Carsten Neumann wrote: >>> Is there a way to force the >>> construction to happen early ? (What triggers the construction anyways ?) >> Construction of these are on demand, so just call >> getDefault[unlit]Material(). > > hm, that creates the default materials, I was wondering more about what > creates the pointer objects (i.e. the objects of type > SimpleMaterialMTRefPtr) that point to them.
Ah, no. That happens before main, but the order is undefined (except that it happens per dll/exe). Otherwise automatic initialization methods (like factory registration) would not work. > *If* these are also created "on demand" (and it looks like they are [1]) > we have a problem, because while we could call getDefaultMaterial() from > osgInit it would break separation of base and system lib and does not > generalize well to other, similar situations. We could use a statically > created object to call addPostFactoryInitFunction with a function that > just calls getDefaultMaterial, but I don't see why that object should be > "on demand"-created at all? > I need to see if/what the standard has to say on the point in time when > static objects are created. I think it works like this, given my current "battle experience" :) Static initializers are constructed in order inside each compilation unit, but the order between compilation units is undefined, except that calls between compilation units (during static initialization) forces on-demand initialization. This breaks down if you have recursive initialization dependencies between static initializations in compilation units, unless you're carueful. (And/or use on-demand construction singletons that do not depend on each other's constructors recursively.) Cheers, /Marcus ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Opensg-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-users
