Paste number 71407: problem with generation

Index of paste annotations: 2 | 1

Paste number 71407: problem with generation
Pasted by: topo
When:7 months, 1 day ago
Share:Tweet this! | http://paste.lisp.org/+1J3J
Channel:#lispcafe
Paste contents:
Raw Source | XML | Display As
(asdf:oos 'asdf:load-op :cl-opengl)
(asdf:oos 'asdf:load-op :cl-glu)
(load "glut.lisp")

(load "/Users/topo/slime-2.0/swank-loader.lisp")

(defparameter *window-width* 640)
(defparameter *window-height* 480)

(defvar a nil)


(defvar *object3* nil)

(defparameter *time* 0)

(defun time-in-seconds ()
  (float (/ (get-internal-real-time) internal-time-units-per-second)))

(defmacro safe-cffi-callback (lisp-function &rest parameter-list &aux (callback-tmpname (gensym)))
  `(prog2
       (cffi:defcallback ,callback-tmpname :void ,parameter-list
	 (handler-case (,lisp-function ,@(mapcar #'car parameter-list))
	   (error (condition)
	     (setf (symbol-function ',lisp-function) (constantly nil))
	     (format t "Error in ~a: ~a~%" ',lisp-function condition))))
       (cffi:callback ,callback-tmpname)))


;;(defun make-object4 ()
;;  (let ((list (GL:gen-lists 1))
;;	(qobj (glu:new-quadric)))
 ;;   (glu:Quadric-Draw-Style qobj GLU_FILL)
 ;;   (gl:New-List list GL_COMPILE)
 ;;   (glu:Sphere qobj 0.7d0 20 20)		; qobj, radius, slices, stacks
 ;;   (gl:End-List)
 ;;   list))

(defun random-elt2 (list)
  ;;esta funcion evalua el cons escojido
  (eval (elt list (random (length list)))))

(defun hola( )
  (random-elt2
   '((cons 'CL-OPENGL:ROTATE (cons 122 (cons 1233 (cons 15  (cons 15 nil) ))))
     (cons 'CL-OPENGL:TRANSLATE (cons 1 (cons 2 (cons 1.3  nil) )))  
     (cons 'CL-OPENGL:TRANSLATE (cons 0 (cons 26 (cons 0  nil)))))))
 
(defun creapush-pop( )
  (cons (random-elt2
	 '(
	   (cons 'CL-OPENGL:ROTATE (cons 122 (cons 1233 (cons 15  (cons 15 nil) ))))
	   (cons 'CL-OPENGL:TRANSLATE (cons 31 (cons 2 (cons 1.3  nil) )))  
	   (cons 'CL-OPENGL:TRANSLATE (cons 0 (cons 6 (cons 0  nil) )))
	   (cons 'CL-OPENGL:TRANSLATE (cons 131 (cons 22 (cons 11.3  nil) )))   
	  (make-structure)
	   ;; (cons (make-structure) nil)
	 ;;   (cons (hola) (make-structure))
	   
))
	(cons '(glut:solid-sphere 26.529d0 9 6) (cons '(gl:pop-matrix) nil ))))



;;(let ((temp (creapush-pop)))
;;  (first temp) ; your first part
;; (second temp)  
;;)

;;(first list) (second list) 

;;(let ((cpp (creapush-pop))) (list (list 'gl:push-matrix) (first cpp) (second cpp)))

(defun random-elt (list)
  (elt list (random (length list))))

(defun make-structure ()
  (case (random-elt '(transformation iterations geo push-pop))
    (transformation 
     (let ((trans+geo (copy-seq (random-elt '((gl:scale 1 0.1 0) 
					      (gl:translate -1 -3 -1.5)
					      (gl:translate (* (sin (* *time* 0.3)) 59) -3 -1.5)
					      (glut:solid-sphere 12.529d0 13 3) 
					      (glut:solid-torus 3.2d0 14.2d0 20 32)
					      (gl:color 0.2 0.8 0)
					      (gl:color 0.0 0.3 0.6)
					      (gl:color 0.2 0.0 0.9)
					      (gl:color 0.5 0.1 1)
					      (gl:rotate 119 997 27 1))))))
       (concatenate 'list (list trans+geo) (make-structure))))
    (iterations (list (cons 'dotimes 
			    (cons 
			     (cons 'i (cons '10  nil) ) 
			     (cons (hola ) (make-structure))))))

    
    ;;(values (list 1 2) (list 3 4) (list 3 4))
    
    ;;(push-pop (let ((cpp (creapush-pop))) (values (list '(gl:push-matrix)) (first cpp) (second cpp) (third cpp))))
    (push-pop (let ((cpp (creapush-pop))) (list (list 'gl:push-matrix) (first cpp) (second cpp) (third cpp))))
    
    (geo (list (random-elt '((glut:solid-sphere 19.529d0 13 3) 
			     (glut:solid-cube 19.d0)
			     (glut:wire-cube 12.2d0)
			     
			     ;;(glut:solid-teapot 50.2d0)
			     (glut:solid-cone 20.2d0 80.2d0 6 6)
			     (glut:solid-dodecahedron )
			     (glut:solid-octahedron)
			     (glut:wire-sphere 14.2d0 20 32)
			     (glut:wire-torus 13.2d0 50.2d0 30 42)
			     (glut:solid-torus 8.2d0 14.2d0 20 32))) ))))


;;nuevas cosas:
;;(gl:push-matrix)
;;(gl:pop-matrix)
;;(gl:color 0.2 0.1 0)

;;si sale push matrix , debe escojer luego entre cualquier objeto que incluya todos has que salga popmatrix 
;;y acaba la funcion.

;;(gl:begin :quads)
;;	(gl:tex-coord -1.5 -1.5) (gl:vertex -700 -1000)
;;	(gl:tex-coord 1.5 -1.5) (gl:vertex 200 -500)
;;	(gl:tex-coord 1.5 1.5) (gl:vertex 26000 5000)
;;	(gl:tex-coord -1.5 1.5) (gl:vertex -2000 10000)
;;	(gl:end)

;;(gl:scale (+ 1 (* 0.07 (sin (* *time* 1))))
;;		  (+ 1 (* 0.004 (cos (* *time* 5))))
;;		  1)


 
( setf a (make-structure))







;;(sin (* *time* 
;;(* *time* 40)
(defun draw ()
  (gl:clear-color 1 0 0 1)
  (gl:clear :color-buffer-bit :depth-buffer-bit)
  (gl:matrix-mode :projection)
  (gl:load-identity)
  (glu:perspective 60 (/ 800 600) 1 700)
  (gl:matrix-mode :modelview)
  (gl:load-identity)
  (gl:enable :lighting)
  (gl:enable :light0)
  (gl:enable :depth-test)
  (gl:enable :color-material)
  (gl:enable :auto-normal)
  (gl:enable :normalize)
  
  (gl:translate -60 3 -390)
  
  (gl:rotate -14 -77 88 1)
    ;;a
    ;;(eval a)
  
  (dolist (primitive a)
    ;; PRIMITIVE is now a value such as: (GLUT:SOLID-SPHERE 3d0 13 3)
    ;; But it's still just data, until we ask Lisp to treat it as code:
    (eval primitive))
  
  ;; (funcall a)
  
  
    
  (glut:swap-buffers))

(defun animate (dt))

(defun init ()
  (glut:init-posix-argv sb-ext:*posix-argv*)
  (glut:init-window-size *window-width* *window-height*)
  (glut:init-display-string "rgb double depth>=16 samples=8")
  (glut:create-window "GLUT - <Untitled>")

;;  (setf *object3* (make-object4))
  
  (glut:display-func (safe-cffi-callback draw))
  (let ((last-time))
    (flet ((aux-animate (&aux (current-time (time-in-seconds))
                              (dt (- current-time
                                     (if last-time last-time current-time))))
             (setq *time* (+ *time* dt)
                   last-time current-time)
             (animate dt)
             (sb-sys:serve-all-events 0.01)
             (glut:post-redisplay)))
      (glut:idle-func (safe-cffi-callback aux-animate))))
  
  (flet ((window-resize (width height)
           (setq *window-width* width
                 *window-height* height)
           (gl:viewport 0 0 *window-width* *window-height*)))
    (glut:reshape-func (safe-cffi-callback window-resize (width :int) (height :int))))
  
  (swank:create-server)
  (glut:main-loop))

(unless (boundp 'inited)
  (defparameter inited nil)
  (init))

Annotations for this paste:

Annotation number 2: it should be
Pasted by: topo
When:7 months, 1 day ago
Share:Tweet this! | http://paste.lisp.org/+1J3J#2
Paste contents:
Raw Source | Display As
((CL-OPENGL:PUSH-MATRIX)
 (DOTIMES (I 10)
    (CL-OPENGL:ROTATE 122 1233 15 15)
    (CL-OPENGL:PUSH-MATRIX)
    (CL-OPENGL:ROTATE 119 997 27 1)
     (CL-OPENGL:TRANSLATE (* (SIN (* *TIME* 0.3)) 59) -3 -1.5)
     (GLUT:SOLID-TORUS 3.2d0 14.2d0 20 32) (CL-OPENGL:PUSH-MATRIX)
     (CL-OPENGL:TRANSLATE 131 22 11.3) (GLUT:SOLID-SPHERE 26.529d0 9 6)
     (CL-OPENGL:POP-MATRIX)
    (GLUT:SOLID-SPHERE 26.529d0 9 6)
    (CL-OPENGL:POP-MATRIX))
 (GLUT:SOLID-SPHERE 26.529d0 9 6) (CL-OPENGL:POP-MATRIX))

Annotation number 1: error with a more pair of parenthesis
Pasted by: topo
When:7 months, 1 day ago
Share:Tweet this! | http://paste.lisp.org/+1J3J#1
Paste contents:
Raw Source | Display As
((CL-OPENGL:PUSH-MATRIX)
 ((DOTIMES (I 10)
    (CL-OPENGL:ROTATE 122 1233 15 15)
    (CL-OPENGL:PUSH-MATRIX)
    ((CL-OPENGL:ROTATE 119 997 27 1)
     (CL-OPENGL:TRANSLATE (* (SIN (* *TIME* 0.3)) 59) -3 -1.5)
     (GLUT:SOLID-TORUS 3.2d0 14.2d0 20 32) (CL-OPENGL:PUSH-MATRIX)
     (CL-OPENGL:TRANSLATE 131 22 11.3) (GLUT:SOLID-SPHERE 26.529d0 9 6)
     (CL-OPENGL:POP-MATRIX))
    (GLUT:SOLID-SPHERE 26.529d0 9 6)
    (CL-OPENGL:POP-MATRIX)))
 (GLUT:SOLID-SPHERE 26.529d0 9 6) (CL-OPENGL:POP-MATRIX))

Colorize as:
Show Line Numbers
Index of paste annotations: 2 | 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.