diff options
Diffstat (limited to 'chickadee/graphics/layout.scm')
-rw-r--r-- | chickadee/graphics/layout.scm | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/chickadee/graphics/layout.scm b/chickadee/graphics/layout.scm new file mode 100644 index 0000000..04a42b0 --- /dev/null +++ b/chickadee/graphics/layout.scm @@ -0,0 +1,102 @@ +;;; 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: +;; +;; Pipeline layout specifications. +;; +;;; Code: + +(define-module (chickadee graphics layout) + #:use-module (ice-9 match) + #:use-module (srfi srfi-9) + #:export (<vertex-attribute> + make-vertex-attribute + vertex-attribute? + vertex-attribute-format + vertex-attribute-offset + + <vertex-buffer-layout> + make-vertex-buffer-layout + vertex-buffer-layout? + vertex-buffer-layout-stride + vertex-buffer-layout-step-mode + vertex-buffer-layout-attributes + + <texture-layout> + make-texture-layout + texture-layout? + texture-layout-sample-type + texture-layout-dimension + texture-layout-multisample? + + <sampler-layout> + make-sampler-layout + sampler-layout? + sampler-layout-type + + <buffer-layout> + make-buffer-layout + buffer-layout? + buffer-layout-type + buffer-layout-min-size)) + +(define-record-type <vertex-attribute> + (%make-vertex-attribute format offset) + vertex-attribute? + (format vertex-attribute-format) + (offset vertex-attribute-offset)) + +(define* (make-vertex-attribute #:key format (offset 0)) + (%make-vertex-attribute format offset)) + +(define-record-type <vertex-buffer-layout> + (%make-vertex-buffer-layout stride step-mode attributes) + vertex-buffer-layout? + (stride vertex-buffer-layout-stride) + (step-mode vertex-buffer-layout-step-mode) + (attributes vertex-buffer-layout-attributes)) + +(define* (make-vertex-buffer-layout #:key stride (step-mode 'vertex) + (attributes #())) + (%make-vertex-buffer-layout stride step-mode attributes)) + +(define-record-type <texture-layout> + (%make-texture-layout sample-type dimension multisample?) + texture-layout? + (sample-type texture-layout-sample-type) + (dimension texture-layout-dimension) + (multisample? texture-layout-multisample?)) + +(define* (make-texture-layout #:key (sample-type 'float) (dimension '2d) + multisample?) + (%make-texture-layout sample-type dimension multisample?)) + +(define-record-type <sampler-layout> + (%make-sampler-layout type) + sampler-layout? + (type sampler-layout-type)) + +(define* (make-sampler-layout #:key (type 'filtering)) + (%make-sampler-layout type)) + +(define-record-type <buffer-layout> + (%make-buffer-layout type min-size) + buffer-layout? + (type buffer-layout-type) + (min-size buffer-layout-min-size)) + +(define* (make-buffer-layout #:key (type 'uniform) (min-size 0)) + (%make-buffer-layout type min-size)) |