Alright I am setting up all the matrices like that:
D3DXMATRIX WorldTransformationMatrix;
D3DXMatrixIdentity(&WorldTransformationMatrix);
d3d->SetTransform(D3DTS_WORLD,&WorldTransformationMatrix);
D3DXVECTOR3 vEyePt(0.0f,0.0f,0.0f);
D3DXVECTOR3 vLookatPt(0.0f,0.0f,1.0f);
D3DXVECTOR3 vUpVec(0.0f,1.0f,0.0f);
D3DXMATRIX ViewMatrix;
D3DXMatrixLookAtLH(&ViewMatrix,&vEyePt,&vLookatPt,&vUpVec);
d3d->SetTransform(D3DTS_VIEW,&ViewMatrix);
D3DXMATRIX ProjectionMatrix;
D3DXMatrixPerspectiveFovLH( &ProjectionMatrix,
45.0f*PI/180.0f,
800.0f/600.0f,
0.05f,
100.0f);
d3d->SetTransform(D3DTS_PROJECTION,&(D3DXMATRIX)ProjectionMatrix);
I'm creating the vertex buffer like this:
VER vertices[3];
vertices[0].color=0xff908070;
vertices[0].x=1.50;
vertices[0].y=1.50;
vertices[0].z=10.0;
vertices[1].color=0xff908070;
vertices[1].x=1.00;
vertices[1].y=1.50;
vertices[1].z=10.0;
vertices[2].color=0xff908070;
vertices[2].x=1.50;
vertices[2].y=1.00;
vertices[2].z=10.0;
d3d->CreateVertexBuffer(3*sizeof(VER),0,FVF,D3DPOOL_DEFAULT,&vb,NULL);
VER *pvert;
hr=vb->Lock(0,0,(void**)&pvert,0);
memcpy(pvert,vertices,3*sizeof(VER));
vb->Unlock();
And render this way:
d3d->BeginScene();
d3d->SetStreamSource(0,vb,0,sizeof(VER));
d3d->SetFVF(FVF);
d3d->DrawPrimitive(D3DPT_TRIANGLELIST,0,1);
d3d->EndScene();
FVF and VER are declared this way:
struct CUSTOMVERTEX
{
float x,y,z;
D3DCOLOR color;
};
#define FVF D3DFVF_XYZ|D3DFVF_DIFFUSE
The problem: Nothing shows up.
Rendering the D3DFVF_XYZRHW way is ok, so I guess something is with the matrices. Anything I missed?
Thanks.
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"