2

私はこのようなサンプル コードを OpenSuse 11.3 (非常に新しいインストール) で openGL 用に作成しました (Yast2 のソフトウェア マネージャーから openGL を検索して出てきたすべてのライブラリをインストールしました)。

**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 ''

これを機能させるには、Suse に追加のライブラリをインストールする必要がありますか?

4

1 に答える 1

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.]

于 2011-09-06T20:36:42.157 に答える