summaryrefslogtreecommitdiff
path: root/chickadee/graphics/layout.scm
blob: 04a42b09f0ac70dd4f472b9e1a180d9c2cf70742 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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))