0

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;
}
user11869
  • 1,083
  • 2
  • 14
  • 29
  • Is it okay to pass a 3 element array for outer levels and 1 element array for inner to `glPatchParameterfv (...)`? GL defines 4 outer levels and 2 inner. While in triangles mode only the first 3 outer and first inner are used, but I would imagine the API call always expects 4 and 2 element arrays and potentially overruns the array's allocated memory because of this. I would use { 5, -1 } and { 3, 3, 3, -1 } just to be on the safe side. – Andon M. Coleman Oct 12 '13 at 04:54
  • Does the shader info log for your compiled tess eval shader have anything to report? Since this is an optional stage, you can successfully link a program without a valid tessellation evaluation shader. Also since your vertex shader does not write to the default vertex output `gl_Position`, you can see why removing or forgetting to attach the tessellation evaluation stage to your program will cause nothing to be output. – Andon M. Coleman Oct 12 '13 at 05:14
  • I think passing 3 element array for outer levels and 1 element array for inner is fine because apitrace shows that the driver converts them to 4 element and 2 element arrays respectively. I'll try what you suggested – user11869 Oct 12 '13 at 22:13

0 Answers0