Occlusion Query
https://www.khronos.org/opengl/wiki/Query_Object#Occlusion_queries
Our window has 800 x 600 = 480.000 pixels, if we draw a triangle that looks like this:
That means only 1 / 8 of the window is covered by the triangle, that would be about 60.000 pixels.
In Main.cpp
void Render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* start query */
glBeginQuery(GL_SAMPLES_PASSED, query);
glUseProgram(program);
glBindVertexArray(vertexarray);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
glUseProgram(0);
/* stop query */
glEndQuery(GL_SAMPLES_PASSED);
/* wait until OpenGL has the result */
GLint result = GL_FALSE;
while (result == GL_FALSE)
glGetQueryObjectiv(query, GL_QUERY_RESULT_AVAILABLE, &result);
/* get the result */
glGetQueryObjectiv(query, GL_QUERY_RESULT, &result);
cout << "sample count for 1 triangle: " << result << endl;
CheckForGLError();
}
Try to resize the window so that fewer pixels are draws, minimize the window to see how the number changes.