--- /dev/null
+;;; Gacela, a GNU Guile extension for fast games development
+;;; Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
+;;;
+;;; 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 <http://www.gnu.org/licenses/>.
+
+
+(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))))
(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)
with-color
progn-textures
draw
- load-image
- resize-surface
load-texture
draw-texture
draw-line
(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 ()
(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))