OpenGL in threaded program

Hello. I am writing a multithread app that use OpenGL(and GLUT) to draw to windows. Each thread has its own window to draw to, but sometimes the app crashes, sometimes it draw in wrong window, do some other bizarre things, but sometimes work fine. Is it a bad idea to use OpenGL in this kind of program? or is there any Right Way to do it?
I am using MS VC++ version 6 on win2000.
Thanks for any help.

vachi

I think the common error when using threaded OpenGL applications is to forget the wglMakeCurrent before drawing anything… That could explain that there are things rendered in the wrong window…

My advice is: check your code by ensuring that the proper rendering context is active when you issue any GL command.

There is no RIGHT WAY to write such an application. You just need to pay attention to your OpenGL state.

Regards.

Eric

Um…active context before issuing gl calls…<looking in source code>
glutSetWindow() won’t suffice?

vachi

Aie…

I am not too familiar with GLUT (I use it from time to time but that’s all).

I am not sure if GLUT is thread-safe… Perhaps other people reading this could help ???

I might try it when I have a minute !

Regards.

Eric