3D acceleration in virtual machines - Part 2: VirtualBox & OpenGL - Tutorial


Updated: January 2, 2009

This is the second of the three articles dedicated to configuring and using 3D virtualization in virtual machines. Today, we will learn how to enable 3D acceleration for OpenGL applications (and games) for Windows virtual machines running in VirtualBox installed on either a Windows or a Linux host.

In the first article, we saw how we can enable 3D acceleration for DirectX programs in Windows, using VMware products. The choice of the host platform did not matter. We were able to run our 3D-enabled Windows guests on top of both Windows and Linux hosts.  In the last article, we'll try to configure a Linux host and a Linux virtual machine to share GPU resources. Follow me.

Teaser

VirtualBox & OpenGL

What do we need?

You need VirtualBox 2.1.0 (or higher) installed. From version 2.1.0, VirtualBox officially support 3D acceleration for OpenGL applications. This feature greatly complements the VMware & DirectX combo. The choice of the host is not important.

For this tutorial, I've used the following:

  1. VirtualBox 2.1.0 installed on Windows XP SP3 host (RE: Windows host example)
  2. VirtualBox 2.1.0 installed on Ubuntu 8.10 host (RE: Linux host example)
  3. Windows XP SP3 installed as the guest operating system in both cases
  4. Guest Additions installed in the guest operating system
  5. Some configurations changed in the virtual machine settings
  6. A game that uses OpenGL to test the functionality

You may also have to refer to some of the other tutorials in the Virtualization section to get everything going. My tutorials are chronological and incremental and build one upon another. So if you're having difficulties mastering the installation and configuration of either VirtualBox and/or Windows XP as a guest operating system, you should spend some time reading. In particular:

How to install VirtualBox Guest Additions - Tutorial

Installing Windows XP - Full tutorial

Make sure Guest Additions are installed

Boot your virtual machine once and check whether the Guest Additions are installed. Similarly to VMware Tools, the Guest Additions feature an icon in the system tray.  Now, shut down the machine and enable the 3D acceleration.

Guest addons

Configure virtual machine to use 3D acceleration

This is much simpler than the VMware configuration. You do not have to edit any configuration file manually. The entire procedure takes 17 seconds and is done entirely using GUI.

Open VirtualBox. Select the virtual machine you want to use. Click on Settings. Under General, change the Video Memory Size to a desired amount, in our example 64MB, and tick the box Enable 3D Acceleration. That's it!

Enable

Now boot the guest, install the game of your choice and test. I selected OpenArena for the task.

Test configuration

And here we go:

OpenArena

The performance was not stellar. It was reasonable, similar to the results obtained with VMware Server & DirectX. The game worked, although it was much slower than a native installation.

Linux host, Windows guest

Similarly, we do the same thing on Linux.

Linux host

Now, surprise, surprise, the performance on the Ubuntu host was much, much better than on Windows! The game performance and responsiveness were almost as good as the native installation.

Well, since the 3D acceleration is still an experimental feature, it is quite expectable that different setups should yield markedly different results. For now, though, it seems that if you want to run OpenGL applications, having a Linux host is the best choice.

In a way, this sounds logical, because DirectX is a purely Windows feature and OpenGL is its open-source equivalent. VirtualBox, being developed by Sun, one of the open-source pioneers, running on top of the open-source Ubuntu, seems like a more prominent candidate for a more seamless OpenGL integration.

Conclusion

VirtualBox & OpenGL is a great combination, especially if you have a Linux host. I admit the need for virtualized OpenGL applications seems less of an issue here, because Linux natively supports these applications, but if and when a need might arise, you will get excellent results.

Again, please, keep in mind the currently experimental feature of the whole thing. I cannot promise the same results. Still, considering the fact I have tested the functionality on four different systems, including Windows and two flavors of Linux, including 3 different machines, including both Intel and AMD architecture, including 32-bit and 64-bit operating systems, you should be fine. Best of all, the configuration is utterly simple. Ten seconds and you're done!

So, we've had two articles, two great solutions so far. We have the VMware & DirectX combo and we have the VirtualBox & OpenGL, something for everyone. In the third article, we'll attempt to introduce 3D acceleration into the Linux guests.

Cheers.

RSS Feed icon

del.icio.us del.icio.us stumbleupon stumble digg digg reddit reddit slashdot slashdot



Advertise!

Would you like to advertise your product/site on Dedoimedo?

Read more

Donate to Dedoimedo!

Do you want to
help me take early retirement? How about donating
some dinero to
Dedoimedo?

Read more

Donate