-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdepth_program.cpp
More file actions
31 lines (27 loc) · 834 Bytes
/
depth_program.cpp
File metadata and controls
31 lines (27 loc) · 834 Bytes
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
#include "depth_program.hpp"
#include "compile_program.hpp"
DepthProgram::DepthProgram() {
program = compile_program(
"#version 330\n"
"uniform mat4 object_to_clip;\n"
"layout(location=0) in vec4 Position;\n" //note: layout keyword used to make sure that the location-0 attribute is always bound to something
"in vec3 Normal;\n" //DEBUG
"out vec3 color;\n" //DEBUG
"void main() {\n"
" gl_Position = object_to_clip * Position;\n"
" color = 0.5 + 0.5 * Normal;\n" //DEBUG
"}\n"
,
"#version 330\n"
"in vec3 color;\n" //DEBUG
//"uniform vec4 color;\n"
"out vec4 fragColor;\n"
"void main() {\n"
" fragColor = vec4(color, 1.0);\n"
"}\n"
);
object_to_clip_mat4 = glGetUniformLocation(program, "object_to_clip");
}
Load< DepthProgram > depth_program(LoadTagInit, [](){
return new DepthProgram();
});