R: [Plib-users] Trouble when changing resolution
Brought to you by:
sjbaker
From: Paolo L. <p.l...@ci...> - 2003-04-29 09:13:10
|
jeanfrancois.chalbos wrote: > > I have a problem when I change my program's resolution. > ==> TEXTURES DISAPPEARED > > I used glut and ssg (with 3ds import objects). > It's happen when I destroy the current window > and create another one. Jean Francois, as to my knowledge of GLUT&OpenGL under Windows, textures are resources of the window context, so when you destroy a window you loose all its resources. Textures loading during ssgLoad implicitly occurs in the current window context (which has to be created before calling ssgInit), so the window you keep open when ssgLoad is the one which holds all texture data. My suggestion is to not destroy the first window, yet possibly hide it (don't know the GLUT hide function) and, after had open the new window, share the textures between the two by means of the wglShareLists function. The following code should help you: // // till now you have the old window open // HGLRC oldwin_ctx = wglGetCurrentContext(); // // open the new window // glutCreateWindow( "..." ); HGLRC newwin_ctx = wglGetCurrentContext(); // // share textures (and display list also) between the two // if ( !wglShareLists( newwin_ctx, oldwin_ctx ) ) fprintf( stderr, "sharing error %d\n", GetLastError() ); Obviously this approach is also suitable when one wants to load data once and display in two or more windows. I red somewhere that in GLX texture sharing between windows is the default instead. Greetings - Paolo Leoncini |