(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)
(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)