X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Ftest-shapes-gles1%2Ftest-shapes-gles1.c;h=e0bdd0186658710959578d858294a24fbb457f37;hb=630b996f22fe007ccbf7e93cdf5ff12bf2c3cf05;hp=b22cb7f38edb873503d724934724825f85988b54;hpb=6dd8ad6d6bd0da0fc46fadb0e122fba6bae05736;p=freeglut diff --git a/progs/test-shapes-gles1/test-shapes-gles1.c b/progs/test-shapes-gles1/test-shapes-gles1.c index b22cb7f..e0bdd01 100644 --- a/progs/test-shapes-gles1/test-shapes-gles1.c +++ b/progs/test-shapes-gles1/test-shapes-gles1.c @@ -37,6 +37,7 @@ */ #include +#include #include #include @@ -70,6 +71,7 @@ static double offset[ 3 ] = { 0, 0, 0 }; static GLboolean show_info = GL_TRUE; static float ar; static GLboolean persProject = GL_TRUE; +static GLboolean animateXRot = GL_FALSE; /* * These one-liners draw particular objects, fetching appropriate @@ -90,16 +92,18 @@ static void drawSolidIcosahedron(void) { glutSolidIcosahedron (); static void drawWireIcosahedron(void) { glutWireIcosahedron (); } static void drawSolidSierpinskiSponge(void) { glutSolidSierpinskiSponge (depth, offset, orad);} /* orad doubles as size input */ static void drawWireSierpinskiSponge(void) { glutWireSierpinskiSponge (depth, offset, orad); } /* orad doubles as size input */ -static void drawSolidSphere(void) { glutSolidSphere(orad,slices,stacks); } /* orad doubles as size input */ -static void drawWireSphere(void) { glutWireSphere(orad,slices,stacks); } /* orad doubles as size input */ -#ifndef EGL_VERSION_1_0 static void drawSolidTorus(void) { glutSolidTorus(irad,orad,slices,stacks); } static void drawWireTorus(void) { glutWireTorus (irad,orad,slices,stacks); } +static void drawSolidSphere(void) { glutSolidSphere(orad,slices,stacks); } /* orad doubles as size input */ +static void drawWireSphere(void) { glutWireSphere(orad,slices,stacks); } /* orad doubles as size input */ static void drawSolidCone(void) { glutSolidCone(orad,orad,slices,stacks); } /* orad doubles as size input */ static void drawWireCone(void) { glutWireCone(orad,orad,slices,stacks); } /* orad doubles as size input */ static void drawSolidCylinder(void) { glutSolidCylinder(orad,orad,slices,stacks); } /* orad doubles as size input */ static void drawWireCylinder(void) { glutWireCylinder(orad,orad,slices,stacks); } /* orad doubles as size input */ -#endif +static void drawSolidTeapot(void) +{ glFrontFace(GL_CW); glutSolidTeapot(orad); glFrontFace(GL_CCW); /* orad doubles as size input */} +static void drawWireTeapot(void) +{ glFrontFace(GL_CW); glutWireTeapot(orad); glFrontFace(GL_CCW); /* orad doubles as size input */} /* * This structure defines an entry in our function-table. @@ -114,14 +118,19 @@ typedef struct #define ENTRY(e) {#e, drawSolid##e, drawWire##e} static const entry table [] = { - ENTRY (Cube), ENTRY (Tetrahedron), + ENTRY (Cube), ENTRY (Octahedron), ENTRY (Dodecahedron), ENTRY (RhombicDodecahedron), ENTRY (Icosahedron), ENTRY (SierpinskiSponge), + ENTRY (Teapot), + ENTRY (Torus), ENTRY (Sphere), + ENTRY (Cone), + ENTRY (Cylinder), + /* ENTRY (Cuboctahedron) */ }; #undef ENTRY @@ -151,6 +160,7 @@ static void display(void) { const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; const double a = t*90.0; + const double b = (animateXRot?t:1)*60.0; glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -166,14 +176,14 @@ static void display(void) glPushMatrix(); glTranslated(0,1.2,-6); - glRotated(60,1,0,0); + glRotated(b,1,0,0); glRotated(a,0,0,1); table [function_index].solid (); glPopMatrix(); glPushMatrix(); glTranslated(0,-1.2,-6); - glRotated(60,1,0,0); + glRotated(b,1,0,0); glRotated(a,0,0,1); table [function_index].wire (); glPopMatrix(); @@ -218,6 +228,9 @@ key(unsigned char key, int x, int y) case 'P': case 'p': persProject=!persProject; break; + case 'R': + case 'r': animateXRot=!animateXRot; break; + default: break; } @@ -258,7 +271,7 @@ idle(void) static void onMouseClick(int button, int state, int x, int y) { if (state == GLUT_DOWN) - special(GLUT_KEY_PAGE_DOWN, 0, 0); + special(GLUT_KEY_PAGE_UP, 0, 0); } const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f }; @@ -273,25 +286,8 @@ const GLfloat high_shininess[] = { 100.0f }; /* Program entry point */ -int -main(int argc, char *argv[]) -{ - glutInitWindowSize(640,480); - glutInitWindowPosition(40,40); - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); - - glutCreateWindow("FreeGLUT Shapes"); - - glutReshapeFunc(resize); - glutDisplayFunc(display); - glutKeyboardFunc(key); - glutSpecialFunc(special); - glutIdleFunc(idle); - glutMouseFunc(onMouseClick); - - glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ) ; - +void init_context() { + printf("init_context\n"); fflush(stdout); glClearColor(1,1,1,1); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); @@ -312,6 +308,27 @@ main(int argc, char *argv[]) glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); +} + +int +main(int argc, char *argv[]) +{ + glutInitWindowSize(640,480); + glutInitWindowPosition(40,40); + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); + + glutCreateWindow("FreeGLUT Shapes"); + + glutReshapeFunc(resize); + glutDisplayFunc(display); + glutKeyboardFunc(key); + glutSpecialFunc(special); + glutIdleFunc(idle); + glutMouseFunc(onMouseClick); + glutInitContextFunc(init_context); + + glutSetOption ( GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION ) ; glutMainLoop();