diff options
author | Bertram <bertram@cegetel.net> | 2009-07-24 22:59:13 +0200 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2009-07-24 22:59:13 +0200 |
commit | 8195e73cb801d56240beb966554a864729d9f20c (patch) | |
tree | f2a00036d15eaf70cb9abe4930b4199b1e5eae05 /src/gui | |
parent | ea6f492198a03cffc3be47df000fa16dfc3b262f (diff) | |
download | mana-client-8195e73cb801d56240beb966554a864729d9f20c.tar.gz mana-client-8195e73cb801d56240beb966554a864729d9f20c.tar.bz2 mana-client-8195e73cb801d56240beb966554a864729d9f20c.tar.xz mana-client-8195e73cb801d56240beb966554a864729d9f20c.zip |
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?
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/desktop.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
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 { |