I have built 3D plots using openGL. Now, I would like to include a function so that the user can query the data based on it’s color.
I was trying to use glReadPixels to query the color (RGB) using the position of the mouse and then convert this color back to the value according to the color scale. Example:
pPixelData = (float *) calloc(3, sizeof(float));
// Copy the area under the mouse cursor
glReadPixels(mx, my, 1, 1, GL_RGB, GL_FLOAT, pPixelData);
The problem is that when I do this the color is diferent from the scale due to lighting effects. My question is:
a) can I use glReadPixels to capture the color (in RGB format) without the influence of lighting?
b)do I have to render the whole 3D plot first with lighting disabled and then use glReadPixels?
I would prefer to use a) if possible.