Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float lats = 0;
- float longs = 0;
- float delta = (2 * 3.14159) / stacks;
- float theta = 3.14/ segs;
- float x = 0;
- float y = 0;
- float z = 0;
- for (float i = 0; i < segs; i++){
- for (float j = 0; j < stacks ; j++) {
- glBegin(GL_QUADS);
- x = cosf(longs)*sinf(lats);
- y = cosf(lats);
- z = sinf(longs)*sinf(lats);
- glNormal3f(x, y, z);
- glTexCoord2f((1.0f / stacks) * j, (1.0f / segs) * i);
- glVertex3f(x, y, z);
- lats += theta;
- x = cosf(longs)*sinf(lats);
- y = cosf(lats);
- z = sinf(longs)*sinf(lats);
- glNormal3f(x, y, z);
- glTexCoord2f((1.0f / stacks) * j, (1.0f / segs) * (i + 1));
- glVertex3f(x, y, z);
- longs -= delta;
- x = cosf(longs)*sinf(lats);
- y = cosf(lats);
- z = sinf(longs)*sinf(lats);
- glNormal3f(x, y, z);
- glTexCoord2f((1.0f / stacks) * (j + 1), (1.0f / segs) * (i + 1));
- glVertex3f(x, y, z);
- lats -= theta;
- x = cosf(longs)*sinf(lats);
- y = cosf(lats);
- z = sinf(longs)*sinf(lats);
- glNormal3f(x, y, z);
- glTexCoord2f((1.0f / stacks) * (j + 1), (1.0f / segs) * i);
- glVertex3f(x, y, z);
- }
- lats += theta;
- longs = 0;
- }
- glEnd();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement