I need to get a histogram of an image that’s already drawn in the frame buffer.
It seems that I have to read the image back to the memory using glReadPixel() for glHistogram() to work correctly, which is very time-consuming and kind of a waste. Without glReadPixle( ), everything I get from the histogram is zero.
Anybody knows if I can avoid reading back to memory and still get the right histogram data for the image?
The following is the code I used:
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set up for histogramming
glHistogram (GL_HISTOGRAM, HISTOGRAM_SIZE, GL_RGB, GL_FALSE);
glReadPixels(0, 0, 100, 100, GL_RGB, GL_FLOAT, aa);
glGetHistogram(GL_HISTOGRAM, GL_FALSE, GL_RGB, GL_UNSIGNED_SHORT, histogram);
Your help will be really appreciated.