Bind texture with pbuffer

When I render to a texture using pbuffer, how can I bind the texture I render to ? (to use it later as a normal texure…)

First, just to check. Make sure you’ve registered the following extensions -
WGL_ARB_pixel_format
WGL_ARB_pbuffer
WGL_ARB_render_texture

Set your render context.
Bind the pbuffer texture that you’ve just rendered to -

glBindTexture(GL_TEXTURE_2D,pbufferTexID);
wglBindTexImageARB(pbufferHandle,WGL_FRONT_LEFT_ARB);

//Draw textured stuff

wglReleaseTexImageARB(pbufferHandle,WGL_FRONT_LEFT_ARB);

Oh yeah. Make sure, when you create your pbuffer, you have the WGL_BIND_TO_TEXTURE_RGBA_ARB. So something like this -

int iattributes[] =
{
WGL_DRAW_TO_PBUFFER_ARB, true,
WGL_SUPPORT_OPENGL_ARB, true,
WGL_BIND_TO_TEXTURE_RGBA_ARB, true,
WGL_RED_BITS_ARB, 8,
WGL_GREEN_BITS_ARB, 8,
WGL_BLUE_BITS_ARB, 8,
WGL_ALPHA_BITS_ARB, 8,
WGL_DEPTH_BITS_ARB, 24,
WGL_DOUBLE_BUFFER_ARB, FALSE,
0
};
wglChoosePixelFormatARB( hdc, iattributes, fattributes, MAX_PFORMATS, pformatsOut, &nformatsOut )

and then create it with -

int otherAttribs[] =
{
WGL_TEXTURE_FORMAT_ARB,WGL_TEXTURE_RGBA_ARB, WGL_TEXTURE_TARGET_ARB,WGL_TEXTURE_2D_ARB,
0
};
pbufferhandle = wglCreatePbufferARB(hdc,pformat[0], WIDTH, HEIGHT, otherAttribs)) )

Thanks !