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

Support for WSL2 in Windows? #75

Open
chrisRidgers opened this issue Oct 5, 2021 · 1 comment
Open

Support for WSL2 in Windows? #75

chrisRidgers opened this issue Oct 5, 2021 · 1 comment

Comments

@chrisRidgers
Copy link

I've been prodding around the learnopengl.com tutorials for a few weeks and was noticing some performance issues while inside of my linux environment in WSL.

I've mentioned them here: #59 (comment)

But to state here:

I think performance of OpenGL code is limited in WSL because the environment cannot access the graphics card of the host machine. It's essentially using the embedded graphics of whatever virtual cpu it's using.

You can probably confirm this by removing several of the window hints, and inferring information from glxgears and other similar applications, the graphics driver supports some older version of opengl, and from there you can do some googling around whether or not to install nvidia drivers inside of WSL or use the host drivers etc. But ultimately, accessing the GPU from WSL is not supported by Microsoft or Docker.

There's some articles around Windows WSL and Docker getting graphics card access in an upcoming build (Windows 11, build 22000?)

https://developer.nvidia.com/cuda/wsl
https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

But I've just attempted to cmake from WSL inside windows11 and ran into errors regarding missing X11 window stuff:

cmake ..
-- Using X11 for window creation
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)

Which might be to do with this repo specifically? As part of its cmake configuration? Presumably if WSL can now throw up a window then cmake shouldn't need to check that X11 is available. Maybe its too much of an edge case.

I'm a huge noob in this area, im essentially learning cmake, WSL, and OpenGL in parralel. But can this project be updated to support a Windows11/ WSL w/ graphics environment? Based on gui-apps article from microsoft I think X11 wouldn't be a dependency (in WSL?)? Glitter/ opengl apps would launch a window and the x11 distribution as part of WSL would pick that up and draw the windows on screen?

I'm not sure exactly how the driver is involved, but I think it's supposed to use the hosts CUDA driver from inside WSL -- still learning.

@chrisRidgers
Copy link
Author

chrisRidgers commented Aug 17, 2022

I prodded this some more, nigh a year later.

By sheer fumbling in the dark, i installed the following packages in WSL (Ubuntu Focal 20.04 LTS)

libgl1-mesa-dev
libxrandr-dev
libxinerama-dev
libxcurosr-dev
libxi-dev

Which got me a successful install via CMAKE followed by Make.

The resulting binary spat out an error regarding creating an opengl context, but some remnant of a ghost in my brain from last year told me to remove the window hints in main.cpp and after a recompile i had a window in WSL2!

image

I've no idea what version of OpenGL is being used at this point, what performance will look like etc.

But thats the native window server (wayland? x?) as supported by WSL2 - and im in a spot where i can write code and play about, which is good.

The only place in the codebase im seeing those dependencies referenced: or at least libxi-dev, is in a travis ci file inside the assimp vendor folder, and a CmakeLists file glfw.

Should glitters cmakes file have highlighted missing dependencies?

It was installing libg1-mesa-dev that got me past the initial X11_X11 errors.... which wasn't obvious. I thought an env var was missing not an entire library dependency.

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

No branches or pull requests

1 participant