Public Group

# Help need Basic source code for direct x 9-12

## Recommended Posts

Hi,

I’ve been studying for years 3D graphics and learning c/c++ , have made some good progress but am still pretty bad at coding and when I compile stuff from the books I’ve got (frank d Luna directs 9 + 12[2 books] , direct x 11  [allen sherrod & Wendy jones]. When I compile stuff from the books. I get compile time errors . I’ve not been trying to get  it right for a while cos I’ve been busy with other stuff but I was wondering if someone could point me to the source code that just displays a polygon or an .obj file that can run in a win 10 x86/x64 direct x 9 - 12 [please state which direct version it is[my modern windows 10 pro doesn’t run any of my old disc based direct x 9 games though [doh!🤪]].

ive just hit a bit of a brick wall learning what I need to but I’ve learned too much for over 20 years to give up, I’ll get back to it with a vengeance soon anyway 😁.

Hope someone can supply some c++ source code that sets me up for direct x coding, that way I can study and it will give me a bit of help getting stuff up and running, thanks 👍😁

##### Share on other sites

The better tactic however is to try again, and ask questions here, to get your thing running.

##### Share on other sites

You can find some DirectX 12 code samples on Microsoft's GitHub account here:

These should help you get started. I believe they also have DirectX 11 samples somewhere (Assuming they haven't deleted them, they will either be on a branch or archived repository somewhere).

On a side note regarding the compile errors you get from various books etc, it might be worth checking the publishers website directly to see if there are any coding errors which have been resolved in an update, for example 'Introduction to DirectX12 Programming by Frank D Luna' is stored on GitHub with updates/corrections published there - https://github.com/d3dcoder/d3d12book/commits/master

The most likely cause of the errors you're seeing though is that your setup differs from that of the book author, for example you have a more recent SDK installed which isn't backwards compatible with the version used to write the book (The older the book the worse this tends to be!). The most common error I tend to get when importing projects is a mismatch of the Windows SDK versions, I find that Visual Studio seems to default to installing the very latest version so it's worth re-running the installer and then [Assuming you're using 2017 or 2019] on the 'Individual Components' tab select the relevant Windows SDK version for your project (Most books tend to list the SDK requirements etc somewhere).

Another thing I used to commonly come across which massively caught be out when I first encountered it was that Visual Studio was creating my projects with ANSI string support but the code was written for Unicode (Or vice-versa, I cannot remember for certain which way around it was!), this would result in errors where the following code would fail to compile due to the 'L' prefix in front of the "Main Color Buffer" string depending on which encoding the project is set to use:

g_SceneColorBuffer.Create( L"Main Color Buffer", bufferWidth, bufferHeight, 1, DefaultHdrColorFormat, esram );

Changing the project's character set would usually resolve these issues (This can be done by right clicking the project in Visual Studio > Properties > Advanced > Under 'Character Set' select either "Use Unicode Character Set" or "Use Multi-Byte Character set")

Hope this helps!

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 23
• 38
• 16
• 75
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!