PDA

View Full Version : wglShareLists() with dummy window



knackered
03-13-2002, 10:20 AM
Well, I tried appending this question to another topic, but that topic doesn't seem to have been visited by anyone. So, I'll have to start a new one, as I need an answer before I make fundamental changes to my engine:-

I need to create/destroy/create multiple windows, with multiple renderering contexts (win32).

Question:-
I'm thinking of having an invisible dummy window (say with a client area of 1x1) with a gl context, which holds all display lists and textures, while all other visible windows 'share' the dummy windows display lists and textures using wglShareLists().
Would this impact performance more than having all other windows share the first visible windows resources?

The reason I want to do it this way is that I want to be able to create and destroy *all* windows randomly at runtime, but keeping track of the context that 'owns' the resources would be a pain. That's why I'm thinking an invisible window would be a neat solution.
Would this have any negative effects? Considering the dummy window/context will never be made current (except when creating textures/display lists) or be rendered to...

Also, in the MSDN spec for wglShareLists() it says that NO display lists should exist in the window that is sharing its resources at the time of the wglShareLists() call - does this still hold true?
And does this also apply to textures? (ie. no textures can exist in the sharing context before it shares its resources with another context).

knackered
03-14-2002, 12:31 AM
Ok, ok - your silence speaks volumes - I should test it, you're right.
It's a hell of a lot of work, with my current architecture, but it would make the whole thing more elegant if it has no side-effects.
I shall let you know my conclusions, in the spirit of the forum.

knackered
03-14-2002, 07:04 AM
No, there doesn't seem to be any performance penalty for using a dummy window/context for textures and display lists.
In fact, it works rather nicely!

immy
03-20-2002, 07:43 PM
Hi
I want you to help me about using

wglShareLists()

I am creating a secondary thread from the main thread & creating my display lists in the secondary thread. The display lists are created nicely no problem but i can't be able to call those lists from the main thread. I used the above function but it returns false. My secondary thread's rendering context has the same pixel format as the main thread's rendering context. but the function does not work.
Pls tell me some tutorials on this or send me the code where u used(if u can) so that i can have an idea of whats the problem with my implementation.Tell me ur email i shall contact u or ur msn id if u use msn messenger.See u http://www.opengl.org/discussion_boards/ubb/smile.gif
Thanks in advance.

immy
03-20-2002, 09:07 PM
Hi
I am using visual c++ 6.0(win32 API). My code sequence is like this


Secondary Thread
{
***Create a dummy window; create a rendering context for it with the same pixel format as the main thread's rendering context.

***Make it current & call call
wglShareLists(RC_Main,RC_Thread)
for sharing the display lists among the main rendering context & the thread's rendering context.
***Make the display List& set its status to ready.

}


Main Thread
{
***In WM_CREATE start the secondary thread
***Create Rendering Context
***Make it current
***Initilize openGL parameters like lighting etc
***in WM_TIMER
Call the drawing routine and call the display lists made in the secondary thread if its status is ready

}

Thats the main sequence or flow.

Hoping for a quick reply. Thanks

knackered
03-21-2002, 12:01 AM
All *my* contexts are created in one thread.

I noticed from your psuedo-code that you seem to be calling wglShareLists() (in your secondary thread) *before* the main thread context is created. This won't work.

immy
03-21-2002, 01:12 AM
Hi
When all my rendering contexts have been created then i call
wglShareLists(RC1,RC2);
but the function returns NULL.

The 2nd possibility that Its not working bqz i am creating the main rendering context in the main thread & the secondary rendering context in the secodary thread that can b true.

I try to make the two contexts in the main thread if it will not spoil my design. Tell me ur email or ur msn id if u use msn. It will b nice to share info with u.
Thanks very much http://www.opengl.org/discussion_boards/ubb/smile.gif.

immy
03-21-2002, 04:01 AM
Hi
My problem resolved thanks for the help http://www.opengl.org/discussion_boards/ubb/smile.gif

knackered
03-21-2002, 05:04 AM
How did you resolve it?
...I'm curious.

immy
03-21-2002, 08:10 AM
hi
Tell me ur msn id then i shall tell u :P hehehehehe okay

knackered
03-21-2002, 08:59 AM
No man,
This will be really annoying for someone searching the archives looking for an answer to the same question.
So, pretty please with sugar on top, tell us how you solved your problem.

immy
03-21-2002, 11:25 PM
hi
I simply create the two contexts in the main thread. & called the sharing function from the same thread.
OKAY