问题
Our Windows C++ Ogre-based game is nearing completion. Before we publicly release it, we have to solve this matter :
Ogre crashes on many test-computers if they are not updated to the latest Dx9.0c version. All these computers already had 9.0c installed, but that must have been an older OS-pre-installed sub-version, hence the crash..?
The 1st questions is : how can I ensure that a user has the correct 9.0c version so that the game doesn't crash on the user's face, but instead show a message like "Go get the latest 9.0c version from there...."?
The 2nd question is : is there a standard, automated method to update the user's computer to the latest 9.0c version during the game's installation? That would be the best solution.
Many many thanks in advance,
Bill
回答1:
The 1st questions is : how can I ensure that a user has the correct 9.0c version so that the game doesn't crash on the user's face, but instead show a message like "Go get the latest 9.0c version from there...."?
The best idea is to update/install DirectX silently from Game Installer. Along with other required system components like PhysX, vcredist, etc. Silently, without asking "do you want to install DirectX" (user may not know if he needs DirectX, and if it is already installed, nothing will happen).
See DirectX Installation for Game Developers. Also, I'd recommend to see "Instalation and Maintenance of Games"
This is because (I believe that) when you're making games, you should assume that computer user is total idiot. I.e. if you give instructions, expect that user will screw up, damage the system and blame you for it. Compared to that silent DirectX install is almost fool-proof. Also, it is much more convenient - user won't have to hunt for DirectX download, and will be able to play immediately after installation.
The 2nd question is : is there a standard, automated method to update the user's computer to the latest 9.0c version during the game's installation? That would be the best solution.
AFAIK, DXSDK includes DirectX redistributable, and AFAIK you're supposed to include those redistributables with your product.
回答2:
I had the same problem, but since Ogre supports both Direct3D and OpenGL out of the box, I just tried to LoadLibrary of the neededx directx lib (d3dx9_42.dll), and if it failed, skipped the loading of the directx rendersystem. (I moved out the loading of rendersystem plugins from the plugins.cfg file to manually doing it in the initialization). In that case, my application proceeded to run on OpenGL instead.
Of course, this doesn't work if you have directx-specific code like hlsl shaders or something like that, in that case, just include the redist. Just check with Microsoft and EULAs, it seems that they have something against running redist silently, because they want the user to accept an agreement first. So to be 100% correct you need to run the redist in a non-silent way, or include MS EULa with your own license in your installer.
(Another thing that people seem to have done and got away with it, meaning that their application ran without any problems, is just including the needed directx dlls with their project (like d3dx9_42.dll or whatever). Just simply copying them to the bin directory, that way the render system would always find them. This doesn't seem to be a nice way to do it, but hey, if it works, why not?)
来源:https://stackoverflow.com/questions/3255094/minimum-directx-9-0c-version-and-how-to-check-for-it