I'm following a tutorial and I want to clamp all position values of a triangle between 0 and 1 then output them as a color
this is the code for my vertex shader:
#version 330
layout (location = 0) in vec3 pos;
out vec4 vCol;
uniform mat4 model;
void main(){
gl_Position = model * vec4(pos, 1.0);
vCol = vec4(clamp(pos, 0.0f, 1.0f) 1.0f);
}
and this is the code for my fragment shader:
#version 330
in vec4 vCol;
out vec4 color;
void main(){
color = vCol;
}
these are coordinates of my shape, which is a triangle (the values that are going to be clamped):
GLfloat vertices[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f
};