Using Transform Feedback with glDrawElements?

Hi,
I want to use transform feedback to store the result of a tessellation shader. Secondly, I want to use glDrawElements, not glDrawArrays.

However, I always get an invalid_operation error when doing the drawing call.
I read that glDrawElements will produce this error if transform feedback is “not paused”.
Does this mean that I can’t combine the two at all? What’s the reason for this limitation?

I also noticed that I can’t find any examples where transform feedback is used with the GL_PATCHES mode (which is neccessary for tessellation), but I guess this is only because it’s a rather new feature and probably not the reason of my error. :confused:

Any hints appreciated. :slight_smile:

It’s hard to know what the problem is without seeing your code.

I didn’t want to post the full code because it’s spread over several methods and classes and it would have taken a lot of time to extract the actual OpenGL calls.
But it seems like I got it working now: I changed the mode from GL_PATCHES to GL_TRIANGLES in glBeginTransformFeedback() but still use GL_PATCHES for glDrawElements.

There is nothing special to consider when using GL_PATCHES. It’s the mandatory primitive type for vertex submission commands (gl[Multi]Draw*()) when tessellation is active. BTW, a patch is not really a primitive like a triangle or a line which can actually be rasterized. It’s simply an ordered list of vertices used as inputs for the tessellation control stage. The thing is, the type of primitive generated by the tessellation primitive generator is controlled by the input layout of the tessellation evaluation shader(TES)! So if you have something like this at the top of the TES

layout(triangles) in;

you know that the primitive generator spits out triangles after tessellating input patches. Furthermore, you know that this is automatically the output, possibly used in subsequent geometry shading, just as if you had called glDrawElements(GL_TRIANGLES, …) on some other data. The same goes for quads since they’re simply triangulated. I’m not sure if for isolines there will be line strips or multiple lines generated. Need to review the spec here. If you simply want points (as with GL_POINTS) you need to enable the s.c. [i]point mode

[/i]

layout(..., point_mode) in;

Actually I told you something which was incorrect:

This actually incorrect. GL_PATCHES is not mandatory when tessellation is active, it’s only usable when tessellation is active. Using GL_PATCHES without active tessellation stages is an error.