changing position of an object continuously

I have a circle in the center of the screen and i want to continuously change its X position. I made a function

void move()
{
  while(1)
   posX+=0.001;
}

And i was trying to call it from main(); but the program freezes… If i call it without the while(1) loop then the call is made to the function once. But i want it to be called continuously… How to do that??

Just doing a loop that updates the objects position is not enough: in order to see the object move you also need to draw a new frame with the object at it’s new position. So you basically want the following to happen continuously: update position, redraw frame, update position, redraw frame, …
If you are using GLUT you should update the object’s position at the beginning of your display function (before drawing) and additionally register an idle function (with glutIdleFunction) that simply calls glutPostRedisplay (this tells glut that something in the application has changed and you want to draw a new frame to show the updated state).

Thanks for the reply… But i am a noob at this… If you could provide a sample code that does this job… I can understand much better…

Hey… I got it … Fiddled around a little and your process worked :slight_smile: Thanks…