Hi,
I am trying to find the best way of doing a pixel color trasnslation after the scene has been drawn. I am currently getting an array of pixels from the frame buffer, altering them, and then writing them back to the frame buffer.
I have been supplied with an RGB mapping for each color (8bit) and need to do this conversion after the scene is drawn (I cant alter the color of the objects in the scene), as both rgb and the converted rgb need to be displayed concurrently on different pc’s within this simulation.
The code I am trying works, but is awfully slow. The requrement is to convert a 1024 x 1024 display, which in my calcs is over 1 million pixels.
The following is teh code I have used, and I have added a comment for the average time taken for each step. I am using a Pentium III (500Mhz), GeForce II 32Mb, and Windows NT.
GLubyte pixels[1024][1024][3];
// 53ms avg
glReadPixels(0.0f, 0.0f, 1024.0f, 1024.0f, GL_RGB, GL_UNSIGNED_BYTE, pixels);
// 112ms avg
int i, j;
GLubyte r, g, b;
for (i = 0; i < 1024; i++) {
for (j = 0; j < 1024; j++) {
// this one just swaps r, g, and b as a test
r = pixels[i][j][0];
g = pixels[i][j][1];
b = pixels[i][j][2];
pixels[i][j][0] = b;
pixels[i][j][1] = r;
pixels[i][j][2] = g;
} // for
} // for
// 71ms avg
glRasterPos2i(0, 0);
glDrawPixels(1024.0f, 1024.0f, GL_RGB, GL_UNSIGNED_BYTE, pixels);
Is there any other more efficient way to do this, especially part 1, and 3 above?
Thanks in advance.
[This message has been edited by mike_p (edited 01-20-2002).]