Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <glut.h>
- GLfloat rotObsY = 20.0;
- GLfloat rotObsX = 20.0;
- void rys() {
- glScalef(10, 10, 10);
- glBegin(GL_QUADS);
- glColor3f(0, 0, 0);
- glVertex3f(0, 0, 0);
- glColor3f(1, 0, 0);
- glVertex3f(1, 0, 0);
- glColor3f(1, 1, 0);
- glVertex3f(1, 1, 0);
- glColor3f(0, 1, 0);
- glVertex3f(0, 1, 0);
- glColor3f(0, 0, 0);
- glVertex3f(0, 0, 0);
- glColor3f(1, 0, 0);
- glVertex3f(1, 0, 0);
- glColor3f(1, 0, 1);
- glVertex3f(1, 0, 1);
- glColor3f(0, 0, 1);
- glVertex3f(0, 0, 1);
- glColor3f(0, 0, 0);
- glVertex3f(0, 0, 0);
- glColor3f(0, 1, 0);
- glVertex3f(0, 1, 0);
- glColor3f(0, 1, 1);
- glVertex3f(0, 1, 1);
- glColor3f(0, 0, 1);
- glVertex3f(0, 0, 1);
- glColor3f(1, 1, 1);
- glVertex3f(1, 1, 1);
- glColor3f(1, 1, 0);
- glVertex3f(1, 1, 0);
- glColor3f(0, 1, 0);
- glVertex3f(0, 1, 0);
- glColor3f(0, 1, 1);
- glVertex3f(0, 1, 1);
- glColor3f(1, 1, 1);
- glVertex3f(1, 1, 1);
- glColor3f(1, 0, 1);
- glVertex3f(1, 0, 1);
- glColor3f(1, 0, 0);
- glVertex3f(1, 0, 0);
- glColor3f(1, 1, 0);
- glVertex3f(1, 1, 0);
- glColor3f(1, 1, 1);
- glVertex3f(1, 1, 1);
- glColor3f(1, 0, 1);
- glVertex3f(1, 0, 1);
- glColor3f(0, 0, 1);
- glVertex3f(0, 0, 1);
- glColor3f(0, 1, 1);
- glVertex3f(0, 1, 1);
- glEnd();
- }
- void WyswietlObraz(void)
- {
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- glPushMatrix();
- glTranslatef(0, 0, -40);
- glRotatef(rotObsX, 1, 0, 0);
- glRotatef(rotObsY,0,1,0);
- rys();
- glPopMatrix();
- glutSwapBuffers();
- }
- void UstawParametryWidoku(int szerokosc, int wysokosc)
- {
- glViewport(0, 0, szerokosc, wysokosc);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(40.0, (float)szerokosc/(float)wysokosc, 1.0, 1000.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- void ObslugaKlawiszySpecjalnych(int klawisz, int x, int y)
- {
- switch(klawisz)
- {
- case GLUT_KEY_UP:
- rotObsX = rotObsX + 1.0;
- break;
- case GLUT_KEY_DOWN:
- rotObsX =rotObsX - 1.0;
- break;
- case GLUT_KEY_LEFT:
- rotObsY = rotObsY - 1.0;
- break;
- case GLUT_KEY_RIGHT:
- rotObsY = rotObsY + 1.0 ;
- break;
- }
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
- glutInitWindowPosition(100, 100);
- glutInitWindowSize(1000, 900);
- glutCreateWindow("Robot");
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LEQUAL);
- glClearDepth(1000.0);
- glClearColor (0.0, 0.5, 0.5, 0.5);
- glutDisplayFunc(WyswietlObraz);
- glutReshapeFunc(UstawParametryWidoku);
- glutIdleFunc(WyswietlObraz);
- glutSpecialFunc(ObslugaKlawiszySpecjalnych);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement