From aa45ad29efab50318d38bfd096b07021c4c7bde6 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 21 Jan 2021 19:29:46 -0500 Subject: graphics: Rewrite rendering engine. --- chickadee.scm | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'chickadee.scm') diff --git a/chickadee.scm b/chickadee.scm index 3b6d6fd..82eb1b4 100644 --- a/chickadee.scm +++ b/chickadee.scm @@ -1,5 +1,5 @@ ;;; Chickadee Game Toolkit -;;; Copyright © 2018 David Thompson +;;; Copyright © 2018, 2021 David Thompson ;;; Copyright © 2020 Peter Elliott ;;; ;;; Chickadee is free software: you can redistribute it and/or modify @@ -27,10 +27,9 @@ #:use-module (chickadee config) #:use-module (chickadee game-loop) #:use-module (chickadee math matrix) - #:use-module (chickadee graphics) #:use-module (chickadee graphics color) + #:use-module (chickadee graphics engine) #:use-module (chickadee graphics gl) - #:use-module (chickadee graphics gpu) #:use-module (chickadee graphics viewport) #:use-module (chickadee utils) #:use-module (gl) @@ -281,15 +280,11 @@ border is disabled, otherwise it is enabled.") #:height window-height #:fullscreen? window-fullscreen? #:multisample? #f))) - (gpu (make-gpu (window-gl-context window))) + (gfx (make-graphics-engine (window-gl-context window))) (default-viewport (make-viewport 0 0 window-width window-height)) (default-projection (orthographic-projection 0 window-width window-height 0 - 0 1)) - (clear-mask (logior (attrib-mask color-buffer) - (attrib-mask depth-buffer) - (attrib-mask stencil-buffer) - (attrib-mask accum-buffer)))) + 0 1))) (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. @@ -363,10 +358,10 @@ border is disabled, otherwise it is enabled.") ;; that were queued to play this frame start playing immediately. (update-audio) ;; Free any GPU resources that have been GC'd. - (gpu-reap! gpu)) + (graphics-engine-reap! gfx)) (define (render-sdl-opengl alpha) - (with-viewport default-viewport - (clear-screen) + (with-graphics-state! ((viewport default-viewport)) + (clear-viewport) (with-projection default-projection (draw alpha))) (sdl2:swap-gl-window (unwrap-window window))) @@ -374,7 +369,7 @@ border is disabled, otherwise it is enabled.") (const #t) (lambda () (parameterize ((current-window window) - (current-gpu gpu)) + (current-graphics-engine gfx)) ;; Attempt to activate vsync, if possible. Some systems do ;; not support setting the OpenGL swap interval. (catch #t -- cgit v1.2.3