Skip to content

Instantly share code, notes, and snippets.

@kenpower
Created September 25, 2012 15:40
Show Gist options
  • Save kenpower/3782654 to your computer and use it in GitHub Desktop.
Save kenpower/3782654 to your computer and use it in GitHub Desktop.
Drawing regular polygons in OpenGL
const double PI=3.14159265358979323846;
double r=100;
int sides=10;
glBegin(GL_LINE_STRIP);
for(int i=0;i<sides;i++){
double angle=i*2*PI/sides;
glVertex2d(400+r*cos(angle),300+r*sin(angle));
}
glEnd();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment