Such that program should run behind and when user wants to see the display of the current state window should popup. And again window should be in updated state on the next time user wants the display.
Because of glutMainLoop() code is stuck at 1st iteration after display. When its removed code works fine but no window is created for display.