Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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