I'm learning GLSL tessellation and wrote a program to tessellate a triangle. I use glPatchparameterfv
to specify inner and outer tessellation level, so no tessellation control shader is used. The problem is nothing shows up after tessellation shader is added. I checked that no errors are generated during glLinkProgram
. However, I do get 'GL_INVALID_OPERATION' every time the rendering loop is executed.
Here is the relevant code
float innerLevel[] = {5};
float outerLevel[] = {3, 3, 3};
glPatchParameterfv(GL_PATCH_DEFAULT_OUTER_LEVEL, outerLevel);
glPatchParameterfv(GL_PATCH_DEFAULT_INNER_LEVEL, innerLevel);
My vertex shader:
layout(location=0) in vec4 Position;
out vec3 vPos;
void main() {
vPos = Position.xyz;
}
Tessellation evaluation shader:
layout(triangles, equal_spacing, ccw) in;
in vec3 vPos[];
out vec3 tePos;
uniform mat4 MVP;
void main() {
tePos = gl_TessCoord.x * vPos[0] + gl_TessCoord.y * vPos[1] + gl_TessCoord.z * vPos[2];
gl_Position = MVP * vec4(tePos, 1.0);
}
Fragment shader:
uniform vec4 Diffuse;
void main() {
gl_FragColor = Diffuse;
}