You are looking at historical revision 2566 of this page. It may differ significantly from its current revision.

a simple example using objc, gl

First, take a look at the fantastic objc egg.

To use this code, you need to create a window with interface builder, add an NSOpenGLView to it, then change the class to "MyOpenGLView" (or whatever you call your subclass)

It works just like the temperature converter example on the objc egg page, but with this code for main.

(use objc cocoa gl)

(define (draw-scene)

 (define n 0)
 (define (red)
   (gl:Color3f 1 0 0))
 (define (green)
   (gl:Color3f 0 1 0))
 (define (blue)
   (gl:Color3f 0 0 1))
 (define (triangle color1 color2 color3)
   (gl:Vertex3f 0 1 0)
   (gl:Vertex3f -1 -1 1)
   (gl:Vertex3f 1 -1 1))
 (gl:ClearColor 0 0 0 0)
 (gl:Translatef 0 0 -1)
 (gl:Rotatef n 0 1 0)
 (gl:Begin gl:TRIANGLES)
 (triangle red green blue)

(define-objc-class MyOpenGLView NSOpenGLView ()

 (- VOID ((drawRect: NSRECT r))