Reputation: 26323
Does ist make sense to release a GL context after usage with wglMakeCurrent(0,0)
?
Is there any performance advantage to release after usage instead of switching to another context while a context is current?
Upvotes: 0
Views: 1129
Reputation: 7198
It may make sense in the case where the window hasn't the style flag CS_OWNDC
. In this case the device context is not private and should be released as soon as it's not needed any more.
MSDN wglMakeCurrent(hdc,hglrc) doc:
If
hglrc
is NULL, the function makes the calling thread's current rendering context no longer current, and releases the device context that is used by the rendering context. In this case,hdc
is ignored.
.
Upvotes: 1
Reputation: 45322
As wglMakeCurrent()
will internally call into the GPU driver, this is totally implementation-specific. However, even if there would be a technical reason for releasing the conext before binding a new one to be more efficient, every sensible implementation should internally do the release;bind
sequence also when doing a direct switch.
However, the performance issue with switching rendering contexts is usually not the overhead of wglMakeCurrent
. It is the actual GL flush which is implied by the switch by default. If you are interested in switching between multiple GL context most efficiently, you should have a look at the WGL_ARB_context_flush_control
extension, which allows for controlling the flushing behavior on context switches.
Upvotes: 2