Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define GLUT_DISABLE_ATEXIT_HACK
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <GL/glut.h>
- #include <stdio.h>
- #include <stdlib.h>
- int screenWidth = 600;
- int screenHeight = 600;
- int figure = 0;
- void show(){
- switch(figure){
- default:
- case 0:
- glutSolidSphere(100, 50, 50);
- break;
- case 1:
- glutWireSphere(100, 50, 50);
- break;
- case 2:
- glutSolidCube(100);
- break;
- case 3:
- glutWireCube(100);
- break;
- case 4:
- glutSolidCone(100, 100, 50, 50);
- break;
- case 5:
- glutWireCone(100, 100, 50, 50);
- break;
- case 6:
- glutSolidTorus(100, 200, 50, 50);
- break;
- case 7:
- glutWireTorus(100, 200, 50, 50);
- break;
- case 8:
- glutSolidTeapot(100);
- break;
- case 9:
- glutWireTeapot(100);
- break;
- }
- }
- void display() {
- glLoadIdentity();
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(0.0, 1.0, 0.0);
- show();
- glutPostRedisplay();
- glutSwapBuffers();
- }
- void reshape(int w, int h) {
- glViewport(0, 0, (GLsizei) w, (GLsizei) h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-(GLdouble) screenWidth, (GLdouble) screenWidth, -(GLdouble) screenHeight, (GLdouble) screenHeight, 100, -100);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- void keyboard(unsigned char key, int x, int y){
- switch(key){
- default:
- figure = key - 48;
- break;
- case 27 :
- case 'q':
- exit(0);
- break;
- }
- }
- int main(int argc, char *argv[]) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(screenWidth, screenHeight);
- glutCreateWindow(argv[0]);
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- glutKeyboardFunc(keyboard);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement