// // I_AllocateSurface // // Creates a new (non-primary) surface and returns it. // IWindowSurface* I_AllocateSurface(int width, int height, int bpp) { const PixelFormat* format; if (I_GetPrimarySurface() && bpp == I_GetPrimarySurface()->getBitsPerPixel()) format = I_GetPrimarySurface()->getPixelFormat(); else if (bpp == 8) format = I_Get8bppPixelFormat(); else format = I_Get32bppPixelFormat(); return new IWindowSurface(width, height, format); }
// // I_Get32bppPixelFormat // // Returns the platform's PixelFormat for 32bpp video modes. // This changes on certain platforms depending on the current video mode // in use (or fullscreen vs windowed). // const PixelFormat* I_Get32bppPixelFormat() { if (I_GetPrimarySurface() && I_GetPrimarySurface()->getBitsPerPixel() == 32) return I_GetPrimarySurface()->getPixelFormat(); #ifdef __BIG_ENDIAN__ static PixelFormat format(32, 0, 0, 0, 0, 0, 8, 16, 24); #else static PixelFormat format(32, 0, 0, 0, 0, 24, 16, 8, 0); #endif return &format; }
// // WI_GetHeight // // Returns the height of the area that the intermission screen will be // drawn to. The intermisison screen should be 4:3, except in 320x200 mode. // static int WI_GetHeight() { int surface_width = I_GetPrimarySurface()->getWidth(); int surface_height = I_GetPrimarySurface()->getHeight(); if (I_IsProtectedResolution(I_GetVideoWidth(), I_GetVideoHeight())) return surface_height; if (surface_width * 3 >= surface_height * 4) return surface_height; else return surface_width * 3 / 4; }
void WI_slamBackground (void) { IWindowSurface* primary_surface = I_GetPrimarySurface(); primary_surface->clear(); // ensure black background in matted modes background_surface->lock(); int destw = WI_GetWidth(), desth = WI_GetHeight(); primary_surface->blit(background_surface, 0, 0, background_surface->getWidth(), background_surface->getHeight(), (primary_surface->getWidth() - destw) / 2, (primary_surface->getHeight() - desth) / 2, destw, desth); background_surface->unlock(); }
// // I_RestoreLoadingIcon // // Restores the background area that was saved prior to blitting the // loading icon. // static void I_RestoreLoadingIcon() { IWindowSurface* surface = I_GetPrimarySurface(); surface->lock(); loading_icon_background_surface->lock(); int w = loading_icon_background_surface->getWidth(); int h = loading_icon_background_surface->getHeight(); int x = surface->getWidth() - w; int y = surface->getHeight() - h; surface->blit(loading_icon_background_surface, 0, 0, w, h, x, y, w, h); loading_icon_background_surface->unlock(); surface->unlock(); }
// // 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_GetSurfaceHeight // int I_GetSurfaceHeight() { if (I_VideoInitialized()) return I_GetPrimarySurface()->getHeight(); return 0; }
// // I_GetSurfaceWidth // int I_GetSurfaceWidth() { if (I_VideoInitialized()) return I_GetPrimarySurface()->getWidth(); return 0; }
// // I_GetPrimaryCanvas // // Returns a pointer to the primary surface's default canvas. // DCanvas* I_GetPrimaryCanvas() { if (I_VideoInitialized()) return I_GetPrimarySurface()->getDefaultCanvas(); return NULL; }