Print Cg shader output


I have a fragment shader and I would like to print the interpolated u,v coordinates to the console.
How can I do this?


Create a 32 bit per channel floating point pbuffer, render the values you want into it as fragment color and do a read pixels of the buffer as GL_FLOAT.

do you know any tutorial site for this?

or do I just need to create a float array. and then use Cg function to write the color to this array?


Check esp. the link below.
I think the zip contains all code you need as startup.

You need to use the WGL_ARB_pixel_format extension to allocate a floating point pbuffer and render into it from your Cg fragment shader.
There is no other output possible (except for the depth).
Your “float array” is the pbuffer. Use glReadPixels with GL_FLOAT type to readback the date into your system memory.

No fear, it’s not too difficult. The project contains more than necessary, but you need to add your Cg environment.