OpenGL program not work with X forwarding

3

3

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()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3d(1, 0, 0);
    glBegin(GL_POLYGON);
        glVertex2i(10, 10);
        glVertex2i(WIDTH / 2, HEIGHT - 10);
        glVertex2i(WIDTH - 10, 10);
    glEnd();
    glFlush();
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
    glutCreateWindow("Test");
    glMatrixMode(GL_PROJECTION);
    gluOrtho2D(0, WIDTH, 0, HEIGHT);
    glutDisplayFunc(display);
    glutMainLoop();
}

Running:

$ 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
$

C. Lee

Posted 2010-10-07T05:55:18.503

Reputation: 197

Answers

3

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.

Steinbitglis

Posted 2010-10-07T05:55:18.503

Reputation: 165