GLUT GAME MODE - Textures disappeared

Hi! I am just experimenting with Glut game mode and can’t get one thing.
Imagine I have a simple application which renders a textured cube in the origin.
Now when I run the app in a window mode then I can see the cube textured but as soon as I switch to the game mode (full screen) all textures are lost (not displayed). why?
Note that I load textures in main() function not in init().

eg…
void keboard (…)
{
case ‘f’: if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE))
{
glutEnterGameMode();
sprintf(gameModeString,“1600x1200”);
// register callbacks again
// and init OpenGL context
init();
}
}
I still see a cube which is rendered in the display() function but for some reason all textures disappear. Does it mean that I have to load textures again in init() every time I switch to the game mode?
It can’t be true!? How can I use my textures without after switching to game mode?

I also spotted that when I switch to a game mode then my original window (window mode) is still opened as well as teh game mode window. So I have two apps running at teh same time. What about performance? Does Glut somehow disable that window mode when game mode is running?

[This message has been edited by robert_s (edited 03-04-2002).]

You have to reload your textures after the switch to fullscreen. Textures are part of the OpenGL Rendering Context that GLUT creates for you. When you switch from windowed mode to full screen, it has to destroy the old rendering context and create a new one. You have to load your textures into this context.

Ok! so that means that when I switch to game mode I have to load all my textures again as if I was running the app for the first time?
Ok then what happens with those textures already loaded when I run initially in window mode and then jump into game mode and load textures again. What about those previously loaded textures.
Tcobbs you said that they are destroyed but how could this happen.? I have to manually delete them just before switching to the game mode and when going back to the window mode I have reload all textures again manually?!don’t I!? or they’re somehow automatically deleted?

[This message has been edited by robert_s (edited 03-04-2002).]

I observed that when I load textures only once and run in a window mode then the textures are displayed ok. then when I switch to game mode the geometry is still rendered (cube) but without textures. Now the interesting thing is that when you go back to window mode the textures appear again. so that means that the textures are not destroyed. they still exist but belong only to the window mode not to the newly created full screen mode window which is another extra window. But don’t you think guys that there must be some way of transferring those textures loaded in memory originally for the indow mode and use them in full screen without loading the texturtes again?. in this case imagine if you had say 50 textures to load you would have to wait long time before it would switch to game mode?
Otherwise if you have to load all textures again for the game mode window then it means that it will consume double the memory.
It will just use too much memory for loading textures for both windows! .

[This message has been edited by robert_s (edited 03-04-2002).]

I dont really know what GLUT does, but you can check the source code and see.

The memory problem can be avoided by destroying the window and the RC and recreate window + RC in fullscreen mode. I think this is what games like quake do. It s as if you relaunched the game. It probably has to do with the window attributes. It must be necessary to recreate the window. Also, the driver somehow knows that you are in fullscreen mode and can do page flipping instead of block transfer.

Why do the textures reappear when you go back to windows mode… dont know!

V-man

I’ve never used GLUT, but I have to assume that it handles all the cleanup work. So, when it destroys the rendering context for the window-mode window, all the associated texture memory would be freed up on the OpenGL driver side. Any memory you are using in your program to store the textures is another story, but you don’t have to reload them from disk; you just have to re-send them to OpenGL.

There is some information on sharing textures between rendering contexts in the Redbook in Appendix C. It’s under the section on GLX and WGL. Best way to find it is to select appendix C then search for the word “share”.

I haven’t read the information there but maybe it’ll be helpful.

OK BUT… how do I resend all those textures to OpenGL tcobbs?

Just like you sent them the first time.

No I mean How do I resend those textures to OpenGL without reloading them from disk.

As Zeckensack said, just like you did the first time.

Use glTexImage2D to resend the images to OpenGL. I you don’t want to reload them from disk, then don’t release the memory occupied by the image data after you have uploaded them the first time.