PDA

View Full Version : using two windows with one context (not sharing!)



henniman
01-26-2006, 03:40 AM
Hi,

i am not exactly sure if this is a beginner question
(or even an os specific question) but ive heard that it would be more efficient to avoid performance costly context switches when using two windows by using one context and two windows.

how would i do this?
i mean, create one context, and in
each windows onpaint-function
bind the context to the according window?

how is this done?

best regards,
truly i do not even know if my question
is understandable - many thanks for any hint -

hendrik

Nithos
01-26-2006, 07:31 AM
Not sure as to exactly what you want, but ill try.
So you want 2 seperate windows? if so you can do this using GLUT by capturing the ID that it returns when you create a window. You can assign seperate call backs to each as needed and you can switch between them as well.

GLUT also alows to define Windows within Windows in a hierarchy, and i believe that only has one context as all the sub windows are linked to the parent which only has 1 ID associated to it.

Not sure if this is what you were asking but hopefully this helps.


//WINDOW1 and WINDOW2 are int that store the ID's for its corresponding window
WINDOW1 = glutCreateWindow("Win1");
WINDOW2 = glutCreateWindow("Win2");

//Set the current window to work with
glutSetWindow(WINDOW1);

jide
01-26-2006, 09:10 AM
I'm not sure glut create a single context for multiple windows.

You'll need to use the native W32 library (HWND and such) along with wgl. Can't help you more.

01-26-2006, 11:11 PM
There's no reason why you can't share a context among multiple windows. When you wglMakeCurrent, for example, send your render context and the window's DC. But remember that all window DCs must be on the same device and have the same pixel format, as is documented in the MSDN library.

Cheers