Opengl draw spring - c++

Contributor
Submitted by techrev on Sun, 07/09/2017 - 09:51
Forums

#define GL_PI 3.1415f

 

Drawscene()

{

GLfloat x,y,z,angle;  // Storage for coordinates and angles
glBegin(GL_LINE_STRIP);


z = -50.0f;
for(angle = 0.0f; angle <= (2.0f*GL_PI)*3.0f; angle += 0.1f)
  {
  x = 50.0f*sin(angle);
  y = 50.0f*cos(angle);

  // Specify the point and move the z value up a little
  glVertex3f(x, y, z);
  z += 0.5f;
  }

// Done drawing points
glEnd();

}