Very strange problem about display list

I run into a very strange mess about display lists, the problem is I create a main scene which is rendered in the main view, then I need put some models into it according to user’s select, so I set up a dialog, and display the models in that dialog,all the models are rendered using display lists,I initialize the opengl for dialog and the main view respectively, so each time before the rendering, I must use wglMakeCurrent(m_hdc,m_hRC)to switch different RC, the big problem happened when I close the dialog, the model’s display list replace some other display list in the main scene, for example, I have a Tree display list using billboad, after I close the dialog, the tree becomes the model, I know the clue but can’t confirm, that I don’t know how to copy the dialog’s model display list to the main scene for displaying it, so I name a display list varable nModelList, and a pointer to the dialog pModelDlg, when switch the opengl RC to the main view, then call nModelList = pModelDlg->BuildModelList(); the model can display, but it also replace my other display list, why, how to solve this problem, I look into the Red Book, but can’t find the answer, I need help.


Are you sharing lists between contexts? Try using the same context binding it to different DC’s

No, I use different line names for different context,It is difficult for me to share a common list ID for different rendering context,Is it possible to solve it with other methods? thanks.

Why is it so difficult to Share your Display list ID?

I don’t know how to share, because if I name nModelList in the main view and nList in the dialog, when switch context to the main view, I let nModelList = pModelDlg->nList; there is no model display, so I must build the display list again for the current context,
nModelList = pModelDlg->BuildModelList();
this is the reason that the problem lies with
what is the difference between assigning a list Id to another and directly using the same list name(Id)? I think if you don’t reconstruct the display list again after change the context, simply sharing has no effect, this is big problem of OpenGL, that no book or reference can be looked into.

You share by creating all the contexts, and calling the sharelist function in the beginning while no textures, display list, vp, fp program or any other GL resources are created.
Also, the contexts must be compatible : same pixel format.

Even after all that, there is no guarantee sharelist will work.