How to change icon of the GLUT window?

I want to set my own icon instead of the default one assigned by glut.
So how can I change it?

I suppose you’re using windows and VC++ (if borland { go project properties; }(probably a similar X function would exist in linux, but I don’t know it).
I’m not sure if you can easily change the icon using a single function. The way I know it is when you create the window class yourself and assign the icon with the load icon function. This is the code:

WNDCLASSEX  windowClass;

windowClass.cbSize			= sizeof(WNDCLASSEX);
	windowClass.style			= CS_HREDRAW | CS_VREDRAW;
	windowClass.lpfnWndProc		= WndProc;
	windowClass.cbClsExtra		= 0;
	windowClass.cbWndExtra		= 0;
	windowClass.hInstance		= hInstance;
	windowClass.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	windowClass.hIconSm			= LoadIcon(NULL, IDI_WINLOGO);
	windowClass.hCursor			= LoadCursor(NULL, IDC_ARROW);
	windowClass.hbrBackground	= NULL;
	windowClass.lpszMenuName	= NULL;
	windowClass.lpszClassName	= "MyClass";

Notice the LoadIcon lines above.
Of course this means you have to write win32 code for the rest of your application which is not exactly pretty depending on your level. I’ve never used it (or seen it) but maybe there is a function to only change the icon. Try a search for “LoadIcon Win32 API”. Best of luck.

What I know is that MFC window classes have the method SetIcon(ID_RESOURCE). And it changes the icon.
So there should be a way to do it through API.

I believe he just showed you how to using the Windows API…