Flipping a sprite in DirectX

I have a sprite which faces to the right. I wanted to make it face left when moving left. After reading a dozen-plus forum threads without finding an answer, I’m posting this for reference. I’m a DirectX noob so this may not be the best solution, but it worked for me.

D3DXVECTOR2 position(caveman.x, caveman.y);
D3DXVECTOR2 spriteCenter(caveman.width / 2.0f, caveman.height / 2.0f);
D3DXVECTOR2 scaling(caveman.faceLeft ? -1 : 1, 1);
D3DXMATRIX matrix;
D3DXMatrixTransformation2D(&matrix, &spriteCenter, 0, &scaling, NULL, 0, &position);

Also, you will need to turn off culling on your DirectX device object.

d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);