[racket] openGL on Mac OS

From: Petr Samarin (petrsamarin at gmail.com)
Date: Thu Jun 28 13:22:59 EDT 2012

> On Jun 27, 2012, at 11:54 PM, Matthew Flatt wrote:
> Any other ideas?

How about creating a dummy frame with an opengl canvas specifically if the system is a mac os?
This can be done before providing the sgl library:

(when (symbol=? (system-type) 'macosx)
 (new canvas%
      [parent (new frame% [label ""])]
      [style '(gl)]))

Running openGL afterwards does not result in segmentation fault any more, and the dummy canvas will be garbage collected.
But it's a quick hack, and far from being an ideal solution!

On Jun 27, 2012, at 11:54 PM, Matthew Flatt wrote:
> At Wed, 27 Jun 2012 23:14:21 +0200, Petr Samarin wrote:
>> I was trying out some examples from the documentation and used openGL code 
>> outside of openGL context!
> That makes sense. I vaguely recall that Apple's GL is likely to crash
> without a context, while other GL implementations tend not to crash in
> that case.
> I'm not sure of the right way to add a check for a context. The context
> is determined outside of the GL API, and the `sgl' library inherits the
> assumption that a context will be set somehow --- possibly via
> `racket/gui', but possibly through some other library.
> One possibility is to introduce a third library that GL libraries like
> `sgl' and context-supplying libraries like `racket/gui' could use to
> communicate o the availability of a context. If `sgl' insists that a
> context is available according to the next library, then there's an
> issue of backward compatibility (in case someone uses `sgl' with
> contexts other than from `racket/gui'). Also, I think a check
> implemented that way might significantly affect performance.
> Any other ideas?

Posted on the users mailing list.