You can use this code, which is originally from Asphyre 4.1 (it uses vertex & index buffers):

Code:
 Theta:= 0.0;
 ThetaInc:= 2.0 * Pi / Rings;
 PhiInc:= 2.0 * Pi / Sides;

 for j:= 0 to Rings do
  begin
   CosTheta:= Cos(Theta);
   SinTheta:= Sin(Theta);

   Phi:= 0.0;
   for i:= 0 to Sides do
    begin
     CosPhi:= Cos(Phi);
     SinPhi:= Sin(Phi);
     Delta := Radius + TubeRadius * CosPhi;

     IncludeVertex(
      Vector3(CosTheta * Delta, TubeRadius * SinPhi, -SinTheta * Delta),
      Vector3(CosTheta * CosPhi, SinPhi, -SinTheta * CosPhi),
      Point2(Theta * TexTilesX / (2.0 * Pi), Phi * TexTilesY / (2.0 * Pi)));

     ni:= i + 1;
     nj:= j + 1;

     if &#40;i < Sides&#41;and&#40;j < Rings&#41; then
      begin
       IncludeIndex&#40;i + j * SideBlock&#41;;
       IncludeIndex&#40;i + nj * SideBlock&#41;;
       IncludeIndex&#40;ni + nj * SideBlock&#41;;

       IncludeIndex&#40;i + j * SideBlock&#41;;
       IncludeIndex&#40;ni + nj * SideBlock&#41;;
       IncludeIndex&#40;ni + j * SideBlock&#41;;
      end;

     Phi&#58;= Phi + PhiInc;
    end;

   Theta&#58;= Theta + ThetaInc;
  end;
Porting the code to OpenGL should be a matter of changing "IncludeVertex" to rendering calls.