Monday, August 17, 2009

How to enable directX9 or 10 in VirtualBox with Ubuntu host

From version 3.0.2 VirtualBox included an experimental support for DirectX.

Although many believe that running complex 3D applications (i.e. games) inside a virtual machine is pure heresy, this goal could not be so far away. Virtual Machines are getting more and more popular mostly because they express the latent desire of every user to be allowed to choose the desired operating system without being forced by the software which too often is designed to run on one OS only. Should you have a fast and capable computer it could be possible in the near future to run a brand new 3D video game inside your virtual machine.
I recently discovered the new feature of VirtualBox which once selected allow the guest system to access the 3D graphics capabilities available on the host.
I created a guest system on my Ubuntu 9.04 host system by installing my old copy of Windows XP. The 3D graphics implementation in MS Windows is called DirectX which includes a whole set of APIs to manage several multimedia tasks. As you can imagine enabling the 3D acceleration on VirtualBox isn't sufficient to access the Direct3D functions as the direct interlocutor on the host side is OpenGL.

In order to reach my goal I had to find a way to translate the Direct3D calls of my guest machine to OpenGL. By googling I found WineD3D, a WineHQ project which works as a wrapper for MS Direct3D calls. You can find a brief description of the project plus the instruction to compile the DLL on a Ubuntu system here. To use WineD3D on a native Windows system -which is what I wanted given that I was interested in replacing the Direct3D DLLs on my Windows XP guest machine- you can find precompiled binaries here.
After having downloaded the package run the Windows XP guest machine in safe mode. Then launch the WineD3D setup, select the Direct3D version you want to replace (notably 8, 9 and 10 -experimental-) and that's it, the trick is done.
Now you can run dxdiag in your guest Windows XP machine (Start --> Run..--> dxdiag) and check the DirectX components which are implemented and available. You will see that the d3d8.dll and d3d9.dll are marked like files that can cause problems and need to be reinstalled. Just ignore the warning because those are the DLL which have been replaced by WineD3D.


Have fun.

No comments:

Post a Comment