I am trying to get the value of each rbg value of each pixel. But each value returns the exact same thing. The code I am using is seriously not optomised, considering for each pixel it checks every pixel every time. But I was just using this to try the concept. But like i said, it is constantly returning the same value, any one possibly know why, or what i am doing wrong.
int width = 800;
int height = 600;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
unsigned char pick_col[3];
glReadPixels(j, i, screenWidth, screenWidth, GL_RGB, GL_UNSIGNED_BYTE,
pick_col);`
cout << (float)pick_col[0]/255 << " " << (float)pick_col[1]/255 << " " <<
(float)pick_col[2]/255 << endl;
}
}
I have also tried using
GLubyte pick_col[800 * 600 * 4];
int width = 800;
int height = 600;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
glReadPixels(j, i, screenWidth, screenWidth, GL_RGBA, GL_UNSIGNED_BYTE,
pick_col);
cout
<< (float)pick_col[i*width * 4 + j * 4] << " "
<< (float)pick_col[i*width * 4 + j * 4 + 1] << " "
<< (float)pick_col[i*width * 4 + j * 4 + 2] << endl;
}
}