From 556fd6c80969ab9a474f2c66ae1aceec3866f16a Mon Sep 17 00:00:00 2001 From: jsancho Date: Tue, 16 Aug 2011 19:20:58 +0000 Subject: [PATCH] --- src/gacela.scm | 3 ++- src/gacela_GL.c | 1 + src/gacela_SDL.c | 7 +++++++ src/gacela_draw.scm | 5 +++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gacela.scm b/src/gacela.scm index 6a0b501..dba48e6 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -114,8 +114,9 @@ (glClearColor 0 0 0 0) ; (glClearDepth 1) ; (glDepthFunc GL_LEQUAL) -; (glEnable GL_BLEND) + (glEnable GL_BLEND) ; (glBlendFunc GL_SRC_ALPHA GL_ONE) + (glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA) (glHint GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST) #t) diff --git a/src/gacela_GL.c b/src/gacela_GL.c index da64a2e..541e4ab 100644 --- a/src/gacela_GL.c +++ b/src/gacela_GL.c @@ -417,6 +417,7 @@ GL_register_functions (void* data) // Blending scm_c_define ("GL_BLEND", scm_from_int (GL_BLEND)); scm_c_define ("GL_ONE", scm_from_int (GL_ONE)); + scm_c_define ("GL_ONE_MINUS_SRC_ALPHA", scm_from_int (GL_ONE_MINUS_SRC_ALPHA)); scm_c_define ("GL_SRC_ALPHA", scm_from_int (GL_SRC_ALPHA)); // Fog diff --git a/src/gacela_SDL.c b/src/gacela_SDL.c index 7977444..f7f4151 100644 --- a/src/gacela_SDL.c +++ b/src/gacela_SDL.c @@ -214,6 +214,12 @@ gacela_SDL_SetColorKey (SCM surface, SCM flag, SCM key) return scm_from_int (SDL_SetColorKey (get_surface_address (surface), scm_to_int (flag), scm_to_int (key))); } +SCM +gacela_SDL_SetAlpha (SCM surface, SCM flag, SCM alpha) +{ + return scm_from_int (SDL_SetAlpha (get_surface_address (surface), scm_to_int (flag), scm_to_int (alpha))); +} + SCM gacela_SDL_LoadBMP (SCM file) { @@ -479,6 +485,7 @@ SDL_register_functions (void* data) scm_c_define_gsubr ("SDL_DisplayFormat", 1, 0, 0, gacela_SDL_DisplayFormat); 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); scm_c_define_gsubr ("SDL_LoadBMP", 1, 0, 0, gacela_SDL_LoadBMP); scm_c_define_gsubr ("IMG_Load", 1, 0, 0, gacela_IMG_Load); scm_c_define_gsubr ("SDL_GetVideoInfo", 0, 0, 0, gacela_SDL_GetVideoInfo); diff --git a/src/gacela_draw.scm b/src/gacela_draw.scm index 184eba2..5fbc92e 100644 --- a/src/gacela_draw.scm +++ b/src/gacela_draw.scm @@ -63,6 +63,7 @@ (init-sdl) (let ((image (IMG_Load filename))) (cond (image + (SDL_SetAlpha image 0 0) (let* ((width (surface-w image)) (height (surface-h image)) (power-2 (nearest-power-of-two (min width height))) (resized-image #f)) @@ -85,8 +86,8 @@ (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_BGR GL_BGRA) - (if (= (surface-format-BytesPerPixel image) 3) GL_RGB GL_RGBA))) + (if (= (surface-format-BytesPerPixel image) 3) GL_RGB GL_RGBA) + (if (= (surface-format-BytesPerPixel image) 3) GL_BGR GL_BGRA))) (texture (car (glGenTextures 1)))) (glBindTexture GL_TEXTURE_2D texture) -- 2.39.2