“openSuse 和 openGL”的示例程序环境
我在 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 中安装任何额外的库才能使其正常工作?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要设置
DISPLAY
环境变量以指向您的 X 服务器(显然,它必须启动)。如果运行该代码的主机是同一台主机,则
DISPLAY=:0
将适用于常规设置。如果您通过 SSH 远程运行该代码,请确保您的服务器和 ssh 客户端都设置为(并使用)X11 转发。 (此后它应该“正常工作”。)
如果您使用 SSH 以外的其他方式远程运行,请设置
DISPLAY=<显示器的主机名或 IP 地址>:<显示器编号>
,例如:[注意:为了使 OpenGL 能够在远程正常工作,您需要一台具有 GLX 扩展名的服务器。]
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:[Note: For OpenGL to work well remotely, you'll need a server that has the GLX extension.]