Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream>
  3. #include <GL/glut.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. void drawLine();
  9.  
  10. void CoordinateAxes();
  11. void plot(float x, float y);
  12.  
  13.  
  14.  
  15.  
  16. float x, y, dx, dy, D1, D2, xInc, yInc;
  17. int arraySize;
  18. static int step;
  19.  
  20.  
  21. int main(int argc, char** argv)
  22. {
  23.  
  24.  
  25. glutInit(&argc, argv);
  26. glutInitDisplayMode(GLUT_RGB);
  27. glutInitWindowPosition(100, 100);
  28. glutInitWindowSize(500,500);
  29.  
  30. glutCreateWindow("DDA Algorithm");
  31. glutDisplayFunc(drawLine);
  32.  
  33. glutMainLoop();
  34. return 0;
  35. }
  36.  
  37. void drawLine()
  38. {
  39.  
  40. CoordinateAxes();
  41. glColor3ub(255 ,255,255);
  42. glBegin(GL_LINES);
  43. plot(0,0);
  44. plot(0,100);
  45. plot(100,100);
  46. plot(100,0);
  47. glEnd();
  48. glFlush();
  49. }
  50.  
  51.  
  52. void CoordinateAxes()
  53. {
  54. glColor3ub(0,0,255);
  55. glBegin(GL_LINES);
  56. glVertex2f(0,1);
  57. glVertex2f(0,-1);
  58. glVertex2f(-1,0);
  59. glVertex2f(1,0);
  60. glEnd();
  61. }
  62.  
  63. void plot(float x, float y)
  64. {
  65. glVertex2f(x/500, y/500);
  66. cout << "(" << x << "," << y << ")";
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement