OpenGL: Wrapping texture around cylinder
<p>I am trying to add textures to a cylinder to draw a stone well. I'm starting with a cylinder and then mapping a stone texture I found <a href="http://web.cs.wpi.edu/%7Eemmanuel/courses/cs4731/A14/homework/HW4/stones.bmp" rel="nofollow noreferrer">here</a> but am getting some weird results.  Here is the function I am using:</p>
<pre><code>void draw_well(double x, double y, double z,
    double dx, double dy, double dz,
    double th)
{
    //  Set specular color to white
    float white[] = {1,1,1,1};
    float black[] = {0,0,0,1};
    glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,shinyvec);
    glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,white);
    glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,black);

    glPushMatrix();

    //  Offset
    glTranslated(x,y,z);
    glRotated(th,0,1,0);
    glScaled(dx,dy,dz);

    //  Enable textures
    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);

    glBindTexture(GL_TEXTURE_2D,texture[0]); // Stone texture

    glBegin(GL_QUAD_STRIP);
    for (int i = 0; i &lt;= 359; i++)
    {
        glNormal3d(Cos(i), 1, Sin(i));

        glTexCoord2f(0,0); glVertex3f(Cos(i), -1, Sin(i));
        glTexCoord2f(0,1); glVertex3f(Cos(i), 1, Sin(i));
        glTexCoord2f(1,1); glVertex3f(Cos(i + 1), 1, Sin(i + 1));
        glTexCoord2f(1,0); glVertex3f(Cos(i + 1), -1, Sin(i + 1));
    }
    glEnd();

    glPopMatrix();
    glDisable(GL_TEXTURE_2D);
}


// Later down in the display function
draw_well(0, 0, 0, 1, 1, 1, 0);
</code></pre>
<p>and the output I receive is</p>
<p><a href="https://i.stack.imgur.com/xJGuz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xJGuz.png" alt="enter image description here" /></a></p>
<p>I'm still pretty new to OpenGL and more specifically textures so my understanding is pretty limited.  My thought process here is that I would map the texture to each <code>QUAD</code> used to make the cylinder, but clearly I am doing something wrong.  Any explanation on what is causing this weird output and how to fix it would be greatly appreciated.</p>