wglShareLists - need more details

I’d like to use wglShareLists() to share display lists and textures between OpenGL windows within my program. It says you must call it before any lists are created though, so is it impossible to share with new OpenGL windows that appear? In my program the user has the option to open more OpenGL windows, so how can I share resources between these and the original windows (where the display lists have already been created)?

Another thing not clear from the docs: once shared, should display lists only be created in the “original” OpenGL window, or can they be created in either window, and still get shared by both?

Thanks,
Rob.

It says you must call it before any lists are created though, so is it impossible to share with new OpenGL windows that appear?
This is only true for the 2nd HGLRC in the call, presumably your new context, so this shouldn’t present a problem in your case. You could think of it as

wglShareLists( baseRC, newRC );
(newRC shouldn’t have any existing lists)

In my program the user has the option to open more OpenGL windows, so how can I share resources between these and the original windows (where the display lists have already been created)?
Same as above. You can use any currently shared RC as the baseRC.

Another thing not clear from the docs: once shared, should display lists only be created in the “original” OpenGL window, or can they be created in either window, and still get shared by both?
It’s quite possible to create any number of RCs, each created through a unique window’s DC. This happens frequently in many editors, for example, that have multiple views of a model. All shared resources will remain shared among the existing shared RCs until the last one is destroyed, or until an RC is explicitly removed from the list.

There are a few caveats. You can see the entire spec here:

http://msdn.microsoft.com/library/en-us/opengl/ntopnglr_6flf.asp?frame=true

Thanks for your reply, it helped!

Originally posted by Q:
wglShareLists( baseRC, newRC );
(newRC shouldn’t have any existing lists)
This is the bit I had wrong. Reading the docs gave me the impression the arguments should be the other way around.

To me “context with which to share display lists” sounds like the new one, and “context to share display lists” sounds like the original one.

Stupid Microsoft documentation (or stupid me maybe).

Works now. :cool:

Thanks again,
Rob.

the new context is sharing its stuff with the old context, the context it wants to share to

I had seen a lot of dicussion on sharing GL resources across multiple RC’s. But nobody talks about how to deallocate resources that are shared without having to deallocate the RC.

For example:-

wglMakeCurrent(DC1, RC1);
glGenTexture(1, &id);

wglMakeCurrent(DC2, RC2);
wglShareLists(RC1, RC2); // now ‘id’ is shared.

MSDN says:-

wglMakeCurrent(DC1, RC1);
glDeleteTextures(1, &id);
ReleaseContext(RC1);

MSDN says ‘id’ still exists until RC2 is released

What if the application only wants to delete ‘id’ without having to delete all the RC’s that share ‘id’.

MSDN does not specify whether calling “glDeleteTextures(1, &id)” in all the RC’s (RC1 & RC2) will actually delete resources held by ‘id’.

Does anyone have any information on deallocating shared Gl resources across multiple RC’s without actully having to delete all RC’s ?

May be the driver implementers call answer this.

AND once again no replies. Probably hasn’t been considered by the driver developers or else one of them usually jumps to answer.

I don’t have any code setup that I can quickly toss together a test application to find out. But if anyone does this should only take a few minutes to verify. Let’s get some OpenGL mythbusters on the issue!

dimensionX,

I looked at it again and MSDN doesn’t seem to say that.

When you create an OpenGL rendering context, it has its own display-list space. The wglShareLists function enables a rendering context to share the display-list space of another rendering context; any number of rendering contexts can share a single display-list space. Once a rendering context shares a display-list space, the rendering context always uses the display-list space until the rendering context is deleted. When the last rendering context of a shared display-list space is deleted, the shared display-list space is deleted. All the indexes and definitions of display lists in a shared display-list space are shared.

You can only share display lists with rendering contexts within the same process. However, not all rendering contexts in a process can share display lists. Rendering contexts can share display lists only if they use the same implementation of OpenGL functions. All client rendering contexts of a given pixel format can always share display lists.

All rendering contexts of a shared display list must use an identical pixel format. Otherwise the results depend on the implementation of OpenGL used.

It doesn’t say anything about deleting display lists or textures explicitly, which means that if you call glDelete, then it is really deleted.

Where is the problem?

“When the last rendering context of a shared display-list space is deleted, the shared display-list space is deleted.”

It doesn’t say anything about deleting display lists or textures explicitly, which means that if you call glDelete, then it is really deleted.
what does “display-list space” mean in the above statement from MSDN ? I presume it means, OpenGL display lists, texture objects etc… I guess, since the RCs are shared and “All the indexes and definitions of display lists in a shared display-list space are shared - MSDN” it should work. I shall try and see if this is true. Thanks!

what does “display-list space” mean in the above statement from MSDN ?
I think they mean it in the sense of memory space. Every program has it’s own virtual memory space as you know.

When the last rendering context of a shared display-list space is deleted, the shared display-list space is deleted
I think what they mean is that if you close the GLRC without deleting the display lists, they will continue to exist because of your other GLRCs.

When you close your “last GLRC”, and you still don’t call glDeleteLists or glDeleteTextures because you are lazy, then they will be deleted automatically.

It’s a good idea to put this stuff in the Wikipedia.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.