PDA

View Full Version : two RCs for one DC?



Mark Shaxted
11-17-2007, 10:11 AM
Can I use wglCreateContext twice on the same DC to create two seperate render contexts?

What I want to do is use one context to render to (in one thread) an use the other RC simply as a shared context in another thread (basically to upload textures in the background, which will be shared across multiple windows).

Or is it best to just create a hidden window and share the RC from there?

Many thanks
Mark

Zengar
11-17-2007, 01:05 PM
You can create multiple RCs using the same DC,but you can only bind one RC to a DC at the same time. A RC can be bound to any windows, not only the one that was used to create it - the only restriction is - they must have the same pixelformat.

Mark Shaxted
11-17-2007, 01:38 PM
OK, Thanks Zengar.

Dummy window it is then!

Mark Shaxted
11-17-2007, 01:50 PM
Hang on...

If I understand correctly, I only need to wglCreateContext on ONE window, and then just make it current to any other window (assuming the same pixel format)?

I'm making a multimonitor app with several top level (maybe fullscreen) windows. Each will use the same pixel format. So presumably using just one RC will save some system resources (?). BTW I'm using just one thread to render to each window serially.

Zengar
11-18-2007, 05:03 PM
RC to DC binding has a one-to-one relationship. One RC can be current on only one DC and via versa :)

Relic
11-19-2007, 02:15 AM
You can create multiple RCs using the same DC,but you can only bind one RC to a DC at the same time.

Actually:
You can create multiple RCs using the same DC, but you can only bind one RC per thread to a DC at the same time.

Read the wglMakeCurrent manual, it explains all these issues.
http://msdn2.microsoft.com/en-us/library/ms537558.aspx

Zengar
11-19-2007, 02:40 AM
It is correct, yes. One RC per one DC per one thread :)