2

I have written a sample code like this in OpenSuse 11.3 (a very new installation) for openGL (installed all the libs that came up in search for openGL from the Software Manager of Yast2).

**File: SimpleOpenGL.c**

#include <GL/glut.h>

int main(int argc,char **argv)
{
    glutInit(&argc,argv);

    glutInitWindowPosition(100,100);
    glutInitWindowSize(800,600);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
    glutCreateWindow("Window");
}

Compiling with : $ gcc -o foo -lGL -lglut SimpleOpenGL.c
Running with   : $ ./foo
freeglut (./foo): failed to open display ''

Do I have to install any additional libs in Suse to get this working?

Mat
  • 202,337
  • 40
  • 393
  • 406
Aditya369
  • 545
  • 1
  • 7
  • 27
  • 1
    By any chance, are you not sitting at the OpenSuse workstation? Failed to open display usually means there's no active X Host. – IslandCow Sep 06 '11 at 20:26
  • I am on a HP Laptop with OpenSuse 11.3 installed. So, Is there any workaround to bypass the issue? :( – Aditya369 Sep 06 '11 at 20:34

1 Answers1

3

You need to set the DISPLAY environment variable to point to your X server (which must, obviously, be started).

If that's the same host that's running that code, DISPLAY=:0 will work for usual setups.

If you're running that code remotely via SSH, make sure both your server and your ssh client are set up for (and using) X11 forwarding. (It should "just work" after that.)

If you're running remotely with something else than SSH, set DISPLAY=<hostname or IP address of your display>:<display number>, so something like:

DISPLAY=192.168.0.1:0.0

[Note: For OpenGL to work well remotely, you'll need a server that has the GLX extension.]

Mat
  • 202,337
  • 40
  • 393
  • 406
  • I am afraid I am new to these terminology like X-Server, DISPLAY environment var, x11 etc. Can you guide me through a few steps for Suse? – Aditya369 Sep 06 '11 at 20:50
  • For information about the X11 display system, see [X Window System](http://en.wikipedia.org/wiki/X_Window_System). The DISPLAY environment variable is what is used by X11 clients (applications) to know where the server (the thing that actually displays stuff on a screen) is located. With X11, the client and server don't have to be on the same machine. – Mat Sep 06 '11 at 20:55
  • I think X supports 3d acceleration on the client? According to wikipedia: "... network transparency: the machine where an application program (the client application) runs can differ from the user's local machine (the display server). X's network protocol is based on X command primitives and, with GLX, OpenGL 3D primitives rather than on a more basic framebuffer copying paradigm. This approach allows both 2D and 3D operations to be fully accelerated on the remote X server." – IslandCow Sep 06 '11 at 22:07
  • Thanks, I couldn't remember that part. – Mat Sep 06 '11 at 22:12
  • Procedure that I used to make it work are (1) run 'xterm' with normal permissions (did not work when run with sudo permissions) (2) An X Window pops up (3) run the make command (if the makefile is ready with all the linking and other misc things). However, I get a "freeglut (./abc): Unknown X event type: 105" error. Any idea? – Aditya369 Sep 10 '11 at 17:21