The texture coordinates are 2-dimenional and have to be in range [0.0, 1.0]:
glBegin(GL_TRIANGLE_STRIP);
for (int i = 0; i <= 32; i++) {
double x_next = 1.0 * cos((i + 1) * 2.0 * PI/ (32 - 2.0));
double y_next = 1.0 * sin((i + 1) * 2.0 * PI / (32 - 2.0));
if (i % 2 == 0) {
glTexCoord3f((float)i / 32.0f, 1.0f);
glVertex3f(x_next, y_next, TABLETOP_Z + cubeLen);
} else {
glTexCoord3f((float)i / 32.0f, 0.0f);
glVertex3f(x_next, y_next, TABLETOP_Z);
}
}
glEnd();
CLICK HERE to find out more related problems solutions.