Advertisement
BloodknightStudios

Untitled

Jan 13th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. const float PI = 3.1416;
  2. const float TWO_PI = 6.2832f;
  3.  
  4. /**
  5. * Function that draws a circle using a line loop.
  6. *
  7. * Params:
  8. * x - the x position of the circles center.
  9. * x - the x position of the circles center.
  10. * radius - circle radius
  11. * segments - circle segments (default 8)
  12. */
  13. inline void drawCircle(GLfloat x, GLfloat y, GLfloat z, GLfloat radius, int segments) {
  14. if (segments == 0) segments = 100;
  15.  
  16. glBegin(GL_LINE_LOOP);
  17. for (int i = 0; i <= segments; i++) {
  18. glVertex3f(x + (radius * cos(i * TWO_PI / segments)), 0.0f, z + (radius * sin(i * TWO_PI / segments)));
  19. }
  20. glEnd();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement