Only canvas dc<%> and bitmap-dc% objects containing a bitmap from make-gl-bitmap support OpenGL (always on Windows and Mac OS X, sometimes on Unix). Normal dc<%> drawing and OpenGL drawing can be mixed in a bitmap-dc%, but a canvas that uses the 'gl style to support OpenGL does not reliably support normal dc<%> drawing; use a bitmap if you need to mix drawing modes, and use a canvas to maximize OpenGL performance.
The racket/gui/base library provides no OpenGL routines. Instead, they must be obtained from a separate library, such as sgl. The facilities in racket/gui/base merely manage the current OpenGL context, connecting it to windows and bitmaps.
Only one OpenGL context can be active at a time across all threads and eventspaces. OpenGL contexts are not protected against interference among threads; that is, if a thread selects one of its OpenGL contexts, then other threads can write into the context via OpenGL commands. However, if all threads issue OpenGL commands only within a thunk passed to call-as-current, then drawing from the separate threads will not interfere, because call-as-current uses a lock to serialize context selection across all threads in Racket.
The method blocks to obtain a lock that protects the global OpenGL context, and it releases the lock when the thunk returns or escapes. The lock is re-entrant, so a nested use of the method in the same thread with the same OpenGL context does not obtain or release the lock.
The lock prevents interference among OpenGL-using threads. If a thread is terminated while holding the context lock, the lock is released. Continuation jumps into the thunk do not grab the lock or set the OpenGL context. See gl-context<%> for more information on interference.
The result of the method call is the result of the thunk if it is called, or the result of the alternate event if it is chosen instead of the context lock.
Mac OS X: NSOpenGLContext
Note that these values are not necessary the most “low-level” context objects, but are instead the ones useful to Racket. For example, a NSOpenGLContext wraps a CGLContextObj.
A context is unavailable if OpenGL support is disabled at compile time or run time, if the context is associated with a bitmap-dc% with no selected bitmap or with a monochrome selected bitmap, if the context is for a canvas that no longer exists, or if there was a low-level error when preparing the context.
Added in version 1.3 of package draw-lib.