Reputation: 15682
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
Upvotes: 1
Views: 474
Reputation: 139840
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
...
Upvotes: 3