implement multiple windows in multiple threads

Dear all,
I am trying to implement multiple windows in multiple threads using openGL.
I am creating one openGL window in each thread using glutCreateWindow(). And in final thread I am launching glutMainLoop().While running application frequently I am facing one of the following error:

  1. X Error of failed request: GLXBadContextTag
    Major opcode of failed request: 143 (GLX)
    Minor opcode of failed request: 5 (X_GLXMakeCurrent)
    Serial number of failed request: 101
    Current serial number in output stream: 103

  2. Xlib: unexpected async reply (sequence 0x67)!

Please help me for how to solve this problem. Or any other way to implement this concept?

Thanks & Regards,
Jayaprakash

The problem is, Glut is not threadsafe.

Creating one window+OpenGL context in each thread should work in general. Each OpenGL context is thread-specific: to render in one context, the thread which created that context must call the paint() function.

Can’t help you with Linux-specific windows creation though.

Try this code.

Hi,

I have not tried with threads, but wt i want to share is that, when u create a new window or sub window, in open GL each and every sub window is capable of handling, event handlers, display functions. So i think, even the loop back also possible. It is just like main() call.

Hope the above try will solve your problem.
thanks,
Santosh