1
\$\begingroup\$

I'm trying to write some class for loading meshes from X files.

But I can't use the function D3DXLoadMeshFromX because its third parameter is LPDirect3DDevice9.

In my D3D initialization code I don't have variable of this type. Did I initialize D3D incorrectly? How can I call this function?

\$\endgroup\$
5
  • \$\begingroup\$ LPDirect3DDevice9 is a typedef for IDirect3DDevice9*. Try passing a pointer to your device. \$\endgroup\$ Jul 19, 2013 at 9:21
  • \$\begingroup\$ In my code it is just ID3D11Device* \$\endgroup\$
    – Loryan55
    Jul 19, 2013 at 9:25
  • \$\begingroup\$ My guess is that ID3D11Device11 implements ID3D11Device9 so that should work to. Just test it. \$\endgroup\$ Jul 19, 2013 at 9:34
  • \$\begingroup\$ Its definition looks like this: ID3D11Device : public IUnknown So i dont understand... I tried this: ..., (LPDIRECT3DDEVICE9)m_pd3dDevice, .. But i dont think it will work. I cant test right now.. \$\endgroup\$
    – Loryan55
    Jul 19, 2013 at 9:45
  • 1
    \$\begingroup\$ @NikolaDimitroff The D3D9 and 11 device interfaces are not related at all; D3DXLoadMeshFromX doesn't work with 11. \$\endgroup\$
    – user1430
    Jul 19, 2013 at 22:33

2 Answers 2

2
\$\begingroup\$

D3DXLoadMeshFromX is not supported in DirectX 11.

You will have to create your own model importer for a file format. Something simple like .obj would be a good place to start.

\$\endgroup\$
2
  • \$\begingroup\$ Is there any open-source for loading OBJ mesh? \$\endgroup\$
    – Loryan55
    Jul 20, 2013 at 6:01
  • \$\begingroup\$ This is a very basic tutorial for loading .obj files rastertek.com/dx11tut08.html \$\endgroup\$
    – Syntac_
    Jul 22, 2013 at 12:14
1
\$\begingroup\$

LPDirect3DDevice9 is an alias for the type IDirect3DDevice9 *, which is a pointer to a Direct3D 9 device object. You are using D3D11, which means you have a completely incompatible device interface. Your device initialization is (probably) fine, you will just not be able to use D3DXLoadMeshFromX because it's only supported on an older version of Direct3D.

D3DX was deprecated after D3D10. The functionality you are looking for is no longer available as part of the core SDK, you will need to find it elsewhere.

You can either write your own, for any number of file formats including .X (.obj is popular and Google can help you find tutorials) or utilize a 3rd party library such as Assimp.

\$\endgroup\$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .