Hi,
I am trying to write a PBM file derived from an RGB buffer of the currently rendered object. I am almost finished writing my code but need a bit of help. In particular I use a single colour to render each 3D object. I then want to write a PBM (ascii) where each bixel is set to bool true iff the RGB pixel value == glColour3fv(colourPalette[colourArray_integer]). For all other RGB value the corresponding bixel value should be bool false. Simple or what?
My first question is how to pass the colour i.e. a pointer/reference to the currently set colour glColor3fv info to the function that does this. Is there a simple call in OpenGL to do this seemingly trivial task? What is the easiest/simplest to implement way of doing this. I am not looking to wrtie particularly clever code: quick and dirty is fine for now.
//*****************************************************************************//
bool convertRGBToMask(ofstream &file, GLbyte *pRGB, GLint height, GLint width, unsigned long dimensionsOfImage, GLfloat *renderedColour){
//*****************************************************************************//
bool bixelValue;
if (file==NULL) return true; // bool true i.e. error arisen
if (int(height*width)!=int(dimensionsofImage)) return true; // bool true i.e. error arisen
for (int h=0;h<height;h++){
for(int w=0;w<width;w++){
bixelValue=false; // reset to false
if(*pRGB==renderedColour){
bixelValue=true;
if (w<width-1) file_out << bixelValue << " ";
else fout << bixelValue << "
";
}
if (w < width -1) file_out << bixelValue << " ";
else file_out << bixelValue << "
";
pRGB++; // increment pointer
}
}
file_out <<"
"; // insert blank line at end of file
file_out.close();
return false; // false i.e. no error
}
Secondly I need to compare the pixelRGB value with the current value: is this best (fastest) done by converting to an unsigned summed integer or similar, or should I return floats directly. Which will be faster?
Thanks
Mark