From 3fe8cdf05c6ecd0baee3d3d450f54534b1778ce4 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sat, 13 Sep 2014 17:49:21 +0200 Subject: [PATCH] Workaround for OGL bug --- VocaluxeLib/Draw/CTexture.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/VocaluxeLib/Draw/CTexture.cs b/VocaluxeLib/Draw/CTexture.cs index dda82f9c..2db8df42 100644 --- a/VocaluxeLib/Draw/CTexture.cs +++ b/VocaluxeLib/Draw/CTexture.cs @@ -117,8 +117,25 @@ namespace VocaluxeLib.Draw private void _CalcRatios() { - WidthRatio = (float)_DataSize.Width / _W2; - HeightRatio = (float)_DataSize.Height / _H2; + // OpenGL has a problem with partial (NPOT) textures, so we remove 1 pixel + if (_DataSize.Width == _W2) + WidthRatio = 1f; + else + { + int mod = 0; + if (_DataSize.Width > 1) + mod = -1; + WidthRatio = (float)(_DataSize.Width + mod) / _W2; + } + if (_DataSize.Height == _H2) + WidthRatio = 1f; + else + { + int mod = 0; + if (_DataSize.Height > 1) + mod = -1; + HeightRatio = (float)(_DataSize.Height + mod) / _H2; + } } } } \ No newline at end of file