void ReloadOpenGL() { InitOpenGL(); ReloadGraphics(); ReloadFonts(); UI.Minimap.Reload(); }
/** ** Toggle full screen mode. */ void ToggleFullScreen(void) { #ifdef USE_WIN32 long framesize; SDL_Rect clip; Uint32 flags; int w; int h; int bpp; #ifndef USE_OPENGL unsigned char *pixels; SDL_Color *palette; int ncolors; #endif if (!TheScreen) { // don't bother if there's no surface. return; } flags = TheScreen->flags; w = TheScreen->w; h = TheScreen->h; bpp = TheScreen->format->BitsPerPixel; if (!SDL_VideoModeOK(w, h, bpp, flags ^ SDL_FULLSCREEN)) { return; } SDL_GetClipRect(TheScreen, &clip); // save the contents of the screen. framesize = w * h * TheScreen->format->BytesPerPixel; #ifndef USE_OPENGL if (!(pixels = new unsigned char[framesize])) { // out of memory return; } SDL_LockSurface(TheScreen); memcpy(pixels, TheScreen->pixels, framesize); #ifdef DEBUG // shut up compiler palette = NULL; ncolors=0; #endif if (TheScreen->format->palette) { ncolors = TheScreen->format->palette->ncolors; if (!(palette = new SDL_Color[ncolors])) { delete[] pixels; return; } memcpy(palette, TheScreen->format->palette->colors, ncolors * sizeof(SDL_Color)); } SDL_UnlockSurface(TheScreen); #endif TheScreen = SDL_SetVideoMode(w, h, bpp, flags ^ SDL_FULLSCREEN); if (!TheScreen) { TheScreen = SDL_SetVideoMode(w, h, bpp, flags); if (!TheScreen) { // completely screwed. #ifndef USE_OPENGL delete[] pixels; delete[] palette; #endif fprintf(stderr, "Toggle to fullscreen, crashed all\n"); Exit(-1); } } // Windows shows the SDL cursor when starting in fullscreen mode // then switching to window mode. This hides the cursor again. SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_DISABLE); #ifdef USE_OPENGL InitOpenGL(); ReloadGraphics(); ReloadFonts(); UI.Minimap.Reload(); #else SDL_LockSurface(TheScreen); memcpy(TheScreen->pixels, pixels, framesize); delete[] pixels; if (TheScreen->format->palette) { // !!! FIXME : No idea if that flags param is right. SDL_SetPalette(TheScreen, SDL_LOGPAL, palette, 0, ncolors); delete[] palette; } SDL_UnlockSurface(TheScreen); #endif SDL_SetClipRect(TheScreen, &clip); Invalidate(); // Update display #else // !USE_WIN32 SDL_WM_ToggleFullScreen(TheScreen); #endif Video.FullScreen = (TheScreen->flags & SDL_FULLSCREEN) ? 1 : 0; }