I’m attempting to use the glDrawPixels function to view some data in color at particular pixel locations. I’m able to accomplish this ok in a gray scale environment. I’m including the approach I used for that situation. Any comments (or examples to point me to) on how to see the color RGB values displayed would be appreciated. Please be specific as I’m a beginner with openGl.
Here’s a snippet of my current implementation:
float *TheTempData;
int BufferSize = window_width*window_height;
TheTempData = new float[BufferSize];
for( row = 0; row < window_height; row++)
{
rowoffset = row*width;
for( col = 0; col < widow_width; col++)
{
int index = rowOffset + col;
float temp = call to a function that returns a floating point value for temperature from a floating point 2-D array.
float grey_temp = (temp - minTemp) / (maxTemp - minTemp); // max/minTemp are floats
grey_temp = MAX(grey_temp, 0.0);
grey_temp = MIN(grey_temp, 1.0);
TheTempData[index] = grey_temp;
}
}
To draw the pixels:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix();
glDrawPixels(window_width, window_height, GL_LUMINANCE, GL_FLOAT, TheTempData);
I just want to display the same data in color, and if possible, avoid reading in the database (that the temperature values are extracted from) in a different data type (e.g. unsigned long as opposed to the current float type).
Thanks for the help!