Professional Documents
Culture Documents
Class : SE IT
Roll No : 9045
Topic : Assignment 2
void myInit(void)
{
glClearColor(0.1,0.1,0.1,0.0);
glColor3f(1.0f,0.0f,0.0f);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-w/2,w/2,-h/2,h/2);
}
dx=(x2-x1)/length; //Step 2
dy=(y2-y1)/length;
x=x1+0.5*sign(dx); //Step 3
y=y1+0.5*sign(dy);
int i=1;
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
while(i<=length)
{
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
x=x+dx;
y=y+dy;
i=i+1;
}
}
dx=(x2-x1)/length; //Step 2
dy=(y2-y1)/length;
x=x1+0.5*sign(dx); //Step 3
y=y1+0.5*sign(dy);
int i=1;
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
while(i<=length)
{
if(i%5==0)
{
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
}
x=x+dx;
y=y+dy;
i=i+1;
}
}
dx=(x2-x1)/length; //Step 2
dy=(y2-y1)/length;
x=x1+0.5*sign(dx); //Step 3
y=y1+0.5*sign(dy);
int i=1;
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
int t=0;
while(i<=length)
{
if(i%15==0)
{
if(t==0)
t=1;
else
t=0;
}
if(t==0)
{
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
}
x=x+dx;
y=y+dy;
i=i+1;
}
}
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,0.0f,0.0f);
glPointSize(4.0);
for(int i=-w;i<=w;i+=2)
{
setpixel(i,0);
setpixel(0,i);
}
glFlush();
}
cout<<endl;
if(item==1)
{
simple(10,10,200,200);
cout<<"You clicked item : Simple Line";
}
if(item==2)
{
dotted(-10,10,-200,200);
cout<<"You clicked item : Simple Line ";
}
if(item==3)
{
dashed(10,-10,200,-200);
cout<<"You clicked item : Simple Line ";
}
if(item==4)
{
exit(0);
}
}
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(700,700);
glutInitWindowPosition(700,700);