can two opengl context share a texture?

can two opengl context share a texture?
I create two opengl windows on a single window(a dialog in fact), one-A is responsible for create a texture and the other-B want to display the texture that created by A.
can i simply glGenTextures and glBindTexture in window A and glBingtexture that created by A in window B?

Yes, see wglShareLists(). Textures, fonts, display lists, etc… can all be shared provided that:
“All rendering contexts of a shared display list must use an identical pixel format.”

but i haven’t generate display list using glNewList.can wglShareLists only can share display list?
there is an other question now:
I create two OpenGL context and generate texture object, how can i know which context I generate the texture object in?

In MSDN it says
The wglShareLists function enables multiple OpenGL rendering contexts to share a single display-list space.

so it doesn’t say it can share the texture

The OpenGL documentation in MSDN is OLD!!
In fact, textures can always be shared if you’re using hardware accelerated driver.

Actually, I’m not sure that you need to do all that:

Let’s suppose this:

  1. A context can be active in only one process at a time (that’s process, not window)
  2. One window is, presumably, a 2D window for previewing/editing textures
  3. The other is an OpenGL window

In this situation, you’d need only one OpenGL context. Theoretically you should be able to use the texture upload functions from the 2D window callbacks.
But it’s probably safer to store the texture as a 2D array of colors and let the 3D window upload it when needed.

In fact,I have to use multi context since I actually have 4 rendering context. It is MFC+OpenGL program,I use
1 CView to be my main view,It is an OpenGL Window with all main Operation in i.user use it to add and manage elements
2 A small NonModel dialog is a mini-view which is also an OpenGL window, it can help user to observe the scene that created by the CView.
because the elements need to be mapped texture, so a Dialog A popout,it have a preview wnd and a texture window
3 the preview window should to indicate how the element seems to be after mapped texture and adjusted material, So it have to be a OpenGL window
4 Texture is a kind of object that should be access by any of OpenGL windows,since it is a individual object that has the property of a image and texture model, so I want it to be a OpenGL window to display how this texture to be

so I HAVE TO share texture between these OpenGL window

QUESTION:
1 In drawing the Dialog-A which has two OpenGL windows on it, each of the OpenGL window’s Draw start with glMakeCurrent(m_pDC->GetSafeHdc(), m_hRC)
and Texture’s glGenTexture and glBindTexture is called in other class’ method,
so I DON’T know which OpenGL context I create texture in.

wglShareLists shares display lists, texture objects, program objects, etc. (no occlusion query objects though because they are not big enough to be worth it)

Just call wglShareLists immediately after you created the context which should share the texture objects.
Make sure the second context parameter in the call is not made current or the operation will fail.
If you do that you don’t need to know which context created the texture because both reference the exact same object.

quot:

wglShareLists shares display lists, texture objects, program objects, etc. (no occlusion query objects though because they are not big enough to be worth it)

what does “no occlusion query objects though because they are not big enough to be worth it” means, sorry about my poor english
//////////////////////////
Just call wglShareLists immediately after you created the context which should share the texture objects.
Make sure the second context parameter in the call is not made current or the operation will fail.
If you do that you don’t need to know which context created the texture because both reference the exact same object.

I have two question about this:
1 what is the context—A that create the texture object and share them with other context
and What is the context—B that use the texture object that other create?
what are the two parameter of wglShareLists corresponding to the A and B?

2 do you mean I create the A and create B;
then make B uncurrent;
wglShareLists( X, Y);with A and B to be the X or Y

Yes, you got it, just use it.
It doesn’t matter which OpenGL context is A or B after you called wglShareLists. There is only one set of OpenGL objects left and referenced by both contexts then.

If you don’t know what occlusion queries are, you don’t need to be concerned.
I just wanted to point out that not all OpenGL objects are shared.
Anyway, you can find infomations about such things on the official OpenGL extension spec page:
http://oss.sgi.com/projects/ogl-sample/registry/
This is a must-have internet favorite for OpenGL programmers.

Relic:
thank you very much about help me with this problem and your suggestion about the remarkable site I should go.
My problem has been solved.
There are so many discussion about the use of the wglShareLists which make me realy confused, until you give me your answer.
thank you very much