--TheGoop
D3DIM Light not displaying
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX, verts, numverts, NULL);
I only tried the LVERTEX bit to see if the normals were screwed up, but they aren't.
Thanks for the help, though...
-La'Choppe
[This message has been edited by LaChoppe (edited September 19, 1999).]
-TheGoop
LPDIRECT3DLIGHT g_pLight = NULL;
LPDIRECT3DMATERIAL3 g_pmtrlObjectMtrl = NULL;
// LIGHT CREATION
if( FAILED( pD3D->CreateLight( &g_pLight, NULL ) ) )
return E_FAIL;
D3DLIGHT2 light;
ZeroMemory(&light, sizeof(D3DLIGHT2));
light.dwSize = sizeof(D3DLIGHT2);
light.dltType = D3DLIGHT_POINT;
light.dvPosition.x = 0.0f;
light.dvPosition.y = 10.0f;
light.dvPosition.z = -80.0f;
light.dcvColor.r = 1.0f;
light.dcvColor.g = 1.0f;
light.dcvColor.b = 1.0f;
light.dvAttenuation0 = 1.0f;
light.dwFlags = D3DLIGHT_ACTIVE;
if (FAILED(g_pLight->SetLight( (LPD3DLIGHT) &light )))
return E_FAIL;
if (FAILED(pvViewport->AddLight( g_pLight )))
return E_FAIL;
// MATERIAL CREATION
if( FAILED( pD3D->CreateMaterial( &g_pmtrlObjectMtrl, NULL ) ) )
return E_FAIL;
D3DMATERIAL mtrl;
D3DMATERIALHANDLE hmtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL) );
mtrl.dwSize = sizeof(D3DMATERIAL);
mtrl.dcvAmbient.r = 0.4f;
mtrl.dcvAmbient.g = 0.6f;
mtrl.dcvAmbient.b = 0.7f;
mtrl.dvPower = 40.0f;
g_pmtrlObjectMtrl->SetMaterial( &mtrl );
g_pmtrlObjectMtrl->GetHandle( pd3dDevice, &hmtrl );
pd3dDevice->SetLightState( D3DLIGHTSTATE_MATERIAL, hmtrl );
pd3dDevice->SetLightState( D3DLIGHTSTATE_AMBIENT, 0x80808080);
pd3dDevice->SetRenderState( D3DRENDERSTATE_DITHERENABLE, TRUE );
pd3dDevice->SetRenderState( D3DRENDERSTATE_SHADEMODE, D3DSHADE_GOURAUD );
// RENDER SCENE
if( SUCCEEDED( pd3dDevice->BeginScene() ) )
{
if (FAILED(pvViewport->Clear2( 1UL, prcViewportRect,
D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0L )))
{
pd3dDevice->EndScene();
return S_OK;
}
// Only one oject right now, no state changes
D3DVERTEX *verts = AllObjects.GetStart()->GetVertices();
unsigned int numverts = AllObjects.GetStart()->GetNumVertices();
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX, verts, numverts, NULL);
pd3dDevice->EndScene();
}
[This message has been edited by LaChoppe (edited September 19, 1999).]
I tried setting the range, and it didn't help. I also tried forcing the normals to be <0,0,-1> (facing the camera), and placing the light in front, to no avail. I even tried replacing the point light with a directional light pointing <0,0,1>.
Any more ideas?
-La'Choppe
I'll try the texture dealie. Thanks...
### ADDED:
I'm back. No apparent effect having the texture set. Also, it makes no difference whether I'm using the HAL or RGB emulation. ;(
[This message has been edited by LaChoppe (edited September 21, 1999).]
Thanks...
-La'Choppe
try drawing just a triangle and see if that gets lit properly.
it my be a problem with the attenuation values, although i see nothing wrong with what you did you could mess with that. you could also call GetLight and see if the values you get back are what you put in.