Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DrawCircle(float cx, float cy, float r, int num_segments)
- {
- float theta = 2 * 3.1415926 / float(num_segments);
- float c = cosf(theta);//precalculate the sine and cosine
- float s = sinf(theta);
- float t;
- float x = r;//we start at angle = 0
- float y = 0;
- glBegin(GL_LINE_LOOP);
- for(int ii = 0; ii < num_segments; ii++)
- {
- glVertex2f(x + cx, y + cy);//output vertex
- //apply the rotation matrix
- t = x;
- x = c * x - s * y;
- y = s * t + c * y;
- }
- glEnd();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement