A 3x3 matrix for 2D affine transforms should have 0, 0, 1 in the last column, just as 4x4 matrices have 0, 0, 0, 1 in the last column. Try this?

```
D3DXMATRIX ToD3DXMATRIX() const
{
D3DXMATRIX m;
m._11 = _11; m._12 = _12; m._13 = 0.0f; m._14 = 0.0f;
m._21 = _21; m._22 = _22; m._23 = 0.0f; m._24 = 0.0f;
m._31 = 0.0f; m._32 = 0.0f; m._33 = 1.0f; m._34 = 0.0f;
m._41 = _31; m._42 = _32; m._43 = 0.0f; m._44 = 1.0f;
return m;
}
```

If that doesn’t work, I’m not sure what’s going on. Translation is in the last row of a matrix (when using row vector convention) so copying row 3 to row 4 should be the right thing to do.

Hi, In my engine I’m working with 3x3 matrices for 2D graphics, only the rendering system is 100% 3D, so everything needs to be converted to 4x4 matrices in the end.

So I have this function:

Which works fine for scaling & rotation, but it acts really strange for translation.

So I tried this:

But it behaves similar.

Anyone see what I’m doing wrong?

EDIT: It might be worthwile to mention that both the 3x3 matrix and the 4x4 matrix are row major matrices, and I’m using the DirectX Left Handed coordinate system (x = width(right), y = height(top), z = depth (‘in’ the screen))