Transform feedback and VAO + Indices

Hey, it seems, like i don't quite get how does TF interact with VAO's and GL_ELEMENT_ARRAY_BUFFER's. I try to make my animation system to work with transform feedback. So i have initial VAO1 containing all necessary attributes and i want to draw it with transform feedback enabled, outputting results into ARRAY_BUFFER, which is bound to another VAO2 used to finally draw.

So... When i draw animationOutputVAO with glDrawElements, i get just a mess of triangles. Any clues on what am i doing wrong? The problem is that couple of examples on TF i found are used for particles and they don't use neither VAO, nor element buffers, so i'm not sure how do i accomplish what i'm trying to do. So i'm resorting to forum and heavy documentation + source code googling.

Hey, it seems, like i don't quite get how does TF interact with VAO's and GL_ELEMENT_ARRAY_BUFFER's.

Separate TF from the latter two in your mind. TF is just another way to run the graphics pipeline.

VAOs capture all of the vertex array and element array bindings and enables within the VAO. The ELEMENT_ARRAY_BUFFER binding is one piece of information stored within a VAO. Bind a VAO and all of the bindings and enables stored within it are re-bound and re-enabled.

Search for the "vertex array object state" table in the OpenGL 4.4 Spec. You'll notice there there are no bindings here related to transform feedback. So basically you don't need your TF object bound while you are initializing your VAO state. It shouldn't make any difference as nothing about it is stored within the VAO.

The TF object is what captures your TF buffer binding. Search for the "transform feedback state" table in the spec for what's captured within a TF object.

i do specify all the TF varyings and program links correctly. also, if i fill output buffer with correct data and disable tranform feedback, it renders correctly. but as soon as i execute drawing with transform feedback, it's filled with garbage.

upd: if i use glDrawArrays to render TF output, it also draws random garbage.

fixed it. it turns out i've actually forgot about one of my vertex attributes, ruining output vertex layout. it does work, but the fact that i need to use glDrawArrays is really inconvenient. i would really like to have same drawing code for animated and non-animated objects, only binding different VAO's. - nevermind me being a silly dummy. i was drawing to transform feedback with glDrawElements, so it was, predictably, unfolding indices. if i draw with glDrawArrays, it doesn't happen and i can use pre-setup VAO with original indices to draw results.