Vec2d* circle( Vec2d _Center = Vec2d( 0, 0 ), int _radius =1, int _points = 360){
Vec2d Circle[_points];
glBegin( GL_LINE_LOOP );
for(int i=0;i<_points;i++) {
float angle = ((360)/_points)*i; // 360 divided into degree segments based on points multiplied by what point your on
Circle[i] = Vec2d( _radius * helpers::d_cos(angle)+_Center.x, _radius*helpers::d_sin(angle) );
glVertex3f( Circle[i].x, _Center.y ,Circle[i].y );
}
glEnd();
return Circle;
}
void drawWireframeCylinder(float _radius = 50, float _height = 100, int _steps = 10){
int apart=3;// spacing
int shapePoints = 360;
float spacing = _height/_steps;
Vec2d center(0,0);
for(int i = 0;i<spacing; i++ ){
center.y = (i*spacing)*apart; // draw up progresivly
Vec2d* dpoints = circle(center,100,360);
//draw in wire
int lineSpacing = 4;
for ( int j = lineSpacing; j<shapePoints; j += lineSpacing){
// glColor3f( 1,0,1 );
glBegin( GL_LINE_LOOP );
glVertex3f( dpoints[j].x, center.y ,dpoints[j].y );
glVertex3f( dpoints[j].x, 0 ,dpoints[j].y ); // y is z in Vec2d object should make a Vec3d
glEnd();
}
}
}
////////////////////////////****//////////////////////////////////////////////////////
void displayFunc ( void ) //arg void returns void
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //clears buffers(what buffers?) by setting bit mask or.
//printf(" %f", mouseX);
glLoadIdentity();
glTranslatef(0.0f, mouseX-500, -200);
glColor3f( 0,1,1 );
//circle();
drawWireframeCylinder();
/*
glBegin(GL_LINE_LOOP);
glVertex3f(-1.0f, -0.5f, 0.0f);
glVertex3f(1.0f, -0.5f, 0.0f);
glVertex3f(1.0f, -1.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);
glEnd();
*/
/*glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-1.0f, -0.5f, 0.0f); // A
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, -0.5f, 0.0f); // B
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f( 0.0f, 0.5f, 0.0f); // C
glEnd();*/
glutPostRedisplay(); //tags the current window to be redisplayed or shown through the
//next iteration loop.
glutSwapBuffers(); //calls for the display of a the current buffer for the curretn window
// i assume to cut down on jerky motion
}