Results 1 to 1 of 1

Thread: Can somone help me fix this bug?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    1

    Can somone help me fix this bug?

    I've been following the DirectXGraphics tutorials at www.directx4vb.com But I can't seem to implement lighting in my engine. I've been slaving over this code for a few days now but I can't find the bug. Lighting works in the tutorial's example project but I can't get it to work in mine. Basically I have this:
    VB Code:
    1. D3DDevice.SetVertexShader D3DFVF_XYZ Or D3DFVF_NORMAL Or D3DFVF_TEX1
    2. D3DDevice.SetRenderState D3DRS_LIGHTING, 1
    3. D3DDevice.SetRenderState D3DRS_AMBIENT, &H202020
    4. With MainMaterial.Ambient 'mainmaterial is a d3dmaterial8
    5. .A = 1: .B = 1: .G = 1: .R = 1
    6. End With
    7. With MainMaterial.Diffuse
    8. .A = 1: .B = 1: .G = 1: .R = 1
    9. End With
    10. D3DDevice.SetMaterial MainMaterial
    in my init proc and I set my light up like this:
    VB Code:
    1. Dim Light as d3dlight8
    2. D3DDevice.SetLight 0, Light
    3. Light.LightType = Directional
    4. Light.Diffuse.R = 1
    5. Light.Diffuse.G = 1
    6. Light.Diffuse.B = 1
    7. Light.Range = 1
    8. Light.Direction = vector(0, -1, 0)
    9. D3DDevice.SetLight 0, Light
    10. D3DDevice.LightEnable 0, 1
    Then I set up my mesh and start rendering, but the light doesn't work. I generated normals for my mesh as the tutorial said but it does nothing. BTW, it isn't done exactly like that, but the sequence is the same.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width