Well, cl-opengl is a good binding. Basically, you use it the same way you would use it in c. What i would be asking though
is how to incorporate Opengl into a windows window which has buttons, menu items, etc (i'm sure theres a way, but i don't
know how). Also, warning, i *think* the glut:keyboard thing is screwed up. It passes a character code (integer) instead of the actual character. This is easily fixed, though, by defining a :before method on glut:keyboard and using
(code-char num). Here's the main website
http://common-lisp.net/project/cl-opengl/You have to use darcs get to retrieve it, download darcs from internet if you don't have it.
Here's an example from its example files:
- Code: Select all
(defpackage :example (:use :cl :gl :glu :glut)) ;;i added this
(in-package :example) ;;i added this
;;rest is from line.lisp example
(defun draw-one-line (x1 y1 x2 y2)
(gl:with-primitives :lines
(gl:vertex x1 y1)
(gl:vertex x2 y2)))
(defclass lines-window (glut:window)
()
(:default-initargs
:width 400 :height 150 :pos-x 100 :pos-y 100
:mode '(:single :rgb) :title "lines.lisp"))
(defmethod glut:display-window :before ((w lines-window))
(gl:clear-color 0 0 0 0)
(gl:shade-model :flat))
(defmethod glut:display ((w lines-window))
(gl:clear :color-buffer-bit)
;; Select white for all lines.
(gl:color 1 1 1)
;; In 1st row, 3 lines, each with a different stipple.
(gl:enable :line-stipple)
(gl:line-stipple 1 #b0000000100000001) ; dotted
(draw-one-line 50 125 150 125)
(gl:line-stipple 1 #b0000000011111111) ; dashed
(draw-one-line 150 125 250 125)
(gl:line-stipple 1 #b0001110001000111) ; dash/dot/dash
(draw-one-line 250 125 350 125)
;; In 2nd row, 3 wide lines, each with different stipple.
(gl:line-width 5)
(gl:line-stipple 1 #b0000000100000001) ; dotted
(draw-one-line 50 100 150 100)
(gl:line-stipple 1 #b0000000011111111) ; dashed
(draw-one-line 150 100 250 100)
(gl:line-stipple 1 #b0001110001000111) ; dash/dot/dash
(draw-one-line 250 100 350 100)
(gl:line-width 1)
;; In 3rd row, 6 lines, with dash/dot/dash stipple as part
;; of a single connected line strip.
(gl:line-stipple 1 #b0001110001000111) ; dash/dot/dash
(gl:with-primitives :line-strip
(dotimes (i 7)
(gl:vertex (+ 50 (* i 50)) 75)))
;; In 4th row, 6 independent lines with same stipple.
(dotimes (i 6)
(draw-one-line (+ 50 (* i 50)) 50
(+ 50 (* (1+ i) 50)) 50))
;; In 5th row, 1 line, with dash/dot/dash stipple and
;; a stipple repeat factor of 5.
(gl:line-stipple 5 #b0001110001000111) ; dash/dot/dash
(draw-one-line 50 25 350 25)
;; Finally,
(gl:disable :line-stipple)
(gl:flush))
(defmethod glut:reshape ((w lines-window) width height)
(gl:viewport 0 0 width height)
(gl:matrix-mode :projection)
(gl:load-identity)
(glu:ortho-2d 0 width 0 height))
(defmethod glut:keyboard ((w lines-window) key x y)
(declare (ignore x y))
(when (eql key #\Esc)
(glut:destroy-current-window)))
(defun rb-lines ()
(glut:display-window (make-instance 'lines-window)))