I have an application which is using 2 threads and 3 contexts.
Thread T1 renders using render context RC1, while thread T2 renders most stuff using RC2 and some stuff using RC3.
So, T2 is calling wglMakeCurrent() once a frame, while T1 might render something else asynchronously.
Unfortunately, wglMakeCurrent() sometimes failes with "the handle is invalid" and other obsure errors. The handles in question are NOT invalid!
The error does not occur, if "Threaded optimization" is turned off in the NVidia control panel.
This happens on WinXP64 SP2, GF470GTX, 197.44 drivers.
The problem also occured on other hardware and older drivers.
Do you have any advice? Thanks in advance.
The error is not dependent on our application rendering in multiple threads. A single rendering thread also triggers the problem. Having two rendering threads only seems to make it worse.
To sum up the problem: When "Threaded optimization" is turned on, wglMakeCurrent() often failes for no apparent reason.