DDA
DDA
h>
#include<GL/glut.h>
#include<math.h>
//int x1,y1,x2,y2;
int n;
int endpoints[8][4];
int dx = x2 - x1;
int dy = y2 - y1;
int i=0;int steps=0;
void bresnham(){
int i;
glClearColor(1.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
for(i=0;i<n;i++){
//x1=endpoints[i][0];y1=endpoints[i][1];x2=endpoints[i]
[2];y2=endpoints[i][3];
draw_line(endpoints[i][0],endpoints[i][1],endpoints[i]
[2],endpoints[i][3]);
glColor3f(1.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2i(endpoints[i][0],endpoints[i][1]);
glVertex2i(endpoints[i][2],endpoints[i][3]);
glEnd();
//printf("The points are %d %d %d %d\n",x1,y1,x2,y2);
glFlush();
}
drawText(220,475,"DDA Line drawing algorithm");
drawText(250,450,"Nikhil V, 1BI18CS099");
glFlush();
void myInit(){
//glClearColor(1.0,1.0,1.0,1.0);
//glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,500,0,500);
glMatrixMode(GL_MODELVIEW);
}