-
Notifications
You must be signed in to change notification settings - Fork 0
/
shaders.h
75 lines (67 loc) · 2.06 KB
/
shaders.h
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
//
// Created by octopus on 10/27/16.
//
#ifndef OGL_PLAYGROUND_SHADERS_H_H
#define OGL_PLAYGROUND_SHADERS_H_H
namespace shaders {
const GLchar * vertex_shader = "#version 330 core\n"
" \n"
"layout (location = 0) in vec3 position;\n"
"out vec3 vcolor;\n"
"\n"
"void main()\n"
"{\n"
" gl_Position = vec4(position.x, position.y, position.z, 1.0);\n"
" vcolor = gl_Position.xyz;\n"
"}\n\0";
const GLchar * fragment_shader = "#version 330 core\n"
"\n"
"out vec4 color;\n"
"in vec3 vcolor;\n"
"\n"
"void main()\n"
"{\n"
" color = vec4(vcolor.x, vcolor.y, vcolor.z, 0.5f);\n"
"}\n\0";
const GLchar * fragment_shader_niceGray = "#version 330 core\n"
"\n"
"out vec4 color;\n"
"\n"
"void main()\n"
"{\n"
" color = vec4(0.1f, 0.5f, 0.1f, 1.0f);\n"
"}\n\0";
const GLchar * vertex_for_texture = ""
"#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
"layout (location = 1) in vec3 aColor;\n"
"layout (location = 2) in vec2 aTexCoord;\n"
"\n"
"out vec3 ourColor;\n"
"out vec2 TexCoord;\n"
"uniform mat4 model1;\n"
"uniform mat4 model2;\n"
"uniform mat4 view;\n"
"uniform mat4 projection;\n"
"\n"
"void main()\n"
"{\n"
" gl_Position = projection * view * model1 * model2 * vec4(aPos, 1.0);\n"
" ourColor = aColor;\n"
" TexCoord = aTexCoord;\n"
"}\n\0";
const GLchar * fragment_for_texture = "\n"
"#version 330 core\n"
"out vec4 FragColor;\n"
" \n"
"in vec3 ourColor;\n"
"in vec2 TexCoord;\n"
"\n"
"uniform sampler2D ourTexture;\n"
"\n"
"void main()\n"
"{\n"
" FragColor = texture(ourTexture, TexCoord);\n"
"}\n\0";
}
#endif //OGL_PLAYGROUND_SHADERS_H_H