Neomex
Neomex

Reputation: 1660

how to set 2D window

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

gluOrtho2D( 0 , 800 , 0 , 600 );

Upvotes: 1

Views: 1440

Answers (3)

Reed Copsey
Reed Copsey

Reputation: 564403

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.

Upvotes: 2

Alexander Dzhoganov
Alexander Dzhoganov

Reputation: 226

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 );

Upvotes: 1

eodabash
eodabash

Reputation: 949

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).

Upvotes: 1

Related Questions