Sample program for "openSuse and openGL" environment
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?
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.]
精彩评论