Created
September 19, 2012 17:39
-
-
Save alesya-h/3751010 to your computer and use it in GitHub Desktop.
Лаба 3 по машинной графике
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload (list "cl-opengl" "cl-glu" "cl-glut")) | |
(defclass my-window (glut:window) | |
() | |
(:default-initargs :width 250 :height 250 :title "lab 3" | |
:mode '(:single :rgb :depth))) | |
(defvar *angle* 0) | |
(defvar *window*) | |
(defun on-timer () | |
(setf *angle* (mod (+ *angle* 1) (* 2 180))) | |
(glut:with-window *window* | |
(glut:post-redisplay)) | |
(glut:schedule-timer 10 #'on-timer)) | |
(defmethod glut:display-window :before ((w my-window)) | |
(gl:clear-color 0 0 0 0) | |
(gl:cull-face :back) | |
(gl:depth-func :less) | |
(gl:disable :dither) | |
(gl:shade-model :smooth) | |
(gl:light-model :light-model-local-viewer 1) | |
(gl:color-material :front :ambient-and-diffuse) | |
(gl:enable :light0 :lighting :cull-face :depth-test) | |
(glut:schedule-timer 0 #'on-timer)) | |
(defmethod glut:display ((window my-window)) | |
(gl:load-identity) | |
(gl:translate 0 0 -5) | |
(gl:rotate 30 1 1 0) | |
(gl:light :light0 :position '(0 1 1 0)) | |
(gl:light :light0 :diffuse '(0.8 0.4 0.6 0)) | |
(gl:clear :color-buffer :depth-buffer) | |
(gl:color 1 1 1) | |
(gl:front-face :cw) | |
(gl:with-pushed-matrix | |
(gl:rotate *angle* 0 1 0) | |
(glut:solid-teapot 1.3) | |
) | |
(gl:front-face :ccw) | |
(gl:flush)) | |
(defmethod glut:reshape ((window my-window) width height) | |
(gl:viewport 0 0 width height) | |
(gl:matrix-mode :projection) | |
(gl:load-identity) | |
(glu:perspective 50 (/ width height) 0.5 20) | |
(gl:matrix-mode :modelview) | |
(gl:load-identity)) | |
(defmethod glut:keyboard ((window my-window) key x y) | |
(declare (ignore x y)) | |
(when (eql key #\Esc) | |
(glut:destroy-current-window))) | |
(defun start () | |
(setf *window* (make-instance 'my-window)) | |
(glut:display-window *window*)) | |
;(start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment