The proper way to emulate wglShareLists is to recreate a context and to use glXCopyContext to restore all states. glXCopyContexts is not well known and for that reason very buggy (the nvidia drivers segfault) and dri drivers only offer it in case of indirect rendering.
I hadn't encountered a case like this before and I fear we have to live with the fact that it can mess up the states. The code itself is ok but please look at the indentation as we use spaces in wine and your patch introduces tabs.
Roderick
Homeworld 2 calls wglShareLists() to share two contexts having already called wglMakeCurrent() on both, thus forcing Wine to create both contexts. This causes wglShareLists() to bomb with a "already created" error. This patch instead deletes the destination context, if it exists, before sharing.
--- Roderick Colenbrander thunderbird2k@gmx.net wrote:
The proper way to emulate wglShareLists is to recreate a context and to use glXCopyContext to restore all states. glXCopyContexts is not well known and for that reason very buggy (the nvidia drivers segfault) and dri drivers only offer it in case of indirect rendering.
To be honest, you know more about this than I. I wasn't completely sure that it was the Right Way to go about things, which is why I left that warning in there. But if the Right Way tends to segfault, we may, as you say, have to live with fudging it.
I hadn't encountered a case like this before
I googled the error message and turned up a post suggesting that some games make the /destination/ context current instead of the source before sharing. This patch should fix those as well. Homeworld 2 is the only game I know of that does both.
and I fear we have to live with the fact that it can mess up the states. The code itself is ok but please look at the indentation as we use spaces in wine and your patch introduces tabs.
Yes, sorry about that. A pox on Emacs and all its works. Thanks for the heads-up; I'll fix the formatting and resubmit later today.
Cheers, jim
To be honest, you know more about this than I. I wasn't completely sure that it was the Right Way to go about things, which is why I left that warning in there. But if the Right Way tends to segfault, we may, as you say, have to live with fudging it.
The warning should absolutely stay there for the case when issues do appear but as I mentioned we can't do anything about it. We could add a state tracker but it would complicate the opengl code a lot. Luckily wglShareLists will be deprecated for a future OpenGL 3.x revision.
Roderick