The complet code is here.
function BitmapImage(c:TOpenGLControl):TBitmap;
var
data,rdata: pbyte;
w,h,s: integer;
bitMap: TBitmap;
begin
c.Repaint;
w := c.Width;
h := c.Height;
s := w*h*4;
result := TBitmap.Create;
bitMap:=result; try
bitMap.SetSize(w,h);
bitMap.PixelFormat:=pf32bit;
getMem(data,s); try
glPixelStorei(GL_PACK_ALIGNMENT, 4);
pixel}
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, data);
rdata := bitMap.RawImage.Data;
Move(data^,rdata^,bitMap.RawImage.DataSize);
finally
freemem(data);
end;
except
bitMap.free;
end;
end;