Más alakzatok

Top  Previous  Next

Megkönnyíti a munkát, ha a gyakori alakzatokat előre deffiniáljuk:

 

procedure TALBaseOpenGL.glCircle(u, v, r: double);

var i: integer;

begin

glBegin(GL_LINE_STRIP);

   For i:=0 to 360 do

       glVertex2d(u+r*cos(DegToRad(i)),v+r*sin(DegToRad(i)));

glEnd;

end;

 

procedure TALBaseOpenGL.glRectangle(p1, p2, p3, p4: TPoint2d);

begin

glBegin(GL_LINES);

   glVertex2d(p1.x,p1.y);

   glVertex2d(p2.x,p2.y);

   glVertex2d(p3.x,p3.y);

   glVertex2d(p4.x,p4.y);

glEnd;

end;

 

procedure TALBaseOpenGL.glRectangle(p: TPoint2d; a, b: double);

begin

glBegin(GL_LINE_STRIP);

   glVertex2d(p.x-a/2,p.y+b/2);

   glVertex2d(p.x+a/2,p.y+b/2);

   glVertex2d(p.x+a/2,p.y-b/2);

   glVertex2d(p.x-a/2,p.y-b/2);

   glVertex2d(p.x-a/2,p.y+b/2);

glEnd;

end;