Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
$
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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