WSL

WSL2 Visualization

Guidance about open visualization interface in WSL2

Posted by Huajian on August 21, 2022
Viewed times

Reference - Download VcXsrv

Reference - Setting VcXsrv

Reference - Activate Virtual IP

Reference - Glx Visual

WSL在图形化界面上的支持并不是很好。但很多时候即使我们不需要桌面,我们也需要打开一些图形窗口,如ROS的Rviz/Gazebo。 这篇文章将介绍如何开启这些界面。

Download VcXsrv & Setting

首先下载VcXsrv Reference - Download Vcxsrv

Configurate Windows Defender Firewall

  • 找到防火墙 800

  • 选择”允许应用或功能通过 Windows Defender 防火墙” 800

  • 允许VcXsrv 800

Start VcXsrv

  • Setting as follow:

WSL2 Setting

  • 确定虚拟IP地址

      echo "export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0;" >> ~/.bashrc
      source ~/.bashrc
    
  • 使用 glxinfo 找到空闲的 id

      sudo apt-get install mesa-utils
      glxinfo
    
      1 GLX Visuals
          visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
      id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
      ----------------------------------------------------------------------------
      0x022 24 tc  0  24  0 r  y .   8  8  8  0 .  .  0 16  0  0  0  0  0  0 0 None
    
  • 找到一个末尾是 None 的id,输入:

      export SDL_VIDEO_X11_VISUALID=<id>
      export SDL_VIDEO_X11_VISUALID=0x44 //example
    
  • 验证可用性

      sudo apt install x11-apps
      xclock
    

Top
Down