GLFW 窗口无法打开 (Ubuntu)
在 Ubuntu (9.04) 下编译和运行我的基于 GLFW 的 C 程序时,尝试打开窗口时失败(它编译正常,安装了最新的 GLFW)。我尝试过不同的分辨率,低至 300x300,并将位深度保留为零,希望默认值能够流行。
相关代码片段如下(直接从我的主文件顶部截取,基于示例文件 gears.c
):
// File: main.c
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <GL/glfw.h>
#ifndef PI
#define PI 3.141592654
#endif
int main(int argc, char* argv[])
{
// Initialize GLFW:
glfwInit();
if (!glfwOpenWindow(300, 300, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) // Yo failure!
{
printf("Window open failed.\n");
glfwTerminate();
return 0;
}
glfwSetWindowTitle("...");
...
// Clean up:
glfwTerminate();
return 0;
}
其他值得注意的事实是:
- 在 VirtualBox 3.0.2 中运行 Ubuntu,配置带 512 MB RAM、启用 3D 加速、64 MB VRAM、成功安装的 Guest Additions
glxgears
工作正常,甚至 > 构建300 FPS- 使用
make-x11
makefile 命令行 的 GLFW:
gcc `pkg-config --cflags libglfw` main.c -o 程序 `pkg-config --libs libglfw` -lglfw -lGLU -lGL -lm
Mark 关于 C - GLFW 窗口在 Debian 上无法打开 似乎并没有缓解这种情况
编辑:
有什么方法可以提取更奇特的错误消息吗?是否有 getLastErrorDesc() 或调试日志文件?
When compiling and running my GLFW-based C program under Ubuntu (9.04), it fails when trying to open the window (it compiles fine, having installed the latest GLFW). I've tried varying resolutions, going as low as 300x300, and left the bit depths to zeros, hoping a default will catch on.
The relevant piece of code reads (directly snipped from the top of my main file, based on the example file gears.c
):
// File: main.c
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <GL/glfw.h>
#ifndef PI
#define PI 3.141592654
#endif
int main(int argc, char* argv[])
{
// Initialize GLFW:
glfwInit();
if (!glfwOpenWindow(300, 300, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) // Yo failure!
{
printf("Window open failed.\n");
glfwTerminate();
return 0;
}
glfwSetWindowTitle("...");
...
// Clean up:
glfwTerminate();
return 0;
}
Other noteworthy facts are:
- Running Ubuntu inside VirtualBox 3.0.2, config'd w/ 512 MB RAM, 3D acceleration enabled, 64 MB VRAM, Guest Additions successfully installed
glxgears
works fine, even > 300 FPS- built GLFW using
make-x11
makefile command line:
gcc `pkg-config --cflags libglfw` main.c -o program `pkg-config --libs libglfw` -lglfw -lGLU -lGL -lm
Mark's tip on C - GLFW window doesn't open on Debian does not seem to alleviate the situation
Edit:
Are there any way to extract a more fancy error message? Any getLastErrorDesc()
or debug log files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您使用的是 Ubuntu 中打包的版本还是 GLFW Subversion 存储库中的某个版本?由于删除了自定义 Visual 选择,Subversion 存储库中的 GLXFBConfig 选择已损坏相当长一段时间,因此您可能收到了错误的代码。
如果是这种情况,您应该恢复到与 Ubuntu 捆绑的版本,或者从 Subversion 中提取新的树。
Are you using the version packaged in Ubuntu or some version from the GLFW Subversion repository? The GLXFBConfig selection in the Subversion repo was broken for quite a while, due to the removal of the custom Visual selection, so you may have received bad code.
If that's the case, you should either revert to the version bundled with Ubuntu or pull a fresh tree from Subversion.
嘿,我也遇到了同样的问题。
最后我想出了如何解决这个问题。
我使用“make x11-install”来安装该库。
过程如下:
运行“make x11-clean”(不必要)
使用vim或任何编辑器编辑Makefile.x11。在 glfw/lib/x11 文件夹中(如果不运行进程 1,则为 Makefile.x11),将前缀从“/usr/local”更改为“/user”
run “make x11-dist -install”进行安装
我还没有尝试过“dist-install”是否重要或位置,但它对我来说非常适合。
Hey I've been suffering from the same problem.
At last I figured out how to solve this one.
I was using "make x11-install" to install the library.
The procedure would be as following:
run "make x11-clean" (not necessary)
use vim or whatever editor to edit Makefile.x11.in in glfw/lib/x11 folder (and Makefile.x11 if you don't run process 1), change the PREFIX from "/usr/local" to "/user"
run "make x11-dist-install" for installation
I haven't tried if its "dist-install" that matters or the location, but it works for me perfectly.
你试图用 0bpp 打开一个窗口,当然它会失败:)
试试这个:
另外,在最新的 Ubuntu 上,实际上有一个名为 libglfw-dev 的包你可以安装,以防万一你忘记链接任何额外的库(像利布兰德)。
You are trying to open a window with 0bpp, of course it's going to fail :)
Try this:
Also, on latest Ubuntu, there's actually a package called libglfw-dev you can install, just in case you forgot to link any extra libraries (like librandr).
我对 GLFW 2.7.7 也有同样的问题,直接从 GLFW 网站提取 .tar.bz2 。
glfwOpenWindow
始终返回 false,即使没有提示且未指定位深度。我自己构建 libglfw,并使用 rpath 链接标志从工作目录加载它。我没有安装 Ubuntu libglfw。
使用 Ubuntu 存储库版本 (
sudo apt-get install libglfw-dev
),窗口将按预期打开。两个库版本之间的显着差异之一是调用 glfwGetVideoModes 的结果。在损坏的 GLFW 2.7.7 上,这仅返回桌面分辨率和深度。在工作版本 Ubuntu 软件包 2.7.2-1 上,这返回了预期的各种模式。
I had this same problem with GLFW 2.7.7, pulled as a .tar.bz2 directly from the GLFW website.
glfwOpenWindow
always returned false, even with no hints and no bit depths specified.I was building libglfw myself, and loading it from the working directory using the rpath link flag. I did not have the Ubuntu libglfw installed.
Using the Ubuntu repository version (
sudo apt-get install libglfw-dev
), the window opens as expected.One of the significant differences between the two library versions is the result of calling glfwGetVideoModes. On the broken GLFW 2.7.7, this returned only the desktop resolution and depth. On the working version, Ubuntu package 2.7.2-1, this returned the expected variety of modes.