title: Drawing the top and bottom of a cylinder
body: <p>I'm trying to create a class that can procedurally create prisms (or cylinders if the precision is high enough) but only the sides of the 3d model are showing (not the top and bottom). This is using openGL and c++. Not going for efficiency, just modifying a previous class that made a sphere.</p>
  
  <pre><code>#define numSlices 2
  Prism::Prism() {
      init(3);
  }
  
  Prism::Prism(int prec) {
      init(prec);
  }
  
  float Prism::toRadians(float degrees) { return (degrees * 2.0f * 3.14159f) / 360.0f; }
  
  void Prism::init(int prec) {
      prec = (prec &lt; 3) ? 3 : prec;
  
      numVertices = (prec + 1) * (numSlices+1);
      numIndices = prec * numSlices * 6;
      for (int i = 0; i &lt; numVertices; i++) { vertices.push_back(glm::vec3()); }
      for (int i = 0; i &lt; numVertices; i++) { texCoords.push_back(glm::vec2()); }
      for (int i = 0; i &lt; numVertices; i++) { normals.push_back(glm::vec3()); }
      for (int i = 0; i &lt; numVertices; i++) { tangents.push_back(glm::vec3()); }
      for (int i = 0; i &lt; numIndices; i++) { indices.push_back(0); }
  
      // calculate triangle vertices
      for (int i = 0; i &lt;= numSlices; i++) {
          for (int j = 0; j &lt;= prec; j++) {
              float y = i;
              float x = -(float)cos(toRadians(j * 360.0f / (float)prec));
              float z = (float)sin(toRadians(j * 360.0f / (float)prec));
              vertices[i * (prec + 1) + j] = glm::vec3(x, y, z);
              texCoords[i * (prec + 1) + j] = glm::vec2(((float)j / prec), ((float)i / numSlices));
  
          }
      }
  
      // calculate triangle indices 
      for (int i = 0; i &lt; numSlices; i++) {
          for (int j = 0; j &lt; prec; j++) {
              indices[6 * (i * prec + j) + 0] = i * (prec + 1) + j;
              indices[6 * (i * prec + j) + 1] = i * (prec + 1) + j + 1;
              indices[6 * (i * prec + j) + 2] = (i + 1) * (prec + 1) + j;
              indices[6 * (i * prec + j) + 3] = i * (prec + 1) + j + 1;
              indices[6 * (i * prec + j) + 4] = (i + 1) * (prec + 1) + j + 1;
              indices[6 * (i * prec + j) + 5] = (i + 1) * (prec + 1) + j;
          }
      }
  
  }
  </code></pre>
  
  <p>Any tips or solutions that stick closely to the code already written would much appreciated.</p>