PDA

View Full Version : Bind texture with pbuffer



Acheum
06-05-2003, 10:38 PM
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...)

DanielHawson
06-06-2003, 05:33 AM
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_AR B);

//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)) )

Acheum
06-10-2003, 10:47 PM
Thanks !