1

What might stop IDirect3DDevice9::SetTransform from working? I've looked at alot of tutorials for using transformation matrices in Direct3D9, including this one here. And as far as I can tell, they all do it the same way.

I'm trying to write some code just to translate a texured polygon. I call SetTransform with a matrix initialized with D3DXMatrixTranslation, and it returns S_OK. However the actual polygons drawn to the screen do not get transformed.

D3DXMATRIX m_Translation;
D3DXMatrixTranslation(&m_Translation,100,100,0);
d3dDevice->SetTransform(D3DTS_WORLD, &m_Translation);

d3dDevice->SetFVF(D3DFVF_TLVERTEX);
d3dDevice->SetStreamSource(0, vertexBuffer, 0, sizeof(TLVERTEX));

HRESULT hr = d3dDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
Kevin Laity
  • 2,489
  • 1
  • 27
  • 34
  • @GMan: nope. Nothing but two polys and a single texture – Kevin Laity Nov 16 '09 at 05:09
  • And that's the actual code, nothing in between? I assume you have your other matrices set up as well? (The projection & view) – GManNickG Nov 16 '09 at 05:38
  • I've never heard of this not working in the fixed function pipeline. I recommend you run it through PIX and see what is happening. (also, have you set up the view and projection matrices appropriately?). Though, IMHO, I believe the fixed function pipeline is dead, it hasn't been updated in almost a decade (by either MS or hardware manufacturers) and its usually quicker and easier to develop with shaders because you know exactly what is happening and don't need to deal with this sort of thing (though of course you need to understand what is happening). – Grant Peters Nov 16 '09 at 05:40
  • This is just for 2D rendering so my understanding was that the projection matrix etc were not needed, but I'll give that a try and see what happens – Kevin Laity Nov 16 '09 at 14:32

1 Answers1

4

You set "D3DFVF_TLVERTEX" which means that you are supplying "Transform and Lit" vertices in the vertex buffer, therefore the device is not going to apply a transformation matrix to these vertices.

gatorfax
  • 1,124
  • 2
  • 7
  • 13