I’m writing a plugin and I need to call NvAPI_Stereo_SetDriverMode. According to the NVAPI documentation, this needs to happen before the Direct3D 9 or 11 device is created.
The soonest I could call this function is when the plugin is loaded, but I do not know when or on which thread this occurs - this isn’t documented. The kGfxDeviceEventInitialize event is called after the device is created, so that is too late.
If the plugin could issue its own create / destroy device events, that might solve my problem, but I don’t think this is possible.
Has anyone come across this issue and know how I can solve it?
I’ve tried the following approaches and nothing seems to work:
I’ve verified all of these approaches are being called, but none of them are early enough. If anyone has any insight into this, please let me know. I’m trying to get NVIDIA 3D vision to work in direct mode. I’ve searched the forums and answers for this and based on the answers and examples I’ve seen, no one currently has this working.
If Unity could to add a pre-initialize device event, then this would work.
Okay, I contacted Unity3D support and they said the following:
Unfortunately it is not possible to send events to your plugin before the graphics device is initialized.
I certainly wish they had this feature. I need to do some NVIDIA driver initialization before the device is created. I also tried to use a wrapper application to do the initialization before Unity starts (ie. using spawn, fork/exec, and CreateProcess), but that doesn’t work either.
If you’re creating a Standalone build, you can write a simple DLL and a launcher.
Launcher will CreateProcess() of standalone executable file with CREATE_SUSPENDED flag set.
Then you can inject your DLL with a call to NvAPI_Stereo_SetDriverMode() from DLL_PROCESS_ATTACH section.
P.S. Don’t forget to call ResumeThread() after you finish injection.