View Full Version : Using Transform Feedback with glDrawElements?

04-15-2013, 10:41 AM
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. :)

Alfonse Reinheart
04-15-2013, 04:52 PM
It's hard to know what the problem is without seeing your code.

04-16-2013, 03:39 AM
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.

04-16-2013, 04:05 AM
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. point mode

layout(..., point_mode) in;