Search code examples
openglvertex-shader

GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN always returns 0


I'm trying to use the transform feedback functionality of OpenGL. I've written a minimalistic vertex shader and created a program with it (there's no fragment shader). I've also made a call to glTransformFeedbackVaryings with a single output varying name and I've set the buffer mode to be GL_INTERLEAVED_ATTRIBS. The shader program compiles and links fine (I also make sure I link after the glTransformFeedbackVaryings call.

I've enabled a single vertex attrib array using glEnableVertexAttribArray, allocated a VBO for the generic vertex attributes and made a call to glVertexAttribPointer for the attribute.

I've bound the TRANSFORM_FEEDBACK_BUFFER to another buffer which I've generated and created a data store which should be plenty big enough to be written to during transform feedback.

I then enable transform feedback and call glDrawArrays(GL_POINTS, 0, 1000). I don't get any crashes throughout the running of the program.

The problem is that I'm getting no indication that the transform feedback is writing anything to the TRANSFORM_FEEDBACK_BUFFER during the glDrawArrays call. I set up a query which monitors GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN and this always returns 0. No matter what I try I can't seem to get the transform feedback to write ANYTHING (never mind anything meaningful!)

If anyone has any suggestions as to how I could get the transform feedback to write anything, or things that I should check for please let me know!

Note: I can't use transform feedback objects and I'm not using vertex array objects.


Solution

  • I think the problem ended up being how I was calling glBindBufferBase. Given that I can't see this function call in the original question it may have been that I omitted it altogether.

    Certainly I didn't realise that the GL_TRANSFORM_FEEDBACK_BUFFER also has to be bound with a call to glBindBuffer to the correct buffer object before calling glBindBufferBase.