Multiple Rendering Contexts in Windows...

Hi,

I need to render to multiple windows/contexts…it looks like I need to call MakeCurrent() for each window before I call the render function. This seems a waste if the RC is already current.

Is there a way to check if a RC is current? I would like to be able to do something like this:

if (!IsCurrent(hglrc)) {
MakeCurrent(hglrc);
}

If someone could shed some light on rendering to multiple windows, I would greatly appreciate it.

Thanks much!

I’m not sure if there is any function to check if the current window’s RC is the current one, but you could just put the wglMakeCurrent call in one of the window messages like WM_SETFOCUS, or WM_ACTIVATE. Then if your app loses focus, the RC is made current when it gets focus back. I wouldn’t think that this would incur much of a performance hit. If you need multiple windows to be rendered to at the same time despite the focus, this might not work for you, though.

Originally posted by Deiussum:
I’m not sure if there is any function to check if the current window’s RC is the current one, but you could just put the wglMakeCurrent call in one of the window messages like WM_SETFOCUS, or WM_ACTIVATE. Then if your app loses focus, the RC is made current when it gets focus back. I wouldn’t think that this would incur much of a performance hit. If you need multiple windows to be rendered to at the same time despite the focus, this might not work for you, though.

Okay, yeah, calling wglMakeCurrent() in the OnSetFocus or whatever makes sense for a window that only gets updated if it’s currently active. Thanks for the tip.

However, I do need to have other windows that are rendering continuously. Sounds like maybe I’m stuck calling wglMakeCurrent() within the rendering loop.

Originally posted by xenovore:
[b]Hi,

I need to render to multiple windows/contexts…it looks like I need to call MakeCurrent() for each window before I call the render function. This seems a waste if the RC is already current.

Is there a way to check if a RC is current? I would like to be able to do something like this:

if (!IsCurrent(hglrc)) {
MakeCurrent(hglrc);
}

If someone could shed some light on rendering to multiple windows, I would greatly appreciate it.

Thanks much![/b]

Try using wglGetCurrentContext()