Changes between Initial Version and Version 1 of SimpleOpenGL


Ignore:
Timestamp:
Apr 15, 2009, 12:17:30 AM (11 years ago)
Author:
rme
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SimpleOpenGL

    v1 v1  
     1This is only slightly more interesting than the [wiki:CocoaBridge red view] example.
     2
     3{{{
     4(in-package "CL-USER")
     5
     6(require "COCOA")
     7
     8(eval-when (:compile-toplevel :load-toplevel :execute)
     9  (objc:load-framework "OpenGL" :gl))
     10
     11(defclass simple-gl-view (ns:ns-opengl-view)
     12  ()
     13  (:metaclass ns:+ns-object))
     14
     15(objc:defmethod (#/drawRect: :void) ((self simple-gl-view) (rect :<NSR>ect))
     16  (#_glClearColor 0.0 0.0 0.0 0.0)
     17  (#_glClear #$GL_COLOR_BUFFER_BIT)
     18  (draw-stuff)
     19  (#_glFlush))
     20
     21(defun draw-stuff ()
     22  (#_glColor3f 1.0 0.85 0.35)
     23  (#_glBegin #$GL_TRIANGLES)
     24   (#_glVertex3f 0.0 0.6 0.0)
     25   (#_glVertex3f -0.2 -0.3 0.0)
     26   (#_glVertex3f 0.2 -0.3 0.0)
     27  (#_glEnd))
     28
     29(defun show-simple-gl ()
     30  (ns:with-ns-rect (frame 0 0 300 300)
     31    (let* ((w (make-instance 'ns:ns-window
     32                             :with-content-rect frame
     33                             :style-mask (logior #$NSTitledWindowMask
     34                                                 #$NSClosableWindowMask
     35                                                 #$NSMiniaturizableWindowMask)
     36                             :backing #$NSBackingStoreBuffered
     37                             :defer t))
     38           (v (make-instance 'simple-gl-view)))
     39      (#/setContentView: w v)
     40      (#/release v)
     41      (#/center w)
     42      (#/orderFront: w nil))))
     43}}}
     44