NeHe intro lisp opengl

This commit is contained in:
Dan Ballard 2011-06-27 07:56:21 -07:00
commit b7f2ae8b96
1 changed files with 42 additions and 0 deletions

42
1.lisp Normal file
View File

@ -0,0 +1,42 @@
;;; glut-template.lisp
;;; load opengl
(require :asdf)
(asdf:load-system :cl-opengl)
(asdf:load-system :cl-glu)
(asdf:load-system :cl-glut)
(defclass my-window (glut:window)
()
(:default-initargs :width 400 :height 300
:title "My Window Title"
:x 100 :y 100
:mode '(:double :rgb :depth)))
;;; initilization method
(defmethod glut:display-window :before ((win my-window))
;;; prepage opengl
(gl:shade-model :smooth) ; enables smooth shading
(gl:clear-color 0 0 0 0) ; background will be black
(gl:clear-depth 1) ; clear buffer to minimum depth
(gl:enable :depth-test) ; enable depth testing
(gl:depth-function :lequal) ; okay to write pixel if its depth
; is less-than-or-equal to the
; depth xcurrently written
(gl:hint :perpective-correction-hint :nicest) ; really nice perspective correction
)
;;; additional glut methods
(defmethod glut:display ((win my-window))
(gl:clear :color-buffer-bit :depth-buffer-bit)
(gl:load-identity))
(defmethod glut:reshape ((win my-window) wight height)
;;; prepare viewport
(gl:viewport 0 0 width height) ; reset current viewport
#<:use "create an instance of our window">