From 27dec2fbf8a4e722d841afb0e96ef049e632ce99 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 26 Mar 2015 11:28:22 +1100 Subject: [PATCH 1/4] Added attribute to irrlicht's driver to enable automatic resize of images that are too big. This is then used to automatically resize any textures (except fonts, background screen) to be automatically resized to 512x512 if they are bigger. --- lib/irrlicht/include/IAttributes.h | 4 ++-- lib/irrlicht/include/IVideoDriver.h | 2 ++ lib/irrlicht/source/Irrlicht/CAttributes.cpp | 4 ++-- lib/irrlicht/source/Irrlicht/CAttributes.h | 4 ++-- lib/irrlicht/source/Irrlicht/CNullDriver.cpp | 5 ++++ lib/irrlicht/source/Irrlicht/CNullDriver.h | 3 +++ .../source/Irrlicht/COpenGLTexture.cpp | 12 ++++++++++ src/graphics/2dutils.cpp | 2 +- src/graphics/irr_driver.cpp | 15 +++++++++++- src/graphics/irr_driver.hpp | 2 +- src/guiengine/scalable_font.cpp | 24 +++++++++++++------ src/main.cpp | 4 ++++ 12 files changed, 65 insertions(+), 16 deletions(-) diff --git a/lib/irrlicht/include/IAttributes.h b/lib/irrlicht/include/IAttributes.h index f1376358e..0361ea125 100644 --- a/lib/irrlicht/include/IAttributes.h +++ b/lib/irrlicht/include/IAttributes.h @@ -501,11 +501,11 @@ public: //! Gets an attribute as dimension2d //! \param attributeName: Name of the attribute to get. //! \return Returns value of the attribute previously set by setAttribute() - virtual core::dimension2d getAttributeAsDimension2d(const c8* attributeName) = 0; + virtual core::dimension2d getAttributeAsDimension2d(const c8* attributeName) const = 0; //! Gets an attribute as dimension2d //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::dimension2d getAttributeAsDimension2d(s32 index) = 0; + virtual core::dimension2d getAttributeAsDimension2d(s32 index) const = 0; //! Sets an attribute as dimension2d virtual void setAttribute(s32 index, core::dimension2d v) = 0; diff --git a/lib/irrlicht/include/IVideoDriver.h b/lib/irrlicht/include/IVideoDriver.h index 79b1b2002..3f3851425 100644 --- a/lib/irrlicht/include/IVideoDriver.h +++ b/lib/irrlicht/include/IVideoDriver.h @@ -324,6 +324,8 @@ namespace video AntiAlias (int) Number of Samples the driver uses for each pixel. 0 and 1 means anti aliasing is off, typical values are 2,4,8,16,32 */ virtual const io::IAttributes& getDriverAttributes() const=0; + //! Non-const version (with a different name to avoid involuntary mistakes). */ + virtual io::IAttributes& getNonConstDriverAttributes() = 0; //! Check if the driver was recently reset. /** For d3d devices you will need to recreate the RTTs if the diff --git a/lib/irrlicht/source/Irrlicht/CAttributes.cpp b/lib/irrlicht/source/Irrlicht/CAttributes.cpp index 21ebe1f1c..71068ca60 100644 --- a/lib/irrlicht/source/Irrlicht/CAttributes.cpp +++ b/lib/irrlicht/source/Irrlicht/CAttributes.cpp @@ -429,7 +429,7 @@ void CAttributes::setAttribute(const c8* attributeName, core::dimension2d v //! Gets an attribute as dimension2d //! \param attributeName: Name of the attribute to get. //! \return Returns value of the attribute previously set by setAttribute() -core::dimension2d CAttributes::getAttributeAsDimension2d(const c8* attributeName) +core::dimension2d CAttributes::getAttributeAsDimension2d(const c8* attributeName) const { IAttribute* att = getAttributeP(attributeName); if (att) @@ -737,7 +737,7 @@ core::rect CAttributes::getAttributeAsRect(s32 index) //! Gets an attribute as dimension2d //! \param index: Index value, must be between 0 and getAttributeCount()-1. -core::dimension2d CAttributes::getAttributeAsDimension2d(s32 index) +core::dimension2d CAttributes::getAttributeAsDimension2d(s32 index) const { if ((u32)index < Attributes.size()) return Attributes[index]->getDimension2d(); diff --git a/lib/irrlicht/source/Irrlicht/CAttributes.h b/lib/irrlicht/source/Irrlicht/CAttributes.h index 1675a3ab3..3e597a47b 100644 --- a/lib/irrlicht/source/Irrlicht/CAttributes.h +++ b/lib/irrlicht/source/Irrlicht/CAttributes.h @@ -465,11 +465,11 @@ public: //! Gets an attribute as dimension2d //! \param attributeName: Name of the attribute to get. //! \return Returns value of the attribute previously set by setAttribute() - virtual core::dimension2d getAttributeAsDimension2d(const c8* attributeName); + virtual core::dimension2d getAttributeAsDimension2d(const c8* attributeName) const; //! Gets an attribute as dimension2d //! \param index: Index value, must be between 0 and getAttributeCount()-1. - virtual core::dimension2d getAttributeAsDimension2d(s32 index); + virtual core::dimension2d getAttributeAsDimension2d(s32 index) const; //! Sets an attribute as dimension2d virtual void setAttribute(s32 index, core::dimension2d v); diff --git a/lib/irrlicht/source/Irrlicht/CNullDriver.cpp b/lib/irrlicht/source/Irrlicht/CNullDriver.cpp index 11144c114..4ef9c44de 100644 --- a/lib/irrlicht/source/Irrlicht/CNullDriver.cpp +++ b/lib/irrlicht/source/Irrlicht/CNullDriver.cpp @@ -298,6 +298,11 @@ const io::IAttributes& CNullDriver::getDriverAttributes() const return *DriverAttributes; } +//! Get attributes of the actual video driver +io::IAttributes& CNullDriver::getNonConstDriverAttributes() +{ + return *DriverAttributes; +} //! sets transformation void CNullDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) diff --git a/lib/irrlicht/source/Irrlicht/CNullDriver.h b/lib/irrlicht/source/Irrlicht/CNullDriver.h index c2fb5cc16..251062b68 100644 --- a/lib/irrlicht/source/Irrlicht/CNullDriver.h +++ b/lib/irrlicht/source/Irrlicht/CNullDriver.h @@ -64,6 +64,9 @@ namespace video //! Get attributes of the actual video driver const io::IAttributes& getDriverAttributes() const; + //! Non-const version (with a different name to avoid involuntary mistakes). */ + virtual io::IAttributes& getNonConstDriverAttributes(); + //! sets transformation virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); diff --git a/lib/irrlicht/source/Irrlicht/COpenGLTexture.cpp b/lib/irrlicht/source/Irrlicht/COpenGLTexture.cpp index 72a750a50..ef20da830 100644 --- a/lib/irrlicht/source/Irrlicht/COpenGLTexture.cpp +++ b/lib/irrlicht/source/Irrlicht/COpenGLTexture.cpp @@ -11,6 +11,8 @@ #include "COpenGLDriver.h" #include "os.h" #include "CColorConverter.h" +#include "IAttributes.h" +#include "IrrlichtDevice.h" #include "irrString.h" @@ -314,7 +316,17 @@ void COpenGLTexture::getImageValues(IImage* image) ImageSize.Width = (u32)(Driver->MaxTextureSize*ratio); } TextureSize=ImageSize.getOptimalSize(!Driver->queryFeature(EVDF_TEXTURE_NPOT)); + const core::dimension2du max_size = Driver->getDriverAttributes() + .getAttributeAsDimension2d("MAX_TEXTURE_SIZE"); + if (max_size.Width> 0 && TextureSize.Width > max_size.Width) + { + TextureSize.Width = max_size.Width; + } + if (max_size.Height> 0 && TextureSize.Height > max_size.Height) + { + TextureSize.Height = max_size.Height; + } ColorFormat = getBestColorFormat(image->getColorFormat()); } diff --git a/src/graphics/2dutils.cpp b/src/graphics/2dutils.cpp index 537ff43b8..386f1ac24 100644 --- a/src/graphics/2dutils.cpp +++ b/src/graphics/2dutils.cpp @@ -206,7 +206,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect& destRect tex_width, tex_height, tex_center_pos_x, tex_center_pos_y; - getSize(texture->getOriginalSize().Width, texture->getOriginalSize().Height, texture->isRenderTarget(), + getSize(texture->getSize().Width, texture->getSize().Height, texture->isRenderTarget(), destRect, sourceRect, width, height, center_pos_x, center_pos_y, tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 3db7aebb3..e8a6b7232 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -592,10 +592,23 @@ void IrrDriver::initDevice() m_pointer_shown = true; } // initDevice +// ---------------------------------------------------------------------------- +void IrrDriver::setMaxTextureSize() +{ + if( (UserConfigParams::m_high_definition_textures & 0x01) == 0) + { + io::IAttributes &att = m_video_driver->getNonConstDriverAttributes(); + att.setAttribute("MAX_TEXTURE_SIZE", core::dimension2du(512, 512)); + } +} // setMaxTextureSize + +// ---------------------------------------------------------------------------- void IrrDriver::cleanSunInterposer() { delete m_sun_interposer; -} +} // cleanSunInterposer + +// ---------------------------------------------------------------------------- void IrrDriver::createSunInterposer() { scene::IMesh * sphere = m_scene_manager->getGeometryCreator()->createSphereMesh(1, 16, 16); diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index b04b380bc..6d9097b83 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -36,7 +36,6 @@ #include #include "IrrlichtDevice.h" #include "ISkinnedMesh.h" -//#include "graphics/rtts.hpp" #include "graphics/shaders.hpp" #include "graphics/wind.hpp" #include "io/file_manager.hpp" @@ -354,6 +353,7 @@ public: ~IrrDriver(); void initDevice(); void reset(); + void setMaxTextureSize(); void getOpenGLData(std::string *vendor, std::string *renderer, std::string *version); diff --git a/src/guiengine/scalable_font.cpp b/src/guiengine/scalable_font.cpp index 980fcd836..381abdb06 100644 --- a/src/guiengine/scalable_font.cpp +++ b/src/guiengine/scalable_font.cpp @@ -4,16 +4,17 @@ #include "guiengine/scalable_font.hpp" -#include -#include -#include -#include -#include - +#include "graphics/2dutils.hpp" #include "guiengine/engine.hpp" #include "io/file_manager.hpp" #include "utils/translation.hpp" -#include "graphics/2dutils.hpp" + +#include +#include +#include +#include +#include +#include namespace irr { @@ -732,7 +733,16 @@ void ScalableFont::lazyLoadTexture(int texID) // load texture assert(m_texture_files[texID].m_file_name.size() > 0); + + // Font textures can not be resized (besides the impact on quality in + // this case, the indices in the xml files would become wrong). + core::dimension2du old_max_size = Driver->getDriverAttributes() + .getAttributeAsDimension2d("MAX_TEXTURE_SIZE"); + Driver->getNonConstDriverAttributes().setAttribute("MAX_TEXTURE_SIZE", + core::dimension2du(0, 0)); + SpriteBank->setTexture(texID, Driver->getTexture( m_texture_files[texID].m_file_name )); + Driver->getNonConstDriverAttributes().setAttribute("MAX_TEXTURE_SIZE", old_max_size); // set previous mip-map+filter state //Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, mipmap); diff --git a/src/main.cpp b/src/main.cpp index 4b43fc2fb..01b8ed5fe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1128,6 +1128,10 @@ void initRest() powerup_manager = new PowerupManager (); attachment_manager = new AttachmentManager (); highscore_manager = new HighscoreManager (); + + // The maximum texture size can not be set earlier, since + // e.g. the background image needs to be loaded in high res. + irr_driver->setMaxTextureSize(); KartPropertiesManager::addKartSearchDir( file_manager->getAddonsFile("karts/")); track_manager->addTrackSearchDir( From 262eeca87f8e4797814f6e6734c8726beaa0f5f6 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Wed, 25 Mar 2015 20:53:05 -0400 Subject: [PATCH 2/4] Update configuration of HD textures in GUI, especially through presets --- src/states_screens/options_screen_video.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/states_screens/options_screen_video.cpp b/src/states_screens/options_screen_video.cpp index 2e144d697..887fb5d69 100644 --- a/src/states_screens/options_screen_video.cpp +++ b/src/states_screens/options_screen_video.cpp @@ -62,6 +62,7 @@ struct GFXPreset bool dof; bool global_illumination; bool degraded_ibl; + int hd_textures; }; static GFXPreset GFX_PRESETS[] = @@ -70,35 +71,35 @@ static GFXPreset GFX_PRESETS[] = false /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */, false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, false /* weather */, false /* animatedScenery */, 0 /* animatedCharacters */, 0 /* anisotropy */, - false /* depth of field */, false /* global illumination */, true /* degraded IBL */ + false /* depth of field */, false /* global illumination */, true /* degraded IBL */, 0 /* hd_textures */ }, { false /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */, false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, false /* weather */, true /* animatedScenery */, 1 /* animatedCharacters */, 4 /* anisotropy */, - false /* depth of field */, false /* global illumination */, true /* degraded IBL */ + false /* depth of field */, false /* global illumination */, true /* degraded IBL */, 0 /* hd_textures */ }, { true /* light */, 0 /* shadow */, false /* bloom */, false /* motionblur */, false /* lightshaft */, false /* glow */, false /* mlaa */, false /* ssao */, true /* weather */, true /* animatedScenery */, 1 /* animatedCharacters */, 4 /* anisotropy */, - false /* depth of field */, false /* global illumination */, true /* degraded IBL */ + false /* depth of field */, false /* global illumination */, true /* degraded IBL */, 1 /* hd_textures */ }, { true /* light */, 0 /* shadow */, false /* bloom */, true /* motionblur */, true /* lightshaft */, true /* glow */, true /* mlaa */, false /* ssao */, true /* weather */, true /* animatedScenery */, 1 /* animatedCharacters */, 8 /* anisotropy */, - false /* depth of field */, false /* global illumination */, false /* degraded IBL */ + false /* depth of field */, false /* global illumination */, false /* degraded IBL */, 1 /* hd_textures */ }, { true /* light */, 1024 /* shadow */, true /* bloom */, true /* motionblur */, true /* lightshaft */, true /* glow */, true /* mlaa */, true /* ssao */, true /* weather */, true /* animatedScenery */, 2 /* animatedCharacters */, 16 /* anisotropy */, - true /* depth of field */, true /* global illumination */, false /* degraded IBL */ + true /* depth of field */, true /* global illumination */, false /* degraded IBL */, 1 /* hd_textures */ } }; @@ -397,7 +398,8 @@ void OptionsScreenVideo::updateGfxSlider() GFX_PRESETS[l].weather == UserConfigParams::m_weather_effects && GFX_PRESETS[l].dof == UserConfigParams::m_dof && GFX_PRESETS[l].global_illumination == UserConfigParams::m_gi && - GFX_PRESETS[l].degraded_ibl == UserConfigParams::m_degraded_IBL) + GFX_PRESETS[l].degraded_ibl == UserConfigParams::m_degraded_IBL && + GFX_PRESETS[l].hd_textures == (UserConfigParams::m_high_definition_textures & 0x01)) { gfx->setValue(l + 1); found = true; @@ -488,7 +490,11 @@ void OptionsScreenVideo::updateTooltip() //I18N: in graphical options tooltip = tooltip + L"\n" + _("Global illumination : %s", UserConfigParams::m_gi ? enabled : disabled); - + + //I18N: in graphical options + tooltip = tooltip + L"\n" + _("Use high definition textures") + L" : " + + ((UserConfigParams::m_high_definition_textures & 0x1) == 0 ? disabled : enabled); + gfx->setTooltip(tooltip); } // updateTooltip @@ -570,6 +576,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, UserConfigParams::m_dof = GFX_PRESETS[level].dof; UserConfigParams::m_gi = GFX_PRESETS[level].global_illumination; UserConfigParams::m_degraded_IBL = GFX_PRESETS[level].degraded_ibl; + UserConfigParams::m_high_definition_textures = 0x02 | GFX_PRESETS[level].hd_textures; updateGfxSlider(); } From 02d5b43d867c6a59139580ebbed5b3cae1accd5d Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 26 Mar 2015 17:12:51 +1100 Subject: [PATCH 3/4] Replaced all texture->getOriginalSize() with texture->getSize() to take potentially resized textures properly into account. --- src/graphics/2dutils.cpp | 2 +- src/graphics/render_skybox.cpp | 8 ++++---- src/guiengine/CGUISpriteBank.cpp | 4 ++-- src/states_screens/race_gui.cpp | 8 ++++---- src/states_screens/race_gui_base.cpp | 22 +++++++++++----------- src/states_screens/race_gui_overworld.cpp | 6 +++--- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/graphics/2dutils.cpp b/src/graphics/2dutils.cpp index 386f1ac24..afebe54ed 100644 --- a/src/graphics/2dutils.cpp +++ b/src/graphics/2dutils.cpp @@ -117,7 +117,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect& destRect tex_width, tex_height, tex_center_pos_x, tex_center_pos_y; - getSize(texture->getOriginalSize().Width, texture->getOriginalSize().Height, texture->isRenderTarget(), + getSize(texture->getSize().Width, texture->getSize().Height, texture->isRenderTarget(), destRect, sourceRect, width, height, center_pos_x, center_pos_y, tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); diff --git a/src/graphics/render_skybox.cpp b/src/graphics/render_skybox.cpp index 967e756b8..30baf03ac 100644 --- a/src/graphics/render_skybox.cpp +++ b/src/graphics/render_skybox.cpp @@ -226,8 +226,8 @@ GLuint generateCubeMapFromTextures(const std::vector &texture unsigned size = 0; for (unsigned i = 0; i < 6; i++) { - size = MAX2(size, textures[i]->getOriginalSize().Width); - size = MAX2(size, textures[i]->getOriginalSize().Height); + size = MAX2(size, textures[i]->getSize().Width); + size = MAX2(size, textures[i]->getSize().Height); } const unsigned texture_permutation[] = { 2, 3, 0, 1, 5, 4 }; @@ -299,8 +299,8 @@ void IrrDriver::generateDiffuseCoefficients() for (unsigned i = 0; i < 6; i++) { - sh_w = MAX2(sh_w, SphericalHarmonicsTextures[i]->getOriginalSize().Width); - sh_h = MAX2(sh_h, SphericalHarmonicsTextures[i]->getOriginalSize().Height); + sh_w = MAX2(sh_w, SphericalHarmonicsTextures[i]->getSize().Width); + sh_h = MAX2(sh_h, SphericalHarmonicsTextures[i]->getSize().Height); } for (unsigned i = 0; i < 6; i++) diff --git a/src/guiengine/CGUISpriteBank.cpp b/src/guiengine/CGUISpriteBank.cpp index 19150fc2f..d255309e5 100644 --- a/src/guiengine/CGUISpriteBank.cpp +++ b/src/guiengine/CGUISpriteBank.cpp @@ -151,8 +151,8 @@ s32 STKModifiedSpriteBank::addTextureAsSprite(video::ITexture* texture) u32 rectangleIndex = Rectangles.size(); Rectangles.push_back( core::rect(0,0, - texture->getOriginalSize().Width, - texture->getOriginalSize().Height) ); + texture->getSize().Width, + texture->getSize().Height) ); SGUISprite sprite; sprite.frameTime = 0; diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index ad5143cd7..55dc87ed7 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -268,7 +268,7 @@ void RaceGUI::drawScores() offsetX + (int)(m_minimap_player_size/1.25f), offsetY + (int)(m_minimap_player_size/1.25f)); core::rect sourceRect(core::position2d(0,0), - team_icon->getOriginalSize()); + team_icon->getSize()); draw2DImage(team_icon,indicatorPos,sourceRect, NULL,NULL,true); numLeader++; @@ -357,7 +357,7 @@ void RaceGUI::drawGlobalMiniMap() if (old_rtt_mini_map != NULL) { core::rect source(core::position2di(0, 0), - old_rtt_mini_map->getOriginalSize()); + old_rtt_mini_map->getSize()); draw2DImage(old_rtt_mini_map, dest, source, NULL, NULL, true); } @@ -380,7 +380,7 @@ void RaceGUI::drawGlobalMiniMap() video::ITexture* icon = kart->getKartProperties()->getMinimapIcon(); - // int marker_height = m_marker->getOriginalSize().Height; + // int marker_height = m_marker->getSize().Height; core::rect source(core::position2di(0, 0), icon->getSize()); int marker_half_size = (kart->getController()->isPlayerController() ? m_minimap_player_size @@ -720,7 +720,7 @@ void RaceGUI::drawSpeedEnergyRank(const AbstractKart* kart, (int)offset.Y); video::ITexture *meter_texture = m_speed_meter_icon->getTexture(); const core::rect meter_texture_coords(core::position2d(0,0), - meter_texture->getOriginalSize()); + meter_texture->getSize()); draw2DImage(meter_texture, meter_pos, meter_texture_coords, NULL, NULL, true); // TODO: temporary workaround, shouldn't have to use diff --git a/src/states_screens/race_gui_base.cpp b/src/states_screens/race_gui_base.cpp index db54885ae..4465b8ffc 100644 --- a/src/states_screens/race_gui_base.cpp +++ b/src/states_screens/race_gui_base.cpp @@ -327,7 +327,7 @@ void RaceGUIBase::drawPowerupIcons(const AbstractKart* kart, assert(powerup->getIcon() != NULL); video::ITexture *t=powerup->getIcon()->getTexture(); assert(t != NULL); - core::rect rect(core::position2di(0, 0), t->getOriginalSize()); + core::rect rect(core::position2di(0, 0), t->getSize()); for ( int i = 0 ; i < n ; i++ ) { @@ -588,7 +588,7 @@ void RaceGUIBase::drawGlobalMusicDescription() noteX+iconSizeX/2+20, noteY+iconSizeY/2+ICON_SIZE/2); const core::rect source(core::position2d(0,0), - t->getOriginalSize()); + t->getSize()); draw2DImage(t, dest, source, NULL, NULL, true); @@ -855,7 +855,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin) 100+(int)(100*cos(M_PI/2*i+World::getWorld()->getTime()*2))); } const core::rect rect(core::position2d(0,0), - m_icons_frame->getTexture()->getOriginalSize()); + m_icons_frame->getTexture()->getSize()); draw2DImage( m_icons_frame->getTexture(), pos, rect,NULL, colors, true); } @@ -864,7 +864,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin) if (icon && !kart->getKartAnimation() && !kart->isSquashed()) { const core::rect rect(core::position2d(0,0), - icon->getOriginalSize()); + icon->getSize()); draw2DImage(icon, pos, rect, NULL, NULL, true); } @@ -877,7 +877,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin) float t = kart->getKartAnimation()->getAnimationTimer(); float t_anim=100*sin(0.5f*M_PI*t); const core::rect rect1(core::position2d(0,0), - icon->getOriginalSize()); + icon->getSize()); const core::rect pos1((int)(x-t_anim), y, (int)(x+w-t_anim), y+w); draw2DImage(icon, pos1, rect1, @@ -890,7 +890,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin) const core::rect destRect(core::position2d(x,y+w/4), core::position2d(x+w,y+w*3/4)); const core::rect sourceRect(core::position2d(0,0), - icon->getOriginalSize()); + icon->getSize()); draw2DImage(icon, destRect, sourceRect, NULL, NULL, true); @@ -902,8 +902,8 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin) //exploses into 4 parts float t = kart->getKartAnimation()->getAnimationTimer(); float t_anim=50.0f*sin(0.5f*M_PI*t); - u16 icon_size_x=icon->getOriginalSize().Width; - u16 icon_size_y=icon->getOriginalSize().Height; + u16 icon_size_x=icon->getSize().Width; + u16 icon_size_y=icon->getSize().Height; const core::rect rect1(0, 0, icon_size_x/2,icon_size_y/2); const core::rect pos1((int)(x-t_anim), (int)(y-t_anim), @@ -940,7 +940,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin) if (icon_plunger != NULL) { const core::rect rect(core::position2d(0,0), - icon_plunger->getOriginalSize()); + icon_plunger->getSize()); const core::rect pos1(x+10, y-10, x+w+10, y+w-10); draw2DImage(icon_plunger, pos1, rect, NULL, NULL, @@ -956,7 +956,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin) if (icon_attachment != NULL) { const core::rect rect(core::position2d(0,0), - icon_attachment->getOriginalSize()); + icon_attachment->getSize()); const core::rect pos1(x-20, y-10, x+w-20, y+w-10); draw2DImage(icon_attachment, pos1, rect, NULL, @@ -1054,7 +1054,7 @@ void RaceGUIBase::drawPlungerInFace(const Camera *camera, float dt) plunger_x+plunger_size, offset_y+plunger_size); const core::rect source(core::position2d(0,0), - t->getOriginalSize()); + t->getSize()); draw2DImage(t, dest, source, &viewport /* clip */, diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp index a77839be4..b6242217c 100644 --- a/src/states_screens/race_gui_overworld.cpp +++ b/src/states_screens/race_gui_overworld.cpp @@ -330,7 +330,7 @@ void RaceGUIOverworld::drawGlobalMiniMap() if (old_rtt_mini_map != NULL) { - core::rect source(core::position2di(0, 0), old_rtt_mini_map->getOriginalSize()); + core::rect source(core::position2di(0, 0), old_rtt_mini_map->getSize()); draw2DImage(old_rtt_mini_map, dest, source, 0, 0, true); } else if (new_rtt_mini_map != NULL) @@ -381,7 +381,7 @@ void RaceGUIOverworld::drawGlobalMiniMap() colors[i]=kart->getKartProperties()->getColor(); } const core::rect rect(core::position2d(0,0), - m_icons_frame->getTexture()->getOriginalSize()); + m_icons_frame->getTexture()->getSize()); draw2DImage(m_icons_frame->getTexture(), position, rect, NULL, colors, true); @@ -410,7 +410,7 @@ void RaceGUIOverworld::drawGlobalMiniMap() else if (c->isSolved(RaceManager::DIFFICULTY_EASY)) state = COMPLETED_EASY; const core::rect source(core::position2d(0,0), - m_icons[state]->getOriginalSize()); + m_icons[state]->getSize()); int marker_size = m_minimap_challenge_size; core::position2di mouse = irr_driver->getMouseLocation(); From 6c57ce8507a03e15bfec3741c0de21f00e2d3999 Mon Sep 17 00:00:00 2001 From: hiker Date: Fri, 27 Mar 2015 08:05:55 +1100 Subject: [PATCH 4/4] Disable texture cache for resized textures (which are all in lower res compared what we use now that we resize _every_ big texture). --- src/tracks/track.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index 36f567a00..7df8d8191 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -963,6 +963,8 @@ bool Track::loadMainTrack(const XMLNode &root) // and configure the path to them before loading the mesh. if ( (UserConfigParams::m_high_definition_textures & 0x01) == 0x00) { +#undef USE_RESIZE_CACHE +#ifdef USE_RESIZE_CACHE std::string cached_textures_dir = irr_driver->generateSmallerTextures(m_root); @@ -972,10 +974,11 @@ bool Track::loadMainTrack(const XMLNode &root) std::string texture_default_path = scene_params->getAttributeAsString(scene::B3D_TEXTURE_PATH).c_str(); scene_params->setAttribute(scene::B3D_TEXTURE_PATH, cached_textures_dir.c_str()); - +#endif mesh = irr_driver->getMesh(full_path); - +#ifdef USE_RESIZE_CACHE scene_params->setAttribute(scene::B3D_TEXTURE_PATH, texture_default_path.c_str()); +#endif } else // Load mesh with default (hd) textures { @@ -1637,6 +1640,10 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) file_manager->pushTextureSearchPath(m_root); file_manager->pushModelSearchPath (m_root); + // For now ignore the resize cache, since atm it only handles texturs in + // the track directory. +#undef USE_RESIZE_CACHE +#ifdef USE_RESIZE_CACHE // If the hd texture option is disabled, we generate smaller textures // and we also add the cache directory to the texture search path if ( (UserConfigParams::m_high_definition_textures & 0x01) == 0x00) @@ -1645,7 +1652,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) irr_driver->generateSmallerTextures(m_root); file_manager->pushTextureSearchPath(cached_textures_dir); } - +#endif // First read the temporary materials.xml file if it exists try { @@ -1823,10 +1830,12 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id) World::getWorld()->setClearbackBufferColor(m_sky_color); } +#ifdef USE_RESIZE_CACHE if (!UserConfigParams::m_high_definition_textures) { file_manager->popTextureSearchPath(); } +#endif file_manager->popTextureSearchPath(); file_manager->popModelSearchPath ();