Debian Codegraph @

examples/book/glarea/shaders.h

raw
1 /* gtkmm example Copyright (C) 2025 gtkmm development team
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #ifndef GTKMM_EXAMPLE_SHADERS_H
18 #define GTKMM_EXAMPLE_SHADERS_H
19
20 // GLSL shaders as string literals
21 const char* VERTEX_SHADER_SRC = R"(
22 #version 130
23 in vec4 in_position;
24 in vec4 in_color;
25 out vec4 v_color;
26 uniform mat4 mvp;
27
28 void main() {
29 gl_Position = mvp * in_position;
30 v_color = in_color;
31 }
32 )";
33
34 const char* FRAGMENT_SHADER_SRC = R"(
35 #version 130
36 in vec4 v_color;
37 out vec4 frag_color;
38 uniform bool use_vertex_color;
39 uniform vec4 line_color_uniform;
40
41 void main() {
42 if (use_vertex_color) {
43 frag_color = v_color;
44 } else {
45 frag_color = line_color_uniform;
46 }
47 }
48 )";
49
50 #endif // GTKMM_EXAMPLE_SHADERS_H