From 8195e73cb801d56240beb966554a864729d9f20c Mon Sep 17 00:00:00 2001 From: Bertram Date: Fri, 24 Jul 2009 22:59:13 +0200 Subject: Made the wallpaper be rescaled when necessary under SDL and OpenGL. The SDL methods to rescale the wallpaper has been optimized to permit rescaling at load time while OpenGL draws directly rescaled. Does someone know how to smooth the rescaled image under OpenGL? --- src/gui/widgets/desktop.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src/gui/widgets/desktop.cpp') diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index a4164bcc..6633d2ce 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -74,9 +74,14 @@ void Desktop::draw(gcn::Graphics *graphics) if (mWallpaper) { - g->drawImage(mWallpaper, + if (!mWallpaper->isAnOpenGLOne()) + g->drawImage(mWallpaper, (getWidth() - mWallpaper->getWidth()) / 2, (getHeight() - mWallpaper->getHeight()) / 2); + else + g->drawRescaledImage(mWallpaper, 0, 0, 0, 0, + mWallpaper->getWidth(), mWallpaper->getHeight(), + getWidth(), getHeight(), false); } Container::draw(graphics); @@ -87,13 +92,27 @@ void Desktop::setBestFittingWallpaper() const std::string wallpaperName = Wallpaper::getWallpaper(getWidth(), getHeight()); - Image *temp = ResourceManager::getInstance()->getImage(wallpaperName); + Image *nWallPaper = ResourceManager::getInstance()->getImage(wallpaperName); - if (temp) + if (nWallPaper) { if (mWallpaper) mWallpaper->decRef(); - mWallpaper = temp; + + if (!nWallPaper->isAnOpenGLOne() && (nWallPaper->getWidth() != getWidth() + || nWallPaper->getHeight() != getHeight())) + { + // We rescale to obtain a fullscreen wallpaper... + Image *newRsclWlPpr = nWallPaper->SDLgetScaledImage(getWidth(), getHeight()); + std::string idPath = nWallPaper->getIdPath(); + + // We replace the resource in the resource manager + nWallPaper->decRef(); + ResourceManager::getInstance()->addResource(idPath, newRsclWlPpr); + mWallpaper = newRsclWlPpr; + } + else + mWallpaper = nWallPaper; } else { -- cgit v1.2.3-70-g09d2