title: Cylinder drawn with triangles in OpenGL
body: <p>It's drawing a cylinder with stacks and edges but the problem is that stacks are connected to one point instead of a new one. 
  Maybe a picture will show it better:
  <a href="https://i.stack.imgur.com/9Zd72.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Zd72.jpg" alt="Cylinder"></a></p>
  
  <p>And here's how I'm rendering the side because disks are rendered separately:</p>
  
  <pre><code>for (int i = 1; i &lt;= height; ++i) {
          for (int j = 0; j &lt; edges; ++j) {
              glBegin(GL_TRIANGLES); {
                  // 0 bottom 
                  glVertex3f(x + radius * cos(theta + interval), y , z + radius * sin(theta + interval));
                  // 1 bottom
                  glVertex3f(x + radius * cos(theta), y + y_value * i, z + radius * sin(theta));
                  // 2 top
                  glVertex3f(x + radius * cos(theta), y + y_value * i, z + radius * sin(theta));
                  // 2 top
                  glVertex3f(x + radius * cos(theta), y + y_value * i, z + radius * sin(theta));
                  // 3 top
                  glVertex3f(x + radius * cos(theta + interval), y + y_value * i, z + radius * sin(theta + interval));
                  // 0 bottom 
                  glVertex3f(x + radius * cos(theta + interval), y , z + radius * sin(theta + interval));
              } glEnd();
              theta += interval;
          }
          theta = 0.0;
      }
  </code></pre>
  
  <p>I've been trying to solve it for days and I run out of ideas. Do you know what I am doing wrong?</p>
  
  <p>UPDATE:
  I've changed it to be render with quads using ybungalobill advice. Now I'm struggling with UV mapping. And hopefully once this part is solved it'll be easy enough to convert into triangles. 
  That's what I have now: 
  <a href="https://i.stack.imgur.com/J0PPI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J0PPI.jpg" alt="enter image description here"></a></p>
  
  <p>And that's the code I'm using for UV mapping:</p>
  
  <pre><code>u = 0.0,
  v = 0.0,
  u_inter = 1.0 / edges,
  v_inter = 1.0 / y_value;  // (y_value = height / edges)
  
      for (int i = 1; i &lt;= height; ++i) {
          for (int j = 0; j &lt; edges; ++j) {
              glBegin(GL_QUAD_STRIP); {
                  // 0 bottom 
                  glTexCoord2f(u, v);
                  // 1 bottom
                  glTexCoord2f(u + u_inter, v);
                  // 2 top
                  glTexCoord2f(u + u_inter, v + v_inter);
                  // 3 top
                  glTexCoord2f(u, v + v_inter);
              } glEnd();
              theta += interval;
              u += u_inter;
          }
          v += v_inter;
          theta = 0.0;
      }
  </code></pre>