(in-package #:clnl-interface)
-(defvar *patch-size* 13d0)
-
(defvar *turtle-list* nil)
(defvar *patch-list* nil)
(gl:clear :color-buffer-bit :depth-buffer-bit)
(gl:matrix-mode :projection)
(gl:load-identity)
- (gl:ortho -71 71 -71 71 1 5000)
+ (gl:ortho
+ (floor (* (- (getf *dimensions* :xmin) 0.5) (patch-size)))
+ (floor (* (+ (getf *dimensions* :xmax) 0.5) (patch-size)))
+ (floor (* (- (getf *dimensions* :ymin) 0.5) (patch-size)))
+ (floor (* (+ (getf *dimensions* :ymax) 0.5) (patch-size)))
+ 0 5000)
(gl:matrix-mode :modelview)
(gl:load-identity)
(destructuring-bind (turtles patches) (clnl-nvm:current-state)
((color (nl-color->rgb (getf patch :color))))
(gl:color (car color) (cadr color) (caddr color)))
(gl:with-pushed-matrix
- (gl:translate (* (getf patch :xcor) *patch-size*) (* (getf patch :ycor) *patch-size*) 0)
- (gl:translate (floor (* -.5d0 *patch-size*)) (floor (* -.5d0 *patch-size*)) 0)
- (gl:scale *patch-size* *patch-size* 1)
+ (gl:translate (* (getf patch :xcor) (patch-size)) (* (getf patch :ycor) (patch-size)) 0)
+ (gl:translate (floor (* -.5d0 (patch-size))) (floor (* -.5d0 (patch-size))) 0)
+ (gl:scale (patch-size) (patch-size) 1)
(gl:call-list *patch-list*)))
patches)
(mapcar
(mapcar
(lambda (x-modification y-modification)
(gl:with-pushed-matrix
- (gl:translate (* (getf turtle :xcor) *patch-size*) (* (getf turtle :ycor) *patch-size*) 0)
+ (gl:translate (* (getf turtle :xcor) (patch-size)) (* (getf turtle :ycor) (patch-size)) 0)
(gl:translate x-modification y-modification 0)
(gl:rotate (getf turtle :heading) 0 0 -1)
- (gl:scale *patch-size* *patch-size* 1)
+ (gl:scale (patch-size) (patch-size) 1)
(gl:scale (getf turtle :size) (getf turtle :size) 1)
(gl:call-list *turtle-list*)))
(list 0 (1- (world-width-in-pixels)) (- (1- (world-width-in-pixels))) 0 0)
(setf *turtle-list* (gl:gen-lists 1))
(gl:with-new-list (*turtle-list* :compile)
(gl:rotate 180 0 0 -1)
- (gl:scale (/ 1d0 300d0) (/ 1d0 300d0) 1)
- (gl:translate -150 -150 -4.0)
+ (gl:scale (/ 1 300d0) (/ 1d0 300d0) 1)
+ (gl:translate -150 -150 -0.0)
(gl:begin :polygon)
(gl:vertex 150 5 0)
(gl:vertex 40 250 0)
(defun set-patch-list ()
(setf *patch-list* (gl:gen-lists 1))
(gl:with-new-list (*patch-list* :compile)
- (gl:translate 0d0 0d0 -4.0)
(gl:begin :polygon)
(gl:vertex 0 0 0)
(gl:vertex 0 1 0)
(defun initialize (&key dims)
"INITIALIZE &key DIMS => RESULT
- DIMS: (:xmin XMIN :xmax XMAX :ymin YMIN :ymax YMAX)
+ DIMS: (:xmin XMIN :xmax XMAX :ymin YMIN :ymax YMAX :patch-size PATCH-SIZE)
ARGUMENTS AND VALUES:
XMAX: An integer representing the maximum patch coord in X
YMIN: An integer representing the minimum patch coord in Y
YMAX: An integer representing the maximum patch coord in Y
+ PATCH-SIZE: A double representing the size of the patches in pixels
DESCRIPTION:
the interface lives. From here, one can go into headless or running
mode, but for certain things this interface will still need to act,
and also allows for bringing up and taking down of visual elements."
- (setf *dimensions* dims))
+ (setf *dimensions* dims)
+ (when *glut-window-opened*
+ (cl-glut:reshape-window (world-width-in-pixels) (world-height-in-pixels))))
(defun run ()
"RUN => RESULT
(set-patch-list)
(cl-glut:main-loop)))
+(defun patch-size () (getf *dimensions* :patch-size))
+
(defun world-width-in-pixels ()
- (floor (* *patch-size* (1+ (- (getf *dimensions* :xmax) (getf *dimensions* :xmin))))))
+ (floor (* (patch-size) (1+ (- (getf *dimensions* :xmax) (getf *dimensions* :xmin))))))
(defun world-height-in-pixels ()
- (floor (* *patch-size* (1+ (- (getf *dimensions* :ymax) (getf *dimensions* :ymin))))))
+ (floor (* (patch-size) (1+ (- (getf *dimensions* :ymax) (getf *dimensions* :ymin))))))
(defun export-view ()
"EXPORT-VIEW => IMAGE-DATA
((fbo (first (gl:gen-framebuffers 1)))
(render-buf (first (gl:gen-renderbuffers 1)))
;(width
- ; (floor (* *patch-size* (1+ (-
+ ; (floor (* (patch-size) (1+ (-
; (getf *dimensions* :ymax)
; (getf *dimensions* :ymin))))))
;(height
- ; (floor (* *patch-size* (1+ (- (getf *world-dims* :xmax) (getf *world-dims* :xmin))))))
- ; (floor (* *patch-size* (1+ (-
+ ; (floor (* (patch-size) (1+ (- (getf *world-dims* :xmax) (getf *world-dims* :xmin))))))
+ ; (floor (* (patch-size) (1+ (-
; (getf *dimensions* :xmax)
; (getf *dimensions* :xmin)))))
(width (world-width-in-pixels)) ; Hard coded for now, yay v1 (if you see this comment in a year, please cry for me)
"62B8B468D5ED63CDFB567C984E0CAB53DBD03CEB")
(defviewtest "Basic 1" "crt 1"
- "67F7062D7485C3A31D0065549AB8BED71A48BFEE")
+ "BB7774BC721E16BD92B18228BBBAC8D7BAAA6271")
(defviewtest "Basic 2" "crt 10 ask turtles [ fd 1 ]"
- '("FC3B914602A7F41C5044B7A605DFF36D866B3A7F" "E09857180035872901B8BE27FE5470FD3D987966"))
+ '("D7A3F7FC99CB46A9AC07A5FFAC8DBE4F3C8DFAEE" "CDDDB68DC28E1D1EE72AE3C3474E91381E45D7AB"))
(defviewtest "Wrapping" "crt 10 ask turtles [ fd 6 ]"
- '("72065F4E85CAE90DCFAE85AFC5A09295D46CD3D0" "CAABD296A8C72B18401F19C14C0DC83BB07718A9"))
+ '("51DACC1A8EE0758F94E8C3C1EC46467D46F796D0" "E08B45180949AB58E3F75A07DDC3CC07BC71DFDB"))
(defviewtest "Die" "crt 10 ask turtles [ fd 1 ] ask turtles [ die ]"
"62B8B468D5ED63CDFB567C984E0CAB53DBD03CEB")
(defviewtest "rt" "crt 20 ask turtles [ fd 2 rt 100 fd 2 ]"
- '("7E4DB3DBDE0F1C7D821629B89B8DC20ECFBF06AD" "9143414BB6DF425455C7ACBA6620FD51C9EC5E3A"))
+ '("1C325D14717E92D6368EF3D0276250A49AC94E3C" "6B8AE7C1F8AAB44934EFC17D3F8DC02EA93D42D0"))
(defviewtest "lt" "crt 20 ask turtles [ fd 2 lt 100 fd 2 ]"
- '("BF49775097BBFAE12E42D6F13FAFC93090B7ACAC" "ABAEAF8DDD68E7F0FED6CB243F27DB312588A1E8"))
+ '("5A9976BA3BFF49B9232CC8285E40709B43BB97C6" "24F764D346E607CD10C1CDA83CEF0091FDFBC280"))
(defviewtest "pcolor green" "ask patches [ set pcolor green ]"
"90F5F4870955B9FF02224F00E3C9814B8A6F766E")
(defviewtest "size" "crt 10 ask turtles [ fd 2 set size 3 ] "
- '("66E47E4579C2CA48CA672052B99F25DE94456D3A" "0A8EC908783A913CD15E9A0F19E6B8DBBA4EF5D9"))
+ '("E71BD61118B3B735DE4ADD2EF7897465084DD372" "6A4D9F29F10EAFCF5AB6156CCB35680EF4E41677"))