1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <stdlib.h>
void ProcessSpecialKeys(int key, int x, int y){
switch(key){
case GLUT_KEY_RIGHT:
exit(0);
case GLUT_KEY_LEFT:
exit(0);
case GLUT_KEY_UP:
exit(0);
case GLUT_KEY_DOWN:
exit(0);
default:
exit(0);
}
}
void renderPrimitive(void){
glBegin(GL_QUADS);
glVertex3f(-1.0f,-1.0f,0.0f);
glVertex3f(-1.0f,1.0f,0.0f);
glVertex3f(1.0f,1.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glEnd();
glutSwapBuffers();
}
void display(void){
glTranslatef(0.0f,0.0f,-0.5f);
renderPrimitive();
glutSwapBuffers();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("Dimension");
glutDisplayFunc(display);
glLoadIdentity();
glutSpecialFunc(ProcessSpecialKeys);
glutMainLoop();
return 0;
}
|