From: jsancho Date: Tue, 21 Sep 2010 06:20:34 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=3e8fc39fc56ff5c5c22f31f7e669c971126f8422;p=gacela.git --- diff --git a/gacela_SDL.lisp b/gacela_SDL.lisp index 5dd383e..1d113aa 100644 --- a/gacela_SDL.lisp +++ b/gacela_SDL.lisp @@ -211,14 +211,6 @@ "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")) @@ -229,4 +221,3 @@ (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 0118170..559412b 100644 --- a/gacela_draw.lisp +++ b/gacela_draw.lisp @@ -77,6 +77,12 @@ (SDL_FreeSurface image) (cond ((/= resized-image 0) (values resized-image width height)))))))))) +(defun resize-surface (surface width height) + (let ((old-width (surface-w surface)) (old-height (surface-h surface))) + (cond ((and (= width old-width) (= height old-height)) surface) + (t (let ((zoomx (/ (+ width 0.5) old-width)) (zoomy (/ (+ height 0.5) old-height))) + (zoomSurface surface zoomx zoomy 0)))))) + (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))) (cond ((get-resource key) key)