1

这个有点奇怪,但我还是从头说起:

据我所知,有 3 种方法可以在 Haskell 中打开 OpenGL 窗口:GLUT、GLFW 和 SDL。我根本不想使用 GLUT,因为它迫使你使用IORefs 并且基本上只在IOmonad 中工作。所以我尝试了 GLFW 并在我的笔记本电脑上做了一个小东西,它使用 Xubuntu 和 XFCE 桌面系统。

现在我很高兴并将它复制到我的桌面,一个相当新安装的标准 Ubuntu 和 Unity,并且惊讶地什么也没看到。在笔记本电脑上运行良好的 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
4

1 回答 1

3

此错误消息试图告诉您颜色、深度和 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
...
于 2011-09-30T20:12:49.453 回答