Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include<windows.h>
- #ifdef __APPLE__
- #include <GLUT/glut.h>
- #else
- #include <GL/glut.h>
- #endif
- #include <stdlib.h>
- #include <math.h>
- float p = -10.0; // Display Measurement with ortho starting from the left -10 and right 10
- void display(void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- if (p <= 10) // moving limit with the display measurement
- p = p + .003; // changing the object position for redisplaying
- else
- p = -10; // For backing the object continuously
- glutPostRedisplay(); // To redraw the object in the display
- glBegin(GL_QUADS);
- glColor3f(1.0, 0.0, 1.0);
- glVertex2f(p + 1, -8); // a // boat
- glVertex2f(p + 6, -8); // b
- glVertex2f(p + 5, -9); // c
- glVertex2f(p + 2, -9); // d
- glColor3f(0.0, 1.0, 1.0);
- glVertex2f(p + 4, -5); // a // khamba
- glVertex2f(p + 5, -5); // b
- glVertex2f(p + 5, -8); // c
- glVertex2f(p + 4, -8); // d
- glColor3f(1.0, 1.0, 0.0);
- glVertex2f(p + 3, -6); // a // flag
- glVertex2f(p + 4, -5); // b
- glVertex2f(p + 4, -7); // c
- glVertex2f(p + 3, -6); // a
- glEnd();
- glFlush();
- }
- void init(void)
- {
- glClearColor(1.0, 0.0, 0.0, 0.0); // Background Color
- glOrtho(-10, 10, -10, 10, -10, 10); // To specify the coordinate & Specify the distances to the nearer and farther depth clipping planes.
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // Single Frame
- glutInitWindowSize(600, 600);
- glutInitWindowPosition(100, 100);
- glutCreateWindow("moving_object");
- init(); // Set up constants with default values
- glutDisplayFunc(display);
- glutMainLoop(); // It enters the GLUT event processing loop.should be called at most once in a GLUT program. Once called, this routine will never return. It will call as necessary any callbacks that have been registered.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment