My opengl program creates a glwindow, draw images, capture the pixels and save as image file. It works well with my laptop, but it occurs freeglut error (failed to open display.) when I run the program in non-display linux ssh server. I believe 'glCreateWindow' occurs that error, but I can't generate Renderbuffer or Framebuffer without creating window.
glutInit(&myargc, myargv);
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
glutInitWindowPosition( 50, 50 );
glutInitWindowSize( WIDTH, HEIGHT );
main_window = glutCreateWindow("__Window__"); // CreateWindow
glewInit();
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
LOG(INFO) << "0";
glGenRenderbuffers(1, &depth);
LOG(INFO) << "1";
glBindRenderbuffer(GL_RENDERBUFFER, depth);
If I run this code in non-display linux ssh server, the error message says "freeglut : failed to open display."
And If I skip creating window,
// main_window = glutCreateWindow("__Window__"); // skip this code
The LOG output is only 0 then segmentation fault occurs, which means It cannot generate render buffer without window.