from http://nehe.gamedev.net/tutorial/flag_effect_(waving_texture)/16002/