On Sat, Nov 16, 2013 at 12:49 PM, Greg Bennett <gwbenn...@sentex.ca> wrote: > > ;; Adding the (defmethod keyboard ...) form and running > ;; (gb-blend) produces that yellow window, the keys a,s,r,m,x > ;; have no effect on it at all. > > ;; The x in its top right kills it. Esc kills it too and > ;; leads to this in the message > ;; window of what was the repl: > ;+ Lisp connection closed unexpectedly: connection broken > ;+ by remote peer > When dealing with non-lisp libraries (like glut), one common cause of the lisp dieing unexpectedly like that is libraries that handle errors by just exiting completely. If you check the *inferior-lisp* buffer in emacs, it might have printed out an error message first. In this case, I get "freeglut (SBCL): ERROR: Function <glutPostRedisplay> called with no current window defined.", which suggests the problem is the call to (glut:post-redisplay) after calling (glut:destroy-current-window).
> ;; I said Typically, because just ONCE the code without > ;; the keyboard method produced a yellow pane with a white > ;; square in its centre. The time with the white square you probably forgot to define the RESHAPE method, which looks like it doesn't quite match the drawing code you have. > ;; We seem to need this reshape method > ;; in order that anything show on the screen > (defmethod glut:reshape ((w blender-window) width height) > (gl:viewport 0 0 width height) > (gl:matrix-mode :projection) > (gl:load-identity) this part looks wrong: > (glu:ortho-2d 0 width 0 height)) Should probably either be removed, or be (glu:ortho-2d -1 1 -1 1) which I think would be the same as the default. (glu:ortho-2d 0 width 0 height) sets the projection so that 0,0 is at the corner of the window, and each pixel is 1 unit. The DISPLAY method draws a square from -0.5 to 0.5, so it would cover half a pixel at the corner with that projection. > ;; There is it in the top left of the screen > ;; correct title, solid yellow background. > ;; (? Should there have been a yellow square in the middle ?) Should have been a white square on yellow background: background is yellow (1,1,0), and square is blue (0,0,1), and the blend mode is ADD by default, without alpha, so result is white (1,1,1). > ;; The keyboard method to drive the blender options > ;; in the OpenGL P G P231 > (defmethod glut:keyboard ((w blender-window) key x y) > (declare (ignore x y)) > (case key > ((#\a) (gl:blend-equation :func-add)) > ((#\s) (gl:blend-equation :func-subtract)) > ((#\r) (gl:blend-equation :func-reverse-subtract)) > ((#\m) (gl:blend-equation :min)) > ((#\x) (gl:blend-equation :max)) > ((#\Esc) (glut:destroy-current-window)) > ) don't call this after destroying the window: > (glut:post-redisplay) > )