4
\$\begingroup\$

I'm having a small issue with D3DXVec3Unproject. I'm currently using Direct3D 11 and not 10, and the signature for this function is:

D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3D10_VIEWPORT *pViewport,
      CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld

As you may have noticed, it requires a D3D10_VIEWPORT, and I'm using a Direct3D 11 viewport, D3D11_VIEWPORT.

Do you have any ideas how I can use D3DXVec3Unproject with Direct3D 11?

\$\endgroup\$
6
\$\begingroup\$

Instead of D3DXVec3Unproject() use XMVector3Unproject(). It accpet float parameters for viewport:

XMVECTOR XMVector3Unproject(
  [in]  XMVECTOR V,
  [in]  float ViewportX,
  [in]  float ViewportY,
  [in]  float ViewportWidth,
  [in]  float ViewportHeight,
  [in]  float ViewportMinZ,
  [in]  float ViewportMaxZ,
  [in]  XMMATRIX Projection,
  [in]  XMMATRIX View,
  [in]  XMMATRIX World
);

NOTE: Here you get some info about converting D3DXMath into DirectxMath.

\$\endgroup\$
2
\$\begingroup\$

The structures are passive data, the only difference is that the D3D11 flavor deals with floats instead of integers for most of the fields.

If your quantities are integral, simply construct a corresponding D3D10_VIEWPORT and call the function.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.