I want to create a histogram of intensities 0.1, 0.2, .... 0.9, 1, from an image rendered using OpenGL and C++. How can I do this? Can I access the pixel intensities in the framebuffer somehow? Also, I'm not using any glsl shaders, and don't intend to.
So far I tried:
unsigned char *framebuffer = frameBuffer = new unsigned char[1920*1080 * 4];
glReadPixels(0, 0, 1920, 1080, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer);
for (int j = 0; j<1920*1080 * 4; j += 4){
if(frameBuffer[j] == 0.1)
// find pixel with R channel at 0.1: this is where the problem is.
// I know I have surfaces with this intensity but I never enter the if statement
}