#include<GL/glut.h>
#include<stdio.h>
#include<stdlib.h>
void draw(int x ,int y){
glBegin(GL_POINTS);
glColor3f(0,1,0);
glVertex2i(x,y);
glEnd();
}
void lineSe(){
float x0 = 50,y0= 50;
float xf= 300,yf=500;
int step = (abs(x0-xf)>abs(y0-yf)?abs(x0-xf):abs(y0-yf) );
float xinc = abs(x0-xf)/(step*1.00);
float yinc = abs(y0-yf)/(step*1.00);
for(int i=0;i<=step;i++){
draw(x0+0.5,y0+.05);
x0+=xinc;y0+=yinc;
}
glFlush();
}
void Init(){
glClearColor(1.0,1.0,1.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
gluOrtho2D(-640,640,-480,480);
lineSe();
}
int main(int argc ,char ** argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE );
glutInitWindowPosition(100,100);
glutInitWindowSize(800,800);
glutCreateWindow("DDA Line");
Init();
glutDisplayFunc(lineSe);
glutMainLoop();
return 0;
}