From: Javier Sancho Date: Mon, 24 Apr 2017 18:11:11 +0000 (+0200) Subject: Keep SDL context open X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=db983f855772fcc138c84b5772a41b1a737f4e47;p=gacela.git Keep SDL context open --- diff --git a/gacela/game.scm b/gacela/game.scm index 326db78..fc0e135 100644 --- a/gacela/game.scm +++ b/gacela/game.scm @@ -137,15 +137,16 @@ milliseconds of the last iteration of the game loop." (define %gl-context #f) (define (init-window) - (sdl2:sdl-init) - (sdl2:set-gl-attribute! 'context-major-version 3) - (sdl2:set-gl-attribute! 'context-minor-version 2) - (sdl2:set-gl-attribute! 'double-buffer 1) - (sdl2:set-gl-attribute! 'depth-size 24) - (set! %sdl-window (sdl2:make-window #:opengl? #t #:show? #t)) - (set! %sdl-renderer (sdl2:make-renderer %sdl-window)) - (set! %gl-context (sdl2:make-gl-context %sdl-window)) - (sdl2:set-gl-swap-interval! 'vsync) + (when (not %sdl-window) + (sdl2:sdl-init) + (sdl2:set-gl-attribute! 'context-major-version 3) + (sdl2:set-gl-attribute! 'context-minor-version 2) + (sdl2:set-gl-attribute! 'double-buffer 1) + (sdl2:set-gl-attribute! 'depth-size 24) + (set! %sdl-window (sdl2:make-window #:opengl? #t #:show? #t)) + (set! %sdl-renderer (sdl2:make-renderer %sdl-window)) + (set! %gl-context (sdl2:make-gl-context %sdl-window)) + (sdl2:set-gl-swap-interval! 'vsync)) (init-gl)) (define (init-gl) @@ -162,8 +163,7 @@ milliseconds of the last iteration of the game loop." (sdl2:show-window! %sdl-window)) (define (close-window) - (sdl2:hide-window! %sdl-window) - (sdl2:sdl-quit)) + (sdl2:hide-window! %sdl-window)) (define (resize-window width height) (gl-viewport 0 0 width height)