Skip to content

Instantly share code, notes, and snippets.

@jdolan
Created January 10, 2023 14:32
Show Gist options
  • Save jdolan/7f34c75faf8162c62677a86f184aeed9 to your computer and use it in GitHub Desktop.
Save jdolan/7f34c75faf8162c62677a86f184aeed9 to your computer and use it in GitHub Desktop.
Naive OpenGL Occlusion Query implementation (don't do this).
glBeginQuery(GL_ANY_SAMPLES_PASSED, query->name);
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, query->elements); // draw the AABB
glEndQuery(GL_ANY_SAMPLES_PASSED);
glGetQueryObjectiv(query->name, GL_QUERY_RESULT, &query->result);
if (query->result) {
// draw the object(s) the query was guarding
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment