~pixelherodev/c3lib

ref: cf043f76c476ce0ff7369897e0800b65babde9fb c3lib/design/glsl.roff -rw-r--r-- 762 bytes
cf043f76Noam Preil add glsl doc 2 months ago
                                                                                
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
.so shared.roff
GLSL AST ideas

.sh
Preliminary design

.pg
Given the following input:

.cd
#version 460 core
out vec4 oColor;
void main()
{
    // set output color to white
    oColor = vec4(1);
}
.ec

.pg
The following AST is produced by the frontend:

.cd
STRUCT{
	DECL{
		"glsl_outputs"
		STRUCT{
			FIELD{
				"oColor"
				VECTOR{
					4
					FLOAT
				}
			}
		}
	}
	EXPORT{
		"c" // C ABI
		"glsl_main" // or some other name
		DECL{
			"main"
			FUNCTION{
				FNTYPE{
					BOOL
					PARAM{
						"glsl_outputs"
						PTR{[[glsl_outputs]]} // pointer to a value whose type is the decl from above
				}
				BLOCK{
					ASSIGNMENT{
						FIELD_LOOKUP{
							IDENT{"glsl_outputs"}
							"oColor"
						}
						
					}
					RETURN{1}
				}
			}
		}
	}
}
.ec