// // I_ShutdownHardware // // Destroys the application window and frees its memory. // void STACK_ARGS I_ShutdownHardware() { if (loading_icon_background_surface) I_FreeSurface(loading_icon_background_surface); loading_icon_background_surface = NULL; delete video_subsystem; video_subsystem = NULL; }
// // I_BlitLoadingIcon // // Takes care of the actual drawing of the loading icon. // static void I_BlitLoadingIcon() { const patch_t* diskpatch = W_CachePatch("STDISK"); IWindowSurface* surface = I_GetPrimarySurface(); surface->lock(); int bpp = surface->getBitsPerPixel(); int scale = std::min(CleanXfac, CleanYfac); int w = diskpatch->width() * scale; int h = diskpatch->height() * scale; int x = surface->getWidth() - w; int y = surface->getHeight() - h; // offset x and y for the lower right corner of the screen int ofsx = x + (scale * diskpatch->leftoffset()); int ofsy = y + (scale * diskpatch->topoffset()); // save the area where the icon will be drawn to an off-screen surface // so that it can be restored after the frame is blitted if (!loading_icon_background_surface || loading_icon_background_surface->getWidth() != w || loading_icon_background_surface->getHeight() != h || loading_icon_background_surface->getBitsPerPixel() != bpp) { if (loading_icon_background_surface) I_FreeSurface(loading_icon_background_surface); loading_icon_background_surface = I_AllocateSurface(w, h, bpp); } loading_icon_background_surface->lock(); loading_icon_background_surface->blit(surface, x, y, w, h, 0, 0, w, h); surface->getDefaultCanvas()->DrawPatchStretched(diskpatch, ofsx, ofsy, w, h); loading_icon_background_surface->unlock(); surface->unlock(); }
// // I_SetVideoMode // // Main function to set the video mode at the hardware level. // void I_SetVideoMode(int width, int height, int surface_bpp, bool fullscreen, bool vsync) { // ensure the requested mode is valid IVideoMode desired_mode(width, height, surface_bpp, fullscreen); IVideoMode mode = I_ValidateVideoMode(&desired_mode); assert(mode.isValid()); IWindow* window = I_GetWindow(); window->setMode(mode.getWidth(), mode.getHeight(), mode.getBitsPerPixel(), mode.isFullScreen(), vsync); I_ForceUpdateGrab(); // [SL] 2011-11-30 - Prevent the player's view angle from moving I_FlushInput(); // Set up the primary and emulated surfaces primary_surface = window->getPrimarySurface(); int surface_width = primary_surface->getWidth(), surface_height = primary_surface->getHeight(); I_FreeSurface(converted_surface); converted_surface = NULL; I_FreeSurface(matted_surface); matted_surface = NULL; I_FreeSurface(emulated_surface); emulated_surface = NULL; // Handle a requested 8bpp surface when the video capabilities only support 32bpp if (surface_bpp != mode.getBitsPerPixel()) { const PixelFormat* format = surface_bpp == 8 ? I_Get8bppPixelFormat() : I_Get32bppPixelFormat(); converted_surface = new IWindowSurface(surface_width, surface_height, format); primary_surface = converted_surface; } // clear window's surface to all black; primary_surface->lock(); primary_surface->clear(); primary_surface->unlock(); // [SL] Determine the size of the matted surface. // A matted surface will be used if pillar-boxing or letter-boxing are used, or // if vid_320x200/vid_640x400 are being used in a wide-screen video mode, or // if vid_overscan is used to create a matte around the entire screen. // // Only vid_overscan creates a matted surface if the video mode is 320x200 or 640x400. // if (vid_overscan < 1.0f) { surface_width *= vid_overscan; surface_height *= vid_overscan; } if (!I_IsProtectedResolution(I_GetVideoWidth(), I_GetVideoHeight())) { if (vid_320x200 || vid_640x400) surface_width = surface_height * 4 / 3; else if (V_UsePillarBox()) surface_width = surface_height * 4 / 3; else if (V_UseLetterBox()) surface_height = surface_width * 9 / 16; } // Ensure matted surface dimensions are sane and sanitized. surface_width = clamp<uint16_t>(surface_width, 320, MAXWIDTH); surface_height = clamp<uint16_t>(surface_height, 200, MAXHEIGHT); // Anything wider than 16:9 starts to look more distorted and provides even more advantage, so for now // if the monitor aspect ratio is wider than 16:9, clamp it to that (TODO: Aspect ratio selection) if (surface_width / surface_height > 16 / 9) surface_width = (surface_height * 16) / 9; // Is matting being used? Create matted_surface based on the primary_surface. if (surface_width != primary_surface->getWidth() || surface_height != primary_surface->getHeight()) { matted_surface = new IWindowSurface(primary_surface, surface_width, surface_height); primary_surface = matted_surface; } // Create emulated_surface for emulating low resolution modes. if (vid_320x200) { emulated_surface = new IWindowSurface(320, 200, primary_surface->getPixelFormat()); emulated_surface->clear(); } else if (vid_640x400) { emulated_surface = new IWindowSurface(640, 400, primary_surface->getPixelFormat()); emulated_surface->clear(); } screen = primary_surface->getDefaultCanvas(); assert(I_VideoInitialized()); if (*window->getVideoMode() != desired_mode) DPrintf("I_SetVideoMode: could not set video mode to %s. Using %s instead.\n", I_GetVideoModeString(&desired_mode).c_str(), I_GetVideoModeString(window->getVideoMode()).c_str()); else DPrintf("I_SetVideoMode: set video mode to %s\n", I_GetVideoModeString(window->getVideoMode()).c_str()); const argb_t* palette = V_GetGamePalette()->colors; if (matted_surface) matted_surface->setPalette(palette); if (emulated_surface) emulated_surface->setPalette(palette); if (converted_surface) converted_surface->setPalette(palette); // handle the -noblit parameter when playing a LMP demo if (noblit) window->disableRefresh(); else window->enableRefresh(); }
void WI_End() { WI_unloadData(); I_FreeSurface(background_surface); }