Question

How to set up 2d view in Directx? Is there any similar function, to this OpenGL one?

gluOrtho2D( 0 , 800 , 0 , 600 );
Was it helpful?

Solution

The equivelent call in DirectX 9 would be D3DXMatrixOrthoRH - However, you very likely will want to use the Left handed version, if you are trying to follow other DirectX code, as DirectX 9 is often done in a left handed coordinate system (instead of RH like OpenGL). The left handed version is D3DXMatrixOrthoLH.

OTHER TIPS

You can use something like this: http://msdn.microsoft.com/en-us/library/bb204940(v=vs.85).aspx to create an orthographic projection matrix for you, however actually getting this to affect your rendering is not as simple as it is with fixed-function (version 1.x style) OpenGL programming. DirectX has no immediate mode, so you would need to have an appropriate shader set to do your rendering, create your orthographic projection matrix, and pass this to the shader (and use it in the shader code).

From the manual:

Builds a left-handed orthographic projection matrix.

D3DXMATRIX * D3DXMatrixOrthoLH( __inout D3DXMATRIX *pOut, __in FLOAT w, __in FLOAT h, __in FLOAT zn, __in FLOAT zf );

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top