Guest User

Untitled

a guest
Feb 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. // Counters for the index of the vertex in the fan vertices and quad vertices arrays respectively.
  2. int f = 1, q = 0;
  3.  
  4. // The first vertex for the triangle fan is at the origin.
  5. fanPoints[0][0] = 0.0;
  6. fanPoints[0][1] = 0.0;
  7. fanPoints[0][2] = 0.0;
  8.  
  9. /**
  10. * Produce the vertices for the triangle fans and the quads.
  11. * Using parametric circle equations to determine the co-ordinates of a vertex.
  12. */
  13.  
  14. for (i = 0; i <= SEGMENTS; i++) {
  15.  
  16.  
  17. // Calculate the sine and cosine of the angle between the line connecting the vertex to the origin and the X-axis.
  18. angle = i * (((float) PI * 2.0) / (float) SEGMENTS);
  19. sine = (GLfloat) sin(angle);
  20. cosine = (GLfloat) cos(angle);
  21.  
  22. fanPoints[f++][0] = 1.0 * cosine;
  23. fanPoints[f++][1] = 0.0;
  24. fanPoints[f++][2] = 1.0 * sine;
  25. quadsPoints[q++][0] = 1.0 * cosine;
  26. quadsPoints[q++][1] = 0.0;
  27. quadsPoints[q++][2] = 1.0 * sine;
  28. quadsPoints[q++][0] = 2.0 * cosine;
  29. quadsPoints[q++][1] = 0.0;
  30. quadsPoints[q++][2] = 2.0 * sine;
  31.  
  32. }
  33.  
  34. glNewList(dish, GL_COMPILE);
  35.  
  36. // Draw the quad strips.
  37. glBegin(GL_QUAD_STRIP);
  38.  
  39. // All the vertices of the quad strips are coloured the same.
  40. glColor3f(0.1, 0.7, 0.2);
  41.  
  42. glVertex3f(quadsPoints[0][0], quadsPoints[0][1], quadsPoints[0][2]);
  43.  
  44. glEnd();
  45.  
  46. glEndList();
Add Comment
Please, Sign In to add comment