lights cant be enabled...

This topic is 4977 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

every time i enable a light...it gets disabled by it self...i dont know why... :( even when i put this code in my Render() function which is called to render a frame...it gets disbled...
if(! _lights->Item[ 0 ]->Enabled )
{
// there is a break point in next line so i know whether
// the light is enabled or not.
_ligts->Item[ 0 ]->Enabled = true;
}

i initialized the light using same way as in directx9 sdk light sample to make sure there is no mistake...but it still gets disabled and everything is black... :( ...there is no normal problem... also...when i disable them...everything looks white...strange... all samples in directx9 sdk works ok... anyone knows what causes this problem to happen? thanx...

Share on other sites
Stupid question: Do you call SetRenderState(D3DRS_LIGHTING, TRUE);?

Share on other sites
yeah i did enable it in device render state...

Share on other sites
Another stupid question: Did you copy the code directly from the editor, because you have _lights and _ligts both in the code.

Chris

Share on other sites
Don't you get a compile time error.

(! _lights->Item[ 0 ]->Enabled
_ligts->Item[ 0 ]->Enabled = true;
^
^

Whatever it may be do you have used these two,

SetLight(DWORD , CONST D3DLIGHT9 *pLight)
and then
LightEnable( DWORD index ,BOOL bEnable)

Share on other sites
another thing to check - have you setup a material? if you dont, it wont matter how many lights you enable it'll still be black.

Share on other sites
Did you actually Commit() the light (let DX know it exists before enabling it)? That may not causr the problem, but it still needs to be done...

Share on other sites
The problem could also be with the way you are configuring your D3DLIGHT9 structure. Also, if you have *very* low polygon meshes (for example, that you are using to test) they won't light up very well at all. Are you setting a material though? As Syrillix says, if you don't do that, everything will be black regardless.

Share on other sites
that _ligt was a miss-spell...sorry... :D

well...i read all replays..thanx for replaying...i didnt set a material...so may be thats the problem...

but...as i remember...i didnt need to set a material to render a teapot...may be i forgot...i will try now...

i did all other stuff correctly...like calling Commit() for the light i just setup...

Share on other sites
You don't have to set a material. The default one is white. It's recommended you do set one though, just so you can diagnose things better.