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?
Arqade is a question and answer site for passionate videogamers on all platforms. It only takes a minute to sign up.Sign up to join this community
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.
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:
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.
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 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.
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 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
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.
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 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.
DirectX is neither a programming language, nor driver software. It's a collection of APIs. An API being, if I can quote Wikipedia:
In computer programming, an application programming interface (API) is a set of routines, protocols, and tools for building software and applications. An API expresses a software component in terms of its operations, inputs, outputs, and underlying types, defining functionalities that are independent of their respective implementations, which allows definitions and implementations to vary without compromising the interface. A good API makes it easier to develop a program by providing all the building blocks, which are then put together by the programmer. An API may be for a web-based system, operating system, or database system, and it provides facilities to develop applications for that system using a given programming language.
DirectX provides functionality, which allows the interaction between hardware and software. That's why different GPUs support different versions of DirectX and different games require a different version of DirectX since they need functionality that the previous versions do not offer.
For example, Hardware Acceleration, anti-aliasing, etc. are functionalities that the Direct3D API, which is part of the DirectX library, provides. If a game is written in a way that uses that Direct3D functionality you will need to install the API, which provides the processes and classes.
So, basically - the games are not "written in DirectX" but are written to use DirectX functionality. Hence, it's not a programming language. Also, it's not a driver because it does not control the hardware, it only allows for a specific type of communication between hardware and software.