Re: [HOpenGL] Re: Exiting gracefully from (H)GLUT?

C. Reinke wrote:
[...] I found that I had to move the call to genLists after createWindow.
I'd expect that, because most (all?) versions of GLUT don't initialize the OpenGL context until the window has actually been created. [...]
Exactly, I just had a look in the GLUT sources. So the general rule of thumb is:
Issue OpenGL calls *after* the first createWindow, never before.
Isn't that an argument against the displayFunc parameter to HOpenGL's createWindow? One could still have a createSimpleWindow or something for simple applications, but why pass and install a null handler if one most certainly needs to replace it soon?
This makes sense perfectly: Remember that you could have multiple Windows, so the effect of e.g. setting the current to color depends on the current GLX/OpenGL context. The latter one is created with createWindow, changed with e.g. setWindow, overlay handling, etc. etc.
I was fooled by display lists - while their drawing commands aren't executed until they are called, the implicit state queries that determine how a vertex will appear when drawn are executed at construction time:-( Hence they also suffer from the dependency you describe. Btw, is this foreign import shutdownHaskellAndExit :: Int -> IO () going to be standard Haskell/FFI/xx ? The earlier discussion here mentioned some hs_exit instead, but it wasn't clear whether that would make it into the addendum, either. Ah, the FFI release candidate 3 mentions hs_exit in section "6.1 CForeign" - is that the way to go then? Claus

C. Reinke wrote:
Issue OpenGL calls *after* the first createWindow, never before.
Isn't that an argument against the displayFunc parameter to HOpenGL's createWindow? One could still have a createSimpleWindow or something for simple applications, but why pass and install a null handler if one most certainly needs to replace it soon?
This would break the current API, so I'd vote against such a change for HOpenGL 1.x, but I'm open for suggestions for an additional function (OK, this *could* break applications, too, but it's much less likely). I would propose to leave createWindow as it is and add: createWindow' :: String -> [DisplayMode] -> Maybe WindowPosition -> Maybe WindowSize -> IO Window Any comments?
I was fooled by display lists [...]
Who wasn't? :-} It has been a little bit unclear to me for a long time (and obviously other people, too) that creating a GLUT window or an overlay effectively creates a new OpenGL state machine and you start with none at all. A look in the GLX spec was helpful... [ exitWith vs. shutdownHaskellAndExit vs. hs_exit ] To keep easy backwards compatibility, the GLUT module will contain wrappers/re-implementations for GHC's currently faulty (IMHO) functions from System, so you can issue exitWith ExitSuccess without getting a cryptic RTS message. A new compatibility release of HOpenGL will be released very soon, I'm just in the middle of fighting a number of small issues regarding different compilers, OpenGL implementations, OS variations, etc. *sigh* Cheers, S.
participants (2)
-
C.Reinke
-
Sven Panne