Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Mar 2013
Offline Last Active Apr 10 2013 03:38 AM

Topics I've Started

A defect in rendering

04 March 2013 - 12:43 AM


    I have found a defect in rendering a model in directx9,the defect is illustrated by the following attach files.when I rotate the model,the defect disappeared.I enabled the depth testing and lighting.here is my code.


Attached File  无标题.jpg   18.59KB   48 downloads,

D3DLIGHT9 light;    // create the light struct
    D3DMATERIAL9 material;    // create the material struct
    ZeroMemory(&light, sizeof(light));    // clear out the light struct for use
    light.Type = D3DLIGHT_DIRECTIONAL;    // make the light type 'directional light'
    light.Diffuse =material.Diffuse ;
light.Ambient=material.Ambient ;
light.Specular=material.Specular ;
    light.Direction = D3DXVECTOR3(-1.0f, -0.3f, -1.0f);

    m_pDevice->SetLight(0, &light);    // send the light struct properties to light #0
    m_pDevice->LightEnable(0, TRUE);    // turn on light #0

    m_pDevice->SetMaterial(&material);    // set the globably-used material to &material

    r=m_pDevice->SetRenderState(D3DRS_LIGHTING, TRUE);    // turn on the 3D lighting
    r=m_pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);    // turn on the z-buffer
   r=m_pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(250, 250, 250));    // ambient light

Does that mean I'm doing something wrong?Thanks for the help!