Hi,
the test program in the bottom doesn't work as
expected in slime on my linux systems:
It should do the following:
when calling (run) with C-M-x it opens a window.
When pressing ESC in this window it will close.
When calling (run) again slime is destroyed.
One work around I found is to call (reinit) before calling (run) the second time.
The problem is that *glut-initialized-p* isn't reset to nil after leaving
the main loop in glut/main.lisp:
;; this is the fix:
(defun main-loop ()
(without-fp-traps
(%glutMainLoop))
(setf *glut-initialized-p* nil) ; add this line to fix the bug
init))
;; this is the test program:
#.(progn
(require :asdf)
(require :cl-opengl)
(require :cl-glut)
(require :cffi))
(defpackage #:mk
(:use #:cl #:gl #:cffi))
(in-package #:mk)
(defcallback draw :void ()
(clear :color-buffer)
(with-primitives :lines
(vertex 1 0)
(vertex 0 1))
(glut:swap-buffers))
(defcallback key :void ((key :uchar) (x :int) (y :int))
(declare (ignore x y))
(case (code-char key)
(#\Esc (glut:leave-main-loop))))
(defun run ()
(glut:init)
(glut:init-display-mode :double :rgb)
(glut:create-window "test")
(glut:display-func (callback draw))
(glut:keyboard-func (callback key))
(glut:main-loop))
(defun reinit ()
(with-foreign-objects ((argcp :int) (argv :pointer))
(setf (mem-ref argcp :int) 1)
(with-foreign-string (str "test")
(setf (mem-ref argv :pointer) str)
(glut::%glutInit argcp argv))))
--
Martin Kielhorn
Randall Division of Cell & Molecular Biophysics
King's College London, New Hunt's House
Guy's Campus, London SE1 1UL, U.K.
tel: +44 (0) 207 848 6519, fax: +44 (0) 207 848 6435