0

I am trying to (using a 2D Directx9 engine library) rotate/translate a set of points in a vertex buffer.

I understand how this would be done in a 3D system - i.e using the vertex shader stage of the rendering pipeline with transformation matricies...

But Im not sure that applies in 2D? (or am I wrong). I don't know where the vertex shader stage happens in 2D or at least in the 2D engine library I am using (from the book Programming2DGames)? or whether it happens at all?

Basically I can create a transformation matrix using some thing like D3DXMatrixTransformation2D() and I know how to apply that to an LPD3DXSPRITE object (using Sprite->SetTransform()), but how can I apply that transformation matrix to a set of 10+ coordinates stored in a vertex Buffer instead of a sprite.

Any help or suggestions would be greatly appreciated. Thanks

unknownSPY
  • 706
  • 4
  • 15
  • 27

1 Answers1

0

I think you have 2 choices:

1) Create 2nd vertex buffer and transform all vertices using D3DXVec2TransformCoord in loop. Or use single buffer if you don't need old vertices.

2) Use vertex shader:

ID3DXEffect* effect;
MATRIX matrixToTransfrom;
UINT passes;

effect->SetTechnique(technique);
effect->SetVector(handleMatrix, &matrixToTransform);
effect->Begin(&passes, 0);
effect->BeginPass(0);

sprite->Begin(xxx);

// drawing

sprite->End();

effect->EndPass();
effect->End();
Tomashu
  • 515
  • 1
  • 11
  • 20
  • Thanks for the help. Option 1) Would this produce much of a performance hit? or does it just depend on the size of the buffer. Im guessing option 2 (if i can get it to work) would be the prefered option? – unknownSPY Oct 16 '14 at 09:37