Writing the on screen data to buffer (file)

Hi !!
Does anyone knows how to make the on screen data (I render a static scene) to a buffer of RGB (like a ppm file) .
I`m suppose to do a texture mapping into a serious of triangles and I need this data as a buffer (or a file) and not as on screen image.
I thought using the texture mapping function of opengl will save me a lot of work…