[Openmcl-devel] Multi-dimensional foreign memory array

nrms nils.stritzel at gmx.net
Tue Mar 8 10:45:28 PST 2005


Hi Gary!
It got me started, but I guess I will need some more enlightment which 
maybe a result of the fact that I am not a Lisp veteran. I tried to 
start quite easy with programm that paints a white quadrat on a black 
background. This something I have done in a small C-program before. As 
a starting point I used opengl-ffi.lisp
and tried to adapt it. Unfortunately I don't get a white quadrat, I get 
only the black background.
Furthermore I have two rather naive (or stupit) questions, although I 
think the answers won't solve my problem
Does  ":element-type '(unsigned-byte 8)" mean the element get 8 bits in 
memory, i.e. 1 byte?
In (%stack-block ((p size)) p is a pointer and size is size of the 
memory block, but in which unit? Bytes?
By the way chapter 9.3 refers to 9.1 for a description of rlet, but 
there is none there.

So what I coded myself is the following segment (or run the attachement 
if interested).

(in-package :drawpixel)

(defconstant *check-image-width* 10)
(defconstant *check-image-height* 10)
(defparameter *check-image*
    (make-array (list *check-image-height* *check-image-width* 3)
               :element-type '(unsigned-byte 8)))

(defun make-check-image ()
   (for (i 0 (- *check-image-width* 1))
        (for (j 0 (- *check-image-height* 1))
	    (for (k 0 2)
		 (setf (aref *check-image* i j k) 255)))))


(defun setup-rc ()
   (#_glClearColor 0.0 0.0 0.0 0.0)
   (make-check-image)
   (#_glPixelStorei #$GL_UNPACK_ALIGNMENT 1)
   (#_glClear #$GL_COLOR_BUFFER_BIT))


(ccl::defcallback render-scene (:void)
		  (%stack-block ((ap (array-total-size *check-image*)))
				    (copy-unsigned-byte-array-to-foreign-memory *check-image* ap)
				    (for (i 1 100)
					 (#_glRasterPos2i i (* i i))
					 (#_glDrawPixels *check-image-width*
							 *check-image-height*
							 #$GL_RGB
							 #$GL_UNSIGNED_BYTE
							 ap)))
				    (#_glFlush))



(defun main () ; no int argc or char **argv
   (opengl:initialize-glut)
   (#_glutInitDisplayMode (logior #$GLUT_RGB
				 #$GLUT_SINGLE
				 #+ignore #$GLUT_DEPTH))
   (#_glutInitWindowSize 800 600)
   (#_glutInitWindowPosition 100 100)
   (ccl::with-cstrs ((title "Bounce"))
		   (#_glutCreateWindow title))
   (setup-rc)
   (#_glutDisplayFunc render-scene)

   (#_glutMainLoop) ; this never returns and interferes w/scheduling

  )


Thanks for any hints!

Nils


-------------- next part --------------
A non-text attachment was scrubbed...
Name: drawpixel.lisp
Type: application/octet-stream
Size: 5513 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20050308/e4f41b82/attachment.obj>
-------------- next part --------------





>

Does this mean


More information about the Openmcl-devel mailing list