Guidelines for updating legacy DirectX SDK code

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
SmokeyMcPot
Posts: 1
Joined: December 17th, 2017, 9:44 am

Guidelines for updating legacy DirectX SDK code

Post by SmokeyMcPot » December 17th, 2017, 12:36 pm

Chili, let me start by saying: "U the man"
Image

OK so now we got that outha the way, hey man the name is Smokey Mc. Pot, big fan of your work.
I've got a background in Delphi (Pascal) and the last couple of weeks I've been trying to make the change to C++. Let me tell you this, I'm a long way of making C++ my bitch.

I'm pretty comfortable programming in Delphi but it does hide a lot of the good stuff under the hood. So for example you rarely have to deal with pointers cause that shit's all taken care of for you, it comes with a rich vcl (visual component library) and database support is also very good. But this al comes at a steep price. Both literally and figuratively, basically it boils down to this: It's all good and easy when your working with their wrappers for every thing the os does. But if you really want to get funky
Image
with the os, you have to translate the headers from the sdk and basically you're on your own.

So I thought let's cut out the middle man, start cooking with gasoline. I'm working my way through the chili vid's, can't even skip the beginners series laughing my ass off watching this. ( My girl also thinks I'm really cozy with my headphones :D )
And i'm down with learning things from the basics, but sometimes I just wanna cheat.
So there's a lot of DirectX11 tutorials/example material out there that's based on the legacy DirectX SDK and we're living today with the windows 10 sdk. So how do we migrate that MF ?
I can't seem to find any good guidelines online and the ones I do find are all steering me in the direction of DirectXTK and DirectXTex what isn't a problem in itself, I can see the potential of it. But for now that would be to much of a change in code. And for now that is some next level shit.

So I've got this book: Introduction to 3D game programming with DirectX 11
by Frank D Luna.
Which is great but hard, I'm trying to learn more about particle systems but it's all legacy SDK code so...

Do you have any pointers on how to migrate that shizzle without changing the code to much ?

Any help would be greatly appreciated.

Arigato gozaimasu
Smokey Mc. Pot

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Guidelines for updating legacy DirectX SDK code

Post by albinopapa » December 17th, 2017, 1:52 pm

Doh, another one buys into the Frank Luna DX 11 trap. That book is invaluable in the math department, learn that shit. As far as the DX11 stuff, Microsoft really rammed it in hard and left without tipping when they deprecated the D3D11X library with Windows 8/8.1. So here are my suggestions.

The D3D11X and the XNAMath stuff has been removed and re-purposed to the DirectX math library, so replace any
#include <xnamath.h> with
#include <DirectXMath.h>

All the DirectX math types and functions are in the DirectX namespace, so you need to either type
DirectX::XMFLOAT4 position; or
using namespace DirectX;
XMFLOAT4 position;

The D3D11XCompileFromFile has been moved out into the D3DCompile library. Replace D3D11XCompileFromFile with D3DCompileFromFile. The two functions don't take the same number of paramters, but most are the same. Also, if it has D3D10_SHADER_ENABLE_STRICTNESS listed, it's now D3DCOMPILE_ENABLE_STRICTNESS.
#include <D3Dcompiler.h>
#pragma comment(lib, "D3Dcompiler.lib" )
You may need to include: D3DCompiler_47.dll with any programs you share with others in the same directory as the .exe file.

For loading images to textures, you can either download the DirectXTex or DirectXTK ( which includes the DirectXTex library anyway ), learn how to load images using the Windows Imaging Component (WIC) library or just use chili's Surface class where he uses GDI+ to load images. If you go with option 2 or 3, you'll have to create the texture and shader resource manually. If you go with option 1 ( downloading DirectXTK or DirectXTex ), then you only call CreateWICTextureFromFile and you get a texture and/or a shader resource automatically.

The Frank Luna material uses the XNAMath library, so not much to say about that, all the names are pretty much the same as in the DirectX math library ( XMFLOAT2,XMFLOAT3,XMFLOAT4,XMFLOAT4X4,...).

The rastertek tutorials on the other hand use the D3DX math library, so you'd have to change a lot of stuff. D3DXVector3 -> DirectX::XMFLOAT3. Also, the D3DX math library functions usually don't return values, they use in/out pointers. The DirectX math library mostly return values, but they all deal with SIMD types, aliased as DirectX::XMVECTOR and DirectX::XMMATRIX.

If you want simplicity, download the DirectXTK and use SimpleMath. It wraps the DirectX math library into classes like Vector2,Vector3,Matrix,Plane,Ray,...

The last thing I can think of is the Effects framework that Frank Luna uses. It's still available to download on the Microsoft GitHub, but you should just compile the shaders separately. Those are pretty easy to separate. If I had one in front of me I could show you the differences, but unfortunately I don't. I have never used the Effects framework so I'm not familiar with it enough to give examples, I've only seen them around the internet.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Guidelines for updating legacy DirectX SDK code

Post by chili » December 18th, 2017, 12:04 pm

I've never read the Luna book. Heard good things about the original (apart from the D3DX bullshit) and bad stuff about the updated version, so overall you probably still got the right version.

Papa's got better knowledge about this, so I will defer to his expertise ;)
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Guidelines for updating legacy DirectX SDK code

Post by albinopapa » December 18th, 2017, 10:42 pm

Are you referring to his book over DX12? I haven't read reviews either way. My experience with it comes from helping BurakCanik a couple years ago, and another from this forum recently with this issue.

I don't have the physical book, but I found it online in PDF somewhere. I really should give it a read lol.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply