RenderingPipeline

from geometry to pixels

Remote OpenGL

Sometimes you want to connect to a remote linux machine via ssh and use the remote GPU for OpenGL (rendering). Maybe because of automated testing of rendering in a windowless OpenGL application, maybe because you just want to query the OpenGL capabilities with glewinfo. This might not work as intended: It might not work at all or you are stuck with OpenGL 2.1. Here’s why:

Internally to request an OpenGL context, XOpenDisplay will get called to connect to a display with a running XSession of the user. The display to connect to is normally pulled from the $DISPLAY environment variable, three things can happen here:

  • The display to connect does not exist, then there is no way to get a context (likely if you connect from a non-unix machine).
  • The display is a remote display, this means the render calls will be send over the network back to your machine, that protocol is limited to OpenGL 2.1.
  • The display is a local (local on the remote machine) display where the ssh user has a XSession running (== you are also logged in on that machine!) -> OpenGL will render on the distant machine with full OpenGL capabilities.

The last scenario is what you want (but it will never happen automatically). Log in to the testing machine locally, write down the value of the $DISPLAY variable (most likely “:0”) and log in via ssh, set $DISPLAY to that value and have fun!

Setting the $DISPLAY variable on a remote machine could look like this:

#> echo $DISPLAY
 
#> glewinfo
Error: glewCreateContext failed
#> export DISPLAY=":0"
#> glewinfo | head
---------------------------
GLEW Extension Info
---------------------------
 
GLEW version 1.7.0
Reporting capabilities of display :0, visual 0x2b
Running on a GeForce GTX 580/PCIe/SSE2 from NVIDIA Corporation
OpenGL version 4.2.0 NVIDIA 295.33 is supported
#>

If you log in from one linux machine to another, you might get OpenGL 2.1 if you forget to set the $DISPLAY variable:

#> echo $DISPLAY
localhost:10.0
#> glewinfo | head
---------------------------
GLEW Extension Info
---------------------------
 
GLEW version 1.7.0
Reporting capabilities of display localhost:10.0, visual 0x2b
Running on a GeForce GTX 580/PCIe/SSE2 from NVIDIA Corporation
OpenGL version 2.1.2 NVIDIA 295.33 is supported

, , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*