TGEA 1.8: Cannot instantiate Sun on dedicated server
by Cliff · in Torque Game Engine Advanced · 12/20/2008 (3:10 am) · 2 replies
Howdy!
I've got a dedicated server that is trying to load a simple sun into the mission, but it crashes because it tries to initialize the lighting, but has no Canvas.
I looked for a similar post, but didn't see anything, so I apologize if I missed it. Has anyone else out there experienced this issue? I've isolated the problem to sgLightManager::activate in sgLightManager.cpp, but it's being called from Sun::createLightIfNeeded in sun.cpp. I can see a few ways to fix this, but at the same time I wanted to see what others had made of it.
I've got a dedicated server that is trying to load a simple sun into the mission, but it crashes because it tries to initialize the lighting, but has no Canvas.
I looked for a similar post, but didn't see anything, so I apologize if I missed it. Has anyone else out there experienced this issue? I've isolated the problem to sgLightManager::activate in sgLightManager.cpp, but it's being called from Sun::createLightIfNeeded in sun.cpp. I can see a few ways to fix this, but at the same time I wanted to see what others had made of it.
Torque 3D Owner Tom Bampton
Open up GFXInit.cpp and add this at the end:
ConsoleStaticMethod( GFXInit, createNullDevice, void, 1, 1, "() Create a NULL device") { // Enumerate things for GFX before we have an active device. GFXInit::enumerateAdapters(); // Create a device. GFXAdapter *a = GFXInit::chooseAdapter(NullDevice); GFXDevice *newDevice; // Do we have a global device already? (This is the site if you want // to start rendering to multiple devices simultaneously) if(GFXDevice::getDeviceVector()->size()) newDevice = GFX; else newDevice = GFXInit::createDevice(a); newDevice->setAllowRender( false ); return; }In your server scripts call GFXInit::createNullDevice(); early in the init, before createServer() is called.
Don't call createNullDevice on the client, clients will get a GFX device created through the Canvas.
T.