Sorry, I was typing fast. That was just an example, not the real code I am using but should show what I am doing.
Error is that the return value of d3dDevice->SetLight is D3DERR_INVALIDCALL. I looked the function up in msdn ( http://msdn.microsof...6(v=vs.85).aspx ) and it says, "If a set of lighting properties exists at this index, it is overwritten by the new properties specified in pLight." And that is exactly what I am trying to do. I had defined a light property in index 0, now I want to update it with new property.
Can you tell me what I am doing wrong? Thanks!
Does the light that you want to update (at index 0) work properly?
I recommend you to go step by step:
First, call GetLight() and get the light at index 0. Then, only update diffuse color. If no error occurs, then update ambient color. And if no error occurs, update other property etc. etc. etc.
Also, doc says "You can call IDirect3DDevice9::SetLight with new information as needed to update the light's illumination properties.". There's a point here: "light's illumination properties". What do they exactly mean with illumination property?
Are position and direction vectors illumination property?
Or type?
I dunno, but I think that this is where the problem comes.
hth.
-R
There's no "hard", and "the impossible" takes just a little time.
Does the light that you want to update (at index 0) work properly?
I recommend you to go step by step:
First, call GetLight() and get the light at index 0. Then, only update diffuse color. If no error occurs, then update ambient color. And if no error occurs, update other property etc. etc. etc.
Also, doc says "You can call IDirect3DDevice9::SetLight with new information as needed to update the light's illumination properties.". There's a point here: "light's illumination properties". What do they exactly mean with illumination property?
Are position and direction vectors illumination property?
Or type?
I dunno, but I think that this is where the problem comes.
hth.
-R
Oh man, you're genius. I should call GetLight and then only change the properties, and at last call SetLight. Thank you very much!
From a quick glance I can't spot a violation of the parameters, but sometimes even documentation is wrong or incomplete. So programci_84's approach (combined with a "binary search") from a working light is probably your best shot. Just be aware that reading back states from a device is not always possible (pure device). Looking at the SDK tutorials might also help (e.g. they actually do sometimes set a range for directional lights, though the docs state it's ignored).