vector<GLfloat> vertices;
float const R = 1.0f / (float)(rings - 1);
float const S = 1.0f / (float)(sectors - 1);
unsigned int r, s;
vertices.resize(rings * sectors * 3);
vector<GLfloat>::iterator v = vertices.begin();
for(r = 0; r < rings; r++) for(s = 0; s < sectors; s++)
{
float const x = sinf(M_PI * r * R) * cosf(2 * M_PI * s * S);
float const y = sinf(-M_PI_2 + M_PI * r * R );
float const z = sinf(2.0f * M_PI * s * S) * sinf(M_PI * r * R );
*v++ = x * radius;
*v++ = y * radius;
*v++ = z * radius;
}