Professional Documents
Culture Documents
Include
Include
h>
#include<GL/glut.h>
#include<stdlib.h>
#include<stdio.h>
float x,x2,y,y2,x1,y1,p,i;
void display(void)
{ glBegin(GL_POINTS);
glVertex2f(x1,y1);
p=2*dy-dx;
{if(p<0)
{ x=x1+1;
y=y1;
glBegin(GL_POINTS);
glVertex2f(x,y);
p=p+(2*dy);
else
x=x1+1;
y=y1+1;
glBegin(GL_POINTS);
glVertex2f(x,y);
p=p+(2*dy)-(2*dx);
x1=x;
y1=y;
glVertex2f(x2,y2);
glEnd();
glFlush();
void init(void)
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-100,100,-100,100);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
glutCreateWindow("___");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;