| Current Path : /var/www/html/venkat/check3/file/cg2013/pawan/ |
| Current File : /var/www/html/venkat/check3/file/cg2013/pawan/1.2.cpp |
#include <GL/glut.h>
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
void draw()
{
glClearColor(1.0,1.0,1.0,0);
/*void draw()
{
glClearColor(1.0,1.0,1.0,0);
glClear(GL_COLOR_BUFFER_BIT);
rectangle(0.0,0.4,0.75,0.75);
glFlush();
}*/
glClear(GL_COLOR_BUFFER_BIT);
line(0.0,0.4,0.75,0.75, 10000);
glFlush();
}
void line(float a11, float b11, float a12, float b12, int ss)
{
int ik;
float ttt, da, dy;
float a, y;
da = a12-a11;
dy = b12-b11;
float m = dy/da;
ttt = (da/float(ss));
/*void draw()
{
glClearColor(1.0,1.0,1.0,0);
glClear(GL_COLOR_BUFFER_BIT);
rectangle(0.0,0.4,0.75,0.75);
glFlush();
}*/
glColor3f(1.0,0.0,0.0);
glPointSize(2.0);
glBegin(GL_POINTS);
glVertex3f(a11,b11,0.0);
a = a11;
y = b11;
for (ik = 1; ik <= ss; ik++) {
a = a + ttt;
y = b11 + m*(a-a11);
glVertex3f(a,y,0.0);
}
glEnd();
}
int main(int abcd, char **xyz)
{
glutInit(&abcd, xyz);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
/*void draw()
{
glClearColor(1.0,1.0,1.0,0);
glClear(GL_COLOR_BUFFER_BIT);
rectangle(0.0,0.4,0.75,0.75);
glFlush();
}*/
glutInitWindowSize(500,500);
glutInitWindowPosition(0, 0);
glutCreateWindow("line using closely spaced points");
glutDisplayFunc(draw);
glutMainLoop();
return 0;
}