Lab Report 3
Lab Report 3
ENGINEERING
Lab Report-6
Submitted by
Submitted to Submitted to
Code:
#include<windows.h>
#include<GL/glut.h>
#include<iostream>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2f(-1.0,0.0);
glVertex2f(1.0,0.0);
glVertex2f(0.0,1.0);
glVertex2f(0.0,-1.0);
glEnd();
double x1=0.2,y1=0.2,x2=1.0,y2=1.0;
double temp;
if (x1>x2)
{
temp=x1;
x1=x2;
x2=temp;
}
double x=x1;
double y=y1;
double m=(y2-y1)/(x2-x1);
double b=y-(m*x);
while(x<=x2)
{
glPointSize(7.0);
glBegin(GL_POINTS);
glColor3f(1,0,0);
glVertex2f(x,y);
x=x+0.1;
y=(m*x)+b;
glEnd();
glFlush();
}
}
int main(int argc, char *argv[])
{
glutInit(&argc,argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE|GLUT_DEPTH);
glutCreateWindow("POINT");
glutDisplayFunc(display);
glutMainLoop();
return EXIT_SUCCESS;
}
Output: