Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does WSL support openGL? #2855

Closed
littlepi opened this issue Jan 19, 2018 · 10 comments
Closed

Does WSL support openGL? #2855

littlepi opened this issue Jan 19, 2018 · 10 comments
Labels

Comments

@littlepi
Copy link

I am running a linux software on WSL. The program crashes every time I try to make some drawings with the openGL option. I know that the WSL is not a full linux and is intended to do command line tasks. In my case, I have installed the openGL libararies and everything seems OK. I am wondering if my problem is because of the WSL is incompatible with openGL.

@therealkenc
Copy link
Collaborator

WSL runs OpenGL alright, but it is not a supported scenario. You didn't follow the issue template, but in general from a clean Ubuntu install from the store do:

$ sudo apt install ubuntu-desktop mesa-utils
$ export DISPLAY=localhost:0
$ glxgears

On the Windows side, install VcXsrv, choose multiple windows, display 0, start no client, disable native opengl (sic). The hang out for this stuff is generally #637, but if you have a specific scenario I'll hold this open for a bit. It might be your scenario works. It might not.

@setten
Copy link

setten commented Sep 20, 2019

solved my problem running quantumatk in wsl it was the disable native opengl part

@NoxFly
Copy link

NoxFly commented Dec 2, 2019

WSL runs OpenGL alright, but it is not a supported scenario. You didn't follow the issue template, but in general from a clean Ubuntu install from the store do:

$ sudo apt install ubuntu-desktop mesa-utils
$ export DISPLAY=localhost:0
$ glxgears

On the Windows side, install VcXsrv, choose multiple windows, display 0, start no client, disable native opengl (sic). The hang out for this stuff is generally #637, but if you have a specific scenario I'll hold this open for a bit. It might be your scenario works. It might not.

Is there the same for debian-desktop ?
I can't locate both package when I try to install them (debian- or ubuntu-)
I've the same probleme but with debian application

@francescoboc
Copy link

WSL runs OpenGL alright, but it is not a supported scenario. You didn't follow the issue template, but in general from a clean Ubuntu install from the store do:

$ sudo apt install ubuntu-desktop mesa-utils
$ export DISPLAY=localhost:0
$ glxgears

On the Windows side, install VcXsrv, choose multiple windows, display 0, start no client, disable native opengl (sic). The hang out for this stuff is generally #637, but if you have a specific scenario I'll hold this open for a bit. It might be your scenario works. It might not.

For me, to make things work properly, I also had to set export LIBGL_ALWAYS_INDIRECT=0 (which I find a bit strange... so who's doing the rendering now, if also the wgl flag in VcXsrv is off?), otherwise glxgears would be slow and jerky. I found this solution from this superuser question.

@therealkenc
Copy link
Collaborator

therealkenc commented Apr 15, 2020

I also had to set export LIBGL_ALWAYS_INDIRECT=0

That's correct. [For one sensible definition of correct. Says as much quoth "disable native opengl (sic)" at the top.]

so who's doing the rendering now, if also the wgl flag in VcXsrv is off?)

LLVMpipe

image

@lohhans
Copy link

lohhans commented Apr 10, 2022

WSL runs OpenGL alright, but it is not a supported scenario. You didn't follow the issue template, but in general from a clean Ubuntu install from the store do:

$ sudo apt install ubuntu-desktop mesa-utils
$ export DISPLAY=localhost:0
$ glxgears

On the Windows side, install VcXsrv, choose multiple windows, display 0, start no client, disable native opengl (sic). The hang out for this stuff is generally #637, but if you have a specific scenario I'll hold this open for a bit. It might be your scenario works. It might not.

WORKS! Thanks.

In addition, in WSL Ubuntu I had to add the following arguments to my .bashrc (before performing the steps above):

export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=1

LINK OF SOLUTION 1
LINK OF SOLUTION 2

@mhdadk
Copy link

mhdadk commented May 20, 2022

Here is how I got this to work to use OpenGL to open GUI's (e.g. Open3D and matplotlib) in VS code. I am currently running Ubuntu 20.04.4 LTS on WSL2.

Step 1: Run

$ sudo apt install ubuntu-desktop mesa-utils

Step 2: Follow the instructions in this comment regarding installing VcXsrv, BUT replace

$ export DISPLAY=192.168.1.3:0.0

with

$ export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"

which was obtained from this comment.

Step 3: Follow the instructions here regarding setting up your firewall for VcXsrv.

Step 4: Run

$ glxgears

to test OpenGL.

To get this working with VS code, in a terminal window in VS code, run

$ export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"
$ export LIBGL_ALWAYS_INDIRECT=1

and then start running your code.

@NoxFly
Copy link

NoxFly commented May 21, 2022

Here is how I got this to work to use OpenGL to open GUI's (e.g. Open3D and matplotlib) in VS code. I am currently running Ubuntu 20.04.4 LTS on WSL2.

Step 1: Run

$ sudo apt install ubuntu-desktop mesa-utils

Step 2: Follow the instructions in this comment regarding installing VcXsrv, BUT replace

$ export DISPLAY=192.168.1.3:0.0

with

$ export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"

which was obtained from this comment.

Step 3: Follow the instructions here regarding setting up your firewall for VcXsrv.

Step 4: Run

$ glxgears

to test OpenGL.

To get this working with VS code, in a terminal window in VS code, run

$ export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"
$ export LIBGL_ALWAYS_INDIRECT=1

and then start running your code.

And after running glxinfo | grep "OpenGL version"
You'll see that you're running OpenGL 1.4.2 or something like that, instead of 4.6.0.
Your terminal will also show you this version, but to indicate you that your hardware can run 4.6.0, but because it's an indirect display port, you cannot use a higher version than 1.4.2.
Hence you'll be blocked when you'll try new bigger things. It's a version gap. It's why I stopped WSL.

@mhdadk
Copy link

mhdadk commented May 21, 2022

Here is how I got this to work to use OpenGL to open GUI's (e.g. Open3D and matplotlib) in VS code. I am currently running Ubuntu 20.04.4 LTS on WSL2.
Step 1: Run

$ sudo apt install ubuntu-desktop mesa-utils

Step 2: Follow the instructions in this comment regarding installing VcXsrv, BUT replace

$ export DISPLAY=192.168.1.3:0.0

with

$ export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"

which was obtained from this comment.
Step 3: Follow the instructions here regarding setting up your firewall for VcXsrv.
Step 4: Run

$ glxgears

to test OpenGL.
To get this working with VS code, in a terminal window in VS code, run

$ export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"
$ export LIBGL_ALWAYS_INDIRECT=1

and then start running your code.

And after running glxinfo | grep "OpenGL version" You'll see that you're running OpenGL 1.4.2 or something like that, instead of 4.6.0. Your terminal will also show you this version, but to indicate you that your hardware can run 4.6.0, but because it's an indirect display port, you cannot use a higher version than 1.4.2. Hence you'll be blocked when you'll try new bigger things. It's a version gap. It's why I stopped WSL.

Interesting. So what do you use instead? Do you dual-boot?

@NoxFly
Copy link

NoxFly commented May 21, 2022

Here is how I got this to work to use OpenGL to open GUI's (e.g. Open3D and matplotlib) in VS code. I am currently running Ubuntu 20.04.4 LTS on WSL2.
Step 1: Run

$ sudo apt install ubuntu-desktop mesa-utils

Step 2: Follow the instructions in this comment regarding installing VcXsrv, BUT replace

$ export DISPLAY=192.168.1.3:0.0

with

$ export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"

which was obtained from this comment.
Step 3: Follow the instructions here regarding setting up your firewall for VcXsrv.
Step 4: Run

$ glxgears

to test OpenGL.
To get this working with VS code, in a terminal window in VS code, run

$ export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"
$ export LIBGL_ALWAYS_INDIRECT=1

and then start running your code.

And after running glxinfo | grep "OpenGL version" You'll see that you're running OpenGL 1.4.2 or something like that, instead of 4.6.0. Your terminal will also show you this version, but to indicate you that your hardware can run 4.6.0, but because it's an indirect display port, you cannot use a higher version than 1.4.2. Hence you'll be blocked when you'll try new bigger things. It's a version gap. It's why I stopped WSL.

Interesting. So what do you use instead? Do you dual-boot?

Dual boot yes, but because it takes a consequent part of your disk, another option, with negative points too, can be USB booting with consistence. Because it's an external booter, you have to disable the UEFI security check, and it's not really a good idea. Also, for the same reason, a USB with 300-400Mo/s on R/W is usually good to keep correct performances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants