1 ;;; -*- mode: lisp; syntax: common-lisp -*-
3 ;;; Gray streams require ECL 0.9j or later.
4 (defclass g3d-console-view-stream
(gray:fundamental-character-output-stream
)
5 ((buffer :accessor buffer-of
:initform
(make-array (list 0) :adjustable t
:fill-pointer
0))))
7 (defmethod gray:stream-line-column
((stream g3d-console-view-stream
))
8 (fill-pointer (buffer-of stream
)))
10 (defmethod gray:stream-advance-to-column
((stream g3d-console-view-stream
) column
)
13 (defmethod gray:stream-write-char
((stream g3d-console-view-stream
) char
)
14 (declare (ignore stream
))
15 (vector-push-extend char
(buffer-of stream
)))
17 (defmethod gray:stream-terpri
((stream g3d-console-view-stream
))
18 (write-text-to-g3d (buffer-of stream
))
19 (setf (buffer-of stream
) (make-array 0 :adjustable t
:fill-pointer
0)))
21 (defvar *g3d-console-view-stream
* (make-instance 'g3d-console-view-stream
))
23 (setf *standard-output
* *g3d-console-view-stream
*)
24 (setf *error-output
* *g3d-console-view-stream
*)
25 (setf *trace-output
* *g3d-console-view-stream
*)
27 ;; (defun one-of (choices &optional (prompt "Choice"))
28 ;; (let ((n (length choices)) (i))
29 ;; (do ((c choices (cdr c)) (i 1 (+ i 1)))
31 ;; (format t "~&[~D] ~A~%" i (car c)))
32 ;; (do () ((typep i `(integer 1 ,n)))
33 ;; (format t "~&~A: " prompt)
36 ;; (nth (- i 1) choices)))
39 ;; (defun my-debugger (condition me-or-my-encapsulation)
40 ;; (format t "Jim, it's code, but not as we know it. ~A~&" condition)
43 ;; (let (restart (one-of (compute-restarts)))
44 ;; (if (not restart) (error "My debugger got an error"))
45 ;; (let ((*debugger-hook* me-or-my-encapsulation))
46 ;; (invoke-restart-interactively restart))))
48 ;;(setf *debugger-hook* #'my-debugger)
50 ;; alas C++ does sometimes generate these conditions and then ecl
51 ;; traps them inappropiately
52 (si:trap-fpe
'FLOATING-POINT-UNDERFLOW NIL
)
53 (si:trap-fpe
'FLOATING-POINT-OVERFLOW NIL
)
54 (si:trap-fpe
'DIVISION-BY-ZERO NIL
)
56 (format t
"Welcome to ECL / G3D Test!~%")
58 (defconstant +none
+ 0)
59 (defconstant +mesh
+ 1)
61 (defconstant +cylinder
+ 3)
62 (defconstant +sphere
+ 4)
64 (defconstant +capsule
+ 6)
65 (defconstant +plane
+ 7)
66 (defconstant +axes
+ 8)
67 (defconstant +point
+ 9)