Original Post
Hi all, I am a beginner learning DirectX and I seem to have a problem in transformation. I managed to create a 6 vertice vertex buffer (IDirect3DVertexBuffer9* pVB) for a triangle, as shown below:
Device->CreateVertexBuffer( 6*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &pVB, NULL );
CUSTOMVERTEX *v;
pVB->Lock( 0, 0, (void**)&v, 0 );
v[0]=CUSTOMVERTEX(-1.0f, -1.0f, 2.0f, D3DCOLOR_XRGB(255,0,0));
v[1]=CUSTOMVERTEX(-1.0f, 1.0f, 2.0f, D3DCOLOR_XRGB(0,255,0));
v[2]=CUSTOMVERTEX(1.0f, 1.0f, 2.0f, D3DCOLOR_XRGB(0,0,255));
v[3]=CUSTOMVERTEX(1.0f, -1.0f, 2.0f, D3DCOLOR_XRGB(255,0,0));
v[4]=CUSTOMVERTEX(-1.0f, -1.0f, 2.0f, D3DCOLOR_XRGB(0,255,0));
v[5]=CUSTOMVERTEX(1.0f, 1.0f, 2.0f, D3DCOLOR_XRGB(0,0,255));
pVB->Unlock();
I managed to render both parts of the triangles but when I try to transform the second one along x, the first one gets transformed too. Is there anyway around this? Tried playing with SetStreamSource but its not working out.
Device->BeginScene();
Device->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID);
Device->SetStreamSource( 0, pVB, 0, sizeof(CUSTOMVERTEX) );
Device->SetFVF( D3DFVF_CUSTOMVERTEX );
Device->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
D3DXMATRIX mTrans;
D3DXMatrixTranslation( &mTrans, 1, 0, 0); // Having problems here
Device->SetTransform( D3DTS_WORLD, &mTrans );
Device->SetStreamSource( 0, pVB, 0, sizeof(CUSTOMVERTEX) );
Device->SetFVF( D3DFVF_CUSTOMVERTEX );
Device->DrawPrimitive( D3DPT_TRIANGLELIST, 3, 1 );
Device->EndScene();
Device->Present(0,0,0,0);
edit: not working here?