Using D3D9 Functions and, HLSL

Started by
5 comments, last by markypooch 10 years, 10 months ago

Hello Everyone,

I have two questions. One of them being something I was wondering and haven't tried yet and the other pertaining to shaders.

Is it possible to use DirectX9 Functions inside a DirectX11 Program? Like say, D3D9LoadMesh for the .X format?

I could just write a OBJ Loader being its just an ascii file, but if there is already a helper function available, I don't mind using older/deprecated calls.

also I was wondering if there any tutorials on the web for HLSL 4.0

any response will be appreciated.

I am using C++ and D3D11

-Marcus

Advertisement

Yes, you can absolutely do that. However the D3DX9 mesh loading functions require a D3D9 device, so you will need to create one in addition to your D3D11 device.

Another thing to know is that resource sharing across device is not possible. Resource on a IDirect3DDevice9 cannot be shared with ID3D11Device resources. The only thing you can do is copy between them.

If you really go this way (why not), then don't forget that you don't really need to create a "fully working" D3D9 device, you can specify D3DDEVTYPE_NULLREF as the device type in CreateDevice. It will be fine, as you won't be drawing anything anyway. Oh and create the mesh in the SYSTEMMEM pool.

The you can just lock the index, vertex and attribute buffer (or also the attribute table) and copy them, as BornToCode said.

You would consider creating your own format.

Simply load .x files into DirectX 9c, lock vertices, etc and save in such output file, which would be opened by DX11.

I mean a converter tool, rather than a runtime processing.

Why not just use a model loading library like Assimp with the right flags it will optimize the mesh for you as well. Assimp is actually pretty easy to use and supports more advanced formats then .x or .sdkmesh which both have been deprecated a while ago. Otherwise there is always the DirectX Tool Kit that has replaced most D3DX functions

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Thanks for the replies, I have heard of Assimp and it looks promising. If the most hoops Im gonna have to jump through is just specifying a NULL reference type as my D3D9 device then thats not a bad option, I was beginning to think I was gonna have to go through the laborious process of filling out a whole other SwapChain Structure. I was expecting more negative answers on this topic but it turned out I must not have been the first person to ask this. :)

This topic is closed to new replies.

Advertisement