Allow to force pot textures in graphical restrictions

This commit is contained in:
Deve 2018-01-16 22:50:18 +01:00
parent c3d0db9856
commit 458ffd4617
3 changed files with 18 additions and 8 deletions

View File

@ -44,7 +44,7 @@ namespace GraphicsRestrictions
/** The list of names used in the XML file for the graphics /** The list of names used in the XML file for the graphics
* restriction types. They must be in the same order as the types. */ * restriction types. They must be in the same order as the types. */
std::array<std::string, 29> m_names_of_restrictions = std::array<std::string, 30> m_names_of_restrictions =
{ {
{ {
"UniformBufferObject", "UniformBufferObject",
@ -75,7 +75,8 @@ namespace GraphicsRestrictions
"GI", "GI",
"ForceLegacyDevice", "ForceLegacyDevice",
"VertexIdWorking", "VertexIdWorking",
"HardwareSkinning" "HardwareSkinning",
"NpotTextures"
} }
}; };
} // namespace Private } // namespace Private

View File

@ -63,6 +63,7 @@ namespace GraphicsRestrictions
GR_FORCE_LEGACY_DEVICE, GR_FORCE_LEGACY_DEVICE,
GR_VERTEX_ID_WORKING, GR_VERTEX_ID_WORKING,
GR_HARDWARE_SKINNING, GR_HARDWARE_SKINNING,
GR_NPOT_TEXTURES,
GR_COUNT /** MUST be last entry. */ GR_COUNT /** MUST be last entry. */
} ; } ;

View File

@ -18,6 +18,7 @@
#include "graphics/stk_texture.hpp" #include "graphics/stk_texture.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
#include "graphics/central_settings.hpp" #include "graphics/central_settings.hpp"
#include "graphics/graphics_restrictions.hpp"
#include "graphics/stk_tex_manager.hpp" #include "graphics/stk_tex_manager.hpp"
#include "graphics/irr_driver.hpp" #include "graphics/irr_driver.hpp"
#include "modes/profile_world.hpp" #include "modes/profile_world.hpp"
@ -235,11 +236,18 @@ video::IImage* STKTexture::resizeImage(video::IImage* orig_img,
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
if (image == NULL) if (image == NULL)
assert(orig_size && orig_size->Width > 0 && orig_size->Height > 0); assert(orig_size && orig_size->Width > 0 && orig_size->Height > 0);
video::IVideoDriver* driver = irr_driver->getVideoDriver();
core::dimension2du img_size = image ? image->getDimension() : *orig_size; core::dimension2du img_size = image ? image->getDimension() : *orig_size;
core::dimension2du tex_size = img_size.getOptimalSize
(!irr_driver->getVideoDriver()->queryFeature(video::EVDF_TEXTURE_NPOT)); bool has_npot = !GraphicsRestrictions::isDisabled(
const core::dimension2du& max_size = irr_driver->getVideoDriver() GraphicsRestrictions::GR_NPOT_TEXTURES) &&
->getDriverAttributes().getAttributeAsDimension2d("MAX_TEXTURE_SIZE"); driver->queryFeature(video::EVDF_TEXTURE_NPOT);
core::dimension2du tex_size = img_size.getOptimalSize(!has_npot);
const core::dimension2du& max_size = driver->getDriverAttributes().
getAttributeAsDimension2d("MAX_TEXTURE_SIZE");
if (tex_size.Width > max_size.Width) if (tex_size.Width > max_size.Width)
tex_size.Width = max_size.Width; tex_size.Width = max_size.Width;
@ -257,8 +265,8 @@ video::IImage* STKTexture::resizeImage(video::IImage* orig_img,
if (image->getColorFormat() != video::ECF_A8R8G8B8 || if (image->getColorFormat() != video::ECF_A8R8G8B8 ||
tex_size != img_size) tex_size != img_size)
{ {
video::IImage* new_texture = irr_driver video::IImage* new_texture = driver->createImage(video::ECF_A8R8G8B8,
->getVideoDriver()->createImage(video::ECF_A8R8G8B8, tex_size); tex_size);
if (tex_size != img_size) if (tex_size != img_size)
image->copyToScaling(new_texture); image->copyToScaling(new_texture);
else else