several independent glut windows

Hi people!!

I would like to make a little application that uses several (let’s say 4) OpenGL GLUT windows.
I’ve tried to create a thread (CWinThread) for each window, and from the InitInstance method, I do my initialization and finally I call glutMainLoop(). This, of course, creates the window and starts its loop. The problem is when I want to finish.
How can the application kill each thread and how can each thread kill its glut window?
I’ve tried using a timer attached to each thread. When the application wants to finish, it sets a boolean variable so each thread knows (checks this boolean in its timer) that has to end.

Something like…
HWND hwnd, // handle of window for timer messages
UINT uMsg, // WM_TIMER message
UINT idEvent, // timer identifier
DWORD dwTime // current system time

if (bFinishTheThread)


The point is what to do in the CLEAN UP.
I’ve tried (but I don’t how it works…) to
call glutDestroyWindow with the id of its glut window ->crash
call ::PostQuitMessage(0) to end with this thread ->ends with all the threads and the application with memory leaks.

The point is that I want to use several independent glut windows (not subwindows), and I want to create and destroy them whenever I want.

I hope I was clear, even my poor english.

Thanks for your time!

Cheers =],


ps: for those who have holidays, enjoy them!!!