Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <glut.h>
- #include <cmath>
- #include <math.h>
- float rotace = 0;
- float posunPL = 0;
- float posunND = 0;
- void onResize(int w, int h)
- {
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, w, 0, h, -800, 800);
- }
- void Zobrazeni(void)
- {
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(0.0f, 1.0f, 0.0f);
- glLineWidth(3.0f);
- glEnable(GL_LINE_SMOOTH);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(800+posunPL, 500.0f+posunND, 500);
- glRotatef(rotace, 1.0f, 0, 0.0f);
- glColor3f(1.0, 1.0, 1.0);
- //glBegin(GL_POLYGON);
- /*glVertex3i(150, 150, 0);
- glVertex3i(450, 150, 0);
- glVertex3i(450, 450, 0);
- //glColor3f(1.0, 0.0, 1.0);
- glVertex3i(250, 450, 0);
- //glColor3f(0.0, 0.0, 1.0);
- glVertex3i(150, 250, 0);
- glVertex3i(150, 150, 0);
- glEnd();*/
- glutSolidTeapot(50);
- glFlush();
- }
- void onKeyboard(unsigned char key, int x, int y)
- {
- switch (key)
- {
- case 27:
- exit(0);
- break;
- case 'r':
- rotace += 15;
- glutPostRedisplay();
- break;
- case 'd':
- posunPL += 1;
- glutPostRedisplay();
- break;
- case 'a':
- posunPL -= 1;
- glutPostRedisplay();
- break;
- case 'w':
- posunND += 1;
- glutPostRedisplay();
- break;
- case 's':
- posunND -= 1;
- glutPostRedisplay();
- break;
- }
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutCreateWindow("OpenGL okno");
- glutReshapeWindow(1920, 1080);
- glutPositionWindow(0, 0);
- glutDisplayFunc(Zobrazeni);
- glutReshapeFunc(onResize);
- glutKeyboardFunc(onKeyboard);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement