<p>I have been scouring the web for a code sample that shows how to use pbuffer with GLUT but I could not find anything... </p>

<p>I am puzzled with the context switching between pbuffer and the rendering window. I guess that I will have to use glutSetWindow to switch between the two rendering surface but I am not too sure about the details.</p>

<p>Can someone explain me how to use a pbuffer with GLUT?</p>

The short answer is that there's no
good
way of doing it.
The longer answer is that pbuffers are not cross-platform, so you necessarily have to use platform-specific APIs to access them. How you switch between rendering surfaces depends on your platform; on Windows you'd use wglMakeCurrent() and the like.
The meta-answer is that you should avoid pbuffers if at all possible -
FBO
s provide similar functionality but without this kind of problem, and with better performance too.