unit Shapes;

interface

uses
  OpenGL;

procedure Pyramid;
procedure Cube;
procedure CylinderBase;
procedure Cylinder;

implementation

var
  circleX,
  circleY: array[0..35] of glFloat;

procedure Pyramid;
begin
  glBegin(GL_TRIANGLE_FAN);
    glVertex3f(+0.0,+0.0,+0.0);
    glVertex3f(-0.3,+0.3,-0.4);
    glVertex3f(+0.3,+0.3,-0.4);
    glVertex3f(+0.0,-0.3,-0.4);
    glVertex3f(-0.3,+0.3,-0.4);
  glEnd;
end;

procedure Cube;
begin
  glBegin(GL_TRIANGLE_STRIP);
    glVertex3f(-0.4,+0.4,+0.4);
    glVertex3f(-0.4,-0.4,+0.4);
    glVertex3f(+0.4,+0.4,+0.4);
    glVertex3f(+0.4,-0.4,+0.4);
    glVertex3f(+0.4,+0.4,-0.4);
    glVertex3f(+0.4,-0.4,-0.4);
    glVertex3f(-0.4,+0.4,-0.4);
    glVertex3f(-0.4,-0.4,-0.4);
    glVertex3f(-0.4,+0.4,+0.4);
    glVertex3f(-0.4,-0.4,+0.4);
  glEnd;
end;

procedure CylinderBase;
var
  around: integer;
  pi18: double;
begin
  pi18 := pi/18.0;
  for around := 0 to 35 do
  begin
    circleX[around] := 0.4*sin(around*pi18);
    circleY[around] := 0.4*cos(around*pi18);
  end;
end;

procedure Cylinder;
var
  around: integer;
begin
  glBegin(GL_TRIANGLE_STRIP);
    for around := 0 to 35 do
    begin
      glVertex3f(circleX[around],circleY[around],0.0);
      glVertex3f(circleX[around],circleY[around],1.0);
    end; {for}
    glVertex3f(circleX[0],circleY[0],0.0);
    glVertex3f(circleX[0],circleY[0],1.0);
  glEnd;
end;

end.
