Q:

How do I make a sine wave without using an infinitely-increasing time value as input?

I have a basic understanding of sine wave generation. The problem I am facing is that as the input parameter for time gets larger, my sine wave falls apart and starts to look really ugly.
I'd like to calculate a sine wave without depending on an ever increasing time value. How can I do this?

A:

You could restart your time value every 2pi:
if(time > 2*pi)
  time -= 2*pi;

If is still okay to increase your time variable infinitely but the input for the sine is to large, just use fmod(time, 2*pi).

