From: jsancho Date: Thu, 26 May 2011 06:12:43 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=2fe7e96d7e06b93fa953d3b722a25517d5adb31f;p=gacela.git --- diff --git a/src/gacela_SDL.c b/src/gacela_SDL.c index e20877f..ce2f2cc 100644 --- a/src/gacela_SDL.c +++ b/src/gacela_SDL.c @@ -75,6 +75,22 @@ get_surface_height (SCM surface_smob) return scm_from_int (surface->h); } +SCM +get_surface_pixels (SCM surface_smob) +{ + SDL_Surface *surface = get_surface_address (surface_smob); + + return scm_from_int (surface->pixels); +} + +SCM +get_surface_format_BytesPerPixel (SCM surface_smob) +{ + SDL_Surface *surface = get_surface_address (surface_smob); + + return scm_from_int (surface->format->BytesPerPixel); +} + SCM mark_surface (SCM surface_smob) { @@ -355,6 +371,8 @@ SDL_register_functions (void* data) scm_set_smob_print (surface_tag, print_surface); scm_c_define_gsubr ("surface-w", 1, 0, 0, get_surface_width); scm_c_define_gsubr ("surface-h", 1, 0, 0, get_surface_height); + scm_c_define_gsubr ("surface-pixels", 1, 0, 0, get_surface_pixels); + scm_c_define_gsubr ("surface-format-BytesPerPixel", 1, 0, 0, get_surface_format_BytesPerPixel); scm_c_define ("SDL_INIT_TIMER", scm_from_int (SDL_INIT_TIMER)); scm_c_define ("SDL_INIT_AUDIO", scm_from_int (SDL_INIT_AUDIO)); diff --git a/src/gacela_draw.scm b/src/gacela_draw.scm index 7dc912f..fbe21be 100644 --- a/src/gacela_draw.scm +++ b/src/gacela_draw.scm @@ -63,7 +63,7 @@ (init-video-mode) (let ((image (IMG_Load filename))) (cond (image - (let* ((width (get-surface-width image)) (height (get-surface-height image)) + (let* ((width (surface-w image)) (height (surface-h image)) (power-2 (nearest-power-of-two (min width height))) (resized-image #f)) (cond ((and (= width power-2) (= height power-2)) (values image width height)) @@ -71,7 +71,7 @@ (if resized-image (values resized-image width height))))))))) (define (resize-surface surface width height) - (let ((old-width (get-surface-width surface)) (old-height (get-surface-height surface))) + (let ((old-width (surface-w surface)) (old-height (surface-h surface))) (cond ((and (= width old-width) (= height old-height)) surface) (else (let ((zoomx (/ (+ width 0.5) old-width)) (zoomy (/ (+ height 0.5) old-height))) (zoomSurface surface zoomx zoomy 0)))))) @@ -89,9 +89,8 @@ (glBindTexture GL_TEXTURE_2D texture) (glTexImage2D GL_TEXTURE_2D 0 3 width height 0 byteorder GL_UNSIGNED_BYTE (surface-pixels image)) - (glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER min-filter) - (glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER mag-filter) - (SDL_FreeSurface image) + (glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER min-filter) + (glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER mag-filter) (set-resource key `(:id-texture ,texture :width ,real-w :height ,real-h) (lambda () (true-load-texture filename min-filter mag-filter static))