From: jsancho Date: Wed, 17 Aug 2011 15:53:02 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?p=gacela.git;a=commitdiff_plain;h=5e8896b40426c515f4eb64e0f152c896ddd2d73d --- diff --git a/games/asteroids/Asteroid.png b/games/asteroids/Asteroid.png index c6fdf24..71bbc21 100644 Binary files a/games/asteroids/Asteroid.png and b/games/asteroids/Asteroid.png differ diff --git a/games/asteroids/Ship1.png b/games/asteroids/Ship1.png index b385753..d457940 100644 Binary files a/games/asteroids/Ship1.png and b/games/asteroids/Ship1.png differ diff --git a/src/gacela_SDL.c b/src/gacela_SDL.c index f7f4151..ba567b5 100644 --- a/src/gacela_SDL.c +++ b/src/gacela_SDL.c @@ -199,7 +199,27 @@ gacela_SDL_GetTicks (void) SCM gacela_SDL_DisplayFormat (SCM surface) { - return scm_from_int ((int)SDL_DisplayFormat (get_surface_address (surface))); + SDL_Surface *new = SDL_DisplayFormat (get_surface_address (surface)); + + if (new) { + return make_surface (scm_from_locale_string (get_surface_filename (surface)), new); + } + else { + return SCM_BOOL_F; + } +} + +SCM +gacela_SDL_DisplayFormatAlpha (SCM surface) +{ + SDL_Surface *new = SDL_DisplayFormatAlpha (get_surface_address (surface)); + + if (new) { + return make_surface (scm_from_locale_string (get_surface_filename (surface)), new); + } + else { + return SCM_BOOL_F; + } } SCM @@ -483,6 +503,7 @@ SDL_register_functions (void* data) scm_c_define_gsubr ("SDL_Delay", 1, 0, 0, gacela_SDL_Delay); scm_c_define_gsubr ("SDL_GetTicks", 0, 0, 0, gacela_SDL_GetTicks); scm_c_define_gsubr ("SDL_DisplayFormat", 1, 0, 0, gacela_SDL_DisplayFormat); + scm_c_define_gsubr ("SDL_DisplayFormatAlpha", 1, 0, 0, gacela_SDL_DisplayFormatAlpha); scm_c_define_gsubr ("SDL_MapRGB", 4, 0, 0, gacela_SDL_MapRGB); scm_c_define_gsubr ("SDL_SetColorKey", 3, 0, 0, gacela_SDL_SetColorKey); scm_c_define_gsubr ("SDL_SetAlpha", 3, 0, 0, gacela_SDL_SetAlpha); diff --git a/src/gacela_draw.scm b/src/gacela_draw.scm index 5fbc92e..5290dc4 100644 --- a/src/gacela_draw.scm +++ b/src/gacela_draw.scm @@ -59,11 +59,16 @@ (cond ((3d-mode?) (glVertex3f x y z)) (else (glVertex2f x y)))) -(define (load-image-for-texture filename) +(define (load-image filename) (init-sdl) (let ((image (IMG_Load filename))) (cond (image - (SDL_SetAlpha image 0 0) + (SDL_DisplayFormatAlpha image))))) + +(define (load-image-for-texture filename) + (init-sdl) + (let ((image (load-image filename))) + (cond (image (let* ((width (surface-w image)) (height (surface-h image)) (power-2 (nearest-power-of-two (min width height))) (resized-image #f)) @@ -86,12 +91,12 @@ (cond (image (let ((width (surface-w image)) (height (surface-h image)) (byteorder (if (= SDL_BYTEORDER SDL_LIL_ENDIAN) - (if (= (surface-format-BytesPerPixel image) 3) GL_RGB GL_RGBA) - (if (= (surface-format-BytesPerPixel image) 3) GL_BGR GL_BGRA))) + (if (= (surface-format-BytesPerPixel image) 3) GL_BGR GL_BGRA) + (if (= (surface-format-BytesPerPixel image) 3) GL_RGB GL_RGBA))) (texture (car (glGenTextures 1)))) (glBindTexture GL_TEXTURE_2D texture) - (glTexImage2D GL_TEXTURE_2D 0 3 width height 0 byteorder GL_UNSIGNED_BYTE (surface-pixels image)) + (glTexImage2D GL_TEXTURE_2D 0 4 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) (set-texture-size! texture real-w real-h)