Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <windows.h>
- #include <GL/glut.h>
- using namespace std;
- int x1 = 4;
- int y1 = 5;
- int x2 = 200;
- int y2 = 250;
- void display() {
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- gluOrtho2D(0,300,0,300);
- glClear(GL_COLOR_BUFFER_BIT);
- glPointSize(1.0);
- int dx = x2-x1;
- int dy = y2 - y1;
- float m = 1.0 * dy/dx;
- int iteration = max(dy,dx);
- for(int count = 0;count <iteration;count++)
- {
- glBegin(GL_POINTS);
- glColor3f(1.0f, 0.0f, 0.0f);
- glVertex2f(x1, y1);
- glEnd();
- x1++;
- y1+=m;
- }
- glFlush();
- }
- int main(int argc, char** argv) {
- glutInit(&argc, argv);
- glutCreateWindow("midpoint");
- glutInitWindowSize(320, 320);
- glutInitWindowPosition(50, 50);
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement