X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fteapot.c;h=c885d27be725454faf6d1ea81db06781e9e94d84;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=373a8b221b1c1e91fa5736759762fdc6c50c4d04;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/glx/teapot.c b/hacks/glx/teapot.c index 373a8b22..c885d27b 100644 --- a/hacks/glx/teapot.c +++ b/hacks/glx/teapot.c @@ -50,12 +50,21 @@ OpenGL(TM) is a trademark of Silicon Graphics, Inc. #include "teapot.h" -#ifdef HAVE_COCOA -# include -#else +#ifndef HAVE_JWXYZ # include #endif +#ifdef HAVE_ANDROID +# include +#endif + +#ifdef HAVE_JWZGLES +# include "jwzgles.h" +#else +# define HAVE_GLMAP +#endif + +#ifdef HAVE_GLMAP /* Rim, body, lid, and bottom data must be reflected in x and y; handle and spout data across the y axis only. */ @@ -191,20 +200,20 @@ unit_teapot (int grid, int wire_p) &p[0][0][0]); glMapGrid2f(grid, 0.0, 1.0, grid, 0.0, 1.0); glEvalMesh2(type, 0, grid, 0, grid); - polys += grid*grid; + polys += grid*grid*2; glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &q[0][0][0]); glEvalMesh2(type, 0, grid, 0, grid); - polys += grid*grid; + polys += grid*grid*2; if (i < 6) { glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &r[0][0][0]); glEvalMesh2(type, 0, grid, 0, grid); - polys += grid*grid; + polys += grid*grid*2; glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &s[0][0][0]); glEvalMesh2(type, 0, grid, 0, grid); - polys += grid*grid; + polys += grid*grid*2; } } glPopMatrix(); @@ -212,3 +221,65 @@ unit_teapot (int grid, int wire_p) return polys; } + +#else /* !HAVE_GLMAP */ + +# include "normals.h" +# include "teapot2.h" + +int +unit_teapot (int grid, int wire_p) +{ + int polys = sizeof (teapot_triangles) / sizeof (*teapot_triangles) / 9; + int i; + const GLfloat *p = teapot_triangles; + GLfloat scale = 1 / 2.3; + + glPushMatrix(); + glScalef (scale, scale, scale); + glTranslatef (0, -1.25, 0); + + if (wire_p) + { + glBegin (GL_LINES); + for (i = 0; i < polys; i++) + { + XYZ p1, p2, p3; + p1.x = *p++; p1.y = *p++; p1.z = *p++; + p2.x = *p++; p2.y = *p++; p2.z = *p++; + p3.x = *p++; p3.y = *p++; p3.z = *p++; + glVertex3f (p1.x, p1.y, p1.z); /* Draw 2 edges of each triangle */ + glVertex3f (p2.x, p2.y, p2.z); + glVertex3f (p1.x, p1.y, p1.z); + glVertex3f (p3.x, p3.y, p3.z); + i++; /* Skip every other triangle */ + p += 9; + } + glEnd(); + polys /= 2; + } + else + { + glFrontFace (GL_CCW); + glBegin (GL_TRIANGLES); + for (i = 0; i < polys; i++) + { + XYZ p1, p2, p3; + p1.x = *p++; p1.y = *p++; p1.z = *p++; + p2.x = *p++; p2.y = *p++; p2.z = *p++; + p3.x = *p++; p3.y = *p++; p3.z = *p++; + do_normal (p1.x, p1.y, p1.z, + p2.x, p2.y, p2.z, + p3.x, p3.y, p3.z); + glVertex3f (p1.x, p1.y, p1.z); + glVertex3f (p2.x, p2.y, p2.z); + glVertex3f (p3.x, p3.y, p3.z); + } + glEnd(); + } + glPopMatrix(); + + return polys; +} + +#endif /* !HAVE_GLMAP */