From 00003b at gmail.com Sat Nov 16 20:16:21 2013 From: 00003b at gmail.com (Bart Botta) Date: Sat, 16 Nov 2013 14:16:21 -0600 Subject: Blending (Redbook Ch6) In-Reply-To: <1384627788.2917.1.camel@greg-HP-Pavilion-dv7> References: <1384627788.2917.1.camel@greg-HP-Pavilion-dv7> Message-ID: On Sat, Nov 16, 2013 at 12:49 PM, Greg Bennett 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 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) > ) From 00003b at gmail.com Mon Nov 11 21:46:55 2013 From: 00003b at gmail.com (Bart Botta) Date: Mon, 11 Nov 2013 15:46:55 -0600 Subject: Blending In-Reply-To: <1384200310.6407.25.camel@greg-HP-Pavilion-dv7> References: <1384200310.6407.25.camel@greg-HP-Pavilion-dv7> Message-ID: On Mon, Nov 11, 2013 at 2:05 PM, Greg Bennett wrote: > glClearColor(1.0, 10., 1.0, 0.0); > glBlendFunc(GL_ONE, GL_ONE); > glEnable(GL_BLEND); > (gl:clear-color 1.0 1.0 1.0 0.0) ;; assuming 10. was a typo (gl:blend-func :one :one) (gl:enable :blend) From gwbennett at sentex.ca Mon Nov 11 20:05:10 2013 From: gwbennett at sentex.ca (Greg Bennett) Date: Mon, 11 Nov 2013 15:05:10 -0500 Subject: Blending Message-ID: <1384200310.6407.25.camel@greg-HP-Pavilion-dv7> Hello there .. I am trying to experiment with the 4th, A, attribute of glColor to erase lines, points, etc. Looking at Chapter 6 of the OpenGL Programming Guide, I see mention of blending and its activation when using that attribute. Specifically, Example 6-1 on P230 begins with glClearColor(1.0, 10., 1.0, 0.0); glBlendFunc(GL_ONE, GL_ONE); glEnable(GL_BLEND); I can see the definitions of glBlendFunc and glEnable in the file funcs-gl-gles1-gles2.lisp so I presume they are callable. It is the arguments which have me tricked. GL_ONE is defined as (1, 1, 1) on P228, GL_BLEND gets no mention that I can find. I would appreciate pointers to the calling sequences under cl-opengl of the above 3 lines. I have to say that I can do some erasing without calling glBlendFunc or glEnable, although what happens is a bit odd. Perhaps there are examples/resources of which I am unaware which would have saved me posting what may be a simple query to the list. Thanks for any and all assistance, and for you patience. Cheers /Greg Bennett From caelanburris at gmail.com Wed Nov 6 19:23:23 2013 From: caelanburris at gmail.com (Caelan Burris) Date: Wed, 6 Nov 2013 14:23:23 -0500 Subject: Packages In-Reply-To: <527A8D1C.7000404@sentex.ca> References: <527A8D1C.7000404@sentex.ca> Message-ID: cl-opengl includes a GLUT binding, so unless you want to use GLFW, just install cl-opengl. On Wed, Nov 6, 2013 at 1:40 PM, Greg Bennett wrote: > Running ccl 1.9-r15968M under linux mint 14, I assume that the easiest > way to get cl-opengl is via quicklisp. > > On its release pages I see three projects which mention cl-opengl in some > way: > cl-glfw-20130615git <- lots of stuff > cl-glfw3 > cl-opengl-20131003git <- the core pieces, I believe. > > Should I install them all, I wonder ? > > Cheers /Greg Bennett > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gwbennett at sentex.ca Wed Nov 6 18:40:28 2013 From: gwbennett at sentex.ca (Greg Bennett) Date: Wed, 06 Nov 2013 13:40:28 -0500 Subject: Packages Message-ID: <527A8D1C.7000404@sentex.ca> Running ccl 1.9-r15968M under linux mint 14, I assume that the easiest way to get cl-opengl is via quicklisp. On its release pages I see three projectswhich mention cl-opengl in some way: cl-glfw-20130615git <- lots of stuff cl-glfw3 cl-opengl-20131003git <- the core pieces, I believe. Should I install them all, I wonder ? Cheers /Greg Bennett -------------- next part -------------- An HTML attachment was scrubbed... URL: From gwbennett at sentex.ca Sat Nov 16 18:49:48 2013 From: gwbennett at sentex.ca (Greg Bennett) Date: Sat, 16 Nov 2013 13:49:48 -0500 Subject: Blending (Redbook Ch6) Message-ID: <1384627788.2917.1.camel@greg-HP-Pavilion-dv7> ;; I am trying to learn to use cl-opengl by translating some of those ;; examples from the redbook which are not in the distributed code ;; under ../examples/redbook. ;; In particular, I should like to understand some of Ch6 of the Redbook ;; dealing with blending and antialiasing. I began with blending. ;; While I seem to have pieces working, the code below, and its author, ;; are obviously missing one or more essential ideas. I would be happy ;; to learn what they are, so that I can discover how I might had found ;; them out without bothering the list about possibly trivial matters. ;; (lisp-implementation-version) returns ;; Version 1.9-r15972M (linuxX8664) for ccl. ;; I use 2-pane emacs with C-c C-c to move forms from source ;; buffer to *slime-repl ccl* buffer ;; all under Linux Mint 14 (64 bit). ;; Thanks for any and all assistance ;; Cheers /Greg Bennett ;;+ Code and comments on its execution follow. ;; This is blender.lisp ;; An attempt to adapt the code in the ;; OpenGL Programming Guide P230/1 ;; to cl-opengl ;; borrowing from redbook/examples/lines.lisp for basic windowing code, ;; and with helpful hints from Bart Botta about how to convert the C ;; code to opengl's forms. ;; Comparing the Guide with the examples files, I infer that ;; the contents of void inint(void) go to (defmethod (glut:display-window ())) ;; while void display(void) -> (defmethod (glut:display( ))) ;; *Typically executing the forms below down to and including ;; (defun (gb-blend( ..)) ;; and then running (gb-blend) produces a solid yellow ;; window. The x in its top right does indeed kill it. ;; 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 ;+ alt-x slime asks whether I want to start another lisp ;+ answer no -> (presumably) the lisp with which contact ;+ had been severed. This repl knows about nothing which ;+ preceded its interruption. ;; I said Typically, because just ONCE the code without ;; the keyboard method produced a yellow pane with a white ;; square in its centre. ;; Adding the keyboard method to this -> that same pair ;; which reacted to the keys as described on P230 in respect ;; of the white square: ;; a no change ;; s white -> blue ;; r blue -> yellow ;; m yellow -> black ;; x black -> white ;; Esc graceful fold. ;; Having closed the window, ;; immediately re-doing (gb-blend) -> that same collection ;; of responses to keys. ;; Closing lisp, redoing the whole exercise from ;; the same, unchanged, source file -> only the ;; solid yellow pane, unchanged by key presses, save Esc which ;; produces the train wreck described earlier. ;; A package (defpackage :zot (:use :cl)) ;; Use it (in-package :zot) ;; Class for windows in which blending actions should occur (defclass blender-window (glut:window) () (:default-initargs :width 400 :height 400 :pos-x 50 :pos-y 50 :mode '(:single :rgb) :title "Blender Window")) ;; Set up some attributes ;; Described as in void init(void) on P230 (defmethod glut:display-window ((w blender-window)) (gl:clear-color 1.0 1.0 0.0 0.0) (gl:blend-func :one :one) (gl:enable :blend) ) ;; 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) (glu:ortho-2d 0 width 0 height)) ;; A method on display to get what seems ;; to be a rectangle to be modified by blending actions ;; code in void display(void) on P230 (defmethod glut:display ((w blender-window)) (gl:clear :color-buffer-bit) (gl:color 0.0 0.0 1.0) (gl:rect -0.5 -0.5 0.5 0.5) (gl:flush)) (defun gb-blend () (glut:display-window (make-instance 'blender-window))) ;; If I have translated correctly, that's all I need. ;; Let's make a blender-window ;; 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 ?) ;; On to blending through the keyboard. ;; 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)) ) (glut:post-redisplay) ) ;; Assuming correct translation, run (gb-blend) and press 'a' ;; The story is at the top of the file. From gwbennett at sentex.ca Mon Nov 11 19:43:32 2013 From: gwbennett at sentex.ca (Greg Bennett) Date: Mon, 11 Nov 2013 14:43:32 -0500 Subject: Blending Message-ID: <1384199012.6407.12.camel@greg-HP-Pavilion-dv7> I am trying to use some of the ideas of Ch6 Blending, etc. of the OpenGL Programming Guide. Specifically I am interested in the use of the A attribute of glColor for erasing points, lines, etc.. The beginning of Ch6 talks about blending and its first example emphasizes the need to call glEnable and glBlendFunc before actually drawing anything, although I can get somewhere without these. I have found the definitions of the cl-opengl versions in funcs-gl-gles1-gles2.lisp (in the gl subdirectory of cl-opengl), so I assume they are callable. I'm stuck one the appropriate arguments. P230 0f the Guide, Example 6-1 starts with glColorClear(1.0, 1.0, 1.0, 0.0); glBlendFunc(GL_ONE, GL_ONE); glEnable(GL_BLEND); and GL_ONE is defined on P228 as (1,1,1). I would be grateful for information about the calling sequences of the above 3 lines in cl-opengl. Perhaps there are examples/sources I should be aware of which would save me posting to the list. Thanks for any and all assistance. Cheers /Greg Bennett