From: jsancho Date: Thu, 16 Jun 2011 16:57:18 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=141a622804c650ab7e2b61ecc3af87c4be6495c5;p=gacela.git --- diff --git a/Makefile b/Makefile index e8951dd..70014bc 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,7 @@ INSTALL_SCRIPT = ${INSTALL} INSTALL_STRIP_PROGRAM = $(install_sh) -c -s LDFLAGS = LIBOBJS = -LIBS = -lSDL -lSDL_image -lSDL_mixer -lGL -lGLU -lftgl +LIBS = -lSDL -lSDL_image -lSDL_gfx -lSDL_mixer -lGL -lGLU -lftgl LTLIBOBJS = MAKEINFO = ${SHELL} /home/jsancho/proyectos/guile/missing --run makeinfo MKDIR_P = /bin/mkdir -p diff --git a/configure.ac b/configure.ac index b86920c..92b9bdb 100644 --- a/configure.ac +++ b/configure.ac @@ -13,6 +13,11 @@ AC_CHECK_LIB(SDL_image, LIBS="$LIBS -lSDL_image", AC_MSG_ERROR([*** SDL_image library not found!]) ) +AC_CHECK_LIB(SDL_gfx, + main, + LIBS="$LIBS -lSDL_gfx", + AC_MSG_ERROR([*** SDL_gfx library not found!]) +) AC_CHECK_LIB(SDL_mixer, main, LIBS="$LIBS -lSDL_mixer", diff --git a/src/gacela_GL.c b/src/gacela_GL.c index a031dba..7e232bb 100644 --- a/src/gacela_GL.c +++ b/src/gacela_GL.c @@ -235,7 +235,7 @@ gacela_glGenTextures (SCM n) glGenTextures (nint, &text[0]); for (i = nint - 1; i >= 0; i--) { - textures = scm_cons (scm_from_int (text[i]), textures); + textures = scm_cons (make_glTexture (text[i]), textures); } return textures; diff --git a/src/gacela_SDL.c b/src/gacela_SDL.c index ce2f2cc..ba47328 100644 --- a/src/gacela_SDL.c +++ b/src/gacela_SDL.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "gacela_SDL.h" struct surface @@ -59,6 +60,16 @@ get_surface_address (SCM surface_smob) return surface->surface_address; } +SCM +get_surface_filename (SCM surface_smob) +{ + struct surface *surface; + + scm_assert_smob_type (surface_tag, surface_smob); + surface = (struct surface *) SCM_SMOB_DATA (surface_smob); + return surface->filename; +} + SCM get_surface_width (SCM surface_smob) { @@ -278,6 +289,19 @@ gacela_SDL_EnableKeyRepeat (SCM delay, SCM interval) return scm_from_int (SDL_EnableKeyRepeat (scm_to_int (delay), scm_to_int (interval))); } +SCM +gacela_zoomSurface (SCM src, SCM zoomx, SCM zoomy, SCM smooth) +{ + SDL_Surface *image = zoomSurface (get_surface_address (src), scm_to_double (zoomx), scm_to_double (zoomy), scm_to_int (smooth)); + + if (image) { + return make_surface (get_surface_filename (src), image); + } + else { + return SCM_BOOL_F; + } +} + SCM gacela_Mix_OpenAudio (SCM frequency, SCM format, SCM channels, SCM chunksize) { @@ -369,6 +393,7 @@ SDL_register_functions (void* data) scm_set_smob_mark (surface_tag, mark_surface); scm_set_smob_free (surface_tag, free_surface); scm_set_smob_print (surface_tag, print_surface); + scm_c_define_gsubr ("surface-file", 1, 0, 0, get_surface_filename); 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); @@ -454,6 +479,7 @@ SDL_register_functions (void* data) scm_c_define_gsubr ("SDL_PollEvent", 0, 0, 0, gacela_SDL_PollEvent); scm_c_define_gsubr ("SDL_GL_SwapBuffers", 0, 0, 0, gacela_SDL_GL_SwapBuffers); scm_c_define_gsubr ("SDL_EnableKeyRepeat", 2, 0, 0, gacela_SDL_EnableKeyRepeat); + scm_c_define_gsubr ("zoomSurface", 4, 0, 0, gacela_zoomSurface); scm_c_define_gsubr ("Mix_OpenAudio", 4, 0, 0, gacela_Mix_OpenAudio); scm_c_define_gsubr ("Mix_LoadMUS", 1, 0, 0, gacela_Mix_LoadMUS); scm_c_define_gsubr ("Mix_LoadWAV", 1, 0, 0, gacela_Mix_LoadWAV); diff --git a/src/gacela_draw.scm b/src/gacela_draw.scm index c30d25e..1964735 100644 --- a/src/gacela_draw.scm +++ b/src/gacela_draw.scm @@ -26,12 +26,12 @@ (else `(begin ,@code)))) (define-macro (progn-textures . code) - `(let (values) + `(let ((result #f)) (init-video-mode) (glEnable GL_TEXTURE_2D) - (set! values (multiple-value-list (begin ,@code))) + (set! result (begin ,@code)) (glDisable GL_TEXTURE_2D) - (apply values values))) + result)) (define (draw . vertexes) (begin-draw (length vertexes)) @@ -68,7 +68,9 @@ (resized-image #f)) (cond ((and (= width power-2) (= height power-2)) (values image width height)) (else (set! resized-image (resize-surface image power-2 power-2)) - (if resized-image (values resized-image width height))))))))) + (if resized-image (values resized-image width height)))))) + (else + (values #f 0 0))))) (define (resize-surface surface width height) (let ((old-width (surface-w surface)) (old-height (surface-h surface))) @@ -81,8 +83,8 @@ (receive (image real-w real-h) (load-image-for-texture filename) (cond (image - (let ((width (get-surface-width image)) (height (get-surface-height image)) - (byteorder (if (= (SDL_ByteOrder) SDL_LIL_ENDIAN) + (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))) (texture (car (glGenTextures 1)))) diff --git a/src/gacela_mobs.scm b/src/gacela_mobs.scm index c937178..cbeb721 100755 --- a/src/gacela_mobs.scm +++ b/src/gacela_mobs.scm @@ -63,18 +63,18 @@ (let ((line (car look))) (receive (lines images) (process-look (cdr look)) (cond ((string? line) - (values (cons `(draw-texture ,line) lines) - (cons line images))) + (let ((var (gensym))) + (values (cons `(draw-texture ,var) lines) + (cons `(,var (load-texture ,line)) images)))) (else (values (cons line lines) images)))))))) (receive (look-lines look-images) (process-look look) - `(let ((attr ',attr)) + `(let ,(cons `(attr ',attr) look-images) (lambda (option) (case option ((#:render) (glPushMatrix) ,@look-lines -; ,@(map (lambda (x) (if (string? x) `(draw-texture ,x) x)) look) (glPopMatrix)))))))