跨 Linux 发行版编译时的 OpenGL 问题

发布于 2024-09-11 15:13:46 字数 487 浏览 3 评论 0原文

我最近用 opengl(使用 freeglut)编写了一个迷宫游戏,在 Ubuntu 或 Cygwin 中构建时运行良好,但是当使用 freeglut 在 Fedora Core 12 上构建时,游戏崩溃了,我的教授在构建它时看不到任何东西在他的机器上(他没有透露其操作系统)。

另外,在之前的作业中,即使我已经实现了双缓冲并且在每次显示后刷新缓冲区,我还是会出现闪烁。闪烁发生在我的 Fedora 机器上,在我的 Ubunutu 机器上很少发生,而在 cygwin 中根本不会发生。

最后,在 Fedora 机器上,雾非常浓,似乎忽略了对“glFogf(GL_FOG_DENSITY, 0.1)”的调用。然而,在 Cygwin 和 Ubuntu 上,雾的表现完美。

操作系统之间的 freeglut 实现之间是否存在很多差异,这会成为一个问题?我的教授似乎准备在这些项目上让我失败,但我不知道为什么 opengl 在操作系统之间表现得如此不稳定。

如果您有任何见解,请告诉我,感谢您的宝贵时间。

I recently wrote a maze game in opengl (using freeglut) that works fine when built in Ubuntu or Cygwin, but when built on Fedora Core 12 with freeglut, the game falls apart, and my professor can't see a thing when he builds it on his machine (the OS of which he has failed to disclose).

Also, on previous assignments, I got flickering even though I've implemented double buffering and and am flushing the buffer after each display. The flickering occurs on my Fedora machine, infrequently on my Ubunutu machine, and not at all in cygwin.

Finally, on the Fedora machine, the fog is extremely dense and seems to be ignoring the call to 'glFogf(GL_FOG_DENSITY, 0.1)'. However, on Cygwin and Ubuntu the fog performs flawlessly.

Are there that many differences between implementations of freeglut between OS's that this would be an issue? My professor seems like he's about ready to fail me on these projects, but I have no clue why opengl is acting this erratic between operating systems.

Please let me know if you have any insight and thanks for your time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

剩一世无双 2024-09-18 15:13:46

我将以下两个电话按顺序混淆了。应该是这样的。

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutCreateWindow("我的窗口");

我是这样的:

glutCreateWindow("My Window");
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

因此,我不能保证双缓冲窗口,因此有时它会闪烁,有时不会。

同样在 Red-Hat 发行版中,size_t 被定义为有符号整型,而 Ubuntu 使用无符号整型。当尝试使用函数 fread() 时,这导致了我的教授机器上出现循环问题,该函数的返回类型在 Fedora 中为 -1,在 Ubuntu 中为 static_cast(-1),我认为这不太好:/。我花了几天时间才找到 Ubuntu 内核源代码中的问题。

I got the following two calls mixed up in order. Should be this way.

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutCreateWindow("My Window");

I had it this way:

glutCreateWindow("My Window");
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

As such I wasn't guaranteed a double-buffered window and thus sometimes it would flicker and sometimes it wouldn't.

Also in Red-Hat distributions, size_t is defined as a signed int while Ubuntu uses an unsigned int. This led to a loop issue on my professors machine when trying to use the function fread(), whose return type is -1 in Fedora and static_cast(-1) in Ubuntu, which I imagine is not good :/. Took me a couple days to track down the issue in the Ubuntu kernel source.

葬﹪忆之殇 2024-09-18 15:13:46

根据我教授 OpenGL 的经验,当 glut 的使用方式与预期不同时,就会发生这种情况。一些实现/驱动程序可以处理它,而另一些则不能 - 当以非标准方式使用它们时,实现之间存在很大的差异。当以标准方式使用时,差异非常小。

我见过的最常见的原因是每次屏幕更改后没有调用 glutPostRedisplay 。

其他可能的原因是在显示函数以外的地方进行绘制,或者没有正确设置回调。

除此之外,我只能猜测发生了什么,但如果一个实现什么也没显示,那么我很确定你遇到了一些基本错误。

I my experience teaching OpenGL, this kind of thing happens when glut is used in a way differently from what is intended. Some implementations/drivers handle it, and others don't - there are quite large differences between implementations when they are used in non-standard ways. When used in standard ways the differences are pretty small.

The most common reason I've seen for this is when glutPostRedisplay isn't being called after each change to the screen.

Other possible reasons are drawing in places other than the display function, or not having the callbacks set up correctly.

Beyond this, I can only guess what's going on, but if one implementation is showing nothing at all then I'd be pretty sure you've got something basic wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文