title: Hot to run OpenGL application on Windows Subsystem for Linux
body: <p>I have two video cards:</p>
  
  <blockquote>
    <p>Intel(R) HD Graphics 630,  Driver Version: 25.20.100.6472</p>
    
    <p>NVIDIA Quadro M1200, Driver Version: 26.21.14.3102</p>
  </blockquote>
  
  <p>On Windows 10, both cards work well with OpenGL/OpenGl ES applications.</p>
  
  <p>I try to run OpenGL ES application (based on Java/LibGDX/LWJGL3) on Windows Subsystem for Linux, using <code>Xming 6.9.0.31</code> X Server, and I get the following error:</p>
  
  <blockquote>
    <p>"GLX version 1.3 is required"</p>
  </blockquote>
  
  <p>I have already installed <code>mesa-utils</code> package.</p>
  
  <p>When I try run to <code>glmark2</code> benchmark, I get the following error:</p>
  
  <blockquote>
    <p>Error: GLX version >= 1.3 is required</p>
    
    <p>Error: Error: Couldn't get GL visual config!</p>
    
    <p>Error: main: Could not initialize canvas</p>
  </blockquote>
  
  <p>When I try to run <code>glxgears -info</code> benchmark, the application starts, gears are shown but are not rotating. It seems that application only renders the first frame. On terminal we have some interesting information:</p>
  
  <blockquote>
    <p>GL_RENDERER   = Quadro M1200/PCIe/SSE2</p>
    
    <p>GL_VERSION    = 1.2 (4.6.0 NVIDIA 431.02)</p>
    
    <p>GL_VENDOR     = NVIDIA Corporation</p>
    
    <p>GL_EXTENSIONS = GL_ARB_depth_texture GL_ARB_imaging
    GL_ARB_multitexture GL_ARB_point_parameters GL_ARB_point_sprite
    GL_ARB_shadow GL_ARB_texture_border_clamp GL_ARB_texture_cube_map
    GL_ARB_texture_env_add GL_ARB_texture_env_combine
    GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3
    GL_ARB_texture_mirrored_repeat GL_ARB_transpose_matrix
    GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color
    GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract
    GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_multi_draw_arrays
    GL_EXT_packed_pixels GL_EXT_rescale_normal GL_EXT_secondary_color
    GL_EXT_separate_specular_color GL_EXT_shadow_funcs
    GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D
    GL_EXT_texture_edge_clamp GL_EXT_texture_env_add
    GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_lod
    GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_vertex_array
    GL_ATI_texture_mirror_once GL_IBM_texture_mirrored_repeat
    GL_NV_blend_square GL_NV_point_sprite GL_NV_texgen_reflection
    GL_NV_texture_rectangle GL_SGIS_generate_mipmap GL_SGIS_texture_lod
    GL_SGIX_depth_texture GL_SGIX_shadow VisualID 54, 0x36</p>
    
    <p>5493 frames in 35.0 seconds = 156.996 FPS</p>
    
    <p>2085 frames in 34.7 seconds = 60.154 FPS</p>
    
    <p>2085 frames in 34.7 seconds = 60.146 FPS</p>
    
    <p>2085 frames in 35.0 seconds = 59.567 FPS</p>
    
    <p>2085 frames in 34.7 seconds = 60.089 FPS</p>
  </blockquote>
  
  <p>The log suggests that frames was rendered, but nothing happens in the application window.</p>
  
  <p>The result of <code>glxinfo | grep -i "version" -A 2 -B 2</code>:</p>
  
  <blockquote>
    <p>direct rendering: No (If you want to find out why, try setting
    LIBGL_DEBUG=verbose)</p>
    
    <p>server glx vendor string: SGI</p>
    
    <p>server glx version string: 1.2</p>
    
    <p>(...)</p>
    
    <p>client glx vendor string: NVIDIA Corporation</p>
    
    <p>client glx version string: 1.4</p>
    
    <p>(...)   </p>
    
    <p>GLX version: 1.2</p>
    
    <p>(...)</p>
    
    <p>OpenGL vendor string: NVIDIA Corporation</p>
    
    <p>OpenGL renderer string: Quadro M1200/PCIe/SSE2</p>
    
    <p>OpenGL version string: 1.2 (4.6.0 NVIDIA 431.02)</p>
    
    <p>(...)</p>
  </blockquote>
  
  <p>Looking at the listing above I don't understand why there is no direct rendering, why server GLX version is 1.2 (not 1.4), vendor is SGI, and why OpenGL version string is 1.2 (not higher)?</p>
  
  <p>What should I do to properly run OpenGL apps in WSL?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p><code>nvidia-setting</code> command shows the following output:</p>
  
  <pre><code>ERROR: NVIDIA driver is not loaded
  ERROR: Unable to load info from any available system
  </code></pre>
  
  <p>Why? The previous commands have shown that I have Nvidia driver installed for WSL.</p>
  
  <p><strong>EDIT 2</strong>:</p>
  
  <p>After installation of Nvidia driver from repository:</p>
  
  <p><code>sudo apt install nvidia-driver-390</code></p>
  
  <p>I have the following error of <code>nvidia-setting</code>:</p>
  
  <pre><code>libGL error: No matching fbConfigs or visuals found
  libGL error: failed to load driver: swrast
  
  ERROR: NVIDIA driver is not loaded
  
  
  ERROR: Error querying enabled displays on GPU 0 (Missing Extension).
  
  
  ERROR: Error querying connected displays on GPU 0 (Missing Extension).
  
  ** Message: 11:40:41.535: PRIME: No offloading required. Abort
  ** Message: 11:40:41.537: PRIME: is it supported? no
  
  ERROR: nvidia-settings could not find the registry key file. This file should have been installed along with this driver at /usr/share/nvidia/nvidia-application-profiles-key-documentation. The application profiles will continue to work,
         but values cannot be prepopulated or validated, and will not be listed in the help text. Please see the README for possible values and descriptions.
  </code></pre>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>It seems that Xming 6 supports very old OpenGL version, so I decided to use <code>Cygwin/X</code> as X Server.</p>
  
  <p>I start it using the following command:</p>
  
  <pre><code>startx -- -listen tcp
  </code></pre>
  
  <p>Based on output in terminals of Cygwin and WSL, <code>Mesa3D</code> driver is used. On WSL, <code>glxgears</code> and <code>glmark2</code> work correctly. They show that the following renderer is used (from <code>Mesa3d</code>):</p>
  
  <pre><code>OpenGL Information
  GL_VENDOR:     VMware, Inc.
  GL_RENDERER:   llvmpipe (LLVM 8.0, 256 bits)
  GL_VERSION:    3.1 Mesa 19.0.2
  </code></pre>
  
  <p>But my Java application crashes:</p>
  
  <pre><code>shared memfd open() failed: Function not implemented
  ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
  ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
  ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
  ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
  ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
  ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
  ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
  ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
  AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
  X Error of failed request:  BadMatch (invalid parameter attributes)
    Major opcode of failed request:  42 (X_SetInputFocus)
    Serial number of failed request:  159
    Current serial number in output stream:  176
  </code></pre>
  
  <p>On the other hand, when I start Cygwin/X using the following command:</p>
  
  <pre><code>startxwin -- -listen tcp
  </code></pre>
  
  <p>it seems it starts with accelerated renderer, because there is the following info on the screen:</p>
  
  <pre><code>GL_VERSION:     4.6.0 NVIDIA 431.70
  GL_VENDOR:      NVIDIA Corporation
  GL_RENDERER:    Quadro M1200/PCIe/SSE2
  (II) GLX: enabled GLX_SGI_make_current_read
  (II) GLX: enabled GLX_SGI_swap_control
  (II) GLX: enabled GLX_MESA_swap_control
  (II) GLX: enabled GLX_SGIX_pbuffer
  (II) GLX: enabled GLX_ARB_multisample
  (II) GLX: enabled GLX_SGIS_multisample
  (II) GLX: enabled GLX_ARB_fbconfig_float
  (II) GLX: enabled GLX_EXT_fbconfig_packed_float
  (II) GLX: enabled GLX_ARB_create_context
  (II) GLX: enabled GLX_ARB_create_context_profile
  (II) GLX: enabled GLX_ARB_create_context_robustness
  (II) GLX: enabled GLX_EXT_create_context_es2_profile
  (II) AIGLX: enabled GLX_MESA_copy_sub_buffer
  (II) 894 pixel formats reported by wglGetPixelFormatAttribivARB
  (II) 858 fbConfigs
  (II) ignored pixel formats: 0 not OpenGL, 0 unknown pixel type, 36 unaccelerated
  (II) GLX: Initialized Win32 native WGL GL provider for screen 0
  </code></pre>
  
  <p>But OpenGL apps (<code>glxgears</code>, <code>glmark2</code>, and my own) do not work on WSL, producing errors similar to this:</p>
  
  <pre><code>libGL error: No matching fbConfigs or visuals found
  libGL error: failed to load driver: swrast
  X Error of failed request:  GLXBadContext
    Major opcode of failed request:  148 (GLX)
    Minor opcode of failed request:  6 (X_GLXIsDirect)
    Serial number of failed request:  32
    Current serial number in output stream:  31
  </code></pre>
  
  <p>When I try to install the latest Nvidia driver for my card: <code>NVIDIA-Linux-x86_64-430.40.run</code>, I have the following error:</p>
  
  <blockquote>
    <p>WARNING: The file '/proc/sys/kernel/modprobe' is unavailable; the X
    server will use <code>/sbin/modprobe</code> as the path to the <code>modprobe</code>
    utility.  This path differs from the one determined by
    <code>nvidia-installer</code>, /bin/kmod.  Please verify that <code>/sbin/modprobe</code>
    works correctly or mount the /proc file system and verify that
    '/proc/sys/kernel/modprobe' reports the correct path.
    -> Performing CC sanity check with CC="/usr/bin/cc".</p>
    
    <p>ERROR: Unable to find the kernel source tree for the currently running
    kernel.  Please make sure you have installed the kernel source files
    for your kernel and that they are properly configured; on Red Hat
    Linux systems, for example, be sure you have the 'kernel-source' or
    'kernel-devel' RPM installed.  If you know the correct kernel source
    files are installed, you may specify the kernel source path with the
    '--kernel-source-path' command line option.</p>
  </blockquote>
  
  <p>Summarizing:</p>
  
  <p>How can I succesfully run OpenGL-hardware-accelerated applications on WSL? How to install latest/working NVidia drivers on WSL?</p>