Hi all,
I've been messing about with dll-initialization a bit (since we moved
our project to dll's recently). I've managed to write up something that
ensures that every thread created in the process which has my dll loaded
always has it's OpenSG-aspect data initialized. It wasn't very hard.
For OpenSG, it would be something like the code I've included at the end
of this mail. This would be included in the lib (probably OSGBase) that
defines all the thread stuff.
If you wanted, you could even put osgInit(0,0) in the
DLL_PROCESS_ATTACH, since the cmd-line data doesn't seem to be used at
the moment. (That's what I do in my dll, so that all the little exe's I
got doesn't have to bother with initializing anything, they just link to
my dll and start using stuff).
Best Regards,
/Marcus
---
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
{
osg::BaseThread * thr = osg::ExternalThread::get(0);
if (!thr->isInitialized()) {
osg::ExternalThread::get(0)->initialize(0);
}
}
break;
case DLL_PROCESS_DETACH:
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users