X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffg_geometry.c;h=2c6f344c2fdb245e3d5cf5d403f0ec606e2245d7;hb=da66462c2b7ce3185bc714cbabade787291c5c6f;hp=f0ab8d9903ad45d5f2ff83420d792e03c56282f5;hpb=005341f3e1fc913acaa37442c2cbe906dc4a07b4;p=freeglut diff --git a/src/fg_geometry.c b/src/fg_geometry.c index f0ab8d9..2c6f344 100644 --- a/src/fg_geometry.c +++ b/src/fg_geometry.c @@ -29,143 +29,92 @@ #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 */ -/* General function for drawing geometry. As for all geometry we have no - * redundancy (or hardly any in the case of cones and cylinders) in terms - * of the vertex/normal combinations, we just use glDrawArrays. - * useWireMode controls the drawing of solids (false) or wire frame - * versions (TRUE) of the geometry you pass +/* General functions for drawing geometry + * Solids are drawn by glDrawArrays if composed of triangles, or by + * glDrawElements if consisting of squares or pentagons that were + * decomposed into triangles (some vertices are repeated in that case). + * WireFrame drawing will have to be done per face, using GL_LINE_LOOP and + * issuing one draw call per face. Always use glDrawArrays as no triangle + * decomposition needed. We use the "first" parameter in glDrawArrays to go + * from face to face. */ -static void fghDrawGeometry(GLenum vertexMode, GLdouble *vertices, GLdouble *normals, GLboolean *edgeFlags, GLsizei numVertices, GLboolean useWireMode) +static void fghDrawGeometryWire(GLdouble *vertices, GLdouble *normals, GLsizei numFaces, GLsizei numEdgePerFace) { - if (useWireMode) - { - glPushAttrib(GL_POLYGON_BIT); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - } + int i; + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); - if (1) - { - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - if (edgeFlags) - glEnableClientState(GL_EDGE_FLAG_ARRAY); - - glVertexPointer(3, GL_DOUBLE, 0, vertices); - glNormalPointer(GL_DOUBLE, 0, normals); - if (edgeFlags) - glEdgeFlagPointer(0,edgeFlags); - glDrawArrays(vertexMode, 0, numVertices); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - if (edgeFlags) - glDisableClientState(GL_EDGE_FLAG_ARRAY); - } + glVertexPointer(3, GL_DOUBLE, 0, vertices); + glNormalPointer(GL_DOUBLE, 0, normals); + + /* Draw per face (TODO: could use glMultiDrawArrays if available) */ + for (i=0; i