简体   繁体   English

编译Linux发行版时的OpenGL问题

[英]OpenGL Problems When Compiling Across Linux Distributions

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). 我最近在opengl中编写了一个迷宫游戏(使用freeglut),当它在Ubuntu或Cygwin中构建时效果很好,但是当使用freeglut构建在Fedora Core 12上时,游戏就崩溃了,我的教授在构建它时看不到任何东西在他的机器上(他没有透露的操作系统)。

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. 闪烁发生在我的Fedora机器上,很少发生在我的Ubunutu机器上,而在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)'. 最后,在Fedora机器上,雾非常密集,似乎忽略了对'glFogf(GL_FOG_DENSITY,0.1)'的调用。 However, on Cygwin and Ubuntu the fog performs flawlessly. 然而,在Cygwin和Ubuntu上,雾的表现完美无瑕。

Are there that many differences between implementations of freeglut between OS's that this would be an issue? 操作系统之间的freeglut实现之间存在很多差异吗?这会是一个问题吗? 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. 我的教授似乎准备让我在这些项目上失败,但我不知道为什么opengl在操作系统之间表现得如此不稳定。

Please let me know if you have any insight and thanks for your time. 如果您有任何见解并感谢您的时间,请告诉我。

I got the following two calls mixed up in order. 我按顺序将以下两个调用混合起来。 Should be this way. 应该是这样的。

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutCreateWindow("My Window"); glutCreateWindow(“我的窗口”);

I had it this way: 我这样做了:

glutCreateWindow("My Window"); glutCreateWindow(“我的窗口”); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); 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. 同样在Red-Hat发行版中,size_t被定义为signed int,而Ubuntu使用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 :/. 这导致我的教授机器在尝试使用函数fread()时出现循环问题,函数fread(),其返回类型在Fedora中为-1,在Ubuntu中为static_cast(-1),我认为这不好:/。 Took me a couple days to track down the issue in the Ubuntu kernel source. 花了几天时间来跟踪Ubuntu内核源代码中的问题。

I my experience teaching OpenGL, this kind of thing happens when glut is used in a way differently from what is intended. 我在教授OpenGL方面的经验,当使用过剩的方式与预期不同时,会出现这种情况。 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. 我见过的最常见的原因是每次更改屏幕后都没有调用glutPostRedisplay。

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. 除此之外,我只能猜测发生了什么,但如果一个实现什么都没有显示,那么我很确定你有一些基本的错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM