Skip to main content
gamedev.net
🔒 Locked

Multiple Window and Stuff Loading

Started by netsach 2 replies 750+ views
Original Post
netsach
netsach
Hello ! When having multiple window displaying the same things (ie different views from a common scene), i need to do one textures, display lists, etc initialization per window / context. If i do not do it, for example a single texture load and using the texture id to render both windows, it appears only on the one window context which was active when the opengl texture was created. In the case i generate it once per window context, everything is fine. But in that case, i need to do one initialization per window, which takes time and resources. I would like to know if there is a way i could load this stuff once and for all, and not "per gl context". If anyone has an idea, i'd be really happy :-) Thanx PS: I posted this question one week ago on NeHe's forum, but i got no answer so far, so i try here. Sorry for the cross-post.
netsach
netsach

BTW if it is impossible, just say it, so i know for sure it can't be done. And if you have any document/link reference that tells so, i'd be happy to know.
netsach
netsach
# This is a long post, but i think it brings some answers
# and i wanted to make sure everything is clear for those
# who may read it later or stumble upon this while googling.
# For those who want to do a single load for multiple window,
# please read to the end. Other may go back to sleep :-)

Woooohoooo thanks for the hint. I search the web and found happiness. RTFM, code, compile, run, sunshine in my eyes :-) Well, almost.

Here are the details :
- searched for wglShareLists, found about shares display lists and textures, so i was happy.
- found about glXCreateContext with shared context argument that does the same thing on GLX. Even more happy.

I could create 2 windows, load a single texture once, used the same texture identifier for both window rendering. It works partly. Partly, because the two window DO display the texture WHEN the two window are on the same display. BUT when they are on 2 separate display (ie 2 different cards), the program hangs and X/linux/nvidia crashes (ouch, nasty drivers :-)

I found nothing about that on windows, using wglShareLists (i once tried multiple accelerated windows desktop but only the main display was acelerated so i switched to linux). But I found this paragraph in the glXCreateContext man page :

# From http://www.mevis.de/~uwe/opengl/glXCreateContext.html :
If shareList is not NULL, then all display-list indexes and definitions are shared by context shareList and by the newly created context. An arbitrary number of contexts can share a single display-list space. However, all rendering contexts that share a single display-list space must themselves exist in the same address space. Two rendering contexts share an address space if both are nondirect using the same server, or if both are direct and owned by a single process. Note that in the nondirect case, it is not necessary for the calling threads to share an address space, only for their related rendering contexts to share an address space.

Reading that, i understand that i should have either :
- nondirect rendering contexts using the same server
- direct rendering contexts owned by a single process

Here is the part about direct and indirect contexts :

# From http://www.mevis.de/~uwe/opengl/glXCreateContext.html :
If direct is True, then a direct rendering context is created if the implementation supports direct rendering and the connection is to an X server that is local. If direct is False, then a rendering context that renders through the X server is always created. Direct rendering provides a performance advantage in some implementations. However, direct rendering contexts cannot be shared outside a single process, and they cannot be used to render to GLX pixmaps.

Obviously I cannot use direct rendering context (last line), so i should stick to 'nondirect rendering contexts owned by a single process', ie. 'nondirect rendering contexts owned by the same server' as said in the first paragraph.

And as far as i know, if you have different displays using different cards, there is a separate X server instance for each of them, ie. i can't have 'rendering contexts owned by the same server', using different card. The solution would be to have only a single X server for all of VGA output. Which i think is not possible (please let my know if i'm wrong !)

=> As a conclusion : Is shared object possible on multiple windows ?

- YES : You can get shared contexts and shared display lists / textures when having multiple windows on a single display (ie single output or twinview configured multiple output card)

- NO : You cannot get different cards to work with the same resources, and you have to load and keep a separate bunch of display lists / textures per window, in case you want to do multiple windows on multiple displays (ie multiple cards, or non-twinview configured multiple output card)

Too bad i'm stuck after all these trial and error marathon :-)

Regards,
netsach

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.