[plt-scheme] Open GL tutorial for DrScheme

From: Ivanyi Peter (pivanyi at freemail.hu)
Date: Wed Nov 29 08:26:21 EST 2006

Jean-Paul.ROY at unice.fr írta:

> Is there any introductory tutorial (small programs, not SX
modeller)  
> to the Open-GL layer of DrScheme, for students who have
never been  
> exposed before to the Open-GL universe ? Most of the books
are  
> written in C.

Basically you need a new canvas, something like what I have
defined
below. (Although I did not try this one out)
Then you need a function "my-display" which does the OpenGL
rendering and a "my-configure" which reacts if the size of the
window has changed. If you want to respond to keyboard or 
mouse then override the on-event method.
After this just follow the instructions in any OpenGL book.
Almost all
C functions "translate directly" to Scheme functions.
The problematic areas are selection and feedback buffer and
bitmap
or texture handling. (They are problematic in a sense, that
they are 
there and they are working, but slightly differently
compared to the
C interface.)

Best regards,

Peter Ivanyi



(define my-canvas%
  (class* canvas% ()
    (inherit with-gl-context swap-gl-buffers)

    (define/override (on-paint)
      (with-gl-context
        (lambda ()
          (glClearColor 0.0 0.0 0.0 0.0)
          (glClear (list sx-color-buffer-bit
sx-depth-buffer-bit))

          (my-display)
          (swap-gl-buffers)
        )
      )
    )

    (define/override (on-size width height)
      (with-gl-context
        (lambda ()
          (my-configure width height)
        )
      )
    )
    (super-instantiate () (style '(gl)))
  )
)

________________________________________________________________________________
Új és használt számítástechnikai cikkek, mobiltelefonok, szórakoztatóelektronika. Válogasson az egyik legnagyobb internetes piactéren!http://ad.adverticum.net/b/cl,1,6022,120683,191339/click.prm



Posted on the users mailing list.