PDA

View Full Version : starting OpenGL App on remote system



StephanP
09-03-2015, 06:08 AM
Hi there,

I have a problem with my OpenGL app. I use GLFW. I want to connect to another system via ssh and start the app, so that it is displayed on the screen of the remote system. (On the remote system I have OpenBox, and i don't want to have the console there). When I try to do that, I get the error message "GLFW failed to initialize". A lot issues in that direction are about remote rendering, but I don't want to do that. I guess I have to set the DISPLAY variable somehow, but don't know how to do this correctly.

Is GLFW even capable for this task?

Any ideas might be helpful.

GClements
09-03-2015, 02:00 PM
I guess I have to set the DISPLAY variable somehow, but don't know how to do this correctly.
You need to know the name of the display to which you wish to connect (it will probably be ":0", i.e. display 0 on the host running the program), the display has to exist (i.e. an X server has to be running for that display), and you need permission to connect to the X server.

If the X server is running because the system started it automatically on boot, the system probably started a display manager (e.g. xdm, gdm, kdm) which displays a login dialog. If that's the case, you'll need to actually complete the login process before the display manager will give you the credentials which programs will need in order to connect to the X server.

If the X server isn't running, you need to start it. That may need to be done from the root account.

If the system is meant to act as a "display server" (i.e. you're only going to use it remotely), your best bet is to modify the boot process to start the X server directly, without running a display manager, and to just store the authentication credentials in the .Xauthority file in the home directory of the intended user (or start the X server with authentication disabled; if you do that, ensure that it only accepts connections from the local system, not from the network, and don't do this on a multi-user system).

This is going to require reading some documentation. The boot sequence is different for each distribution, so I can't give details; you'll need to read the documentation for your particular distribution. The manual pages for X, Xserver and/or Xorg may help. As may the manual pages for xinit and/or startx and the startx script itself, if those are available for your distribution.

X authentication works via shared secrets. The X server is started with the -auth flag followed by the name of a file containing authentication tokens. A user is given access to an X server by storing the same tokens in the .Xauthority file in their home directory. When an X program connects to an X server that requires authentication, it obtains a token from that file (or the file specified by the XAUTHORITY environment variable, if set) and presents it to the X server. Thus, a client can only connect if it has read access to a file containing authentication tokens.

Normally this is handled by a display manager, which generates the tokens, starts the X server, and displays a login dialog. Upon successful login, it copies the tokens to the .Xauthority file for the logged-in user. If you aren't using a display manager, you need to do this yourself. The authentication files can be manipulated using the xauth utility.

Ultimately, this is an X11 question rather than an OpenGL question. If you can get any X program to show up on the display, you shouldn't have any particular problems with an OpenGL program (whether using GLFW, GLUT, GTK, Qt or whatever).

StephanP
09-04-2015, 12:12 AM
Thanks for the detailed description. Since GLFW was causing some problems, i guessed it was the source in this case.

I'll have a closer look into X11. The X server is started on boot and the remote system is embedded in our network, so I'll take care about that.

Dark Photon
09-04-2015, 06:46 AM
As a follow-on to what GClements said:

As a quick-and-dirty test, put your program aside and try one of:


xclock -display :0.0
xdpyinfo -display :0.0

(if remote system, use "-display <hostname>:0.0" or "-display <IP>:0.0"). If problems accessing the display, resolve then retry. Follow-up here with problems/questions. Once that works, then retry with your app.