summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-09-14 09:00:13 -0400
committerDavid Thompson <dthompson2@worcester.edu>2023-11-08 21:35:34 -0500
commit5c6c61f5750ad0dc798ae4c3ca5d19d9b25551cc (patch)
treed9075b4bc7f717bf25f241ad7f0ef72f88d39c24
parent084d356d75f4deb28a5dfdebe769de20a4969005 (diff)
graphics: Factor out GL calls in (chickadee) module.
-rw-r--r--chickadee.scm9
-rw-r--r--chickadee/graphics/gpu.scm16
2 files changed, 14 insertions, 11 deletions
diff --git a/chickadee.scm b/chickadee.scm
index 88928e1..0f04767 100644
--- a/chickadee.scm
+++ b/chickadee.scm
@@ -31,8 +31,6 @@
#:use-module (chickadee graphics gpu)
#:use-module (chickadee graphics viewport)
#:use-module (chickadee utils)
- #:use-module (gl)
- #:use-module (gl enums)
#:use-module (ice-9 atomic)
#:use-module (ice-9 match)
#:use-module (sdl2)
@@ -422,6 +420,9 @@ border is disabled, otherwise it is enabled.")
(graphics-engine-gc gfx))
(define (render-sdl-opengl alpha)
(graphics-engine-reset! gfx)
+ ;; Enable seamless cube maps.
+ ;; TODO: This should go somewhere else.
+ (set-gpu-seamless-cube-maps! (current-gpu) #t)
(with-viewport (vector-ref default-viewport 0)
(clear-viewport)
(with-graphics-state ((projection (vector-ref default-projection 0)))
@@ -445,10 +446,6 @@ border is disabled, otherwise it is enabled.")
(lambda args
(display "warning: could not enable vsync\n"
(current-error-port))))
- ;; Turn off multisampling by default.
- (gl-disable (version-1-3 multisample))
- ;; Enable seamless cube maps.
- (gl-enable (version-3-2 texture-cube-map-seamless))
(sdl2:load-game-controller-mappings!
(scope-datadir "gamecontrollerdb.txt"))
(run-game* #:init load
diff --git a/chickadee/graphics/gpu.scm b/chickadee/graphics/gpu.scm
index 3832256..44ffa7b 100644
--- a/chickadee/graphics/gpu.scm
+++ b/chickadee/graphics/gpu.scm
@@ -187,6 +187,7 @@
gpu-stencil-test
gpu-scissor-test
gpu-multisample?
+ gpu-seamless-cube-maps?
gpu-viewport
gpu-clear-color
gpu-framebuffer
@@ -204,6 +205,7 @@
set-gpu-stencil-test!
set-gpu-scissor-test!
set-gpu-multisample!
+ set-gpu-seamless-cube-maps!
set-gpu-viewport!
set-gpu-clear-color!
set-gpu-framebuffer!
@@ -678,6 +680,11 @@
(gl-enable (version-1-3 multisample))
(gl-disable (version-1-3 multisample))))
+(define (bind-seamless-cube-maps seamless-cube-maps?)
+ (if seamless-cube-maps?
+ (gl-enable (version-3-2 texture-cube-map-seamless))
+ (gl-disable (version-3-2 texture-cube-map-seamless))))
+
(define (bind-clear-color color)
(gl-clear-color (color-r color)
(color-g color)
@@ -844,6 +851,7 @@
(viewport gpu-viewport %set-gpu-viewport!)
(clear-color gpu-clear-color %set-gpu-clear-color!)
(multisample? gpu-multisample? %set-gpu-multisample!)
+ (seamless-cube-maps! gpu-seamless-cube-maps? %set-gpu-seamless-cube-maps!)
(framebuffer gpu-framebuffer %set-gpu-framebuffer!)
(renderbuffer gpu-renderbuffer %set-gpu-renderbuffer!)
(buffer gpu-buffer %set-gpu-buffer!)
@@ -901,6 +909,8 @@
%set-gpu-clear-color! gpu-clear-color bind-clear-color equal?)
(define-gpu-setter set-gpu-multisample!
%set-gpu-multisample! gpu-multisample? bind-multisample eq?)
+(define-gpu-setter set-gpu-seamless-cube-maps!
+ %set-gpu-seamless-cube-maps! gpu-seamless-cube-maps? bind-seamless-cube-maps eq?)
(define-gpu-setter set-gpu-framebuffer!
%set-gpu-framebuffer! gpu-framebuffer bind-gpu-framebuffer eq?)
(define-gpu-setter set-gpu-renderbuffer!
@@ -979,6 +989,7 @@
(set-gpu-viewport! gpu window-rect:empty)
(set-gpu-clear-color! gpu black)
(set-gpu-multisample! gpu #f)
+ (set-gpu-seamless-cube-maps! gpu #f)
(set-gpu-framebuffer! gpu gpu-framebuffer:null)
(set-gpu-renderbuffer! gpu gpu-renderbuffer:null)
(set-gpu-buffer! gpu gpu-buffer:null)
@@ -990,11 +1001,6 @@
(set-gpu-texture! gpu i gpu-texture:null)
(loop (+ i 1))))))
-
-;;;
-;;; Accessors
-;;;
-
(define (set-gpu-texture-min-filter! gpu texture filter)
(set-gpu-texture! gpu 0 texture)
(set-active-texture-unit! 0)