🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectX7 vs DirectX9 vs DirectX11

Started by
9 comments, last by JohnnyCode 3 years, 4 months ago

Hello,

So I have recently been getting into DirectX, but have yet to really dive in yet. I was wondering what the coding difference is between DirectX7 - DirectX9 and DirectX11? I have a lot of old books of the early 2000s that focus on DirectX7, but it's outdated. If I was to follow along using DirectX11 would I run into a lot of problems?

Basically, I was wondering how much has changed between the 3 versions? In what areas is it totally different and wouldn't translate directly. I'm sure some of it is the same? I hope that makes sense.

Also, one last question. Besides being cross-platform what are your thoughts on OpenGL vs DirectX? What about when it comes to 2D games?

Thanks! Have a great week.

Advertisement

I've never used DirectX 7 but even between DX 9 and 11 there are a lot of changes. In fact Microsoft changed DX11 itself so there are basically two versions of it. My guess is you will get frustrated trying to use such old documentation. Even Frank Luna's DX 11 book is somewhat outdated.

RamblingBaba said:
I was wondering what the coding difference is between DirectX7 - DirectX9 and DirectX11?

ok so i assume that u understand that the fundamental concept in rendering a 2D or 3D object is essentially this:

2D and/or 3D Object → Renderer → Image

Then the renderer can be a DX7 renderer, a DX9 renderer or DX11 renderer or later…

Now, here are some of the differences between dx7, dx9 and dx11 :

  • the way you would feed your 2D/3D Object data to each of these renderers has changed over the years
  • the output image produced by each of these renderers for this Object data has improved over the years
  • With DX7 the image rendering was purely done through a fixed rendering pipeline, today with DX11 or later, this pipeline is no longer fixed (it is programmable)
  • and more… (performance, stability, picture clarity, etc…)

RamblingBaba said:
If I was to follow along using DirectX11 would I run into a lot of problems?

If you follow DX11 books or tutorials, you would be more update with current methods of rendering than with DX7. If you stick to DX7 in hope that you can easily switch to DX11 or later in the future, you would indeed run into a lot of problems because of the vast differences between them. Even DX12 has already got many differences from DX11;

These differences emerge because the hardware manufacturers of video cards keep evolving those cards. They never wait ?

For example, if you don't know what a Raytracer is or a Mesh Shader is then you need to catch up. I won't explain those here, but these are new Rendering features which are now supported on hardware running with DX12, which were not supported by hardware running with DX7;

So it's good idea to catch up with DX11 or DX12 if u can;

RamblingBaba said:
Basically, I was wondering how much has changed between the 3 versions? In what areas is it totally different and wouldn't translate directly. I'm sure some of it is the same? I hope that makes sense.

The fixed rendering pipeline aspect does not translate to the programmable rendering pipeline.

You cannot use a D3DLIGHT7 (or whatever it was in DX7) in the new DX11/DX12. In fact there is no D3DLIGHT structure anymore;

Some of it is the same? well, errm… I was going to say ‘yes’ but ‘no’ is better -lol-.
DirectX still uses COM-interfaces that's the same, initialising DESC structs to 0, oh yeah that's the same… that's it, the rest is different
-lol-

In DX7, you had a device; in DX11 you now have a device and a context;

RamblingBaba said:
Besides being cross-platform what are your thoughts on OpenGL vs DirectX? What about when it comes to 2D games?

As u rightly say, besides the cross-platform aspect, u can use either - i've used both, i see no issue - best is to create your renderer to work with both, some like this:

// pseudo
class renderer
{
  abstract interface 
};

class ogl: public renderer
{
 ogl-specific render code
};

class vulkan: public renderer
{
 vulkan-specific render code
};

class dx12: public renderer
{
 dx12....
}

void CallOfDutyGhosts::create_renderer( )
{
  renderer* r = new dx12(); // or new ogl() // or whatever..
  
  // this way your game is renderer agnostic
  r->create_device( );
  ...
}  
  

That's it!

Anything not clarified here or explained in its entirety, i leave as an exercise for you to research and find out ?

All the best ?

@ddlox Hey man,

Thank you so much for the in-depth explanations it really helped me out! Last night I did a full DX11 tutorial and discovered it for sure isn't the same. Perhaps I can still use these books though for the game concepts and logic because translating them just seems like more work and less learning. I'd like to say I'm really just interested in using DirectX11 for 2D games, perhaps with 3D elements depending on what I'm doing and the learning goes. I specifically am interested in shaders (HLSL) at the moment.

Lastly, if you don't mind, why would you personally use DX11 over DX12? From what I gathered people prefer learning with DX11 first. I'm not exactly sure why though, but I can assume? I know a lot of games have performance issues with DX12 and people prefer DX11. I've googled this question and really didn't find a definitive answer. What does the future hold for DirectX? Will there be a 13?

I currently use SFML and I just wanted to finally dip into some 3D because it has intimidated me and I've avoided it for so long, haha. I've wanted to see what it's like to create a 2D game with DirectX. I've done a bit of OpenGL and I have to say I'm not exactly a big fan of it, despite SFML being built off it. I'm thoroughly enjoying DirectX11.

Thank you very much and have a great day.

PS: By the way, if anyone reads this and is interested in where I have started to learn DX11 check out this guy https://www.youtube.com/watch?v=gQIG77PfLgo&list=PLcacUGyBsOIBlGyQQWzp6D1Xn6ZENx9Y2&index=1​ I'm currently on tutorial 19. I also suggest a guy named Chilitomatonoodle if you want some comedy approach.

RamblingBaba said:
why would you personally use DX11 over DX12? From what I gathered people prefer learning with DX11 first. I'm not exactly sure why though, but I can assume? I know a lot of games have performance issues with DX12 and people prefer DX11. I've googled this question and really didn't find a definitive answer. What does the future hold for DirectX? Will there be a 13?

Mostly this has to do with ignorance of the naming convention and perhaps the last 15 years of graphics industry history.

For the first few years the DirectX suite was independent of the operating system. In the late 1990s 3D graphics cards were introduced and both hardware functions and APIs were wildly variable. D3D was no exception, changing dramatically along with the hardware. Feature evolution slowed and designs started to solidify around the current model in 2001. Back in 2002 DirectX switched their numbering schemes, locking the series 9 numbers with Windows XP, then 9.0a, 9.0b, 9.0c, and IIRC around 2005 declaring both the interface and the API version number would be tied to the OS.

Since then Windows Vista was DX10, Windows 7 was DX11, Windows 8 was DX11.1, Windows 8.1 was DX11.2, and Windows 10 was DX12 (with some minor variations for driver model concerns). This means there is D3D12 version 1607, D3D12 version 1703, D3D12 version 1709, D3D12 version 1809, D3D12 version 1903, D3D12 version 2004, each with the version number of the Windows 10 versions 1607, 1703, 1709, 1809, 1903, and 2004.

Presumably D3D 13 will come out with Windows 11. Either that, or they will need to change their numbering scheme they've tried to follow for the past 15 years.

With the changes in the 9 series they switched from using device capability flags to feature levels. A device may say it implements feature level 9_3 (cards in roughly 2004), or 10_1, or 11_0, 11_1, or 12_1, or whatever else. 12_2 (also called DirectX 12 Ultimate, in Windows 10 version 2004) is the latest iteration from a few months back, with card manufacturers deciding how far back for the hardware to incorporate it with drivers.

Deciding which feature level to support is up to you. If you decide you want to write code for decade-old cards, go with the 11_0 feature level. If you are writing graphics code that targets 8-year-old cards, the 11_1 feature level. If you decide you must implement and require the latest features of shader model 6.5 and hardware raytracing, require the 12_2 feature level.

RamblingBaba said:
why would you personally use DX11 over DX12?

Before answering this question, if I may:

If your game is a PC game (as opposed to console), then there is a chance for your PC game's renderer to become CPU bound (for a number of reasons), which means that rendering instructions executed on the CPU take too long to run (for many reasons that I won't explain here). Console games are usually GPU bound. One of DX12 targets as an API was to address CPU bottlenecks; such that making DX12 API calls would not cause huge CPU bottlenecks or reduce them altogether. This means that console games wouldn't really benefit much from DX12 because this API did not really address GPU bound issues.

So now, to answer your question, you as an astute game developer would stick to DX11:

  • if you know that your game was not (or never) CPU bound
  • if you don't care about the other new graphical features and improvements that DX12 has to offer

Read this and you will further understand why game states in dx11 can cause CPU bottlenecks, and these state changes are also reasons why many gamedevs made the jump to dx12:

https://gamingbolt.com/ex-naughty-dog-dev-explains-difference-between-dx12-and-dx11-less-gains-on-consoles-compared-to-pc

DX11 is good to get started in, it is an easier API than 12 (that's probably why you found that people prefer it), moving to 12 will be a little bit steep, but it's not too bad as opposed from DX7 ?

Chilitomatonoodle is good but sometimes it feels to me that he overdoes it -LoL- but I do recommend it yes, go for it (but focus on what you want to achieve).

RamblingBaba said:
What does the future hold for DirectX? Will there be a 13?

i think so, Microsoft has come a long way with DirectX, I started using it since DirectX v2 or 3.0! I can't even remember now… LoL; DX5 was one I really enjoyed then 7, 9, 11; I like 12 but not so much (personal taste reasons more than anything else);

so I don't think we have seen the end of DX yet;

RamblingBaba said:
I've done a bit of OpenGL and I have to say I'm not exactly a big fan of it, despite SFML being built off it. I'm thoroughly enjoying DirectX11.

Fair enough, that's what it's all about, enjoy it, you're making a game LoL! ?

Have fun ?

directx9 is a little bit similar to opengl 1.x

it has a fixed function pipeline as a basis, which is backwards compatible with older graphics cards.
but you also can enable shaders if you want that, and if they are supported on your graphics card, you can use it. so its very flexible.

never seen directx 7.

dx11 is more similar to opengl ES2 where you get just simple functions to upload vertex buffer objects. and then you get a simple shader language to put up the textures, colors, and lights on the top to the polygons.

So, DirectX7 is very old, and I would highly recommend not bothering with it. Mainly because the driver support on modern machines isn't great (especially on AMD GPUs) so if you make a DX7 game and there is some bug or issue on the driver level it's probably never going to get fixed. I had some old demos in DX7, from the Blitz3D days, and I had a lot of problems getting them to run when I tried recently on Windows 10.

DirectX9 is fairly straight-forward and should still work on modern cards. Though if you are doing this to learn, then it's not as relevant (but could be a valid option if you want to see how things used to be done). At least with DX9 you have shaders, so you have more control to implement what you want, though obviously you'll miss out on some newer features. On DX9 you can also use D3DX, which makes some things simpler, like loading textures or fonts, which you need to code yourself or use a library on newer APIs.

Personally, I made a lot of progress on DX11, it's more advanced but not overly complex, so if you want to build something that is still using current techniques, DX11 is a valid choice. DX12 became more low level and I wouldn't recommend it unless you have some experience already. It's not impossible, but if you are making a 2D game you won't need any of the advanced features, and even DX9 would suffice.

If you want my advice, just go with DirectX11. It's modern enough, and still very well supported. You won't be wasting your time learning ancient APIs (like DX7) and it will give you more flexibility than DX9. DX12 and Vulkan are interesting, and I think they are the future, but you're better off starting with something easier to learn the ropes first.

I used this site to get started, and I think it's a pretty helpful resource.

http://www.directxtutorial.com/LessonList.aspx?listid=11

I also learned a lot here. Even though it's for OpenGL, it's easy enough to port to whatever API once you understand.

https://learnopengl.com/

Also be sure to read Frank Luna's book, one of the best out th​ere:

https://www.amazon.com/Introduction-3D-Game-Programming-DirectX-ebook/dp/B0085CDJY4/

Hope that helps.

Direct3D 11 is probably the cleanest, simplest “classic” 3D API.

Roundabout 2000 to 2004 some key features emerged that marked a clear before/after transition: shaders, vertex buffers and render to texture. Direct3D 7 is on the wrong side of this divide (although it does have partial functionality). Direct3D 9 is contemporary with it and you can actually pick and choose which Direct3D 9 features you use and write code in a very 11-ish way. Both come with significant baggage: needing to use DirectDraw as well (7 only), lost devices, half-texel offsets, confusing legacy fixed pipeline calls, etc.

Direct3D 11 is just an all-round better and easier to use implementation of these features, and also adds the fourth which emerged some years later and which I've neglected to mention so far: GPU compute.

OpenGL is full-featured and fully functional, but has several legacy design flaws coming from how it was evolved incrementally rather than redesigned from scratch every few major versions. The buffer object API has been particularly troublesome and is regularly patched with new extensions. You'll find a lot of online resources claiming how so much easier OpenGL is than Direct3D, but dig a little and you'll find that they refer to 20+ year old versions of both. Direct3D actually started pulling ahead in ease of use with version 9.

The big advantages of OpenGL include portability (although these days that's really just Linux) and the extension mechanism which can give you early access to new features (but often at the expense of portability). Disadvantages include tooling, driver quality (although it's nowhere near as bad as it was 10 years ago) and an API with so many different ways to do the same thing that it's often difficult to figure out what the best way is.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Or some prefer the abstract character of opengl, and port it over dx distribution, the higher, the better, which gennerally allows you of more instructions in shader stage etc.

DX is attractive by aleviated logic offer, we've seen it all those stages of pre vertex and such.

DX11/12 in its version are just plain good old style GPU targeted libraries (as far as I know).

This topic is closed to new replies.

Advertisement