1
0
Fork 0

add FrameBuffer Object

This commit is contained in:
MrDev023 2017-01-14 19:32:47 +01:00
parent 18bb7ab823
commit eda25cf2c9
7 changed files with 304 additions and 227 deletions

12
res/shaders/fbo.frag Normal file
View file

@ -0,0 +1,12 @@
#version 150
//Il ny a pas de layout(location=i) dans OpenGL < 3.3, mais tu peux utiliser glFragData[i] = myvalue à la place.
uniform sampler2D materialTex;
in vec2 fragTexCoord;
in vec3 fragVert;
out vec4 finalColor;
void main() {
finalColor = texture(materialTex, fragTexCoord);
}

18
res/shaders/fbo.vert Normal file
View file

@ -0,0 +1,18 @@
#version 150
uniform mat4 projection;
in vec3 vert;
in vec2 vertTexCoord;
out vec3 fragVert;
out vec2 fragTexCoord;
void main() {
// Pass some variables to the fragment shader
fragTexCoord = vertTexCoord;
fragVert = vert;
// Apply all matrix transformations to vert
gl_Position = projection * vec4(vert, 1);
}

View file

@ -1,12 +1,12 @@
#version 150
#version 330
//Il ny a pas de layout(location=i) dans OpenGL < 3.3, mais tu peux utiliser glFragData[i] = myvalue à la place.
uniform sampler2D materialTex;
uniform vec4 color;
in vec2 fragTexCoord;
in vec3 fragVert;
out vec4 finalColor;
layout(location = 0) out vec4 finalColor;
void main() {
finalColor = texture(materialTex, fragTexCoord) * color;