is there a vm that i can do opengl 3+ with? virtualbox and vmware don't
Asked Answered
H

3

6

I am trying to write some openFrameworks (C++) code in a VM. My host is Windows 8 and I've tried both Arch Linux and Ubuntu guests. My host computer runs the graphics code just fine with an NVidia Optimus setup and 8GB of RAM.

I do my main development in Visual Studio, however I do prefer to create Android and test packages from Linux. For this reason I just want to fire up a VM and take care of business. The problem is that some of my graphics apps need OpenGL 3+

Has anybody else had the same problem and solved it?

Hulburt answered 19/12, 2014 at 12:49 Comment(1)
Yeah, virtualboxs default GPU drivers don't offer an OpenGL feature level that high. You can try to enable 3D GPU acceleration and download the virtual box extension pack (or whatever it's called). That may help, but in general "doing GPU stuff in a VM" is not advisable and is usually pretty bad.Moonstone
K
3

Try VirtualBox and prepend MESA_GL_VERSION_OVERRIDE=3.0 MESA_GLSL_VERSION_OVERRIDE=130 to your linux command line. Some of the opengl3 functions may work. Though not all of them will. I used that to bring up Civ5, the animation did not show up, nor did the on-screen fonts.

If you want to see the source code:

VirtualBox uses chromium 1.9 that is opengl 2.1. The info can be verified by the glxinfo command. Use the following commands to track the VirtualBox opengl lib file:

$ ldd /usr/bin/glxinfo
$ apt-file search /usr/lib/x86_64-linux-gnu/libGL.so.1.2
$ LIBGL_DEBUG=verbose glxinfo

Then follow links:

$ ls -l x86_64-linux-gnu/dri/
lrwxrwxrwx Apr 14 2014 vboxvideo_dri.so -> ../../VBoxOGL.so

$ apt-file search /usr/lib/VBoxOGL.so
virtualbox-dbg: /usr/lib/debug/usr/lib/VBoxOGL.so
virtualbox-guest-x11: /usr/lib/VBoxOGL.so

$ dpkg -l virtualbox*
ii virtualbox-guest-x11 4.1.18-dfsg-2+deb7 amd64

$ apt-file list virtualbox-guest-x11
...

The source code tarball was virtualbox-4.3.10-dfsg.orig.tar.gz from trusty repo. The version string can be grep'ed by $ grep -r CR_OPENGL_VERSION_STRING * and $ grep -r CR_VERSION_STRING * in the source code directory.

Update 6/1/2017: Someone told me the kvm works for civ5. A quick search turned up this thread titled "GPU Passthrough with KVM: Have Your Cake and Eat it Too". The thread is too long to read, though hope it could be useful to somebody.

Kitchener answered 10/1, 2016 at 0:58 Comment(4)
Please clarify what you mean by "prepend MESA_GL_VERSION_OVERRIDE...".Britska
prepend to the beginning of your command line. like if you normally run "civ5", now "MEASA_GL... civ5".Kitchener
What's civ5? Sid Meier's Civilization V? You mean running a game with the prepended command?Mither
@Mither You are correct. Put environment variables to the beginning of the command line.Kitchener
O
5

Give up on VirtualBox. VB's OpenGL guest support craps out at 2.1, even then only after you install VB Guest Additions from the command line with switches and then add some Registry keys to actually enable the OpenGL guest drivers.

If you're willing to shell out money, VMware Fusion for Mac and VMware Workstation for Windows both support DirectX 10 and OpenGL 3.3.

Othelia answered 25/3, 2017 at 9:45 Comment(2)
Good to know that VMware play well on Mac. Is it better than Parallels on this OpenGL aspect?Itis
@Itis Parallels only support OpenGL up to 2.1.Corduroys
D
5

A bit late to the party here, but hopefully helpful for someone encountering similar issues these days:

The mesa software renderer now supports OpenGL 4.5, so for me, the solution is to disable 3D acceleration in the settings of the VirtualBox machine! The mesa software OpenGL support then takes over and provides its capabilities. It's for sure not that fast, but for my purpose (testing whether an OpenGL application starts and displays something under linux) it's sufficient!

Restart the virtualbox and test with the glxinfo program whether everything works as expected.

Output on Fedora 39:

$ glxinfo | grep "^OpenGL"
OpenGL vendor string: Mesa
OpenGL renderer string: llvmpipe (LLVM 16.0.6, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 23.2.1
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.5 (Compatibility Profile) Mesa 23.2.1
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 23.2.1
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

More information on glxinfo output for example in this question.

Tested on Fedora (34-39) and Ubuntu (20.04, 22.04).

Dulcie answered 17/8, 2021 at 20:12 Comment(2)
how do you verify it supports opengl4.5? I disabled my 3d acceleration and the program still doesn't work.Tyler
glxinfo prints information on the running/supported OpenGL version, I have updated my answer. Do you get more info from the program you are trying to run (error message, ...)? "doesn't work" could come from many reasons...Dulcie
K
3

Try VirtualBox and prepend MESA_GL_VERSION_OVERRIDE=3.0 MESA_GLSL_VERSION_OVERRIDE=130 to your linux command line. Some of the opengl3 functions may work. Though not all of them will. I used that to bring up Civ5, the animation did not show up, nor did the on-screen fonts.

If you want to see the source code:

VirtualBox uses chromium 1.9 that is opengl 2.1. The info can be verified by the glxinfo command. Use the following commands to track the VirtualBox opengl lib file:

$ ldd /usr/bin/glxinfo
$ apt-file search /usr/lib/x86_64-linux-gnu/libGL.so.1.2
$ LIBGL_DEBUG=verbose glxinfo

Then follow links:

$ ls -l x86_64-linux-gnu/dri/
lrwxrwxrwx Apr 14 2014 vboxvideo_dri.so -> ../../VBoxOGL.so

$ apt-file search /usr/lib/VBoxOGL.so
virtualbox-dbg: /usr/lib/debug/usr/lib/VBoxOGL.so
virtualbox-guest-x11: /usr/lib/VBoxOGL.so

$ dpkg -l virtualbox*
ii virtualbox-guest-x11 4.1.18-dfsg-2+deb7 amd64

$ apt-file list virtualbox-guest-x11
...

The source code tarball was virtualbox-4.3.10-dfsg.orig.tar.gz from trusty repo. The version string can be grep'ed by $ grep -r CR_OPENGL_VERSION_STRING * and $ grep -r CR_VERSION_STRING * in the source code directory.

Update 6/1/2017: Someone told me the kvm works for civ5. A quick search turned up this thread titled "GPU Passthrough with KVM: Have Your Cake and Eat it Too". The thread is too long to read, though hope it could be useful to somebody.

Kitchener answered 10/1, 2016 at 0:58 Comment(4)
Please clarify what you mean by "prepend MESA_GL_VERSION_OVERRIDE...".Britska
prepend to the beginning of your command line. like if you normally run "civ5", now "MEASA_GL... civ5".Kitchener
What's civ5? Sid Meier's Civilization V? You mean running a game with the prepended command?Mither
@Mither You are correct. Put environment variables to the beginning of the command line.Kitchener

© 2022 - 2024 — McMap. All rights reserved.