PDA

View Full Version : Problem with D3DXMesh... Diffuse is not rendered



chronozphere
17-12-2006, 05:35 PM
Hi guys.. :)

I was trying to figure out how D3DXMesh works.
So i made a test project based on one of clooties tut's.
but I wasn't able to render the diffuse colors. :cry:
I used the red/green/bleu triangle in the tutorial but the result was totally black. :(

The files are located here (http://www.uploadtemple.com/view.php/1166376573.zip)

Can anyone help me to figure this out???

Thanx in advance.

NecroDOME
17-12-2006, 07:31 PM
Never done anything with D3DXMeshes... I use my own mesh format. I think it's not as fast as D3DXMesh, but it works :)

Clootie
17-12-2006, 10:04 PM
The behaviour you see (black triangle) is not related to ID3DXMesh at all. Black color is caused by Lighting calculated by D3D (and as you have not setted up any light sources - no wonder it returns black color). To fix it you have to disable D3D lighting engine.

Here are fixed I've done to compile/fix code on mine Delphi7:

// (1) D3DXMESH_DYNAMIC, as WriteOnly will not work with Lock(DISCARD)
D3DXCreateMeshFVF(1,3,D3DXMESH_DYNAMIC,D3DFVF_XYZ OR D3DFVF_DIFFUSE,g_pd3dDevice,fMesh);

// (2) type cast
fMesh.LockAttributeBuffer(D3DLOCK_DISCARD,PDWORD(P ));

// (3) turn lighting off - I've added it in render loop - but can be added in initialization in your case
g_pd3dDevice.SetRenderState(D3DRS_LIGHTING, iFalse);

Clootie
17-12-2006, 10:08 PM
Btw, why are you still using DirectX 8?

chronozphere
18-12-2006, 06:04 AM
Thank you very much Clootie.:)
Somehow I knew you would know the awnser.;)

For now.. i am using DX8, but will upgrade to DX9 in the future. The problem is that i use a PC with a GFX card which only hardware-supports DX7.
So i cant benefit from the new features in DX9. :(