I have an OpenGL program in a Linux server. I want to run the program remotely with X forwarding, but it fails, whereas programs such as xclock and xeyes work fine. (I confirmed that the program works in the local desktop environment.) Below is additional information.

Test Code:

#include <GL/glut.h>

#define WIDTH 300
#define HEIGHT 300

void display()
    glColor3d(1, 0, 0);
        glVertex2i(10, 10);
        glVertex2i(WIDTH / 2, HEIGHT - 10);
        glVertex2i(WIDTH - 10, 10);

int main(int argc, char **argv)
    glutInit(&argc, argv);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
    gluOrtho2D(0, WIDTH, 0, HEIGHT);


$ gcc test.c -lGLU -lglut
$ ./a.out
Xlib:  extension "Generic Event Extension" missing on display "localhost:10.0".
freeglut (./a.out):  ERROR:  Internal error <Visual with necessary capabilities not found> in function fgOpenWindow
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  4 (X_DestroyWindow)
  Resource id in failed request:  0x0
  Serial number of failed request:  17
  Current serial number in output stream:  20
$ glxgears
Xlib:  extension "Generic Event Extension" missing on display "localhost:10.0".
Error: couldn't get an RGB, Double-buffered visual

You need to set up remote rendering, or use a ssh client that supports to get pre-rendered windows.

$ export LIBGL_ALWAYS_INDIRECT=1   or use any nonzero value

On my machine Cygwin/X allows me to run both modes, while Xming only allows the remote rendering (on client). The application I developed also had trouble with not being allowed to use 24-bit mode, but it worked when color-depth was unspecified.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.