Haskell OpenGL 无法在 Ubuntu 中打开

发布于 2024-12-07 18:15:54 字数 1278 浏览 1 评论 0原文

这个有点奇怪,但我将从头开始:

据我所知,在 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 IORefs 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 技术交流群。

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

发布评论

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

评论(1

把时间冻结 2024-12-14 18:15:54

此错误消息试图告诉您,不支持颜色、深度和 Alpha 缓冲区(“GLX 视觉效果”)的位深度组合。要查看您的系统上可以使用哪些,请尝试运行 glxinfo

$ glxinfo
...

65 GLX Visuals
    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x023 24 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8 16 16 16 16  0 0 None
0x024 24 tc  0  32  0 r  . .   8  8  8  8 .  .  0 24  8 16 16 16 16  0 0 None
0x025 24 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  0 16 16 16 16  0 0 None
0x026 24 tc  0  32  0 r  . .   8  8  8  8 .  .  0 24  0 16 16 16 16  0 0 None
0x027 24 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
...

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.

$ glxinfo
...

65 GLX Visuals
    visual  x   bf lv rg d st  colorbuffer  sr ax dp st accumbuffer  ms  cav
  id dep cl sp  sz l  ci b ro  r  g  b  a F gb bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------------
0x023 24 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8 16 16 16 16  0 0 None
0x024 24 tc  0  32  0 r  . .   8  8  8  8 .  .  0 24  8 16 16 16 16  0 0 None
0x025 24 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  0 16 16 16 16  0 0 None
0x026 24 tc  0  32  0 r  . .   8  8  8  8 .  .  0 24  0 16 16 16 16  0 0 None
0x027 24 tc  0  32  0 r  y .   8  8  8  8 .  .  0 24  8  0  0  0  0  0 0 None
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文