diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index a30aa642..ae62cecb 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -717,7 +717,7 @@ namespace Vocaluxe.Lib.Draw h = maxSize; } - STexture texture = new STexture(-1, bmp.Width, bmp.Height); + STexture texture = new STexture(-1, bmp.Width, bmp.Height){UseFullTexture = true}; int id = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, id); @@ -735,10 +735,6 @@ namespace Vocaluxe.Lib.Draw g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height)); g.Dispose(); - //TODO: Check this! - //texture.WidthRatio = 1f; - //texture.HeightRatio = 1f; - BitmapData bmpData = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); diff --git a/VocaluxeLib/Menu/Structs.cs b/VocaluxeLib/Menu/Structs.cs index 9a7827cf..fef94d82 100644 --- a/VocaluxeLib/Menu/Structs.cs +++ b/VocaluxeLib/Menu/Structs.cs @@ -126,6 +126,7 @@ namespace VocaluxeLib.Menu private int _W2, _H2; private float _WidthRatio, _HeightRatio; + private bool _UseFullTexture; /// /// Internal texture width (on device), a power of 2 if necessary /// @@ -135,7 +136,8 @@ namespace VocaluxeLib.Menu set { _W2 = value; - WidthRatio = (float)OrigSize.Width / _W2; + if (!_UseFullTexture) + WidthRatio = (float)OrigSize.Width / _W2; } } /// @@ -147,21 +149,51 @@ namespace VocaluxeLib.Menu set { _H2 = value; - HeightRatio = (float)OrigSize.Height / _H2; + if (!_UseFullTexture) + HeightRatio = (float)OrigSize.Height / _H2; } } + /// + /// Internal use. Specifies which part of texture memory is actually used + /// public float WidthRatio { get { return _WidthRatio; } private set { _WidthRatio = value; } } + /// + /// Internal use. Specifies which part of texture memory is actually used + /// public float HeightRatio { get { return _HeightRatio; } private set { _HeightRatio = value; } } + /// + /// Internal use. Specifies if full texture memory should be used + /// Set to true if you resized the original image to the maximum + /// + public bool UseFullTexture + { + get { return _UseFullTexture; } + set + { + _UseFullTexture = value; + if (value) + { + WidthRatio = 1; + HeightRatio = 1; + } + else + { + WidthRatio = (float)OrigSize.Width / _W2; + HeightRatio = (float)OrigSize.Height / _H2; + } + } + } + public STexture(int index, int origWidth = 1, int origHeight = 1) { Index = index; @@ -178,6 +210,7 @@ namespace VocaluxeLib.Menu _H2 = origHeight; _WidthRatio = 1; _HeightRatio = 1; + _UseFullTexture = false; } } #endregion Drawing