Convert STexture to class CTexture

This commit is contained in:
Flamefire committed 2013-05-04 15:14:02 +02:00
1 parent 017b96be5f
commit f370693dde
45 files changed
+427 -377

No files matched your search

+120
View File
@@ -0,0 +1,120 @@
using System;
using System.Drawing;
using VocaluxeLib.Menu;
namespace VocaluxeLib.Draw
{
public class CTexture
{
public int Index;
public int PBO;
public int ID;
public string TexturePath;
/// <summary>
/// Original size (e.g. of bmp)
/// </summary>
public readonly Size OrigSize;
public float OrigAspect
{
get { return (float)OrigSize.Width / OrigSize.Height; }
}
/// <summary>
/// Current size when drawn
/// </summary>
public SRectF Rect;
public SColorF Color;
private int _W2, _H2;
private float _WidthRatio, _HeightRatio;
private bool _UseFullTexture;
/// <summary>
/// Internal texture width (on device), a power of 2 if necessary
/// </summary>
public int W2
{
get { return _W2; }
set
{
_W2 = value;
if (!_UseFullTexture)
WidthRatio = (float)OrigSize.Width / _W2;
}
}
/// <summary>
/// Internal texture height (on device), a power of 2 if necessary
/// </summary>
public int H2
{
get { return _H2; }
set
{
_H2 = value;
if (!_UseFullTexture)
HeightRatio = (float)OrigSize.Height / _H2;
}
}
/// <summary>
/// Internal use. Specifies which part of texture memory is actually used
/// </summary>
public float WidthRatio
{
get { return _WidthRatio; }
private set { _WidthRatio = value; }
}
/// <summary>
/// Internal use. Specifies which part of texture memory is actually used
/// </summary>
public float HeightRatio
{
get { return _HeightRatio; }
private set { _HeightRatio = value; }
}
/// <summary>
/// Internal use. Specifies if full texture memory should be used
/// Set to true if you resized the original image to the maximum
/// </summary>
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 CTexture(int index, int origWidth = 1, int origHeight = 1)
{
Index = index;
PBO = 0;
ID = -1;
TexturePath = String.Empty;
OrigSize = new Size(origWidth, origHeight);
Rect = new SRectF(0f, 0f, origWidth, origHeight, 0f);
Color = new SColorF(1f, 1f, 1f, 1f);
_W2 = origWidth;
_H2 = origHeight;
_WidthRatio = 1;
_HeightRatio = 1;
_UseFullTexture = false;
}
}
}