Sharing display list with more than one context

Hi
I am trying to share display lists of the main window with two secondary windows. I am able to do so using wglShareLists(). I was able to share the lists but the problem is that it only works for only one secondary window at a time. If I try to display list with the other window then the return value of wglShareLists() is false and the error returned by GetLastError() is a cryptic ‘3221684311’. I tried swapping the first secondary window with the second secondary window, but it wglShareLists() is successful only on the first call and fails on the second call. I have already made sure that that no context is acquired until the sharing is done.

Are you using GL 3.0+ context?
If so, that is not the proper way to share DLs.

What is an acquired context?

Just make sure you don’t have resources created in any of the windows when you call wglShareLists. It is highly likely to work in that case.

Also, make sure that they have the same pixelformat.
http://msdn.microsoft.com/en-us/library/dd374390(VS.85).aspx

Also, make sure you have a good chip in your machine such as ATI/AMD or nVidia. There are a lot of users reporting various problems with Intel(Windows) since their drivers are not good.

By acquired context what I mean is that making the context current with the display context wglMakeCurrent. I have the same pixel format for both the windows. The thing is that it works for either of the secondary windows, but just for the one with which the context is shared with first. It works only the first time wglShareLists is called. The second time I call it for the other window, it fails. In short, I am unable to share the display lists with more than one context and the error message given has no help associated with it.

You still didn’t answered what type of context you are creating.
I’m not sure for the compatibility profile, but I am 100% sure that the same scenario should occur with GL 3+ core profile context.

I figured the solution to the problem. Lets say you have three OpenGl contexts, ctxMain, ctx1, ctx2.

wglShareLists(ctx1,ctxMain);
wglShareLists(ctx2,ctxMain);

Doing this fails for the second wghShareLists call. However, if I do the following

wglShareLists(ctx2,ctx1);
wglShareLists(ctx1,ctxMain);

then it works just fine.