Querying transform feedback results

It is often useful to determine how many primitives were written during transform feedback pass. For example, if a geometry shader was active, the number of primitives written could be different than the number of primitives that were sent down the pipeline.

OpenGL provides a way to query for this information using query objects. To do so, start by creating a query object:

GLuint query; 
glGenQueries(1, &query); 

Then, prior to starting the transform feedback pass, start the counting process using the following command:

glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, query); 

After the end of the transform feedback pass, call glEndQuery to stop counting:

glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.