From c1f992231e679746934021329f3ab9519f784aa0 Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 23 Apr 2011 20:34:38 +0000 Subject: [PATCH] Full support for smoothing scaled icons in the GUI (will only work if you use a patched irrlicht) git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8433 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/irr_driver.cpp | 5 ++++- src/guiengine/skin.cpp | 11 +++++++++++ src/states_screens/race_gui.cpp | 9 +++++++++ src/states_screens/race_gui_base.cpp | 4 +++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index b35e5d1f6..32c07c777 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -224,6 +224,7 @@ void IrrDriver::initDevice() m_scene_manager->getParameters() ->setAttribute(scene::B3D_LOADER_IGNORE_MIPMAP_FLAG, true); m_device->getVideoDriver()->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS,true); + m_device->getVideoDriver()->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY,true); m_gui_env = m_device->getGUIEnvironment(); m_video_driver = m_device->getVideoDriver(); @@ -231,12 +232,14 @@ void IrrDriver::initDevice() material2D.setFlag(video::EMF_ANTI_ALIASING, true); for (unsigned int n=0; nenableMaterial2D(); diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp index 4756b49c0..6ea41f452 100644 --- a/src/guiengine/skin.cpp +++ b/src/guiengine/skin.cpp @@ -1155,6 +1155,13 @@ void Skin::drawIconButton(const core::rect< s32 > &rect, Widget* widget, const b IconButtonWidget* icon_widget = (IconButtonWidget*) widget; + if (widget->m_type == WTYPE_MODEL_VIEW) + { + // Model view widgets don't generate mipmaps so disable material 2D + irr_driver->getVideoDriver()->enableMaterial2D(false); + } + + if (widget->m_deactivated || ID_DEBUG) { SColor colors[] = { SColor(100,255,255,255), @@ -1172,6 +1179,10 @@ void Skin::drawIconButton(const core::rect< s32 > &rect, Widget* widget, const b 0 /* no clipping */, 0, true /* alpha */); } + if (widget->m_type == WTYPE_MODEL_VIEW) + { + irr_driver->getVideoDriver()->enableMaterial2D(); + } } diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 197853fe6..47bed74dd 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -174,8 +174,14 @@ void RaceGUI::renderGlobal(float dt) drawGlobalMusicDescription(); } + // minimap has no mipmaps so disable material2D + irr_driver->getVideoDriver()->enableMaterial2D(false); drawGlobalMiniMap(); + irr_driver->getVideoDriver()->enableMaterial2D(); + KartIconDisplayInfo* info = world->getKartsDisplayInfo(); + + irr_driver->getVideoDriver()->enableMaterial2D(); // seems like we need to remind irrlicht from time to time to use the Material2D drawGlobalPlayerIcons(info); } // renderGlobal @@ -229,8 +235,11 @@ void RaceGUI::renderPlayerView(const Kart *kart) RaceGUI::KartIconDisplayInfo* info = World::getWorld()->getKartsDisplayInfo(); + irr_driver->getVideoDriver()->enableMaterial2D(); // not sure why I need to call it again but with this, it works drawPowerupIcons (kart, viewport, scaling); + irr_driver->getVideoDriver()->enableMaterial2D(); drawSpeedAndEnergy (kart, viewport, scaling); + irr_driver->getVideoDriver()->enableMaterial2D(); drawRankLap (info, kart, viewport); RaceGUIBase::renderPlayerView(kart); diff --git a/src/states_screens/race_gui_base.cpp b/src/states_screens/race_gui_base.cpp index 5a96865b4..a83538af7 100644 --- a/src/states_screens/race_gui_base.cpp +++ b/src/states_screens/race_gui_base.cpp @@ -226,6 +226,8 @@ void RaceGUIBase::drawAllMessages(const Kart* kart, font_height = m_small_font_max_height; } + irr_driver->getVideoDriver()->enableMaterial2D(); // seems like we need to remind irrlicht from time to time to use the Material2D + // The message are displayed in reverse order, so that a multi-line // message (addMessage("1", ...); addMessage("2",...) is displayed // in the right order: "1" on top of "2" @@ -234,7 +236,7 @@ void RaceGUIBase::drawAllMessages(const Kart* kart, { TimedMessage const &msg = *i; - // less important messages were already displayed + // less important messages were already displayed if (!msg.m_important) continue; // Display only messages for all karts, or messages for this kart