OpenGL in a virtual machine

As I prefer to work on a Linux computer for programming, at work I have to use a virtual machine to execute the product and test in a real environment using different Windows versions.

The problem encountered is that the emulated graphics card, even with full drivers in my KVM setup is only providing an OpenGL 1.1 version, something so old that some of the functionalities of our application are not working and display black boxes instead.

After trying to install additional drivers or setup a more complete emulation, a newer emulated card or other complex steps, I found a simpler way : Using a Mesa3D driver with the llvmpipe that will emulate the lastest OpenGL features using what is available on the emulated machine. The result will not be fast enough for a 3D game for example, but every feature will become available.

You can download an already compiled distribution of the Mesa3D sources at https://github.com/pal1000/mesa-dist-win/releases. By default, I download the msvc version as I usually have everything needed. Once downloaded, simply extract the archive in your download or Desktop folder.

I usually install the library System-Wide, as a replacement to the Microsoft OpenGL software renderer that only support the very old OpenGL 1.1 version.

Install

Select the first option to install the LLVM pipe System-Wide so that any application needing OpenGL will use the Mesa3D implementation instead of the Microsoft renderer without any further configuration needed.

Once installed System-Wide, you can simply restart your application and check that the available OpenGL version has been bumped to a default 3.1 version. This default version can be overridden by setting the MESA_GL_VERSION_OVERRIDE environment variable. For example, if you want to get OpenGL 4.6, you can create a MyApplication.cmd that will launch the executable :

@set MESA_GL_VERSION_OVERRIDE=4.6COMPAT
@MyApplication.exe

It is important to note that profiles higher than the default can be incomplete and are not certified as a full implementation. If your application only uses extensions that are implemented, this will work but YMMV.