Hello again, I finally got back to working on my lispy jigsaw puzzle game and I've made a few changes to the code to clean things up and make it more manageable. In the first implementation I made a new surface for every puzzle piece and rotation. This generated a very large number of surfaces. The cleaner solution involves using a single surface containing an image array of each puzzle piece. See this link for an example: http://img395.imageshack.us/my.php?image=leaveshb1.png
To blit the images on the screen I have to use SDL-BASE::BLIT-SURFACE because it take a source and destination rectangle. I created my own blitting function to wrap the low level foreign pointer stuff, and it initially looked like this: (defun blit (src dst sx sy dx dy w h) (sdl-base::blit-surface (sdl:fp src) (sdl:fp dst) (sdl:fp (sdl:rectangle :x sx :y sy :w w :h h)) (sdl:fp (sdl:rectangle :x dx :y dy :w w :h h)))) But this function is very slow because calling SDL:RECTANGLE conses a lot, so much that the GC was kicking in during my paints!. To fix it I had to create some global variables to hold reusable rectangles. Here's the ugly fast code: ;; Use these globals to hold reusable rectangles for BLIT-FAST to ;; avoid consing. This is ugly and not thread safe. Is there a better ;; way to do this?? (defparameter *blit-r-src* (sdl:rectangle :x 0 :y 0 :w 0 :h 0)) (defparameter *blit-r-dst* (sdl:rectangle :x 0 :y 0 :w 0 :h 0)) (defun blit-fast (src dst sx sy dx dy w h) (setf (sdl:x *blit-r-src*) sx)(setf (sdl:y *blit-r-src*) sy) (setf (sdl:width *blit-r-src*) w)(setf (sdl:height *blit-r-src*) h) (setf (sdl:x *blit-r-dst*) dx)(setf (sdl:y *blit-r-dst*) dy) (setf (sdl:width *blit-r-dst*) w)(setf (sdl:height *blit-r-dst*) h) (sdl-base::blit-surface (sdl:fp src) (sdl:fp dst) (sdl:fp *blit-r-src*) (sdl:fp *blit-r-dst*))) It seems like there is a better way of doing that. Any suggestions? Also, I would like to propose another DRAW-SURFACE-* type function which takes a source rectangle (or position) as well as the destination rectangle. Thoughts? Thanks, Anthony
_______________________________________________ application-builder mailing list application-builder@lispniks.com http://www.lispniks.com/mailman/listinfo/application-builder