Added auto property for W/H-Ratio

This commit is contained in:
Flamefire committed 2013-05-03 22:38:19 +02:00
1 parent 5bbfd07e01
commit f8fb7bda25
3 files changed
+41 -24

No files matched your search

-5
View File
@@ -682,9 +682,6 @@ namespace Vocaluxe.Lib.Draw
texture.W2 = _CheckForNextPowerOf2(_W);
texture.H2 = _CheckForNextPowerOf2(_H);
texture.WidthRatio = (float)texture.OrigSize.Width / texture.W2;
texture.HeightRatio = (float)texture.OrigSize.Height / texture.H2;
Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
Texture tex = new Texture(_Device, _W, _H, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
Surface textureSurface = tex.GetSurfaceLevel(0);
@@ -942,8 +939,6 @@ namespace Vocaluxe.Lib.Draw
int h = texture.OrigSize.Height;
texture.W2 = _CheckForNextPowerOf2(w);
texture.H2 = _CheckForNextPowerOf2(h);
texture.WidthRatio = (float)w / texture.W2;
texture.HeightRatio = (float)h / texture.H2;
//Create a new texture in the managed pool, which does not need to be recreated on a lost device
//because a copy of the texture is hold in the Ram
+4 -9
View File
@@ -498,9 +498,6 @@ namespace Vocaluxe.Lib.Draw
texture.W2 = MathHelper.NextPowerOfTwo(texture.OrigSize.Width);
texture.H2 = MathHelper.NextPowerOfTwo(texture.OrigSize.Height);
texture.WidthRatio = (float)texture.OrigSize.Width / texture.W2;
texture.HeightRatio = (float)texture.OrigSize.Height / texture.H2;
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, _X, _Y, _W, _H);
@@ -720,7 +717,7 @@ namespace Vocaluxe.Lib.Draw
h = maxSize;
}
STexture texture = new STexture(-1, w, h);
STexture texture = new STexture(-1, bmp.Width, bmp.Height);
int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id);
@@ -738,8 +735,9 @@ namespace Vocaluxe.Lib.Draw
g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height));
g.Dispose();
texture.WidthRatio = 1f;
texture.HeightRatio = 1f;
//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);
@@ -819,9 +817,6 @@ namespace Vocaluxe.Lib.Draw
texture.W2 = MathHelper.NextPowerOfTwo(w);
texture.H2 = MathHelper.NextPowerOfTwo(h);
texture.WidthRatio = (float)w / texture.W2;
texture.HeightRatio = (float)h / texture.H2;
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data);
+37 -10
View File
@@ -122,18 +122,45 @@ namespace VocaluxeLib.Menu
/// </summary>
public SRectF Rect;
public SColorF Color;
private int _W2, _H2;
private float _WidthRatio, _HeightRatio;
/// <summary>
/// Internal texture width (on device), a power of 2 if necessary
/// </summary>
public int W2;
public int W2
{
get { return _W2; }
set
{
_W2 = value;
WidthRatio = (float)OrigSize.Width / _W2;
}
}
/// <summary>
/// Internal texture height (on device), a power of 2 if necessary
/// </summary>
public int H2;
public float WidthRatio;
public float HeightRatio;
public int H2
{
get { return _H2; }
set
{
_H2 = value;
HeightRatio = (float)OrigSize.Height / _H2;
}
}
public SColorF Color;
public float WidthRatio
{
get { return _WidthRatio; }
private set { _WidthRatio = value; }
}
public float HeightRatio
{
get { return _HeightRatio; }
private set { _HeightRatio = value; }
}
public STexture(int index, int origWidth = 1, int origHeight = 1)
{
@@ -145,12 +172,12 @@ namespace VocaluxeLib.Menu
OrigSize = new Size(origWidth, origHeight);
Rect = new SRectF(0f, 0f, origWidth, origHeight, 0f);
W2 = origWidth;
H2 = origHeight;
WidthRatio = 1;
HeightRatio = 1;
Color = new SColorF(1f, 1f, 1f, 1f);
_W2 = origWidth;
_H2 = origHeight;
_WidthRatio = 1;
_HeightRatio = 1;
}
}
#endregion Drawing