PDA

View Full Version : Multiple Rendering Contexts in Windows...



xenovore
11-28-2000, 09:08 AM
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!

Deiussum
11-28-2000, 09:17 AM
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.

xenovore
11-28-2000, 09:30 AM
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. http://www.opengl.org/discussion_boards/ubb/frown.gif

borelli
12-01-2000, 04:07 AM
Originally posted by xenovore:
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!

Try using wglGetCurrentContext()