Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- #include <stdlib.h>
- #include <stdio.h>
- void init(void){}
- void display(void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f (0.0, 1.0, 0.0);
- glPushMatrix();
- GLfloat vertices[] = {0.1,0.1,0.1, -0.1,0.1,0.1, -0.1,-0.1,0.1, 0.1,-0.1,0.1,
- 0.1,0.1,0.1, 0.1,-0.1,0.1, 0.1,-0.1,-0.1, 0.1,0.1,-0.1,
- 0.1,0.1,0.1, 0.1,0.1,-0.1, -0.1,0.1,-0.1, -0.1,0.1,0.1,
- -0.1,0.1,0.1, -0.1,0.1,-0.1, -0.1,-0.1,-0.1, -0.1,-0.1,0.1,
- -0.1,-0.1,-0.1, 0.1,-0.1,-0.1, 0.1,-0.1,0.1, -0.1,-0.1,0.1,
- 0.1,-0.1,-0.1, -0.1,-0.1,-0.1, -0.1,0.1,-0.1, 0.1,0.1,-0.1};
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, vertices);
- glDrawArrays(GL_QUADS, 0, 24);
- glDisableClientState(GL_VERTEX_ARRAY);
- glPopMatrix();glFlush();
- }
- void keyboard(unsigned char key, int x, int y)
- {
- switch (key) {
- case 'z':
- glRotatef(5, 0, 0.0, 0.1);
- glutPostRedisplay();
- break;
- case 'y':
- glRotatef(5,0,0.1,0);
- glutPostRedisplay();
- break;
- case 'x':
- glRotatef(5,0.1,0,0);
- glutPostRedisplay();
- break;
- case 27:
- exit(0);
- }
- }
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize (400, 400);
- glutCreateWindow (argv[0]); init();
- glutKeyboardFunc (keyboard);
- glutDisplayFunc (display);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement