schell / odin

High level 2d game engine written in Haskell.
http://zyghost.com/series/odin
MIT License
31 stars 4 forks source link

could not create window #1

Closed BartMassey closed 8 years ago

BartMassey commented 8 years ago

Got odin to build, but all I get when I run it is "could not create window". GHC 7.10.3 on Debian amd64. Suggestions welcome.

schell commented 8 years ago

That means glfw-b failed to create a window/opengl context. I'd try to build and run the GLFW-b demo or start a new project with GLFW-b and try opening a new window.

The code that is err'ing in your situation is (from https://github.com/schell/gelatin/blob/master/gelatin-glfw/src/Gelatin/GLFW.hs#L25)

newWindow :: Int -- ^ Width
          -> Int -- ^ Height
          -> String -- ^ Title
          -> Maybe Monitor -- ^ The monitor to fullscreen into.
          -> Maybe Window -- ^ A window to share OpenGL contexts with.
          -> IO Window
newWindow ww wh ws mmon mwin = do
    defaultWindowHints
    windowHint $ WindowHint'OpenGLDebugContext True
    windowHint $ WindowHint'OpenGLProfile OpenGLProfile'Core
    windowHint $ WindowHint'OpenGLForwardCompat True
    windowHint $ WindowHint'ContextVersionMajor 3
    windowHint $ WindowHint'ContextVersionMinor 3
    windowHint $ WindowHint'DepthBits 16
    mwin' <- createWindow ww wh ws mmon mwin
    makeContextCurrent mwin'
    case mwin' of
        Nothing  -> do putStrLn "could not create window"
                       exitFailure
        Just win -> return win

Here we're setting some window hints that may not be compatible with your system. My guess is the OpenGL 3.3 hints are causing a problem - I'm not sure though. Please let me know if that helps.

BartMassey commented 8 years ago

Huh. I got GLFW-b demo running by relaxing the constraints in its cabal file (which are very tight and won't allow it to install on my box AFAICT). After that I went back and rebuilt odin part-one, and it seems to work OK. it creates a very tall window, but that may have to do with my L-shaped dual monitor setup. So I guess I'm good. Sorry to bother you.

schell commented 8 years ago

You're not a bother at all, on the contrary - I enjoy talking about my projects and helping others get up and running!

This bug does seem peculiar though. About the long window, could it be that glfw doesn't know that one of your monitors is rotated 90 degrees?

BartMassey commented 8 years ago

Yes, I believe that is what is happening. I'm going to guess that the failure to create the window earlier was somehow related to this also.

Now if I can just get my head around FRP we're all good. :-)

schell commented 8 years ago

@BartMassey totally - keep in mind there are lots of different types of FRP now. varying is arrowized, pull-based FRP and looks very different from libraries like reflex and reactive-banana. What helped me the most was reading the source of other libs and then writing my own ;) Start here and let me know if I can help. Also check out the #haskell and #haskell-game channels on IRC (irc.freenode.net).