summaryrefslogtreecommitdiff
path: root/chickadee/graphics/depth-stencil.scm
diff options
context:
space:
mode:
Diffstat (limited to 'chickadee/graphics/depth-stencil.scm')
-rw-r--r--chickadee/graphics/depth-stencil.scm137
1 files changed, 137 insertions, 0 deletions
diff --git a/chickadee/graphics/depth-stencil.scm b/chickadee/graphics/depth-stencil.scm
new file mode 100644
index 0000000..a3fac63
--- /dev/null
+++ b/chickadee/graphics/depth-stencil.scm
@@ -0,0 +1,137 @@
+;;; Chickadee Game Toolkit
+;;; Copyright © 2023 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary
+;;
+;; Depth/stencil buffer configuration.
+;;
+;;; Code:
+
+(define-module (chickadee graphics depth-stencil)
+ #:use-module (ice-9 match)
+ #:use-module (srfi srfi-9)
+ #:export (<stencil-face>
+ make-stencil-face
+ stencil-face?
+ stencil-face-compare
+ stencil-face-fail-op
+ stencil-face-depth-fail-op
+ stencil-face-pass-op
+
+ <depth-test>
+ make-depth-test
+ depth-test
+ depth-test-compare
+ depth-test-write?
+
+ <depth+stencil>
+ make-depth+stencil
+ depth+stencil?
+ depth+stencil-format
+ depth+stencil-depth-write-enabled?
+ depth+stencil-compare-function
+ depth+stencil-stencil-front
+ depth+stencil-stencil-back
+ depth+stencil-stencil-read-mask
+ depth+stencil-stencil-write-mask
+
+ <depth-operation>
+ make-depth-operation
+ depth-operation?
+ depth-operation-clear-value
+ depth-operation-load-op
+ depth-operation-store-op
+ depth-operation-read-only?
+
+ <stencil-operation>
+ make-stencil-operation
+ stencil-operation?
+ stencil-operation-clear-value
+ stencil-operation-load-op
+ stencil-operation-store-op
+ stencil-operation-read-only?))
+
+(define-record-type <stencil-face>
+ (%make-stencil-face compare fail-op depth-fail-op pass-op)
+ stencil-face?
+ (compare stencil-face-compare)
+ (fail-op stencil-face-fail-op)
+ (depth-fail-op stencil-face-depth-fail-op)
+ (pass-op stencil-face-pass-op))
+
+(define* (make-stencil-face #:key (compare 'always) (fail-op 'keep)
+ (depth-fail-op 'keep) (pass-op 'keep))
+ (%make-stencil-face compare fail-op depth-fail-op pass-op))
+
+(define-record-type <depth-test>
+ (%make-depth-test compare write?)
+ depth-test?
+ (compare depth-test-compare)
+ (write? depth-test-write?))
+
+(define* (make-depth-test #:key (compare 'less) write?)
+ (%make-depth-test compare write?))
+
+(define-record-type <depth+stencil>
+ (%make-depth+stencil format depth-test stencil-front
+ stencil-back stencil-read-mask stencil-write-mask)
+ depth+stencil?
+ (format depth+stencil-format)
+ (depth-test depth+stencil-depth-test)
+ (stencil-front depth+stencil-stencil-front)
+ (stencil-back depth+stencil-stencil-back)
+ (stencil-read-mask depth+stencil-stencil-read-mask)
+ (stencil-write-mask depth+stencil-stencil-write-mask))
+
+(define* (make-depth+stencil #:key
+ (format 'depth24plus-stencil8)
+ depth-test
+ stencil-face
+ (stencil-front stencil-face)
+ (stencil-back stencil-face)
+ (stencil-read-mask #xffffFFFF)
+ (stencil-write-mask #xffffFFFF))
+ (%make-depth+stencil format depth-test stencil-front
+ stencil-back stencil-read-mask stencil-write-mask))
+
+(define-record-type <depth-operation>
+ (%make-depth-operation clear-value load-op store-op read-only?)
+ depth-operation?
+ (clear-value depth-operation-clear-value)
+ (load-op depth-operation-load-op)
+ (store-op depth-operation-store-op)
+ (read-only? depth-operation-read-only?))
+
+(define* (make-depth-operation #:key
+ (clear-value 0.0)
+ (load-op 'clear)
+ (store-op 'store)
+ read-only?)
+ (%make-depth-operation clear-value load-op store-op read-only?))
+
+(define-record-type <stencil-operation>
+ (%make-stencil-operation clear-value load-op store-op read-only?)
+ stencil-operation?
+ (clear-value stencil-operation-clear-value)
+ (load-op stencil-operation-load-op)
+ (store-op stencil-operation-store-op)
+ (read-only? stencil-operation-read-only?))
+
+(define* (make-stencil-operation #:key
+ (clear-value #x00000000)
+ (load-op 'clear)
+ (store-op 'store)
+ read-only?)
+ (%make-stencil-operation clear-value load-op store-op read-only?))