unit bibli;

interface

procedure pave(x : integer;y:integer;z:integer; long:integer ; larg:integer; haut:integer; couleur:string; alpha:integer);
procedure disk( rayoni:integer; rayone:integer; couleur:string; alpha:integer);
{procedure lumiere (x:integer; y:integer; z:integer; couleurA:string; couleurD:string;couleurS:string);}
procedure skybox(x:integer; y:integer; z:integer; long:integer; larg:integer; haut :integer; couleursol:string; couleurmur:string;alpha:integer);
procedure sablier (rayon : integer;hauteur:integer; couleur : string ; alpha : integer);
procedure maison(x:integer; y : integer; z:integer ; long:integer; larg: integer; haut:integer; couleur:string ; alpha : integer);

implementation
uses
  SysUtils,
  OpenGL,
  glfw,
  couleur ;



{______________________________________________________________________________
-----------------------------pave----------------------------------------------}

procedure pave(x : integer;y:integer;z:integer; long:integer ; larg:integer; haut:integer; couleur:string; alpha:integer);

var
color : array [0..2] of integer;
color1,color2,color3 : integer;
begin
Randomize();
//definition de la couleur
color1 :=tocolor(couleur,0);
color2 := tocolor(couleur,1);
color3 := tocolor(couleur,2);
color[0]:=color1;
color[1]:=color2;
color[2]:=color3;

   //on trace le pave suivant les parametres
  //surface du bas
  glBegin(GL_QUADS);
  glColor4ub(color[0],color[1],color[2],alpha);

    glvertex3f((x-(larg div 2)) , (y - long div 2), z);
    glvertex3f((x-(larg div 2)), (y + long div 2), z);
    glvertex3f((x+(larg div 2)), (y + long div 2), z );
    glvertex3f((x+(larg div 2)) , (y - long div 2), z);
  glend();


  //surface arriere
  glbegin(GL_QUADS);
  glColor4ub(color[0]-10,color[1]-10,color[2]-10,alpha);

    glvertex3f((x-(larg div 2)) , (y - long div 2), z);
    glvertex3f((x-(larg div 2)), (y + long div 2), z);
    glvertex3f((x-(larg div 2)), (y + long div 2), z+haut);
    glvertex3f((x-(larg div 2)), (y - long div 2), z+haut);
  glend();



  glbegin(GL_QUADS);
  glColor4ub(color[0]-20,color[1],color[2]-10,alpha);
  //surface de droite
    glvertex3f((x+(larg div 2)), (y + long div 2), z);
    glvertex3f((x-(larg div 2)), (y + long div 2), z );
    glvertex3f((x-(larg div 2)), (y + long div 2), z+haut);
    glvertex3f((x+(larg div 2)), (y + long div 2), z+haut);
   glend();




   //surface du haut
   glbegin(GL_QUADS);
   glColor4ub(color[0],color[1]-20,color[2]-10,alpha);

    glvertex3f((x+(larg div 2)), (y - long div 2), z+haut);
    glvertex3f((x+(larg div 2)), (y + long div 2), z+haut);
    glvertex3f((x-(larg div 2)), (y + long div 2), z+haut);
    glvertex3f((x-(larg div 2)), (y - long div 2), z+haut);

  glend();


    //surface de gauche
  glbegin(GL_QUADS);
   glColor4ub(color[0]-20,color[1]-10,color[2],alpha);

    glvertex3f((x-(larg div 2)), (y - long div 2), z);
    glvertex3f((x+(larg div 2)), (y - long div 2), z);
    glvertex3f((x+(larg div 2)), (y - long div 2), z+haut);
    glvertex3f((x-(larg div 2)), (y - long div 2), z+haut);


  glend();

  //surface de face
  glbegin(GL_QUADS);
   glColor4ub(color[0]-20,color[1]-10,color[2]-10,alpha);

    glvertex3f((x+(larg div 2)), (y - long div 2), z);
    glvertex3f((x+(larg div 2)), (y + long div 2), z);
    glvertex3f((x+(larg div 2)), (y + long div 2), z+haut);
    glvertex3f((x+(larg div 2)), (y - long div 2), z+haut);


  glend();

end;




{______________________________________________________________________________
-----------------------------DISK----------------------------------------------}


procedure disk( rayoni:integer; rayone:integer; couleur:string; alpha:integer);

var
 disk : gluQuadricObj;
 color : array [0..2] of integer;
 color1,color2,color3 : integer;
begin
Randomize();
 //definition de la couleur
color1 :=tocolor(couleur,0);
color2 := tocolor(couleur,1);
color3 := tocolor(couleur,2);
color[0]:=color1;
color[1]:=color2;
color[2]:=color3;

disk:=gluNewQuadric();
glcolor4ub(color[0],color[1],color[2],alpha);
gluDisk(disk,rayoni,rayone,30,1);





end;



{__________________________________________________________________________________________________
--------------------------------------SKYBOX------------------------------------------------------}
procedure skybox(x:integer; y:integer; z:integer; long:integer; larg:integer; haut :integer; couleursol:string; couleurmur:string; alpha:integer);

var
//couleur du sol
color : array [0..2] of integer;
color1,color2,color3 : integer;
//couleur des murs
color5: array[0..2] of integer;
color6,color7,color8 : integer;


begin
Randomize();
color1 :=tocolorskyboxsol(couleursol,0);
color2 := tocolorskyboxsol(couleursol,1);
color3 := tocolorskyboxsol(couleursol,2);
color[0]:=color1;
color[1]:=color2;
color[2]:=color3;

color6 :=tocolorskyboxmur(couleurmur,0);
color7 := tocolorskyboxmur(couleurmur,1);
color8 := tocolorskyboxmur(couleurmur,2);
color5[0]:=color6;
color5[1]:=color7;
color5[2]:=color8;


//definition de la couleur des mur

  //surface du bas
  glBegin(GL_QUADS);
    glcolor4ub(color[0],color[1],color[2],alpha);
    glvertex3f((x-(larg div 2)) , (y - long div 2), z);

    glvertex3f((x-(larg div 2)), (y + long div 2), z);

    glvertex3f((x+(larg div 2)), (y + long div 2), z );
       
    glvertex3f((x+(larg div 2)) , (y - long div 2), z);
  glend();


  //surface arriere en transparence
  glenable(GL_BLEND);
  glbegin(GL_QUADS);
  glColor4ub(color5[0],color5[1]-10,color5[2]-10,alpha);

    glvertex3f((x-(larg div 2)) , (y - long div 2), z);
    glvertex3f((x-(larg div 2)), (y + long div 2), z);
    glColor4ub(color5[0]-10,color5[1]-10,color5[2]-10,alpha);
    glvertex3f((x-(larg div 2)), (y + long div 2), z+haut);
    glvertex3f((x-(larg div 2)), (y - long div 2), z+haut);
  glend();
  glDisable(GL_BLEND);


  glbegin(GL_QUADS);
  glColor4ub(color5[0]-10,color5[1],color5[2]-10,alpha);
  //surface de droite
    glvertex3f((x+(larg div 2)), (y + long div 2), z);
    glvertex3f((x-(larg div 2)), (y + long div 2), z );
    glColor4ub(color5[0]-20,color5[1]-10,color5[2]-10,alpha);
    glvertex3f((x-(larg div 2)), (y + long div 2), z+haut);
    glvertex3f((x+(larg div 2)), (y + long div 2), z+haut);
   glend();

    //surface de gauche
  glbegin(GL_QUADS);
   glColor4ub(color5[0]-10,color5[1]-10,color5[2]-10,alpha);

    glvertex3f((x-(larg div 2)), (y - long div 2), z);
    glvertex3f((x+(larg div 2)), (y - long div 2), z);
    glColor4ub(color5[0]-10,color5[1]-10,color5[2],alpha);
    glvertex3f((x+(larg div 2)), (y - long div 2), z+haut);
    glvertex3f((x-(larg div 2)), (y - long div 2), z+haut);


  glend();

  //surface de face 
  
  glbegin(GL_QUADS);

   glColor4ub(color5[0],color5[1],color5[2],alpha);

    glvertex3f((x+(larg div 2)), (y - long div 2), z);
    glvertex3f((x+(larg div 2)), (y + long div 2), z);
    glColor4ub(color5[0]-10,color5[1]-10,color5[2]-10,alpha);
    glvertex3f((x+(larg div 2)), (y + long div 2), z+haut);
    glvertex3f((x+(larg div 2)), (y - long div 2), z+haut);


  glend();
  
end;


{______________________________________________________________________________
--------------------------SABLIER---------------------------------------------}
procedure sablier (rayon : integer;hauteur:integer; couleur : string ; alpha : integer);

var
cone1 : gluQuadricObj;
cone2 : gluQuadricObj;
color : array[0..2] of integer;
begin
if couleur ='rouge' then
         begin
          color[0]:= 255;
          color[1]:=20;
          color[2]:=20;
          end
  else if couleur = 'vert' then
          begin
           color[0]:=20;
           color[1]:=255;
           color[2]:=20;
          end
    else if couleur = 'bleu' then
          begin
            color[0]:=20;
            color[1]:=20;
            color[2]:=255;
          end
      else if couleur = 'jaune' then
            begin
             color[0]:=255;
             color[1]:=255;
             color[2]:=20;
           end
        else if couleur = 'blanc' then
                begin
                  color[0]:=255;
                  color[1]:=255;
                  color[2]:=255;
                end
          else if couleur = 'noir' then
                  begin
                    color[0]:=20;
                    color[1]:=20;
                    color[2]:=20;
                  end
                else begin
                      color[0] := random(255);
                      color[1] := random(255);
                      color[2] := random(255);
                     end;

cone1 := gluNewQuadric();
glcolor4ub(color[0],color[1],color[2],alpha);
gluCylinder(cone1,rayon,0,(hauteur div 2),20,1);
cone2 := gluNewQuadric();
gltranslate(0,0,hauteur div 2);
glcolor4ub(color[0]-5,color[1]-5,color[2]-5,alpha);
gluCylinder(cone2,0,rayon,hauteur div 2 ,20,1);



end;



procedure maison(x:integer; y : integer; z:integer ; long:integer; larg: integer;
                 haut:integer; couleur:string ; alpha : integer);
var
color : array[0..2] of integer;
begin
if couleur ='rouge' then
         begin
          color[0]:= 255;
          color[1]:=20;
          color[2]:=20;
          end
  else if couleur = 'vert' then
          begin
           color[0]:=20;
           color[1]:=255;
           color[2]:=20;
          end
    else if couleur = 'bleu' then
          begin
            color[0]:=20;
            color[1]:=20;
            color[2]:=255;
          end
      else if couleur = 'jaune' then
            begin
             color[0]:=255;
             color[1]:=255;
             color[2]:=20;
           end
        else if couleur = 'blanc' then
                begin
                  color[0]:=255;
                  color[1]:=255;
                  color[2]:=255;
                end
          else if couleur = 'noir' then
                  begin
                    color[0]:=20;
                    color[1]:=20;
                    color[2]:=20;
                  end
                else begin
                      color[0] := random(255);
                      color[1] := random(255);
                      color[2] := random(255);
                     end;




pave(x,y,z,long,larg, haut div 2, couleur,alpha);
glbegin(GL_QUADS);
   glColor4ub(128,0,0,alpha);
    glvertex3f((x+(larg div 2)), (y - long div 2), z+(haut div 2));
    glvertex3f((x+(larg div 2)), (y + long div 2), z+(haut div 2));
    glvertex3f((x), (y + long div 2)-1, z+haut);
    glvertex3f((x), (y - long div 2)+1, z+haut);
  glend();

  glbegin(GL_QUADS);
   glColor4ub(128,0,0,alpha);
   glvertex3f((x-(larg div 2)), (y - long div 2), z+(haut div 2));
   glvertex3f((x-(larg div 2)), (y + long div 2), z+(haut div 2));
    glvertex3f((x), (y + long div 2)-1, z+haut);
    glvertex3f((x), (y - long div 2)+1, z+haut);
  glend();

  glbegin(GL_QUADS);
   glColor4ub(135,0,0,alpha);
   glvertex3f((x-(larg div 2)), (y + (long div 2)), z+(haut div 2));
   glvertex3f((x+(larg div 2)), (y + (long div 2)), z+(haut div 2));
    glvertex3f((x), (y + long div 2)-1, z+haut);
    glvertex3f((x), (y + long div 2)-1, z+haut);
  glend();


  glbegin(GL_QUADS);
   glColor4ub(120,0,0,alpha);
   glvertex3f((x-(larg div 2)), y -(long div 2), z+(haut div 2));
   glvertex3f((x+(larg div 2)), y - ( long div 2) , z+ (haut div 2));
   glvertex3f((x), (y - long div 2)+1, z+haut);
   glvertex3f((x), (y - long div 2)+1, z+haut);
  glend();


end;

end.

