60

I am not very experienced with computers, and was wondering what Direct X actually does, on my PC.

Why do various games request different versions? Should the latest version cover all of them, or do certain games only support specific versions?

  • So lets say i decided not to install the direct x version included on the installer since i have the latest one, i could say that it wont encounter any problems at the least? – user4485 May 8 '16 at 12:02
  • 6
    Short tech answer: If Dx9 games have problems try using Dx web installer or install Dx9 June 2010. If game asks to install DirectX, click yes just to be on safe side (there should be no bad effects). – PTwr May 8 '16 at 12:09
54

TL;DR: DirectX is a redistributed library that helps the game talk to your hardware. DirectX should support earlier versions, and as PTwr suggests, is often the culprit of "missing DLL d3dx9_[somenumber].dll" messages. The required version should always be included as part of a game's installation process, so you often end up with multiple versions.

DirectX is simply the software in the middle, that acts as the translator between your graphic card and the game you are playing, among other things1. It is essential that you have the version required of by the video game, or higher. As far as I have seen, having the newer version should not be an issue; however, I have never seen a game that did not come with the required DirectX version in its installer, so there really shouldn't be a problem either way.

Newer versions of DirectX work with newer graphic card features; for example, a game using DirectX 9 has less to work with graphically than a game using DirectX 10, theoretically. That does not account for developer ability, of course.

To elaborate on why we need it, every computer graphic card speaks a different language. A set of cards from the same manufacturer might speak almost the same language, but it will not be exact, like two people speaking Chinese except with different dialects. In the early days of computer gaming, you would need to ensure that your graphic card was actually listed as a supported card. You would have to go through a small list of cards and try and find your exact model number. And if the developers decided they did not want to deliberately add the support, too bad. Computers can be incredibly difficult to work with, even with the slightest inconsistency. A full stop in the wrong place could crash your entire system.

DirectX was created as a means to combat this obvious problem. Game developers would write to use the DirectX libraries, as would graphics card manufacturers. These days, instead of having to search for your card model between a list of potentially hundreds of listed models, you instead only have to ensure your graphics card is compatible with that DirectX version.

As a side note, DirectX was created by Microsoft. As a result, any game with express DirectX requirements will likely only run correctly on Windows. This is why it is rather difficult to play most games on a *nix- or Mac-based system.

1 DirectX has grown to facilitate other media functions, within Windows, but it is primarily associated with the graphical capabilities. Technically, the graphics component of DirectX is known as Direct3D, while other parts include DirectShow for media, DirectWrite for fonts, etc.

  • 1
    I believe mention of DX redist libraries might be good thing, as lack of them is quite common issue ("missing d3dx9_[somenumber].dll" ). And TLDR could be "dx10+ have backward compatibility with dx9, but you need redists" (feature level thingie) – PTwr May 8 '16 at 11:48
  • 3
    @CarstenS with Directx9 (released in 2002) and up its all fine, however with older versions support is long gone so virtual machine with Win98/XP is your best/easiest bet. Even emulation will have more than enough power for those oldies, and compatibility issues are to be expected anyway. Long story short, for games released in last decade you have nothing to worry about. – PTwr May 8 '16 at 16:36
  • 4
    @CarstenS Actually, the problem you hit on is exactly what DirectX is for: to make sure the game makers don't have to worry as much about the hardware that will be used to run their games. As long as the hardware makers make their hardware compatible with DirectX any game that uses it should just work. Making your hardware incompatible with DirectX these days means that in all likelihood you won't sell a lot. – Cronax May 9 '16 at 5:39
  • 3
    @JoeWallis, it simply conveys that directX games only nativley run on windows. Asker is not asking about alternatives, in this case, so elaborating doesnt really add to the question. – user106385 May 9 '16 at 17:54
  • 3
    @JoeWallis The version of those games that runs on *nix systems isn't DirectX. Otherwise, it wouldn't run on *nix systems without something like wine. They simply have both DirectX and OpenGL backends in their engine. – reirab May 9 '16 at 18:03
15

DirectX is a special library that allows programs (typically games) to access the video card more "directly" (thus, the Direct in DirectX). It sits between the graphics card's drivers and the OS.

Back in the pre-DirectX days, Windows programs had one of two options if they needed to talk to the video card:

  • Option one was they could write to the card via the Windows API. They hand off their requests to Windows, and Windows does a bunch of stuff in the background and eventually gets around to writing that data to the graphics card. Most older 2D games could get by with this (think Minesweeper and Solitare, for example) as latency wasn't really an issue for them.
  • Option two was they could write against the video card's drivers themselves. This meant that you needed to support different versions of your program's rendering engine depending on what hardware was installed on the PC. Not precisely the optimum solution, but it worked much faster.

As performance demands grew, and as video cards became more and more sophisticated, standards started to emerge. Two of the biggest early standards were (and still are, although they've evolved) OpenGL and DirectX. Both of these were implemented in the video card drivers, but were exposed by Windows. DirectX came from Microsoft and is only officially supported on Windows, and OpenGL came from SGI and is an open specification. (DirectX also includes a bunch of other stuff that isn't video card related, but I'm ignoring that for the purposes of this answer)

With either of these standards, you can write a program that has direct control over the video card without having to worry about who makes it, just as long as they implement the standard you chose.

Now we come to DirectX installation. The DirectX parts of Windows ship with recent versions of the OS, but DirectX is a standard that tends to evolve as video cards and programs that use them grow and change. Thus, Microsoft makes installers available that can be bundled with games to bring the version of DirectX on your machine up to the version required by the game.

It's totally safe to install an older version of the DirectX redistributable package, as if the DirectX installer realizes it's out of date compared to what's on your machine, it just exits without doing anything. There are also different major versions of DirectX that a game could be created with, (like DirectX 9 or DirectX 11), but these versions peacefully coexist and have their own versions installed at the same time.

  • 6
    OpenGL isn't open source. OpenGL is a specification, and there are implementations of it that are open source (such as Mesa 3D) and implementations that are not (such as Windows's one). – immibis May 8 '16 at 22:12
  • 4
    (The reason that's not the case for DirectX is that for DirectX, Microsoft's implementation is the specification - i.e. your implementation had better do exactly what Microsoft's does, and Microsoft's isn't open source) – immibis May 8 '16 at 22:12
  • @immibis, you're quite right. I've clarified that point. Thanks! – agent86 May 9 '16 at 15:16
9

DirectX is three different things depending on whether you're a gamer or a developer and what version of Windows you using. DirectX used to be add-on that could be upgraded in older versions of Windows, but in current versions of Windows DirectX is a component of the OS that can't be upgraded. It's also an SDK that developers use to create games that use DirectX. These days when a game installs DirectX it's actually installing part of the DirectX SDK, not DirectX itself, that's meant to redistributed to users. It's always safe to do this. It may end up doing nothing because what it installs is already there, but it will never downgrade the version of DirectX. Since all versions of DirectX are backwards compatible with earlier versions there's also never any need to downgrade.

DirectX as an add-on

DirectX used to essentially be an add-on to Windows before Windows XP SP2. It wasn't considered a part of the Windows operating system itself, and at Microsoft a different team of "DirectX" developers worked on the product separately from the "Windows" developers. While it was shipped with Windows since Windows 95 OSR2 and Windows NT 4.0, it could be upgraded separately from the operating system and so wasn't considered a part of it.

It's from this era that we get the whole notion of games installing DirectX. These days that's not really what happens, but it used to be that games would actually install or upgrade DirectX. If a game used the DirectX 7 interfaces then it would usually include the DirectX 7 runtime installer and offer to install it as part of the game's installation. If DirectX 7 or newer was already installed then the runtime installer would do nothing. If not it would install or upgrade DirectX.

DirectX as an OS component

These days DirectX is considered part of Windows, one that can't be upgraded separately. If you're using Windows XP SP2 or SP3, Windows Vista, Windows 7, Windows 8 or Windows 10 then games can't actually upgrade the version of DirectX you're using. While they might come with DirectX 9.0c runtime installer, the last version of DirectX that Microsoft provided one for, it won't upgrade the version of DirectX you have installed because DirectX 9.0c or later is already installed.

DirectX as an SDK

DirectX also used to have a separate SDK (Software Development Kit) component. The SDK provided the files and documentation the developers needed to create games and applications that use DirectX. It also contained support code written by Microsoft designed to make creating games that used DirectX easier.

In particular it provided the D3DX library, which contained code designed to be used with games that used Direct3D. While Direct3D allowed programmers to do things they couldn't do without it, that is, access a video card's accelerated rendering hardware, the D3DX library was all code that programmers could have written themselves. It just saved them from having to do so. Because it wasn't necessary and didn't do anything special it wasn't provided as part of the DirectX runtime. Developers could simply include whatever parts of it in their games that they wanted to use, if any. The D3DX code would would become an integral part of the game, usually as part of the game's executable (.EXE), just as if they had wrote it themselves.

However one day Microsoft decided to change how developers were allowed to use the D3DX library. They turned it into a DLL that the game would have install if the wanted to use it, similar to how games used to install the DirectX runtime. In fact they used the same installer for both. The installer provided by Microsoft would either install the DirectX 9.0c runtime and/or the D3DX DLL depending on what files were packaged with it.

So while modern games include a DirectX installer that won't actually install DirectX, it will often install a D3DX DLL (and/or one of a number of other DLLs provided with DirectX SDK). Each version of the DirectX SDK that came with a D3DX DLL had it's own separately numbered DLL (from d3dx9_24.dll to d3d9_43.dll. Each game only installs the version of the DLL they use, so it's possible even if many other games have "installed DirectX", they haven't installed the version of D3DX needed by the game you're installing now.

These days Microsoft no longer provides a separate DirectX SDK. Like how the DirectX runtime became part of Windows operating system, the Direct SDK is now part of the Windows SDK. They've also stopped updating the D3DX library. Instead Microsoft recommends that developers use "third-party" libraries that they can include with their games and don't need to install separately.

Games that install DirectX today

When game installs DirectX don't worry about it. If it asks if you if you want to install DirectX, then saying "yes" is the safest option. The DirectX runtime installers won't downgrade the version of DirectX installed. Not only won't they, Windows would prevent them if they tried, as DirectX is now a protected part of the operating system. While on a modern version of Windows it won't actually change the version of DirectX installed, the installer may still install DLLs that the game needs.

DirectX compatibility

DirectX is also fully backwards compatible. If you're running Windows 10 then have not only do you have the latest DirectX 12 interfaces, Windows also provides all the previous interfaces as well. Baring some other incompatibility, you can play games designed for Windows 95 and the original version of DirectX.

On the other hand if you're running Windows Vista you only have the DirectX 10 interfaces available. You can't play games that require DirectX 11 or 12. You also can't upgrade to DirectX 11 or 12. To play games that require DirectX 11 you'd need to upgrade to at least Windows 7. If you want to take advantage of the features in a game that require DirectX 12 then you would need to upgrade to Windows 10.

  • Im not quite sure what your trying to add to the already available information, here? – user106385 May 9 '16 at 2:48
  • 1
    @Timelord64 I'm trying to answer the two questions given in the body of the question. They seem to be what the original poster is really asking and the other two answers don't adequately or accurately address those questions. – Ross Ridge May 9 '16 at 4:15
  • Your talking a lot in the context of game dev, where a simple "newer versions support newer features, and are backward compatible" cover it. The only thing your really doing is extrapolating on it, a lot. Good in theory, but I don't think a 'layman' such as the asker will understand it – user106385 May 9 '16 at 4:26
  • 4
    @Timelord64 The original poster may not understand my explanation, but it's not an "extrapolation" of anything. It's also not as simple as you make it, games appear to need to install DirectX, and won't work if you don't, even when there appears to be a newer version of DirectX already installed. That makes it look like DirectX isn't actually backwards compatible, when the reality is that the games aren't actually installing an old version of DirectX, they're installing something else. My answer attempts to fully explain why that is. – Ross Ridge May 9 '16 at 4:55
  • 1
    The libraries are not, in fact, fully backwards compatible, unfortunately, but they were for quite a few versions. That was the promise MS made when they released it. As of DX 9 or so, they quit promising such things. In particular, they removed some of the older methods for defining and calling on a surface. (Due to adding in multiscreen support, I think) This is why a tool like DxWnd is needed to get older DX games functional on Win7+. (Rewriting old code to recompile using the new methods should be pretty straightforward, but that's not the same thing.) Otherwise a good summary. – The Nate May 10 '16 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.