Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<windows.h>
- #include<GL/glut.h>
- void myInit(void)
- {
- glClearColor(1.0, 1.0, 1.0, 0.0);
- glColor3f(0.0f, 0.0f, 0.0f);
- glPointSize(4.0);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-1.0,1.0,-1.0, 1.0, -1.0, 1.0);
- gluOrtho2D(0.0, 640.0, 0.0, 480.0);
- }
- void myDisplay(void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glPointSize(2.0);
- GLint x,y,
- x1=50,
- x2=100,
- y1=100,
- y2=200;
- GLint dx, dy, inc1, inc2, d;
- x = x1;
- y = y1;
- dx = x2-x1;
- dy = y2-y1;
- inc1 = 2 * dy;
- inc2 = 2 * (dy-dx);
- d = inc1 - dx;
- while(x <= x2) {
- glBegin(GL_POINTS);
- {
- glVertex2i(x,y);
- }
- glEnd();
- x++;
- if(d < 0) d = d + inc1;
- else {
- d = d + inc2;
- y++;
- }
- }
- glFlush();
- }
- void main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(640,480);
- glutInitWindowPosition(100,150);
- glutCreateWindow("My First Window");
- glutDisplayFunc(myDisplay);
- myInit();
- glutMainLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement