From 3747c2cd2da9c0a618628fa649ece29830581464 Mon Sep 17 00:00:00 2001 From: jsancho Date: Sun, 19 Sep 2010 19:12:17 +0000 Subject: [PATCH] --- gacela_SDL.lisp | 10 ++++++++++ gacela_draw.lisp | 19 +++---------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/gacela_SDL.lisp b/gacela_SDL.lisp index eff4f1a..5dd383e 100644 --- a/gacela_SDL.lisp +++ b/gacela_SDL.lisp @@ -76,6 +76,7 @@ "SDL_Quit ();") (defcfun "int gacela_SDL_SetVideoMode (int width, int height, int bpp, int flags)" 0 + "close(2);" "return SDL_SetVideoMode (width, height, bpp, flags);") (defcfun "void gacela_SDL_WM_SetCaption (char *title, char *icon)" 0 @@ -210,6 +211,14 @@ "const SDL_Surface *s = surface;" "return s->format->BytesPerPixel;") +(defcfun "int gacela_resize_surface (int surface, int width, int height)" 0 + "const SDL_Surface *s = surface;" + "if (s->w == width && s->h == height) {" + " return s;" + "} else {" + " return zoomSurface (s, width / s->w, height / s->h, 0);" + "}") + ;(defentry apply-surface2 (int int int int int int int int int) (void "apply_surface")) ;(defentry render-text2 (int string int int int) (int "render_text")) ;(defentry box-collision (int int int int int int) (int "box_collision")) @@ -220,3 +229,4 @@ (defentry surface-h (int) (int "gacela_surface_h")) (defentry surface-pixels (int) (int "gacela_surface_pixels")) (defentry surface-format-BytesPerPixel (int) (int "gacela_surface_format_BytesPerPixel")) +(defentry resize-surface (int int int) (int "gacela_resize_surface")) diff --git a/gacela_draw.lisp b/gacela_draw.lisp index 93575a3..0118170 100644 --- a/gacela_draw.lisp +++ b/gacela_draw.lisp @@ -71,24 +71,11 @@ (cond ((/= image 0) (let* ((width (surface-w image)) (height (surface-h image)) (power-2 (nearest-power-of-two (min width height))) - zoomed-image) + resized-image) (cond ((and (= width power-2) (= height power-2)) (values image width height)) - (t (setq zoomed-image (resize-image image power-2 power-2)) + (t (setq resized-image (resize-surface image power-2 power-2)) (SDL_FreeSurface image) - (cond ((/= zoomed-image 0) (values zoomed-image width height)))))))))) - -(defun resize-image (image width height) - (let ((old-width (surface-w image)) (old-height (surface-h image))) - (cond ((and (= width old-width) (= height old-height)) image) - (t (let ((zoomx (/ width old-width)) (zoomy (/ height old-height)) zoomed-image) - (setq zoomed-image (zoomSurface image zoomx zoomy 0)) - (let ((new-width (surface-w zoomed-image)) (new-height (surface-h zoomed-image))) - (cond ((or (and (= width new-width) (= height new-height)) - (and (= old-width new-width) (= old-height new-height))) zoomed-image) - (t (let (rezoomed) - (setq rezoomed (resize-image zoomed-image width height)) - (SDL_FreeSurface zoomed-image) - rezoomed))))))))) + (cond ((/= resized-image 0) (values resized-image width height)))))))))) (defun load-texture (filename &key (min-filter GL_LINEAR) (mag-filter GL_LINEAR) static) (let ((key (make-resource-texture :filename filename :min-filter min-filter :mag-filter mag-filter))) -- 2.39.2