From: jsancho Date: Fri, 17 Jun 2011 15:22:20 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=4ae3375d30bc921cb397feef4024c84ef29f9b74;p=gacela.git --- diff --git a/src/gacela.scm b/src/gacela.scm index 22228ae..26a1e9c 100644 --- a/src/gacela.scm +++ b/src/gacela.scm @@ -45,24 +45,26 @@ (define init-video-mode #f) (define video-mode-on? #f) (define resize-screen #f) -(define apply-mode-change #f) (define quit-video-mode #f) -(let ((screen #f) (flags 0) (current-width *width-screen*) (current-height *height-screen*) (current-bpp *bpp-screen*)) +(let ((screen #f) (flags 0)) (set! init-video-mode - (lambda* (#:optional (width current-width) (height current-height) (bpp current-bpp)) + (lambda () (cond ((not screen) (init-sdl) - (SDL_GL_SetAttribute SDL_GL_DOUBLEBUFFER 1) - (set! flags (+ SDL_OPENGL SDL_GL_DOUBLEBUFFER SDL_HWPALETTE SDL_RESIZABLE - (if (= (assoc-ref (SDL_GetVideoInfo) 'hw_available) 0) SDL_SWSURFACE SDL_HWSURFACE) - (if (= (assoc-ref (SDL_GetVideoInfo) 'blit_hw) 0) 0 SDL_HWACCEL))) - (set! screen (SDL_SetVideoMode width height bpp flags)) - (init-gl) - (resize-screen-GL width height) - (set! current-width width) - (set! current-height height) - (set! current-bpp bpp)) + (let* ((props (get-game-properties)) + (width (assoc-ref props 'width)) (height (assoc-ref props 'height)) + (bpp (assoc-ref props 'bpp)) (title (assoc-ref props 'title)) + (mode (assoc-ref props 'mode)) + (info (SDL_GetVideoInfo))) + (SDL_GL_SetAttribute SDL_GL_DOUBLEBUFFER 1) + (set! flags (+ SDL_OPENGL SDL_GL_DOUBLEBUFFER SDL_HWPALETTE SDL_RESIZABLE + (if (= (assoc-ref info 'hw_available) 0) SDL_SWSURFACE SDL_HWSURFACE) + (if (= (assoc-ref info 'blit_hw) 0) 0 SDL_HWACCEL))) + (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)))) (set! video-mode-on? @@ -71,12 +73,7 @@ (set! resize-screen (lambda* (width height #:optional (bpp current-bpp)) (cond (screen (set! screen (SDL_SetVideoMode width height bpp flags)) - (resize-screen-GL width height))) - (set! current-width width) - (set! current-height height))) - - (set! apply-mode-change - (lambda () (resize-screen-GL current-width current-height))) + (resize-screen-GL width height))))) (set! quit-video-mode (lambda () (set! screen #f)))) @@ -95,6 +92,11 @@ (glDepthFunc GL_LEQUAL) (apply-mode-change)))) +(define (apply-mode-change) + (let* ((props (get-game-properties)) + (width (assoc-ref props 'width)) (height (assoc-ref props 'height))) + (resize-screen-GL width height))) + (define (3d-mode?) (eq? (assoc-ref (get-game-properties) 'mode) '3d))