From: jsancho Date: Thu, 8 Dec 2011 18:06:43 +0000 (+0000) Subject: Gacela as Guile modules. X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=f222261d0c3d6670b2069f66311c9113133deb7c;p=gacela.git Gacela as Guile modules. --- diff --git a/src/audio.scm b/src/audio.scm new file mode 100644 index 0000000..41207f4 --- /dev/null +++ b/src/audio.scm @@ -0,0 +1,37 @@ +;;; Gacela, a GNU Guile extension for fast games development +;;; Copyright (C) 2009 by Javier Sancho Fernandez +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + + +(define-module (gacela audio) + #:use-module (gacela sdl) + #:export (init-audio + quit-audio)) + + +(define init-audio #f) +(define quit-audio #f) + +(let ((audio #f)) + (set! init-audio + (lambda () + (cond ((not audio) + (SDL_Init SDL_INIT_AUDIO) + (set! audio (Mix_OpenAudio 22050 MIX_DEFAULT_FORMAT 2 4096)))))) + + (set! quit-audio + (lambda () + (Mix_CloseAudio) + (set! audio #f)))) diff --git a/src/gacela.scm b/src/gacela.scm index 0de0b7b..a45337a 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -25,39 +25,23 @@ (define *mode* '2d) -;;; Audio Subsystem - -(define init-audio #f) -(define quit-audio #f) - -(let ((audio #f)) - (set! init-audio - (lambda () - (cond ((not audio) (begin (init-sdl) (set! audio (Mix_OpenAudio 22050 MIX_DEFAULT_FORMAT 2 4096)))) - (else audio)))) - - (set! quit-audio - (lambda () - (Mix_CloseAudio) - (set! audio #f)))) - - ;;; Resources Cache (define resources-cache (make-weak-value-hash-table)) -(define get-resource-from-cache #f) -(define insert-resource-into-cache #f) +(define from-cache #f) +(define into-cache #f) (let () - (set! get-resource-from-cache + (set! from-cache (lambda (key) (hash-ref resources-cache key))) - (set! insert-resource-into-cache + (set! into-cache (lambda (key res) (hash-set! resources-cache key res)))) + ;;; GaCeLa Functions (define set-frames-per-second #f) diff --git a/src/video.scm b/src/video.scm index d12e5ec..92d1ca8 100644 --- a/src/video.scm +++ b/src/video.scm @@ -37,8 +37,6 @@ with-color progn-textures draw - load-image - resize-surface load-texture draw-texture draw-line @@ -78,8 +76,7 @@ (set! screen (SDL_SetVideoMode width height bpp flags)) (SDL_WM_SetCaption title "") (init-gl) - (if (eq? mode '3d) (set-3d-mode) (set-2d-mode)))) - (else #t)))) + (if (eq? mode '3d) (set-3d-mode) (set-2d-mode))))))) (set! get-screen-height (lambda () @@ -222,7 +219,6 @@ (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))