Fragment Programs and Pbuffers

I’m trying to do a 2-pass render using fragment programs and p-buffers. Here is the program flow:

Pass 1:

  1. Enable pbuffer rendering context
  2. Enable first fragment program
  3. Render texture into pbuffer
  4. Restore window rendering context

Pass 2:
5) Enable second fragment program
6) Bind pbuffer as texture
7) Draw geometry
8) Un-bind pbuffer texture

Now, unfortunately, pass 2 hangs on step 7. All that the second fragment program does is apply the pbuffer texture to the geometry (a quad) so it looks like this:

TEX o[COLR], f[TEX0], TEX0, 2D;

If I skip step 5 and just do a normal texture application of the pbuffer to the quad, everything works.

Is there something about using p-buffers as textures in fragment programs that I don’t understand?

– Zeno