Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <GL/glut.h>
- using namespace std;
- void drawLine();
- void CoordinateAxes();
- void plot(float x, float y);
- float x, y, dx, dy, D1, D2, xInc, yInc;
- int arraySize;
- static int step;
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_RGB);
- glutInitWindowPosition(100, 100);
- glutInitWindowSize(500,500);
- glutCreateWindow("DDA Algorithm");
- glutDisplayFunc(drawLine);
- glutMainLoop();
- return 0;
- }
- void drawLine()
- {
- CoordinateAxes();
- glColor3ub(255 ,255,255);
- glBegin(GL_LINES);
- plot(0,0);
- plot(0,100);
- plot(100,100);
- plot(100,0);
- glEnd();
- glFlush();
- }
- void CoordinateAxes()
- {
- glColor3ub(0,0,255);
- glBegin(GL_LINES);
- glVertex2f(0,1);
- glVertex2f(0,-1);
- glVertex2f(-1,0);
- glVertex2f(1,0);
- glEnd();
- }
- void plot(float x, float y)
- {
- glVertex2f(x/500, y/500);
- cout << "(" << x << "," << y << ")";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement