//drawLine2 //showing the example of the function drawLine() //also showing animation with event driven method //A vertical line moves from left to right. // T. Kosaka CS TNCT 2001 #include #include #include void setColor(float red,float green,float blue) { glColor3f(red, green, blue); } void drawDot(int x,int y) { glBegin(GL_POINTS); glVertex2i(x, y); glEnd(); } void drawLine(int x1, int y1, int x2, int y2) { int dx,dy,dx2,dy2,x,y,inc,c,tmp; dx=0<=x2-x1?x2-x1:x1-x2; dy=0<=y2-y1?y2-y1:y1-y2; dx2=dx<<1;dy2=dy<<1; if (dy<=dx) { if (x2