From 26d2bf847cdfb6100848b7aec7cb55d6933bec6b Mon Sep 17 00:00:00 2001 From: Deve Date: Sat, 13 Aug 2016 00:01:08 +0200 Subject: [PATCH] Allow to use non-hd textures in OpenGL ES renderer --- lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp | 14 +++++++------- lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp index e49c275f5..e9b8e7efa 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp +++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp @@ -1314,7 +1314,7 @@ namespace video // texcoords need to be flipped horizontally for RTTs const bool isRTT = texture->isRenderTarget(); - const core::dimension2d& ss = texture->getOriginalSize(); + const core::dimension2d& ss = texture->getSize(); const f32 invW = 1.f / static_cast(ss.Width); const f32 invH = 1.f / static_cast(ss.Height); const core::rect tcoords( @@ -1443,10 +1443,10 @@ namespace video // now draw it. core::rect tcoords; - tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)) / texture->getOriginalSize().Width ; - tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)) / texture->getOriginalSize().Height; - tcoords.LowerRightCorner.X = tcoords.UpperLeftCorner.X + ((f32)(sourceSize.Width) / texture->getOriginalSize().Width); - tcoords.LowerRightCorner.Y = tcoords.UpperLeftCorner.Y + ((f32)(sourceSize.Height) / texture->getOriginalSize().Height); + tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)) / texture->getSize().Width ; + tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)) / texture->getSize().Height; + tcoords.LowerRightCorner.X = tcoords.UpperLeftCorner.X + ((f32)(sourceSize.Width) / texture->getSize().Width); + tcoords.LowerRightCorner.Y = tcoords.UpperLeftCorner.Y + ((f32)(sourceSize.Height) / texture->getSize().Height); const core::rect poss(targetPos, sourceSize); @@ -1496,7 +1496,7 @@ namespace video // texcoords need to be flipped horizontally for RTTs const bool isRTT = texture->isRenderTarget(); - const core::dimension2du& ss = texture->getOriginalSize(); + const core::dimension2du& ss = texture->getSize(); const f32 invW = 1.f / static_cast(ss.Width); const f32 invH = 1.f / static_cast(ss.Height); const core::rect tcoords( @@ -1573,7 +1573,7 @@ namespace video clipRect->getWidth(), clipRect->getHeight()); } - const core::dimension2du& ss = texture->getOriginalSize(); + const core::dimension2du& ss = texture->getSize(); core::position2d targetPos(pos); // texcoords need to be flipped horizontally for RTTs const bool isRTT = texture->isRenderTarget(); diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp index ce09c1ec5..4396d6e09 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp +++ b/lib/irrlicht/source/Irrlicht/COGLES2Texture.cpp @@ -15,6 +15,8 @@ #include "os.h" #include "CImage.h" #include "CColorConverter.h" +#include "IAttributes.h" +#include "IrrlichtDevice.h" #include "irrString.h" @@ -171,6 +173,17 @@ void COGLES2Texture::getImageValues(IImage* image) ImageSize.Width = (u32)(Driver->MaxTextureSize*ratio); } TextureSize=ImageSize.getOptimalSize(false); + 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()); }