v / examples / sokol / 07_simple_shader_glsl / simple_shader.glsl
36 lines · 29 sloc · 941 bytes · 22744ce49534014d3a754916deab11afb803fb66
Raw
1// The following defines a vertex shader main function
2@vs vs
3in vec4 position;
4in vec4 color0;
5
6out vec4 color;
7
8// You can add more functions here
9
10void main() {
11 gl_Position = position;
12 color = color0;
13}
14@end
15
16// The following defines a fragment shader main function
17@fs fs
18in vec4 color;
19out vec4 frag_color;
20
21// You can add more functions here
22
23void main() {
24 frag_color = color;
25}
26@end
27
28// The value after `@program` and before `vs fs` decide a part of the name
29// of the C function you need to define in V. The value entered is suffixed `_shader_desc`
30// in the generated C code. Thus the name for this becomes: `simple_shader_desc`.
31// In V it's signature then need to be defined as:
32// `fn C.simple_shader_desc(gfx.Backend) &gfx.ShaderDesc`. See `simple_shader.v` for the define.
33//
34// Running `v shader -v .` in this dir will also show you brief information
35// about how to use the compiled shader.
36@program simple vs fs
37