Advertisement
Guest User

imon re thabra

a guest
Feb 19th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include<iostream>
  2. #include <windows.h>
  3. #include <GL/glut.h>
  4. using namespace std;
  5.  
  6. int x1 = 4;
  7. int y1 = 5;
  8. int x2 = 200;
  9. int y2 = 250;
  10.  
  11.  
  12. void display() {
  13. glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
  14. gluOrtho2D(0,300,0,300);
  15. glClear(GL_COLOR_BUFFER_BIT);
  16. glPointSize(1.0);
  17.  
  18.  
  19. int dx = x2-x1;
  20. int dy = y2 - y1;
  21. float m = 1.0 * dy/dx;
  22.  
  23. int iteration = max(dy,dx);
  24.  
  25. for(int count = 0;count <iteration;count++)
  26. {
  27.  
  28. glBegin(GL_POINTS);
  29. glColor3f(1.0f, 0.0f, 0.0f);
  30. glVertex2f(x1, y1);
  31. glEnd();
  32.  
  33. x1++;
  34. y1+=m;
  35.  
  36. }
  37.  
  38.  
  39.  
  40. glFlush();
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47. int main(int argc, char** argv) {
  48. glutInit(&argc, argv);
  49. glutCreateWindow("midpoint");
  50. glutInitWindowSize(320, 320);
  51. glutInitWindowPosition(50, 50);
  52. glutDisplayFunc(display);
  53. glutMainLoop();
  54.  
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement