diff --git a/freeglut/freeglut/src/fg_geometry.c b/freeglut/freeglut/src/fg_geometry.c index df3f298..ee24984 100644 --- a/freeglut/freeglut/src/fg_geometry.c +++ b/freeglut/freeglut/src/fg_geometry.c @@ -29,38 +29,7 @@ #include "fg_internal.h" /* - * * Need more types of polyhedra? See CPolyhedron in MRPT - * - * TODO BEFORE THE STABLE RELEASE: - * - * See fghTetrahedron - * - * Following functions have been contributed by Andreas Umbach. - * - * glutWireCube() -- looks OK - * glutSolidCube() -- OK - * - * Those functions have been implemented by John Fay. - * - * glutWireTorus() -- looks OK - * glutSolidTorus() -- looks OK - * glutWireDodecahedron() -- looks OK - * glutSolidDodecahedron() -- looks OK - * glutWireOctahedron() -- looks OK - * glutSolidOctahedron() -- looks OK - * glutWireTetrahedron() -- looks OK - * glutSolidTetrahedron() -- looks OK - * glutWireIcosahedron() -- looks OK - * glutSolidIcosahedron() -- looks OK - * - * The Following functions have been updated by Nigel Stewart, based - * on FreeGLUT 2.0.0 implementations: - * - * glutWireSphere() -- looks OK - * glutSolidSphere() -- looks OK - * glutWireCone() -- looks OK - * glutSolidCone() -- looks OK */ @@ -70,8 +39,71 @@ * useWireMode controls the drawing of solids (false) or wire frame * versions (TRUE) of the geometry you pass */ -static void fghDrawGeometry(GLenum vertexMode, GLdouble *vertices, GLdouble *normals, GLboolean *edgeFlags, GLsizei numVertices, GLboolean useWireMode) +static void fghDrawGeometry(GLdouble *vertices, GLdouble *normals, GLboolean *edgeFlags, GLsizei numVertices, GLsizei numFaces, GLsizei numEdgePerFace, GLboolean useWireMode) { +# ifdef FREEGLUT_GLES + /* Solid drawing is the same for OpenGL 1.x and OpenGL ES 1.x, just + * no edge flags for ES. + * WireFrame drawing will have to be done per face though, using + * GL_LINE_LOOP and issuing one draw call per face. For triangles, + * we use glDrawArrays directly on the vertex data for each face, + * while for shapes that are composed of quads or pentagons, we use + * glDrawElements with index vector {0,1,2,5} or {0,1,2,8,5}, + * respectively. + * We use the first parameter in glDrawArrays or glDrawElements to + * go from face to face. + */ + if (useWireMode) + { + /* setup reading the right elements from vertex array */ + GLubyte vertIdx4[4] = {0,1,2,5}; + GLubyte vertIdx5[5] = {0,1,2,8,5}; + GLubyte *indices = NULL; + int vertStride, i, j; + + switch (numEdgePerFace) + { + case 3: + vertStride = 3; /* there are 3 vertices for each face in the array */ + break; + case 4: + indices = vertIdx4; + vertStride = 6; /* there are 6 vertices for each face in the array */ + break; + case 5: + indices = vertIdx5; + vertStride = 9; /* there are 9 vertices for each face in the array */ + break; + } + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + + glVertexPointer(3, GL_DOUBLE, 0, vertices); + glNormalPointer(GL_DOUBLE, 0, normals); + + if (numEdgePerFace==3) + for (i=0; i