Haskell OpenGL 无法在 Ubuntu 中打开
这个有点奇怪,但我将从头开始:
据我所知,在 Haskell 中有 3 种打开 OpenGL 窗口的方法:GLUT、GLFW 和 SDL。我根本不想使用 GLUT,因为它迫使您使用 IORef 并且基本上仅在 IO monad 中工作。所以我尝试了 GLFW 并在我的笔记本电脑上做了一个小东西,它使用 Xubuntu 和 XFCE 桌面系统。
现在我很高兴并将其复制到我的桌面上,这是一个相当新安装的带有 Unity 的标准 Ubuntu,但很惊讶什么也没看到。在笔记本电脑上运行良好的 GLFW 代码在打开窗口之前陷入了无限循环。
然后我将其全部移植到 SDL。相同的代码、相同的窗口和 SDL 崩溃,
Main.hs: user error (SDL_SetVideoMode
SDL message: Couldn't find matching GLX visual)
我已使用 SDLgears 进行检查,使用同样的方法打开一个窗口,效果很好。与其他一些 3D 应用程序相同,并且 OpenGL 可以正常启用。
让我困惑的是它在 XUbuntu 下工作,但在 Ubuntu 上不行。我在这里错过了什么吗?哦,如果有帮助的话,窗口打开功能:
runGame w h (Game g) = withInit [InitVideo] $ do
glSetAttribute glRedSize 8
glSetAttribute glGreenSize 8
glSetAttribute glBlueSize 8
glSetAttribute glAlphaSize 8
glSetAttribute glDepthSize 16
glSetAttribute glDoubleBuffer 1
_ <- setVideoMode w h 32 [OpenGL, Resizable]
matrixMode $= Projection
loadIdentity
perspective 45 (fromIntegral w / fromIntegral h) 0.1 10500.0
matrixMode $= Modelview 0
loadIdentity
shadeModel $= Smooth
hint PerspectiveCorrection $= Nicest
depthFunc $= Just Lequal
clearDepth $= 1.0
g
This one is a bit weird, but I will start at the beginning:
As far as I gathered, there are 3 ways to open up an OpenGL window in Haskell: GLUT, GLFW and SDL. I don't want to use GLUT at all, because it forces you to use IORef
s and basically work in the IO
monad only. So I tried GLFW and made a little thingie on my laptop, which uses Xubuntu with the XFCE desktop system.
Now I was happy and copied it to my desktop, a fairly fresh installed standard Ubuntu with Unity, and was amazed to see nothing. The very same GLFW code that worked fine on the laptop was caught in an endless loop before it opened the window.
Right then I ported it all to SDL. Same code, same window, and SDL crashes with
Main.hs: user error (SDL_SetVideoMode
SDL message: Couldn't find matching GLX visual)
I have checked back with SDLgears, using the same method to open a window, and it works fine. Same with some other 3D application, and OpenGL is enabled fine.
What baffles me is that it works under a XUbuntu but not on an Ubuntu. Am I missing something here? Oh, and if it helps, the window opening function:
runGame w h (Game g) = withInit [InitVideo] $ do
glSetAttribute glRedSize 8
glSetAttribute glGreenSize 8
glSetAttribute glBlueSize 8
glSetAttribute glAlphaSize 8
glSetAttribute glDepthSize 16
glSetAttribute glDoubleBuffer 1
_ <- setVideoMode w h 32 [OpenGL, Resizable]
matrixMode $= Projection
loadIdentity
perspective 45 (fromIntegral w / fromIntegral h) 0.1 10500.0
matrixMode $= Modelview 0
loadIdentity
shadeModel $= Smooth
hint PerspectiveCorrection $= Nicest
depthFunc $= Just Lequal
clearDepth $= 1.0
g
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误消息试图告诉您,不支持颜色、深度和 Alpha 缓冲区(“GLX 视觉效果”)的位深度组合。要查看您的系统上可以使用哪些,请尝试运行
glxinfo
。This error message is trying to tell you that your combination of bit depths for the color, depth and alpha buffers (a "GLX visual") is not supported. To see which ones you can use on your system, try running
glxinfo
.