Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <GL/glut.h>
- static int width;
- static int height;
- GLfloat zSpin;
- void init()
- {
- glClearColor(0, 0, 0, 0);
- glEnable(GL_DEPTH_TEST);
- glMatrixMode(GL_PROJECTION);
- glOrtho(-3, 3, -3, 3, 1, 50);
- glLoadIdentity();
- }
- void display()
- {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glViewport(0, height / 2, width / 2, height / 2);
- glMatrixMode(GL_PROJECTION);
- glOrtho(-3, 3, -3, 3, 1, 50);
- glLoadIdentity();
- glColor3f(1.0f, 0, 0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt(0.0f, -0.5f, 0.0f,
- 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f);
- glutWireTeapot(0.5f);
- glViewport(width / 2, height / 2, width / 2, height / 2);
- glMatrixMode(GL_PROJECTION);
- glOrtho(-3, 3, -3, 3, 1, 50);
- glLoadIdentity();
- glColor3f(1.0f, 0, 0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt(1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f);
- glutWireTeapot(0.5f);
- glViewport(0, 0, width / 2, height / 2);
- glMatrixMode(GL_PROJECTION);
- glOrtho(-3, 3, -3, 3, 1, 50);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glColor3f(1.0f, 0, 0);
- glutWireTeapot(0.5f);
- glViewport(width / 2, 0, width / 2, height / 2);
- //glMatrixMode(GL_PROJECTION);
- gluPerspective(70, 1, 1, 50);
- glLoadIdentity();
- //glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glRotatef(zSpin, 0, 0, 1.0);
- glRotatef(45, 1, 0, 0);
- glColor3f(1.0f, 0, 0);
- glutWireTeapot(0.5f);
- glFlush();
- }
- void reshape(int w, int h)
- {
- width = w;
- height = h;
- glViewport(0, 0, width, height);
- }
- void rotationFunc(void){
- zSpin +=0.3;
- display();
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- int screen_Width = (glutGet(GLUT_SCREEN_WIDTH) - 640) / 2;
- int screen_Height = (glutGet(GLUT_SCREEN_HEIGHT) - 480) / 2;
- glutInitWindowPosition(screen_Width, screen_Height);
- glutInitWindowSize(800, 800);
- glutCreateWindow("Bonus 2");
- init();
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- glutIdleFunc(rotationFunc);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement