The glCopyTexSubImage2D() function should copy what's on the screen/framebuffer straight into the currently bound (blank) texture.
This is an excerpt from a dynamic texture class at www.Delphi3d.net:
[pascal]
procedure TFrameBufferTexture.BeginTextureUpdate;
begin
//Save the drawing style and all settings
glPushAttrib(GL_ALL_ATTRIB_BITS);
glCallList(FSetup); //Setup all the drawing styles needed for the texture update
glViewport(0, 0, FWidth, FHeight); //restrict the drawing area to the size of the texture.
end;
//After calling BeginTextureUpdate, you would draw onto the screen like you would normally, except it will be drawn to the texture, not the screen.
procedure TFrameBufferTexture.EndTextureUpdate;
begin
// The texture is rendered, now copy the image.
glBindTexture(GL_TEXTURE_2D, FTexture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, FWidth, FHeight);
glPopAttrib; //Restore the saved states.
end;
[/pascal]
Bookmarks