<div>
        <div>
                Dear Matthew,</div>
        <div>
                 </div>
        <div>
                I have done a little digging. The problem is not in the gl-context.rkt in itself.</div>
        <div>
                The problem appears when you use the make-gl-bitmap and canvas% together.</div>
        <div>
                I have attached a very simple OpenGL program to this e-mail. Save it as gl-base.scm.</div>
        <div>
                If you execute it,then first it prints appropriately the context, but once the canvas% has been</div>
        <div>
                displayed the context cannot be created any more. For example in the resizing or painting function</div>
        <div>
                it cannot be created any more.</div>
        <div>
                So I suppose the GL context switching is wrong somewhere.</div>
        <div>
                (This is under Windows XP.)</div>
        <div>
                Is this any help to solve the problem?</div>
        <div>
                 </div>
        <div>
                Best regards,</div>
        <div>
                 </div>
        <div>
                Peter Ivanyi</div>
        <div>
                 </div>
        <div>
                -----------------------------------------------------------------------------------------------------------------</div>
        <div>
                 </div>
        <div>
                (module gl-base mzscheme<br />
                <br />
                (require (lib "gl.ss" "sgl")<br />
                 (lib "gl-vectors.ss" "sgl")<br />
                 (lib "class.ss")<br />
                 (lib "mred.ss" "mred")<br />
                )<br />
                <br />
                <br />
                (define (sx-bitmap-new width height)<br />
                 ;(make-object bitmap% width height #f)<br />
                 (let ((config (new gl-config%)))<br />
                 (let* ((b (make-gl-bitmap width height config))<br />
                 (dc (new bitmap-dc% (bitmap b)))<br />
                 (gl (send dc get-gl-context))<br />
                 )<br />
                 (display "gl: ")(display gl)(newline)<br />
                 b<br />
                 )<br />
                 )<br />
                )<br />
                 <br />
                (define (resize w h)<br />
                 (display "resize: ")<br />
                 (sx-bitmap-new 100 100)<br />
                 (glViewport 0 0 w h)<br />
                 #t<br />
                )<br />
                <br />
                (define (draw-opengl)<br />
                 (display "draw: ")<br />
                 (sx-bitmap-new 100 100)<br />
                 (glClearColor 0.0 0.0 0.0 0.0)<br />
                 (glClear GL_COLOR_BUFFER_BIT)<br />
                 (glColor3d 1.0 1.0 1.0)<br />
                 <br />
                 (glMatrixMode GL_PROJECTION)<br />
                 (glLoadIdentity)<br />
                 (glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0)<br />
                 (glMatrixMode GL_MODELVIEW)<br />
                 (glLoadIdentity)<br />
                <br />
                 (glBegin GL_QUADS)<br />
                 (glVertex3d 0.25 0.25 0.0)<br />
                 (glVertex3d 0.75 0.25 0.0)<br />
                 (glVertex3d 0.75 0.75 0.0)<br />
                 (glVertex3d 0.25 0.75 0.0)<br />
                 (glEnd)<br />
                )<br />
                <br />
                <br />
                (define my-canvas%<br />
                 (class* canvas% ()<br />
                 (inherit with-gl-context swap-gl-buffers)<br />
                 <br />
                 (define/override (on-paint)<br />
                 (with-gl-context<br />
                 (lambda ()<br />
                 (draw-opengl)<br />
                 (swap-gl-buffers)<br />
                 )<br />
                 )<br />
                 )<br />
                 <br />
                 (define/override (on-size width height)<br />
                 (with-gl-context<br />
                 (lambda ()<br />
                 (resize width height)<br />
                 )<br />
                 )<br />
                 )<br />
                 (super-instantiate () (style '(gl)))<br />
                 )<br />
                )<br />
                <br />
                <br />
                (define win (new frame% (label "OpenGl Test") (min-width 200) (min-height 200)))<br />
                (define gl (new my-canvas% (parent win)))<br />
                <br />
                (sx-bitmap-new 100 100)<br />
                (send win show #t)<br />
                <br />
                )</div>
        <div>
                 </div>
</div>