I have two problems (bugs?).
Assigning a light structure to ILightSceneNode.LightData causes the DIRECT3D9 present failed failure.
Even just reassigning the same struct is enough for this to happen, e.g.:
ILightSceneNode light = scm.AddLightSceneNode(...
Light ltmp = light.LightData;
light.LightData = ltmp; //<---- THATS IT
This happens only with DX9 not with DX8, OpenGl or SOFTWARE device types. Strangely enough inside my IDE it allways works, only starting the binary shows this error!!!
I am using Irrlicht 1.2, VS2005 c# + Irrlicht.NET, WinXP
Bellow is the complete source to reproduce the problem (just paste inside your main() and setup the RESOURCES_PATH to point to your /examples/media/):
IrrlichtDevice device = new IrrlichtDevice(DriverType.DIRECT3D9, new Dimension2D(1024, 768), 32, false, true, true, true, IntPtr.Zero);
ISceneManager scm = device.SceneManager;
IVideoDriver vd = device.VideoDriver;
ICameraSceneNode cam = scm.AddCameraSceneNode(null, new Vector3D(80, 20, -40), new Vector3D(30.5f, 5, 0), 1);
cam.Position = new Vector3D(0, 30, -120);
IMesh room = scm.GetMesh(RESOURCES_PATH + "room.3ds").GetMesh(0);
scm.MeshManipulator.MakePlanarTextureMapping(room, 0.01f);
ISceneNode roomNode = scm.AddMeshSceneNode(room, null, -1);
roomNode.SetMaterialTexture(0, vd.GetTexture(RESOURCES_PATH + "wall.jpg"));
roomNode.SetMaterialFlag(MaterialFlag.LIGHTING, true);
roomNode.SetMaterialFlag(MaterialFlag.NORMALIZE_NORMALS, true);
ILightSceneNode light1 = scm.AddLightSceneNode(null, new Vector3D(10, 175, 10), new Colorf(0.5f, 0.56f, 0.56f, 0), 150.0f, -1);
Light ltmp = light1.LightData;
// ltmp.SpecularColor = new Colorf(0f, 0f, 0f, 0f);
// ltmp.DiffuseColor = new Colorf(0.55f, 0.52f, 0.5f, 0f);
// ltmp.AmbientColor = new Colorf(0.05f, 0.07f, 0.06f, 0f);
light1.LightData = ltmp;
while (device.Run())
{
vd.BeginScene(true, true, new Color(255, 10, 20,20));
scm.DrawAll();
vd.EndScene();
}
I was actually trying to reduce the specular color since the default is far to bright making the lights virtualy useless.
This is related to my second problem. Changing the Ambient Color (regardless how much/little) causes the problem even inside the IDE!
And BTW I have a pretty large project I am working on by now. Just wannted to release a demo yesterday and got shocked finding out its not working as standalone
I have no intention in porting it to C++ so any .NET oriented advice would be more than appreciated. Also didnt find any problem hints in the Irrlicht.NET dll source.
Thnx guys
One more thing...
If I switch to DirectX Debug version (through DirectX control Panel from Feb. 2007 SDK ) everything works just fine! This is of course no solution just an observation.
Is there a way to change the lightdata structure???
I was trying to find a way grabbing the pointer to the native structure but without success.