:glutIdleFunc flicker

I need to draw two objects.

1st object needs to move when i use keyboard.
2nd object needs to move but is independent of user action(neither keyboard or mouse).I used glutIdleFunc to implement 2nd object.
//callback idle
void idle()
I have enabled glut_double in main and glutswapbuffer in display callback.
There is lot of flickering when i implement this how can i avoid it.

I don’t see anything wrong with that. Can you show us some more code?