How to set orthgraphic matrix for a 2d camera with zooming?
Posted
by
MahanGM
on Game Development
See other posts from Game Development
or by MahanGM
Published on 2013-07-02T00:04:16Z
Indexed on
2013/07/02
11:16 UTC
Read the original article
Hit count: 254
I'm using ID3DXSprite to draw my sprites and haven't set any kind of camera projection matrix. How to setup an orthographic projection matrix for camera in DirectX which it would be able to support zoom functionality?
D3DXMATRIX orthographicMatrix;
D3DXMATRIX identityMatrix;
D3DXMatrixOrthoLH(&orthographicMatrix, nScreenWidth, nScreenHeight, 0.0f, 1.0f);
D3DXMatrixIdentity(&identityMatrix);
device->SetTransform(D3DTS_PROJECTION, &orthographicMatrix);
device->SetTransform(D3DTS_WORLD, &identityMatrix);
device->SetTransform(D3DTS_VIEW, &identityMatrix);
This code is for initial setup. Then, for zooming I multiply zoom factor in nScreenWidth
and nScreenHeight
.
© Game Development or respective owner