From 5a885533855435d54359938bf163acde918d8149 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 6 Nov 2019 17:13:41 -0500 Subject: Clear the screen even when nothing is being drawn. --- chickadee.scm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/chickadee.scm b/chickadee.scm index 8250e19..0a9b0b3 100644 --- a/chickadee.scm +++ b/chickadee.scm @@ -31,6 +31,8 @@ #:use-module (chickadee render gpu) #:use-module (chickadee render viewport) #:use-module (chickadee utils) + #:use-module (gl) + #:use-module (gl enums) #:use-module (ice-9 match) #:use-module (sdl2) #:use-module (sdl2 events) @@ -237,7 +239,11 @@ border is disabled, otherwise it is enabled.") (default-viewport (make-viewport 0 0 window-width window-height)) (default-projection (orthographic-projection 0 window-width window-height 0 - 0 1))) + 0 1)) + (clear-mask (logior (attrib-mask color-buffer) + (attrib-mask depth-buffer) + (attrib-mask stencil-buffer) + (attrib-mask accum-buffer)))) (define (invert-y y) ;; SDL's origin is the top-left, but our origin is the bottom ;; left so we need to invert Y coordinates that SDL gives us. @@ -308,10 +314,9 @@ border is disabled, otherwise it is enabled.") ;; Free any GPU resources that have been GC'd. (gpu-reap!)) (define (render-sdl-opengl alpha) - ;; Switch to the null viewport to ensure that - ;; the default viewport will be re-applied and - ;; clear the screen. - (set-gpu-viewport! gpu null-viewport) + ;; Switch to the default viewport so we can clear the whole screen. + (set-gpu-viewport! gpu default-viewport) + (gl-clear clear-mask) (with-viewport default-viewport (with-projection default-projection (draw alpha))) -- cgit v1.2.3