implementation of sweep object

Does anyone know where I can find examples about how to use sweep method to draw objects? I have spent a couple of hours to search online, but I did not find any example code for this. (There are some about sweep-selection, but I do not think this is what I want.) Could anyone give me some simple examples like drawing a cube by translating a square along the line and a cylinder by rotating a line along the circle? I really know the idea, but it is difficult for me to figure out all the details. Hopefully, the example also includes how to map texture to this kind of complicate objects. Any advice is appreciated. Thanks!

Sorry, it is not helpful so much for me. I am really new for OpenGL Is it possible to find an example or tutorial on it?

Both of these link are quite good, what do you not understand right now ?

Or you prefer to be given some working code you don’t understand ?

I am confused about how to connect two shapes. For example, I wrote like this:
drawSquare(); // simply draw a polygon

But how can I connect these two square together. What the code looks like?

This is not provided by OpenGL.
Take each edge (ex A B) from the original shape, clone it to a translated version (ex C D), and draw a quad using ABDC so that it is CCW when viewed from the outside.
Then the closing top shape must have its order reversed compared to the original shape.

Could you give me some pseudo-code about what I should do step by

Let’s extrude an hexagon along L distance, to make some basic cylinder :

base shape is an regular hexagon ABCDEF in the XY plane, visible when drawn counter clockwise.
# we will fill in the values for GHIJKL, the second hexagon
for each vertex M in (A,B,C,D,E,F) do
  O = M
  O.z += L
  add O to second hexagon list of vertices
# creation of quad sides
for i = 0 to 5 do
  O = hex1.vertex[i]
  P = hex1.vertex[mod(i+1,6)]
  Q = hex2.vertex[i]
  R = hex2.vertex[mod(i+1,6)]
  add POQR to list of quads for sides
# drawing
draw triangle fan ABCDEF
draw side quads
draw triangle fan LKJIHG