[Fieldtrip] Re: [HOpenGL] noticing freeglut vs not

1 view
Skip to first unread message

Conal Elliott

unread,
Nov 20, 2008, 6:10:10 PM11/20/08
to Sven Panne, Fiel...@haskell.org, hop...@haskell.org
Thanks for the pointers.

I'm looking for some way to program my library so that a graceful exit is made where possible and still runs, though exits less gracefully with non-free glut.  I'd be happy with either a new API entry for that case or a change to the meaning of MainLoopReturns.

  - Conal

On Thu, Nov 20, 2008 at 5:33 AM, Sven Panne <sven....@aedion.de> wrote:
On Thursday 13 November 2008 03:24:29 Conal Elliott wrote:
> I'm looking for a way to use MainLoopReturns when freeglut is present and
> not when it isn't.  I could use some help.  I figure that the
> implementation has some way to generate that error message, and maybe we
> could similarly just do a standard ungraceful exit if freeglut is missing.
>
> The great thing about MainLoopReturns is that it plays nicely with ghci.
> Closing a window returns to ghci for more fun.
>
> Some more info at http://trac.haskell.org/FieldTrip/ticket/8 .
>
> Any ideas?

Currently the GLUT binding uses dynamic lookup to get freeglut-only API
entries (see /GLUT/Graphics/UI/GLUT/Extensions.hs, cbits/HsGLUT.c,
include/HsGLUTExt.h) and uses throwIfNull to test for non-existent API
entries. Therefore, e.g. actionOnWindowClose should throw an exception when
"classic" GLUT is used. I am not sure if I understand your request: Do you
want a new API entry for the GLUT binding or a different behavior of the
current entries?

Cheers,
  S.


Claus Reinke

unread,
Dec 4, 2008, 12:52:22 PM12/4/08
to Conal Elliott, Sven Panne, Fiel...@haskell.org, hop...@haskell.org
Is this still an open issue in FieldTrip? If you look at the online versions
of the files Sven mentioned

http://darcs.haskell.org/packages/GLUT/include/HsGLUTExt.h
http://darcs.haskell.org/packages/GLUT/Graphics/UI/GLUT/Extensions.hs

you can see how the dynamic lookup of functions that are only
available in some extensions is handled. Looking at

http://darcs.haskell.org/packages/GLUT/Graphics/UI/GLUT/Begin.hs

it does seem as if constants and StateVars are not directly protected like
this, but 'actionOnWindowClose' calls 'glutSetOption', which you can see in

http://darcs.haskell.org/packages/GLUT/Graphics/UI/GLUT/QueryUtils.hs

as just such a dynamic lookup. In case this isn't clear: your code can
simply catch the exception thrown when that dynamic lookup fails,
letting the exception handler pursue an alternative path (since your ticket
recommends commenting out that line, the handler could perhaps just do
nothing in your case, or issue a warning about missing freeglut?).

No change to the GLUT package should be needed, I think.
Claus


--------------------------------------------------------------------------------


> _______________________________________________
> HOpenGL mailing list
> HOp...@haskell.org
> http://www.haskell.org/mailman/listinfo/hopengl
>
_______________________________________________
FieldTrip mailing list
Fiel...@haskell.org
http://www.haskell.org/mailman/listinfo/fieldtrip

Conal Elliott

unread,
Dec 4, 2008, 1:19:55 PM12/4/08
to Claus Reinke, Fiel...@haskell.org, Sven Panne
Thanks very much Claus.  Sound fixable indeed, with an exception handler.

Would someone with convenient access to a non-freeglut system be up for trying out Claus's suggestion???

   - Conal

Conal Elliott

unread,
Dec 4, 2008, 1:28:34 PM12/4/08
to Claus Reinke, Fiel...@haskell.org

Conal Elliott

unread,
Dec 7, 2008, 12:51:57 PM12/7/08
to Fiel...@haskell.org
Fixed now, thanks to community help.  Works on both free and non-free glut.  On freeglut, a window-close returns from the main loop, so if you're using ghci, you can play some more.  I've released reactive-glut 0.1.3 on http://hackage.haskell.org/cgi-bin/hackage-scripts/package/reactive-glut .

I think there's a problem with input-gathering threads not getting killed off.  Until it's fixed (and I think I know how), you'll want to kill & restart ghci when you notice things getting slow.

  - Conal
Reply all
Reply to author
Forward
0 new messages