Using null instead of CTexture(-1) for "no texture"
This commit is contained in:
1 parent
f370693dde
commit
142a690cc6
27 files changed
+430
-588
No files matched your search
@@ -40,7 +40,7 @@ namespace Vocaluxe.Base
|
||||
private static readonly List<CPlaylistElement> _PreviousFileNames = new List<CPlaylistElement>();
|
||||
|
||||
private static int _Video = -1;
|
||||
private static CTexture _CurrentVideoTexture = new CTexture(-1);
|
||||
private static CTexture _CurrentVideoTexture;
|
||||
private static readonly Stopwatch _FadeTimer = new Stopwatch();
|
||||
private static bool _VideoEnabled;
|
||||
|
||||
@@ -473,7 +473,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
return _CurrentVideoTexture;
|
||||
}
|
||||
return new CTexture(-1);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool _IsBackgroundFile(CPlaylistElement element)
|
||||
|
||||
+16
-28
@@ -31,7 +31,6 @@ namespace Vocaluxe.Base
|
||||
struct SCover
|
||||
{
|
||||
public string Name;
|
||||
public string Value;
|
||||
public CTexture Texture;
|
||||
}
|
||||
|
||||
@@ -47,14 +46,10 @@ namespace Vocaluxe.Base
|
||||
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
|
||||
private static readonly List<SCover> _Cover = new List<SCover>();
|
||||
private static readonly List<SCoverTheme> _CoverThemes = new List<SCoverTheme>();
|
||||
private static CTexture _NoCover = new CTexture(-1);
|
||||
|
||||
private static readonly Object _MutexCover = new Object();
|
||||
|
||||
public static CTexture NoCover
|
||||
{
|
||||
get { return _NoCover; }
|
||||
}
|
||||
public static CTexture NoCover { get; private set; }
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
@@ -100,19 +95,15 @@ namespace Vocaluxe.Base
|
||||
/// </summary>
|
||||
public static CTexture Cover(string name)
|
||||
{
|
||||
CTexture cov = _NoCover;
|
||||
lock (_MutexCover)
|
||||
{
|
||||
foreach (SCover cover in _Cover)
|
||||
{
|
||||
if (cover.Name == name)
|
||||
{
|
||||
cov = cover.Texture;
|
||||
break;
|
||||
}
|
||||
return cover.Texture;
|
||||
}
|
||||
}
|
||||
return cov;
|
||||
return NoCover;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -207,31 +198,30 @@ namespace Vocaluxe.Base
|
||||
List<string> cover = xmlReader.GetValues("Cover");
|
||||
foreach (string coverName in cover)
|
||||
{
|
||||
SCover sk = new SCover();
|
||||
string name;
|
||||
string value;
|
||||
string filePath;
|
||||
xmlReader.GetValue("//root/Cover/" + coverName + "/Name", out name, String.Empty);
|
||||
xmlReader.GetValue("//root/Cover/" + coverName + "/Path", out value, String.Empty);
|
||||
sk.Name = name;
|
||||
sk.Value = Path.Combine(coverTheme.Folder, value);
|
||||
sk.Texture = File.Exists(Path.Combine(CSettings.FolderCover, sk.Value))
|
||||
? CDraw.AddTexture(Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, value))) : _NoCover;
|
||||
xmlReader.GetValue("//root/Cover/" + coverName + "/Path", out filePath, String.Empty);
|
||||
string coverFilePath = Path.Combine(CSettings.FolderCover, Path.Combine(coverTheme.Folder, filePath));
|
||||
if (!File.Exists(coverFilePath))
|
||||
continue;
|
||||
SCover sk = new SCover {Name = name, Texture = CDraw.AddTexture(coverFilePath)};
|
||||
|
||||
_Cover.Add(sk);
|
||||
|
||||
if (sk.Name == "NoCover")
|
||||
_NoCover = sk.Texture;
|
||||
NoCover = sk.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<string> files = new List<string>();
|
||||
|
||||
string path = Path.Combine(CSettings.FolderCover, coverTheme.Folder);
|
||||
files.AddRange(CHelper.ListFiles(path, "*.png", true, true));
|
||||
files.AddRange(CHelper.ListFiles(path, "*.jpg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(path, "*.jpeg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(path, "*.bmp", true, true));
|
||||
string coverPath = Path.Combine(CSettings.FolderCover, coverTheme.Folder);
|
||||
files.AddRange(CHelper.ListFiles(coverPath, "*.png", true, true));
|
||||
files.AddRange(CHelper.ListFiles(coverPath, "*.jpg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(coverPath, "*.jpeg", true, true));
|
||||
files.AddRange(CHelper.ListFiles(coverPath, "*.bmp", true, true));
|
||||
|
||||
|
||||
foreach (string file in files)
|
||||
@@ -241,11 +231,9 @@ namespace Vocaluxe.Base
|
||||
if (_CoverExists(name))
|
||||
continue;
|
||||
// ReSharper disable AssignNullToNotNullAttribute
|
||||
SCover sk = new SCover {Name = name, Value = Path.Combine(coverTheme.Folder, Path.GetFileName(file))};
|
||||
SCover sk = new SCover {Name = name, Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, Path.GetFileName(file)))};
|
||||
// ReSharper restore AssignNullToNotNullAttribute
|
||||
|
||||
sk.Texture = CDraw.AddTexture(Path.Combine(CSettings.FolderCover, sk.Value));
|
||||
|
||||
_Cover.Add(sk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,9 +160,9 @@ namespace Vocaluxe.Base
|
||||
return _Draw.EnqueueTexture(w, h, data);
|
||||
}
|
||||
|
||||
public static bool UpdateTexture(ref CTexture texture, byte[] data)
|
||||
public static bool UpdateTexture(CTexture texture, byte[] data)
|
||||
{
|
||||
return _Draw.UpdateTexture(ref texture, data);
|
||||
return _Draw.UpdateTexture(texture, data);
|
||||
}
|
||||
|
||||
public static void RemoveTexture(ref CTexture texture)
|
||||
@@ -197,7 +197,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void DrawTexture(CStatic staticBounds, CTexture texture, EAspect aspect)
|
||||
{
|
||||
if (texture.OrigSize.Height <= 0)
|
||||
if (texture == null)
|
||||
return;
|
||||
|
||||
RectangleF bounds = new RectangleF(staticBounds.Rect.X, staticBounds.Rect.Y, staticBounds.Rect.W, staticBounds.Rect.H);
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace Vocaluxe.Base
|
||||
sk.VideoIndex = CVideo.Load(Path.Combine(_Skins[skinIndex].Path, sk.Value));
|
||||
CVideo.SetLoop(sk.VideoIndex, true);
|
||||
CVideo.Pause(sk.VideoIndex);
|
||||
sk.Texture = new CTexture(-1);
|
||||
sk.Texture = null;
|
||||
_Skins[skinIndex].VideoList[i] = sk;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -585,7 +585,7 @@ namespace Vocaluxe.Base
|
||||
int skinIndex = GetSkinIndex(partyModeID);
|
||||
if (skinIndex != -1 && textureName != null && _Skins[skinIndex].SkinList.ContainsKey(textureName))
|
||||
return _Skins[skinIndex].SkinList[textureName].Texture;
|
||||
return new CTexture(-1);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetSkinFilePath(string skinName, int partyModeID)
|
||||
@@ -627,7 +627,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
}
|
||||
return new CTexture(-1);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void SkinVideoPause(string videoName, int partyModeID)
|
||||
|
||||
+3
-18
@@ -119,7 +119,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
private CTexture _VideoTexture;
|
||||
private int _VideoStream;
|
||||
private readonly Stopwatch _VideoTimer;
|
||||
private readonly Stopwatch _VideoTimer = new Stopwatch();
|
||||
private bool _Finished;
|
||||
private bool _Loaded;
|
||||
|
||||
@@ -133,14 +133,6 @@ namespace Vocaluxe.Base
|
||||
set { CVideo.SetLoop(_VideoStream, value); }
|
||||
}
|
||||
|
||||
public CVideoPlayer()
|
||||
{
|
||||
_VideoTimer = new Stopwatch();
|
||||
_VideoTexture = new CTexture(-1);
|
||||
_Finished = false;
|
||||
_Loaded = false;
|
||||
}
|
||||
|
||||
public void Load(string videoName)
|
||||
{
|
||||
_VideoStream = CVideo.Load(CTheme.GetVideoFilePath(videoName, -1));
|
||||
@@ -172,14 +164,7 @@ namespace Vocaluxe.Base
|
||||
float videoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
|
||||
_Finished = CVideo.Finished(_VideoStream);
|
||||
|
||||
CTexture tex = new CTexture(-1);
|
||||
CVideo.GetFrame(_VideoStream, ref tex, videoTime, out videoTime);
|
||||
|
||||
if (tex.Index > 0)
|
||||
{
|
||||
CDraw.RemoveTexture(ref _VideoTexture);
|
||||
_VideoTexture = tex;
|
||||
}
|
||||
CVideo.GetFrame(_VideoStream, ref _VideoTexture, videoTime, out videoTime);
|
||||
}
|
||||
RectangleF bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH);
|
||||
RectangleF rect;
|
||||
@@ -191,7 +176,7 @@ namespace Vocaluxe.Base
|
||||
public void PreLoad()
|
||||
{
|
||||
float videoTime = 0f;
|
||||
while (_VideoTexture.Index == -1 && videoTime < 1f)
|
||||
while (_VideoTexture == null && videoTime < 1f)
|
||||
{
|
||||
float dummy;
|
||||
CVideo.GetFrame(_VideoStream, ref _VideoTexture, 0, out dummy);
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static bool GetFrame(ref CTexture tex)
|
||||
{
|
||||
_Webcam.GetFrame(ref tex);
|
||||
return true;
|
||||
return _Webcam.GetFrame(ref tex);
|
||||
}
|
||||
|
||||
public static Bitmap GetBitmap()
|
||||
|
||||
+173
-183
@@ -679,9 +679,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// </summary>
|
||||
public CTexture CopyScreen()
|
||||
{
|
||||
CTexture texture = new CTexture(-1, _W, _H);
|
||||
texture.W2 = _CheckForNextPowerOf2(_W);
|
||||
texture.H2 = _CheckForNextPowerOf2(_H);
|
||||
CTexture texture = new CTexture(-1, _W, _H) {W2 = _CheckForNextPowerOf2(_W), H2 = _CheckForNextPowerOf2(_H)};
|
||||
|
||||
Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
|
||||
Texture tex = new Texture(_Device, _W, _H, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
|
||||
@@ -705,7 +703,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
public void CopyScreen(ref CTexture texture)
|
||||
{
|
||||
//Check for actual texture sizes! (W2/H2) as it may be up/downsized compared to OrigSize
|
||||
if (!_TextureExists(ref texture) || texture.W2 != GetScreenWidth() || texture.H2 != GetScreenHeight())
|
||||
if (!_TextureExists(texture) || texture.W2 != GetScreenWidth() || texture.H2 != GetScreenHeight())
|
||||
{
|
||||
RemoveTexture(ref texture);
|
||||
texture = CopyScreen();
|
||||
@@ -798,31 +796,31 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <returns>A STexture object containing the added texture</returns>
|
||||
public CTexture AddTexture(string texturePath)
|
||||
{
|
||||
if (File.Exists(texturePath))
|
||||
if (!File.Exists(texturePath))
|
||||
{
|
||||
Bitmap bmp;
|
||||
try
|
||||
{
|
||||
bmp = new Bitmap(texturePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error loading Texture: " + texturePath);
|
||||
return new CTexture(-1);
|
||||
}
|
||||
CTexture s;
|
||||
try
|
||||
{
|
||||
s = AddTexture(bmp);
|
||||
}
|
||||
finally
|
||||
{
|
||||
bmp.Dispose();
|
||||
}
|
||||
return s;
|
||||
CLog.LogError("Can't find File: " + texturePath);
|
||||
return null;
|
||||
}
|
||||
CLog.LogError("Can't find File: " + texturePath);
|
||||
return new CTexture(-1);
|
||||
Bitmap bmp;
|
||||
try
|
||||
{
|
||||
bmp = new Bitmap(texturePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error loading Texture: " + texturePath);
|
||||
return null;
|
||||
}
|
||||
CTexture s;
|
||||
try
|
||||
{
|
||||
s = AddTexture(bmp);
|
||||
}
|
||||
finally
|
||||
{
|
||||
bmp.Dispose();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -833,7 +831,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
public CTexture AddTexture(Bitmap bmp)
|
||||
{
|
||||
if (bmp.Height == 0 || bmp.Width == 0)
|
||||
return new CTexture(-1);
|
||||
return null;
|
||||
int maxSize;
|
||||
//Apply the right max size
|
||||
switch (CConfig.TextureQuality)
|
||||
@@ -909,7 +907,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
private CTexture _AddTexture(CTexture texture, int w, byte[] data)
|
||||
{
|
||||
Texture t = _CreateTexture(ref texture, w, data);
|
||||
Texture t = _CreateTexture(texture, w, data);
|
||||
|
||||
lock (_MutexTexture)
|
||||
{
|
||||
@@ -920,7 +918,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
return texture;
|
||||
}
|
||||
|
||||
private Texture _CreateTexture(ref CTexture texture, int w, byte[] data)
|
||||
private Texture _CreateTexture(CTexture texture, int w, byte[] data)
|
||||
{
|
||||
//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
|
||||
@@ -959,7 +957,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
_D3DTextures.Add(_IDs.Peek(), null);
|
||||
texture.Index = _IDs.Dequeue();
|
||||
queue.ID = texture.Index;
|
||||
queue.Index = texture.Index;
|
||||
_Queue.Add(queue);
|
||||
_Textures[texture.Index] = texture;
|
||||
}
|
||||
@@ -974,26 +972,24 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="texture">The texture to update</param>
|
||||
/// <param name="data">A byte array containing the new texture's data</param>
|
||||
/// <returns>True if succeeded</returns>
|
||||
public bool UpdateTexture(ref CTexture texture, byte[] data)
|
||||
public bool UpdateTexture(CTexture texture, byte[] data)
|
||||
{
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && _TextureExists(ref texture))
|
||||
if (!_TextureExists(texture))
|
||||
return false;
|
||||
lock (_MutexTexture)
|
||||
{
|
||||
lock (_MutexTexture)
|
||||
DataRectangle rect = _D3DTextures[texture.Index].LockRectangle(0, LockFlags.Discard);
|
||||
int w = texture.OrigSize.Width;
|
||||
int rowWidth = 4 * texture.W2;
|
||||
for (int i = 0; i + rowWidth <= data.Length; i += 4 * w)
|
||||
{
|
||||
DataRectangle rect = _D3DTextures[texture.Index].LockRectangle(0, LockFlags.Discard);
|
||||
int w = texture.OrigSize.Width;
|
||||
int rowWidth = 4 * texture.W2;
|
||||
for (int i = 0; i + rowWidth <= data.Length; i += 4 * w)
|
||||
{
|
||||
rect.Data.Write(data, i, 4 * w);
|
||||
rect.Data.Position = rect.Data.Position - rowWidth;
|
||||
rect.Data.Position += rect.Pitch;
|
||||
}
|
||||
_D3DTextures[texture.Index].UnlockRectangle(0);
|
||||
rect.Data.Write(data, i, 4 * w);
|
||||
rect.Data.Position = rect.Data.Position - rowWidth;
|
||||
rect.Data.Position += rect.Pitch;
|
||||
}
|
||||
return true;
|
||||
_D3DTextures[texture.Index].UnlockRectangle(0);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#endregion updating
|
||||
|
||||
@@ -1002,17 +998,14 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// </summary>
|
||||
/// <param name="texture">The texture to check</param>
|
||||
/// <returns>True if the texture exists</returns>
|
||||
private bool _TextureExists(ref CTexture texture)
|
||||
private bool _TextureExists(CTexture texture)
|
||||
{
|
||||
lock (_MutexTexture)
|
||||
{
|
||||
if (_Textures.ContainsKey(texture.Index))
|
||||
if (texture != null && _Textures.ContainsKey(texture.Index))
|
||||
{
|
||||
if (_Textures[texture.Index].Index >= 0)
|
||||
{
|
||||
texture = _Textures[texture.Index];
|
||||
if (_Textures[texture.Index].ID > 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -1024,18 +1017,17 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="texture">The texture to be removed</param>
|
||||
public void RemoveTexture(ref CTexture texture)
|
||||
{
|
||||
lock (_MutexTexture)
|
||||
if (texture != null && texture.Index >= 0)
|
||||
{
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0))
|
||||
lock (_MutexTexture)
|
||||
{
|
||||
_D3DTextures[texture.Index].Dispose();
|
||||
_D3DTextures.Remove(texture.Index);
|
||||
_Textures.Remove(texture.Index);
|
||||
_IDs.Enqueue(texture.Index);
|
||||
texture.Index = -1;
|
||||
texture.ID = -1;
|
||||
}
|
||||
}
|
||||
texture = null;
|
||||
}
|
||||
|
||||
#region drawing
|
||||
@@ -1045,6 +1037,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="texture">The texture to be drawn</param>
|
||||
public void DrawTexture(CTexture texture)
|
||||
{
|
||||
if (texture == null)
|
||||
return;
|
||||
DrawTexture(texture, texture.Rect, texture.Color);
|
||||
}
|
||||
|
||||
@@ -1055,6 +1049,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||
public void DrawTexture(CTexture texture, SRectF rect)
|
||||
{
|
||||
if (texture == null)
|
||||
return;
|
||||
DrawTexture(texture, rect, texture.Color);
|
||||
}
|
||||
|
||||
@@ -1080,84 +1076,83 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="mirrored">True if the texture should be mirrored</param>
|
||||
public void DrawTexture(CTexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored = false)
|
||||
{
|
||||
if (_TextureExists(ref texture))
|
||||
if (!_TextureExists(texture))
|
||||
return;
|
||||
if (_D3DTextures[texture.Index] == null)
|
||||
return;
|
||||
|
||||
//Calculate the position
|
||||
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
|
||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
|
||||
float y1 = (bounds.Y - rect.Y) / rect.H * texture.HeightRatio;
|
||||
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
|
||||
|
||||
if (x1 < 0)
|
||||
x1 = 0f;
|
||||
|
||||
if (x2 > texture.WidthRatio)
|
||||
x2 = texture.WidthRatio;
|
||||
|
||||
if (y1 < 0)
|
||||
y1 = 0f;
|
||||
|
||||
if (y2 > texture.HeightRatio)
|
||||
y2 = texture.HeightRatio;
|
||||
|
||||
//Calculate the size
|
||||
float rx1 = rect.X;
|
||||
float rx2 = rect.X + rect.W;
|
||||
float ry1 = rect.Y;
|
||||
float ry2 = rect.Y + rect.H;
|
||||
|
||||
if (rx1 < bounds.X)
|
||||
rx1 = bounds.X;
|
||||
|
||||
if (rx2 > bounds.X + bounds.W)
|
||||
rx2 = bounds.X + bounds.W;
|
||||
|
||||
if (ry1 < bounds.Y)
|
||||
ry1 = bounds.Y;
|
||||
|
||||
if (ry2 > bounds.Y + bounds.H)
|
||||
ry2 = bounds.Y + bounds.H;
|
||||
|
||||
//Align the pixels because Direct3D expects the pixels to be the left top corner
|
||||
rx1 -= 0.5f;
|
||||
ry1 -= 0.5f;
|
||||
rx2 -= 0.5f;
|
||||
ry2 -= 0.5f;
|
||||
|
||||
color.A *= CGraphics.GlobalAlpha;
|
||||
|
||||
if (color.A > 1)
|
||||
color.A = 1;
|
||||
if (color.R > 1)
|
||||
color.R = 1;
|
||||
if (color.G > 1)
|
||||
color.G = 1;
|
||||
if (color.B > 1)
|
||||
color.B = 1;
|
||||
|
||||
Color c = color.AsColor();
|
||||
|
||||
if (!mirrored)
|
||||
{
|
||||
if (_D3DTextures[texture.Index] == null)
|
||||
return;
|
||||
|
||||
//Calculate the position
|
||||
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
|
||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
|
||||
float y1 = (bounds.Y - rect.Y) / rect.H * texture.HeightRatio;
|
||||
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
|
||||
|
||||
if (x1 < 0)
|
||||
x1 = 0f;
|
||||
|
||||
if (x2 > texture.WidthRatio)
|
||||
x2 = texture.WidthRatio;
|
||||
|
||||
if (y1 < 0)
|
||||
y1 = 0f;
|
||||
|
||||
if (y2 > texture.HeightRatio)
|
||||
y2 = texture.HeightRatio;
|
||||
|
||||
//Calculate the size
|
||||
float rx1 = rect.X;
|
||||
float rx2 = rect.X + rect.W;
|
||||
float ry1 = rect.Y;
|
||||
float ry2 = rect.Y + rect.H;
|
||||
|
||||
if (rx1 < bounds.X)
|
||||
rx1 = bounds.X;
|
||||
|
||||
if (rx2 > bounds.X + bounds.W)
|
||||
rx2 = bounds.X + bounds.W;
|
||||
|
||||
if (ry1 < bounds.Y)
|
||||
ry1 = bounds.Y;
|
||||
|
||||
if (ry2 > bounds.Y + bounds.H)
|
||||
ry2 = bounds.Y + bounds.H;
|
||||
|
||||
//Align the pixels because Direct3D expects the pixels to be the left top corner
|
||||
rx1 -= 0.5f;
|
||||
ry1 -= 0.5f;
|
||||
rx2 -= 0.5f;
|
||||
ry2 -= 0.5f;
|
||||
|
||||
color.A *= CGraphics.GlobalAlpha;
|
||||
|
||||
if (color.A > 1)
|
||||
color.A = 1;
|
||||
if (color.R > 1)
|
||||
color.R = 1;
|
||||
if (color.G > 1)
|
||||
color.G = 1;
|
||||
if (color.B > 1)
|
||||
color.B = 1;
|
||||
|
||||
Color c = color.AsColor();
|
||||
|
||||
if (!mirrored)
|
||||
{
|
||||
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
|
||||
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb());
|
||||
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
|
||||
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
|
||||
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb());
|
||||
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
else
|
||||
{
|
||||
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
|
||||
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y1), c.ToArgb());
|
||||
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y2), c.ToArgb());
|
||||
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y2), c.ToArgb());
|
||||
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y1), c.ToArgb());
|
||||
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
|
||||
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb());
|
||||
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
|
||||
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
|
||||
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb());
|
||||
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
else
|
||||
{
|
||||
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
|
||||
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y1), c.ToArgb());
|
||||
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y2), c.ToArgb());
|
||||
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y2), c.ToArgb());
|
||||
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y1), c.ToArgb());
|
||||
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1171,7 +1166,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="end">A Value ranging from 0 to 1 containing the ending of the texture</param>
|
||||
public void DrawTexture(CTexture texture, SRectF rect, SColorF color, float begin, float end)
|
||||
{
|
||||
if (!_TextureExists(ref texture))
|
||||
if (!_TextureExists(texture))
|
||||
return;
|
||||
if (_D3DTextures[texture.Index] == null)
|
||||
return;
|
||||
@@ -1215,7 +1210,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="height">The height of the reflection</param>
|
||||
public void DrawTextureReflection(CTexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
||||
{
|
||||
if (!_TextureExists(ref texture))
|
||||
if (!_TextureExists(texture))
|
||||
return;
|
||||
if (_D3DTextures[texture.Index] == null)
|
||||
return;
|
||||
@@ -1233,61 +1228,58 @@ namespace Vocaluxe.Lib.Draw
|
||||
if (height > bounds.H)
|
||||
height = bounds.H;
|
||||
|
||||
if (_TextureExists(ref texture))
|
||||
{
|
||||
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
|
||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
|
||||
float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
|
||||
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
|
||||
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
|
||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
|
||||
float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
|
||||
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
|
||||
|
||||
if (x1 < 0)
|
||||
x1 = 0f;
|
||||
if (x1 < 0)
|
||||
x1 = 0f;
|
||||
|
||||
if (x2 > texture.WidthRatio)
|
||||
x2 = texture.WidthRatio;
|
||||
if (x2 > texture.WidthRatio)
|
||||
x2 = texture.WidthRatio;
|
||||
|
||||
if (y1 < 0)
|
||||
y1 = 0f;
|
||||
if (y1 < 0)
|
||||
y1 = 0f;
|
||||
|
||||
if (y2 > texture.HeightRatio)
|
||||
y2 = texture.HeightRatio;
|
||||
if (y2 > texture.HeightRatio)
|
||||
y2 = texture.HeightRatio;
|
||||
|
||||
|
||||
float rx1 = rect.X;
|
||||
float rx2 = rect.X + rect.W;
|
||||
float ry1 = rect.Y + rect.H + space;
|
||||
float ry2 = rect.Y + rect.H + space + height;
|
||||
float rx1 = rect.X;
|
||||
float rx2 = rect.X + rect.W;
|
||||
float ry1 = rect.Y + rect.H + space;
|
||||
float ry2 = rect.Y + rect.H + space + height;
|
||||
|
||||
if (rx1 < bounds.X)
|
||||
rx1 = bounds.X;
|
||||
if (rx1 < bounds.X)
|
||||
rx1 = bounds.X;
|
||||
|
||||
if (rx2 > bounds.X + bounds.W)
|
||||
rx2 = bounds.X + bounds.W;
|
||||
if (rx2 > bounds.X + bounds.W)
|
||||
rx2 = bounds.X + bounds.W;
|
||||
|
||||
if (ry1 < bounds.Y + space)
|
||||
ry1 = bounds.Y + space;
|
||||
if (ry1 < bounds.Y + space)
|
||||
ry1 = bounds.Y + space;
|
||||
|
||||
if (ry2 > bounds.Y + bounds.H + space + height)
|
||||
ry2 = bounds.Y + bounds.H + space + height;
|
||||
if (ry2 > bounds.Y + bounds.H + space + height)
|
||||
ry2 = bounds.Y + bounds.H + space + height;
|
||||
|
||||
//Align the pixels because Direct3D expects the pixels to be the left top corner
|
||||
rx1 -= 0.5f;
|
||||
ry1 -= 0.5f;
|
||||
rx2 -= 0.5f;
|
||||
ry2 -= 0.5f;
|
||||
//Align the pixels because Direct3D expects the pixels to be the left top corner
|
||||
rx1 -= 0.5f;
|
||||
ry1 -= 0.5f;
|
||||
rx2 -= 0.5f;
|
||||
ry2 -= 0.5f;
|
||||
|
||||
color.A *= CGraphics.GlobalAlpha;
|
||||
Color c = color.AsColor();
|
||||
color.A = 0;
|
||||
Color transparent = color.AsColor();
|
||||
color.A *= CGraphics.GlobalAlpha;
|
||||
Color c = color.AsColor();
|
||||
color.A = 0;
|
||||
Color transparent = color.AsColor();
|
||||
|
||||
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
|
||||
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
|
||||
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb());
|
||||
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb());
|
||||
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
|
||||
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
STexturedColoredVertex[] vert = new STexturedColoredVertex[4];
|
||||
vert[0] = new STexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
|
||||
vert[1] = new STexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb());
|
||||
vert[2] = new STexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb());
|
||||
vert[3] = new STexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
|
||||
_AddToVertexBuffer(vert, _D3DTextures[texture.Index], _CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
#endregion drawing
|
||||
|
||||
@@ -1299,17 +1291,15 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
STextureQueue q = _Queue[0];
|
||||
_Queue.RemoveAt(0);
|
||||
if (!_Textures.ContainsKey(q.ID))
|
||||
CTexture texture;
|
||||
if (!_Textures.TryGetValue(q.Index, out texture))
|
||||
continue;
|
||||
CTexture texture = _Textures[q.ID];
|
||||
if (q.Width == texture.OrigSize.Width && q.Height == texture.OrigSize.Height)
|
||||
{
|
||||
texture.W2 = _CheckForNextPowerOf2(texture.OrigSize.Width);
|
||||
texture.H2 = _CheckForNextPowerOf2(texture.OrigSize.Height);
|
||||
Texture t = _CreateTexture(ref texture, q.Width, q.Data);
|
||||
_D3DTextures[q.ID] = t;
|
||||
|
||||
_Textures[texture.Index] = texture;
|
||||
Texture t = _CreateTexture(texture, q.Width, q.Data);
|
||||
_D3DTextures[q.Index] = t;
|
||||
}
|
||||
else
|
||||
CLog.LogError("Wrong texture size in queue!");
|
||||
|
||||
@@ -350,33 +350,26 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public CTexture AddTexture(string texturePath)
|
||||
{
|
||||
CTexture texture = new CTexture();
|
||||
if (File.Exists(texturePath))
|
||||
{
|
||||
bool found = false;
|
||||
foreach (CTexture tex in _Textures)
|
||||
{
|
||||
if (tex.TexturePath == texturePath)
|
||||
{
|
||||
texture = tex;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
return tex;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
using (Bitmap bmp = new Bitmap(texturePath))
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap(texturePath))
|
||||
return AddTexture(bmp);
|
||||
CTexture texture = AddTexture(bmp);
|
||||
texture.TexturePath = texturePath;
|
||||
}
|
||||
}
|
||||
|
||||
return texture;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void RemoveTexture(ref CTexture texture)
|
||||
{
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0))
|
||||
if (texture != null && texture.Index >= 0)
|
||||
{
|
||||
for (int i = 0; i < _Textures.Count; i++)
|
||||
{
|
||||
@@ -384,11 +377,11 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
_Bitmaps[texture.Index].Dispose();
|
||||
_Textures.RemoveAt(i);
|
||||
texture.Index = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
texture = null;
|
||||
}
|
||||
|
||||
public CTexture EnqueueTexture(int w, int h, byte[] data)
|
||||
@@ -407,7 +400,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateTexture(ref CTexture texture, byte[] data)
|
||||
public bool UpdateTexture(CTexture texture, byte[] data)
|
||||
{
|
||||
if ((texture.Index >= 0) && (_Textures.Count > 0) && (_Bitmaps.Count > texture.Index))
|
||||
{
|
||||
@@ -415,8 +408,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
|
||||
_Bitmaps[texture.Index].UnlockBits(bmpData);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DrawTexture(CTexture texture)
|
||||
|
||||
+160
-170
@@ -65,7 +65,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
struct STextureQueue
|
||||
{
|
||||
public int ID;
|
||||
public int Index;
|
||||
public int Width;
|
||||
public int Height;
|
||||
public byte[] Data;
|
||||
@@ -522,7 +522,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
public void CopyScreen(ref CTexture texture)
|
||||
{
|
||||
//Check for actual texture sizes! (W2/H2) as it may be up/downsized compared to OrigSize
|
||||
if (!_TextureExists(ref texture) || texture.W2 != GetScreenWidth() || texture.H2 != GetScreenHeight())
|
||||
if (!_TextureExists(texture) || texture.W2 != GetScreenWidth() || texture.H2 != GetScreenHeight())
|
||||
{
|
||||
RemoveTexture(ref texture);
|
||||
texture = CopyScreen();
|
||||
@@ -646,35 +646,35 @@ namespace Vocaluxe.Lib.Draw
|
||||
#region adding
|
||||
public CTexture AddTexture(string texturePath)
|
||||
{
|
||||
if (File.Exists(texturePath))
|
||||
if (!File.Exists(texturePath))
|
||||
{
|
||||
Bitmap bmp;
|
||||
try
|
||||
{
|
||||
bmp = new Bitmap(texturePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error loading Texture: " + texturePath);
|
||||
return new CTexture(-1);
|
||||
}
|
||||
try
|
||||
{
|
||||
return AddTexture(bmp);
|
||||
}
|
||||
finally
|
||||
{
|
||||
bmp.Dispose();
|
||||
}
|
||||
CLog.LogError("Can't find File: " + texturePath);
|
||||
return null;
|
||||
}
|
||||
Bitmap bmp;
|
||||
try
|
||||
{
|
||||
bmp = new Bitmap(texturePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error loading Texture: " + texturePath);
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
return AddTexture(bmp);
|
||||
}
|
||||
finally
|
||||
{
|
||||
bmp.Dispose();
|
||||
}
|
||||
CLog.LogError("Can't find File: " + texturePath);
|
||||
return new CTexture(-1);
|
||||
}
|
||||
|
||||
public CTexture AddTexture(Bitmap bmp)
|
||||
{
|
||||
if (bmp.Height == 0 || bmp.Width == 0)
|
||||
return new CTexture(-1);
|
||||
return null;
|
||||
|
||||
int maxSize;
|
||||
switch (CConfig.TextureQuality)
|
||||
@@ -766,7 +766,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
CTexture texture = new CTexture(-1, w, h);
|
||||
|
||||
_CreateTexture(data, ref texture);
|
||||
_CreateTexture(texture, data);
|
||||
|
||||
lock (_MutexTexture)
|
||||
{
|
||||
@@ -777,7 +777,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
return texture;
|
||||
}
|
||||
|
||||
private void _CreateTexture(byte[] data, ref CTexture texture)
|
||||
private void _CreateTexture(CTexture texture, byte[] data)
|
||||
{
|
||||
int w = texture.OrigSize.Width;
|
||||
int h = texture.OrigSize.Height;
|
||||
@@ -831,7 +831,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
lock (_MutexTexture)
|
||||
{
|
||||
texture.Index = _IDs.Dequeue();
|
||||
queue.ID = texture.Index;
|
||||
queue.Index = texture.Index;
|
||||
_Queue.Add(queue);
|
||||
_Textures[texture.Index] = texture;
|
||||
}
|
||||
@@ -841,51 +841,49 @@ namespace Vocaluxe.Lib.Draw
|
||||
#endregion adding
|
||||
|
||||
#region updating
|
||||
public bool UpdateTexture(ref CTexture texture, byte[] data)
|
||||
public bool UpdateTexture(CTexture texture, byte[] data)
|
||||
{
|
||||
if (_TextureExists(ref texture))
|
||||
if (!_TextureExists(texture))
|
||||
return false;
|
||||
if (_UsePBO)
|
||||
{
|
||||
if (_UsePBO)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO);
|
||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO);
|
||||
|
||||
IntPtr buffer = GL.MapBuffer(BufferTarget.PixelUnpackBuffer, BufferAccess.WriteOnly);
|
||||
Marshal.Copy(data, 0, buffer, data.Length);
|
||||
IntPtr buffer = GL.MapBuffer(BufferTarget.PixelUnpackBuffer, BufferAccess.WriteOnly);
|
||||
Marshal.Copy(data, 0, buffer, data.Length);
|
||||
|
||||
GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.OrigSize.Width, texture.OrigSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.OrigSize.Width, texture.OrigSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.OrigSize.Width, texture.OrigSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data);
|
||||
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge);
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
|
||||
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
|
||||
//GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
//GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.OrigSize.Width, texture.OrigSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data);
|
||||
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge);
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
|
||||
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
|
||||
//GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
//GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion updating
|
||||
|
||||
public void RemoveTexture(ref CTexture texture)
|
||||
{
|
||||
if ((texture.Index > 0) && (_Textures.Count > 0))
|
||||
if (texture != null && texture.Index > 0)
|
||||
{
|
||||
lock (_MutexTexture)
|
||||
{
|
||||
@@ -894,23 +892,19 @@ namespace Vocaluxe.Lib.Draw
|
||||
if (texture.PBO > 0)
|
||||
GL.DeleteBuffers(1, ref texture.PBO);
|
||||
_Textures.Remove(texture.Index);
|
||||
texture.Index = -1;
|
||||
texture.ID = -1;
|
||||
}
|
||||
}
|
||||
texture = null;
|
||||
}
|
||||
|
||||
private bool _TextureExists(ref CTexture texture)
|
||||
private bool _TextureExists(CTexture texture)
|
||||
{
|
||||
lock (_MutexTexture)
|
||||
{
|
||||
if (_Textures.ContainsKey(texture.Index))
|
||||
if (texture != null && _Textures.ContainsKey(texture.Index))
|
||||
{
|
||||
if (_Textures[texture.Index].ID > 0)
|
||||
{
|
||||
texture = _Textures[texture.Index];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -919,11 +913,15 @@ namespace Vocaluxe.Lib.Draw
|
||||
#region drawing
|
||||
public void DrawTexture(CTexture texture)
|
||||
{
|
||||
if (texture == null)
|
||||
return;
|
||||
DrawTexture(texture, texture.Rect, texture.Color);
|
||||
}
|
||||
|
||||
public void DrawTexture(CTexture texture, SRectF rect)
|
||||
{
|
||||
if (texture == null)
|
||||
return;
|
||||
DrawTexture(texture, rect, texture.Color);
|
||||
}
|
||||
|
||||
@@ -934,6 +932,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public void DrawTexture(CTexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored = false)
|
||||
{
|
||||
if (!_TextureExists(texture))
|
||||
return;
|
||||
|
||||
if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon ||
|
||||
Math.Abs(color.A) < float.Epsilon)
|
||||
return;
|
||||
@@ -944,9 +945,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y)
|
||||
return;
|
||||
|
||||
if (!_TextureExists(ref texture))
|
||||
return;
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
|
||||
@@ -1042,38 +1040,40 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public void DrawTexture(CTexture texture, SRectF rect, SColorF color, float begin, float end)
|
||||
{
|
||||
if (_TextureExists(ref texture))
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
if (!_TextureExists(texture))
|
||||
return;
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
GL.Enable(EnableCap.Blend);
|
||||
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
||||
GL.Enable(EnableCap.Blend);
|
||||
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
||||
|
||||
|
||||
GL.Begin(BeginMode.Quads);
|
||||
GL.Begin(BeginMode.Quads);
|
||||
|
||||
GL.TexCoord2(0f + begin * texture.WidthRatio, 0f);
|
||||
GL.Vertex3(rect.X + begin * rect.W, rect.Y, rect.Z + CGraphics.ZOffset);
|
||||
GL.TexCoord2(0f + begin * texture.WidthRatio, 0f);
|
||||
GL.Vertex3(rect.X + begin * rect.W, rect.Y, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.TexCoord2(0f + begin * texture.WidthRatio, texture.HeightRatio);
|
||||
GL.Vertex3(rect.X + begin * rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset);
|
||||
GL.TexCoord2(0f + begin * texture.WidthRatio, texture.HeightRatio);
|
||||
GL.Vertex3(rect.X + begin * rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.TexCoord2(texture.WidthRatio * end, texture.HeightRatio);
|
||||
GL.Vertex3(rect.X + end * rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset);
|
||||
GL.TexCoord2(texture.WidthRatio * end, texture.HeightRatio);
|
||||
GL.Vertex3(rect.X + end * rect.W, rect.Y + rect.H, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.TexCoord2(texture.WidthRatio * end, 0f);
|
||||
GL.Vertex3(rect.X + end * rect.W, rect.Y, rect.Z + CGraphics.ZOffset);
|
||||
GL.TexCoord2(texture.WidthRatio * end, 0f);
|
||||
GL.Vertex3(rect.X + end * rect.W, rect.Y, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.End();
|
||||
GL.End();
|
||||
|
||||
|
||||
GL.Disable(EnableCap.Blend);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
GL.Disable(EnableCap.Blend);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
public void DrawTextureReflection(CTexture texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
||||
{
|
||||
if (!_TextureExists(texture))
|
||||
return;
|
||||
|
||||
if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon ||
|
||||
Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon)
|
||||
return;
|
||||
@@ -1087,84 +1087,81 @@ namespace Vocaluxe.Lib.Draw
|
||||
if (height > bounds.H)
|
||||
height = bounds.H;
|
||||
|
||||
if (_TextureExists(ref texture))
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
|
||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
|
||||
float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
|
||||
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
|
||||
|
||||
if (x1 < 0)
|
||||
x1 = 0f;
|
||||
|
||||
if (x2 > texture.WidthRatio)
|
||||
x2 = texture.WidthRatio;
|
||||
|
||||
if (y1 < 0)
|
||||
y1 = 0f;
|
||||
|
||||
if (y2 > texture.HeightRatio)
|
||||
y2 = texture.HeightRatio;
|
||||
|
||||
|
||||
float rx1 = rect.X;
|
||||
float rx2 = rect.X + rect.W;
|
||||
float ry1 = rect.Y + rect.H + space;
|
||||
float ry2 = rect.Y + rect.H + space + height;
|
||||
|
||||
if (rx1 < bounds.X)
|
||||
rx1 = bounds.X;
|
||||
|
||||
if (rx2 > bounds.X + bounds.W)
|
||||
rx2 = bounds.X + bounds.W;
|
||||
|
||||
if (ry1 < bounds.Y + space)
|
||||
ry1 = bounds.Y + space;
|
||||
|
||||
if (ry2 > bounds.Y + bounds.H + space + height)
|
||||
ry2 = bounds.Y + bounds.H + space + height;
|
||||
|
||||
GL.Enable(EnableCap.Blend);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Texture);
|
||||
GL.PushMatrix();
|
||||
|
||||
if (Math.Abs(rect.Rotation) > float.Epsilon)
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
|
||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
|
||||
float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
|
||||
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
|
||||
|
||||
if (x1 < 0)
|
||||
x1 = 0f;
|
||||
|
||||
if (x2 > texture.WidthRatio)
|
||||
x2 = texture.WidthRatio;
|
||||
|
||||
if (y1 < 0)
|
||||
y1 = 0f;
|
||||
|
||||
if (y2 > texture.HeightRatio)
|
||||
y2 = texture.HeightRatio;
|
||||
|
||||
|
||||
float rx1 = rect.X;
|
||||
float rx2 = rect.X + rect.W;
|
||||
float ry1 = rect.Y + rect.H + space;
|
||||
float ry2 = rect.Y + rect.H + space + height;
|
||||
|
||||
if (rx1 < bounds.X)
|
||||
rx1 = bounds.X;
|
||||
|
||||
if (rx2 > bounds.X + bounds.W)
|
||||
rx2 = bounds.X + bounds.W;
|
||||
|
||||
if (ry1 < bounds.Y + space)
|
||||
ry1 = bounds.Y + space;
|
||||
|
||||
if (ry2 > bounds.Y + bounds.H + space + height)
|
||||
ry2 = bounds.Y + bounds.H + space + height;
|
||||
|
||||
GL.Enable(EnableCap.Blend);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Texture);
|
||||
GL.PushMatrix();
|
||||
|
||||
if (Math.Abs(rect.Rotation) > float.Epsilon)
|
||||
{
|
||||
GL.Translate(0.5f, 0.5f, 0);
|
||||
GL.Rotate(-rect.Rotation, 0f, 0f, 1f);
|
||||
GL.Translate(-0.5f, -0.5f, 0);
|
||||
}
|
||||
|
||||
|
||||
GL.Begin(BeginMode.Quads);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
||||
GL.TexCoord2(x2, y2);
|
||||
GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, 0f);
|
||||
GL.TexCoord2(x2, y1);
|
||||
GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, 0f);
|
||||
GL.TexCoord2(x1, y1);
|
||||
GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
||||
GL.TexCoord2(x1, y2);
|
||||
GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.End();
|
||||
|
||||
|
||||
GL.PopMatrix();
|
||||
|
||||
GL.Disable(EnableCap.Blend);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
GL.Translate(0.5f, 0.5f, 0);
|
||||
GL.Rotate(-rect.Rotation, 0f, 0f, 1f);
|
||||
GL.Translate(-0.5f, -0.5f, 0);
|
||||
}
|
||||
|
||||
|
||||
GL.Begin(BeginMode.Quads);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
||||
GL.TexCoord2(x2, y2);
|
||||
GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, 0f);
|
||||
GL.TexCoord2(x2, y1);
|
||||
GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, 0f);
|
||||
GL.TexCoord2(x1, y1);
|
||||
GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
||||
GL.TexCoord2(x1, y2);
|
||||
GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset);
|
||||
|
||||
GL.End();
|
||||
|
||||
|
||||
GL.PopMatrix();
|
||||
|
||||
GL.Disable(EnableCap.Blend);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
#endregion drawing
|
||||
|
||||
@@ -1181,19 +1178,12 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
STextureQueue q = _Queue[0];
|
||||
_Queue.RemoveAt(0);
|
||||
CTexture texture = new CTexture(-1);
|
||||
if (_Textures.ContainsKey(q.ID))
|
||||
texture = _Textures[q.ID];
|
||||
|
||||
if (texture.Index < 1)
|
||||
CTexture texture;
|
||||
if (!_Textures.TryGetValue(q.Index, out texture))
|
||||
continue;
|
||||
|
||||
if (q.Width == texture.OrigSize.Width && q.Height == texture.OrigSize.Height)
|
||||
{
|
||||
_CreateTexture(q.Data, ref texture);
|
||||
|
||||
_Textures[texture.Index] = texture;
|
||||
}
|
||||
_CreateTexture(texture, q.Data);
|
||||
else
|
||||
CLog.LogError("Wrong texture size in queue!");
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
CTexture AddTexture(Bitmap bitmap);
|
||||
CTexture AddTexture(int w, int h, byte[] data);
|
||||
CTexture EnqueueTexture(int w, int h, byte[] data);
|
||||
bool UpdateTexture(ref CTexture texture, byte[] data);
|
||||
bool UpdateTexture(CTexture texture, byte[] data);
|
||||
void RemoveTexture(ref CTexture texture);
|
||||
|
||||
// Basic Draw Methods
|
||||
|
||||
@@ -662,13 +662,13 @@ namespace Vocaluxe.Lib.Video
|
||||
|
||||
if (num >= 0)
|
||||
{
|
||||
if (frame.Index == -1 || _Width != frame.OrigSize.Width || _Height != frame.OrigSize.Height)
|
||||
if (frame == null || _Width != frame.OrigSize.Width || _Height != frame.OrigSize.Height)
|
||||
{
|
||||
CDraw.RemoveTexture(ref frame);
|
||||
frame = CDraw.AddTexture(_Width, _Height, _FrameBuffer[num].Data);
|
||||
}
|
||||
else
|
||||
CDraw.UpdateTexture(ref frame, _FrameBuffer[num].Data);
|
||||
CDraw.UpdateTexture(frame, _FrameBuffer[num].Data);
|
||||
|
||||
lock (_MutexSyncSignals)
|
||||
{
|
||||
|
||||
@@ -122,13 +122,13 @@ namespace Vocaluxe.Lib.Video
|
||||
{
|
||||
if (data == null)
|
||||
return;
|
||||
if (frame.Index == -1 || width != frame.OrigSize.Width || height != frame.OrigSize.Height || data.Length == 0)
|
||||
if (frame == null || width != frame.OrigSize.Width || height != frame.OrigSize.Height || data.Length == 0)
|
||||
{
|
||||
CDraw.RemoveTexture(ref frame);
|
||||
frame = CDraw.AddTexture(width, height, data);
|
||||
}
|
||||
else
|
||||
CDraw.UpdateTexture(ref frame, data);
|
||||
CDraw.UpdateTexture(frame, data);
|
||||
data = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,13 +57,13 @@ namespace Vocaluxe.Lib.Webcam
|
||||
{
|
||||
lock (_MutexData)
|
||||
{
|
||||
if (frame.Index == -1 || _Width != frame.OrigSize.Width || _Height != frame.OrigSize.Height)
|
||||
if (frame == null || _Width != frame.OrigSize.Width || _Height != frame.OrigSize.Height)
|
||||
{
|
||||
CDraw.RemoveTexture(ref frame);
|
||||
frame = CDraw.AddTexture(_Width, _Height, _Data);
|
||||
}
|
||||
else
|
||||
CDraw.UpdateTexture(ref frame, _Data);
|
||||
CDraw.UpdateTexture(frame, _Data);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Vocaluxe.Screens
|
||||
private const string _ButtonExit = "ButtonExit";
|
||||
|
||||
private SWebcamConfig _Config;
|
||||
private CTexture _WebcamTexture = new CTexture(-1);
|
||||
private CTexture _WebcamTexture;
|
||||
private int _DeviceNr;
|
||||
private int _CapabilityNr;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private EEditMode _EditMode;
|
||||
|
||||
private CTexture _WebcamTexture = new CTexture(-1);
|
||||
private CTexture _WebcamTexture;
|
||||
private Bitmap _Snapshot;
|
||||
|
||||
public override void Init()
|
||||
@@ -210,7 +210,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
CProfiles.SetAvatar(_SelectSlides[_SelectSlideProfiles].Selection,
|
||||
_SelectSlides[_SelectSlideAvatars].Selection);
|
||||
if (CWebcam.IsDeviceAvailable() && _WebcamTexture.Index > 0)
|
||||
if (CWebcam.IsDeviceAvailable() && _WebcamTexture != null)
|
||||
_OnDiscardSnapshot();
|
||||
}
|
||||
else if (_SelectSlides[_SelectSlideGuestProfile].Selected)
|
||||
@@ -311,7 +311,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
int avatarNr = CProfiles.GetAvatarNr(_SelectSlides[_SelectSlideProfiles].Selection);
|
||||
_SelectSlides[_SelectSlideAvatars].Selection = avatarNr;
|
||||
if (CWebcam.IsDeviceAvailable() && _WebcamTexture.Index > 0)
|
||||
if (CWebcam.IsDeviceAvailable() && _WebcamTexture != null)
|
||||
{
|
||||
if (_Snapshot == null)
|
||||
CWebcam.GetFrame(ref _WebcamTexture);
|
||||
|
||||
@@ -368,7 +368,7 @@ namespace Vocaluxe.Screens
|
||||
_Statics[_StaticPointsBarBG[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayer;
|
||||
_Statics[_StaticAvatar[player, numplayer]].Visible = numplayer + 1 == CGame.NumPlayer;
|
||||
|
||||
_Statics[_StaticAvatar[player, numplayer]].Texture = new CTexture(-1);
|
||||
_Statics[_StaticAvatar[player, numplayer]].Texture = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ namespace Vocaluxe.Screens
|
||||
private const float _Volume = 100f;
|
||||
private int _CurrentVideo = -1;
|
||||
private EAspect _VideoAspect = EAspect.Crop;
|
||||
private CTexture _CurrentVideoTexture = new CTexture(-1);
|
||||
private CTexture _CurrentWebcamFrameTexture = new CTexture(-1);
|
||||
private CTexture _Background = new CTexture(-1);
|
||||
private CTexture _CurrentVideoTexture;
|
||||
private CTexture _CurrentWebcamFrameTexture;
|
||||
private CTexture _Background;
|
||||
|
||||
private float _CurrentTime;
|
||||
private float _FinishTime;
|
||||
@@ -412,8 +412,8 @@ namespace Vocaluxe.Screens
|
||||
_FadeOut = false;
|
||||
|
||||
_CurrentVideo = -1;
|
||||
_CurrentVideoTexture = new CTexture(-1);
|
||||
_CurrentWebcamFrameTexture = new CTexture(-1);
|
||||
_CurrentVideoTexture = null;
|
||||
_CurrentWebcamFrameTexture = null;
|
||||
_CurrentBeat = -100;
|
||||
_CurrentTime = 0f;
|
||||
_FinishTime = 0f;
|
||||
@@ -468,12 +468,14 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
else
|
||||
background = _Background;
|
||||
RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH);
|
||||
RectangleF rect;
|
||||
CHelper.SetRect(bounds, out rect, (float)background.OrigAspect, aspect);
|
||||
|
||||
CDraw.DrawTexture(_Background, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f),
|
||||
_Background.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f));
|
||||
if (background != null)
|
||||
{
|
||||
RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH);
|
||||
RectangleF rect;
|
||||
CHelper.SetRect(bounds, out rect, background.OrigAspect, aspect);
|
||||
CDraw.DrawTexture(background, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, 0f),
|
||||
background.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f));
|
||||
}
|
||||
}
|
||||
|
||||
_DrawBG();
|
||||
@@ -1354,7 +1356,7 @@ namespace Vocaluxe.Screens
|
||||
foreach (CLine line in voice.Lines.Where(line => line.VisibleInTimeLine))
|
||||
{
|
||||
STimeRect trect = new STimeRect {StartBeat = line.FirstNoteBeat, EndBeat = line.EndBeat};
|
||||
trect.Rect = GetNewStatic(new CTexture(-1),
|
||||
trect.Rect = GetNewStatic(null,
|
||||
new SColorF(1f, 1f, 1f, 1f),
|
||||
new SRectF(
|
||||
stat.Rect.X + stat.Rect.W * ((CGame.GetTimeFromBeats(trect.StartBeat, song.BPM) + song.Gap - song.Start) / totalTime),
|
||||
|
||||
@@ -6,11 +6,11 @@ namespace VocaluxeLib.Draw
|
||||
{
|
||||
public class CTexture
|
||||
{
|
||||
public int Index;
|
||||
public int Index = -1;
|
||||
public int PBO;
|
||||
public int ID;
|
||||
public int ID = -1;
|
||||
|
||||
public string TexturePath;
|
||||
public string TexturePath = "";
|
||||
|
||||
/// <summary>
|
||||
/// Original size (e.g. of bmp)
|
||||
@@ -26,10 +26,9 @@ namespace VocaluxeLib.Draw
|
||||
/// </summary>
|
||||
public SRectF Rect;
|
||||
|
||||
public SColorF Color;
|
||||
public SColorF Color = new SColorF(1f, 1f, 1f, 1f);
|
||||
|
||||
private int _W2, _H2;
|
||||
private float _WidthRatio, _HeightRatio;
|
||||
private bool _UseFullTexture;
|
||||
/// <summary>
|
||||
/// Internal texture width (on device), a power of 2 if necessary
|
||||
@@ -61,19 +60,11 @@ namespace VocaluxeLib.Draw
|
||||
/// <summary>
|
||||
/// Internal use. Specifies which part of texture memory is actually used
|
||||
/// </summary>
|
||||
public float WidthRatio
|
||||
{
|
||||
get { return _WidthRatio; }
|
||||
private set { _WidthRatio = value; }
|
||||
}
|
||||
public float WidthRatio { get; private set; }
|
||||
/// <summary>
|
||||
/// Internal use. Specifies which part of texture memory is actually used
|
||||
/// </summary>
|
||||
public float HeightRatio
|
||||
{
|
||||
get { return _HeightRatio; }
|
||||
private set { _HeightRatio = value; }
|
||||
}
|
||||
public float HeightRatio { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Internal use. Specifies if full texture memory should be used
|
||||
@@ -101,20 +92,12 @@ namespace VocaluxeLib.Draw
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,8 +80,8 @@ namespace VocaluxeLib.Menu
|
||||
Text.Selected = value;
|
||||
}
|
||||
}
|
||||
public bool Visible;
|
||||
public bool Enabled;
|
||||
public bool Visible = true;
|
||||
public bool Enabled = true;
|
||||
|
||||
public string GetThemeName()
|
||||
{
|
||||
@@ -91,28 +91,10 @@ namespace VocaluxeLib.Menu
|
||||
public CButton(int partyModeID)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeButton();
|
||||
Rect = new SRectF();
|
||||
Color = new SColorF();
|
||||
SelColor = new SColorF();
|
||||
Texture = new CTexture(-1);
|
||||
SelTexture = new CTexture(-1);
|
||||
|
||||
_IsSelText = false;
|
||||
Text = new CText(_PartyModeID);
|
||||
_SelText = new CText(_PartyModeID);
|
||||
Selected = false;
|
||||
Visible = true;
|
||||
EditMode = false;
|
||||
Enabled = true;
|
||||
|
||||
_Reflection = false;
|
||||
_ReflectionSpace = 0f;
|
||||
_ReflectionHeight = 0f;
|
||||
|
||||
_SelReflection = false;
|
||||
_SelReflectionSpace = 0f;
|
||||
_SelReflectionHeight = 0f;
|
||||
}
|
||||
|
||||
public CButton(CButton button)
|
||||
@@ -132,13 +114,10 @@ namespace VocaluxeLib.Menu
|
||||
Texture = button.Texture;
|
||||
SelTexture = button.SelTexture;
|
||||
|
||||
_IsSelText = false;
|
||||
Text = new CText(button.Text);
|
||||
_SelText = new CText(button._SelText);
|
||||
Selected = false;
|
||||
Visible = true;
|
||||
EditMode = false;
|
||||
_ThemeLoaded = false;
|
||||
Enabled = button.Enabled;
|
||||
|
||||
_Reflection = button._Reflection;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace VocaluxeLib.Menu
|
||||
private SRectF _Rect;
|
||||
private float _Size;
|
||||
private SColorF _Color;
|
||||
private float _Alpha;
|
||||
private float _Alpha = 1;
|
||||
private float _Angle; //0..360°
|
||||
private readonly float _MaxAge; //[s]
|
||||
private float _Age; //[s]
|
||||
@@ -62,7 +62,7 @@ namespace VocaluxeLib.Menu
|
||||
private float _LastTime;
|
||||
private readonly EParticleType _Type;
|
||||
|
||||
private readonly Stopwatch _Timer;
|
||||
private readonly Stopwatch _Timer = new Stopwatch();
|
||||
#endregion private vars
|
||||
|
||||
#region public vars
|
||||
@@ -116,21 +116,15 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_TextureName = textureName;
|
||||
_Texture = new CTexture(-1);
|
||||
_Color = color;
|
||||
_Rect = new SRectF(x, y, size, size, z);
|
||||
_Size = size;
|
||||
_Alpha = 1f;
|
||||
_Angle = 0f;
|
||||
_Vx = vx;
|
||||
_Vy = vy;
|
||||
_Vr = vr;
|
||||
_Vsize = vsize;
|
||||
_LastTime = 0f;
|
||||
_Type = type;
|
||||
|
||||
_Timer = new Stopwatch();
|
||||
_Age = 0f;
|
||||
_MaxAge = maxage;
|
||||
_Rotation = (float)(CBase.Game.GetRandomDouble() * 360.0);
|
||||
}
|
||||
@@ -144,17 +138,12 @@ namespace VocaluxeLib.Menu
|
||||
_Color = color;
|
||||
_Rect = new SRectF(x, y, size, size, z);
|
||||
_Size = size;
|
||||
_Alpha = 1f;
|
||||
_Angle = 0f;
|
||||
_Vx = vx;
|
||||
_Vy = vy;
|
||||
_Vr = vr;
|
||||
_Vsize = vsize;
|
||||
_LastTime = 0f;
|
||||
_Type = type;
|
||||
|
||||
_Timer = new Stopwatch();
|
||||
_Age = 0f;
|
||||
_MaxAge = maxage;
|
||||
_Rotation = (float)(CBase.Game.GetRandomDouble() * 360.0);
|
||||
}
|
||||
@@ -357,7 +346,6 @@ namespace VocaluxeLib.Menu
|
||||
Rect = rect;
|
||||
Color = color;
|
||||
_Theme.TextureName = textureName;
|
||||
Texture = new CTexture(-1);
|
||||
_MaxNumber = maxNumber;
|
||||
_Size = size;
|
||||
_Type = type;
|
||||
@@ -603,7 +591,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void UnloadTextures()
|
||||
{
|
||||
Texture = new CTexture();
|
||||
Texture = null;
|
||||
}
|
||||
|
||||
public void LoadTextures()
|
||||
|
||||
@@ -531,7 +531,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void AddValue(string value, int partyModeID)
|
||||
{
|
||||
AddValue(value, new CTexture(-1), _ValueIndexes.Count, partyModeID);
|
||||
AddValue(value, null, _ValueIndexes.Count, partyModeID);
|
||||
}
|
||||
|
||||
public void AddValue(string value, CTexture texture)
|
||||
@@ -560,7 +560,7 @@ namespace VocaluxeLib.Menu
|
||||
public void AddValues(IEnumerable<string> values)
|
||||
{
|
||||
foreach (string value in values)
|
||||
_AddValue(value, new CTexture(-1), _PartyModeID);
|
||||
_AddValue(value, null, _PartyModeID);
|
||||
|
||||
_ValueBounds.Clear();
|
||||
}
|
||||
@@ -589,12 +589,7 @@ namespace VocaluxeLib.Menu
|
||||
RenameValue(Selection, newName);
|
||||
}
|
||||
|
||||
public void RenameValue(int selection, string newName)
|
||||
{
|
||||
RenameValue(selection, newName, new CTexture(-1));
|
||||
}
|
||||
|
||||
public void RenameValue(int selection, string newName, CTexture newTexture)
|
||||
public void RenameValue(int selection, string newName, CTexture newTexture = null)
|
||||
{
|
||||
if (selection < 0 && selection >= _ValueNames.Count)
|
||||
return;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace VocaluxeLib.Menu
|
||||
private CTexture _Texture;
|
||||
public CTexture Texture
|
||||
{
|
||||
get { return _Texture.Index != -1 ? _Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); }
|
||||
get { return _Texture?? CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); }
|
||||
|
||||
set { _Texture = value; }
|
||||
}
|
||||
@@ -59,35 +59,20 @@ namespace VocaluxeLib.Menu
|
||||
public float ReflectionHeight;
|
||||
|
||||
public bool Selected;
|
||||
public bool Visible;
|
||||
public bool Visible=true;
|
||||
|
||||
public float Alpha;
|
||||
public float Alpha=1;
|
||||
|
||||
public EAspect Aspect = EAspect.Stretch;
|
||||
|
||||
public CStatic(int partyModeID)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeStatic();
|
||||
_ThemeLoaded = false;
|
||||
|
||||
_Texture = new CTexture(-1);
|
||||
Color = new SColorF();
|
||||
Rect = new SRectF();
|
||||
Reflection = false;
|
||||
ReflectionSpace = 0f;
|
||||
ReflectionHeight = 0f;
|
||||
|
||||
Selected = false;
|
||||
Alpha = 1f;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
public CStatic(CStatic s)
|
||||
{
|
||||
_PartyModeID = s._PartyModeID;
|
||||
_Theme = new SThemeStatic();
|
||||
_ThemeLoaded = false;
|
||||
|
||||
_Texture = s.Texture;
|
||||
Color = new SColorF(s.Color);
|
||||
@@ -104,37 +89,18 @@ namespace VocaluxeLib.Menu
|
||||
public CStatic(int partyModeID, CTexture texture, SColorF color, SRectF rect)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeStatic();
|
||||
_ThemeLoaded = false;
|
||||
|
||||
_Texture = texture;
|
||||
Color = color;
|
||||
Rect = rect;
|
||||
Reflection = false;
|
||||
ReflectionSpace = 0f;
|
||||
ReflectionHeight = 0f;
|
||||
|
||||
Selected = false;
|
||||
Alpha = 1f;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
public CStatic(int partyModeID, string textureSkinName, SColorF color, SRectF rect)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeStatic {TextureName = textureSkinName};
|
||||
_ThemeLoaded = false;
|
||||
|
||||
_Texture = new CTexture(-1);
|
||||
_Theme.TextureName = textureSkinName;
|
||||
Color = color;
|
||||
Rect = rect;
|
||||
Reflection = false;
|
||||
ReflectionSpace = 0f;
|
||||
ReflectionHeight = 0f;
|
||||
|
||||
Selected = false;
|
||||
Alpha = 1f;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
|
||||
@@ -239,7 +205,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void Draw(float scale, float z, EAspect aspect, bool forceDraw = false)
|
||||
{
|
||||
CTexture texture = _Texture.Index != -1 ? _Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
|
||||
CTexture texture = Texture;
|
||||
|
||||
SRectF bounds = new SRectF(
|
||||
Rect.X - Rect.W * (scale - 1f),
|
||||
|
||||
@@ -25,9 +25,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
public class CCategory
|
||||
{
|
||||
public readonly string Name;
|
||||
private CTexture _CoverTextureSmall = new CTexture(-1);
|
||||
private CTexture _CoverTextureBig = new CTexture(-1);
|
||||
private bool _CoverBigLoaded;
|
||||
private CTexture _CoverTextureSmall;
|
||||
private CTexture _CoverTextureBig;
|
||||
public readonly List<CSongPointer> Songs = new List<CSongPointer>();
|
||||
|
||||
public CCategory(string name)
|
||||
@@ -44,13 +43,12 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public CTexture CoverTextureBig
|
||||
{
|
||||
get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; }
|
||||
get { return _CoverTextureBig ?? _CoverTextureSmall; }
|
||||
set
|
||||
{
|
||||
if (value.Index == -1)
|
||||
return;
|
||||
_CoverTextureBig = value;
|
||||
_CoverBigLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +70,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public class CSong
|
||||
{
|
||||
private bool _CoverSmallLoaded;
|
||||
private bool _CoverBigLoaded;
|
||||
private CTexture _CoverTextureSmall = new CTexture(-1);
|
||||
private CTexture _CoverTextureBig = new CTexture(-1);
|
||||
private CTexture _CoverTextureSmall;
|
||||
private CTexture _CoverTextureBig;
|
||||
|
||||
public SMedley Medley;
|
||||
|
||||
@@ -101,26 +99,18 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_CoverSmallLoaded)
|
||||
if (_CoverTextureSmall == null)
|
||||
LoadSmallCover();
|
||||
return _CoverTextureSmall;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_CoverTextureSmall = value;
|
||||
_CoverSmallLoaded = true;
|
||||
}
|
||||
set { _CoverTextureSmall = value; }
|
||||
}
|
||||
|
||||
public CTexture CoverTextureBig
|
||||
{
|
||||
get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; }
|
||||
set
|
||||
{
|
||||
_CoverTextureBig = value;
|
||||
_CoverBigLoaded = true;
|
||||
}
|
||||
get { return _CoverTextureBig ?? _CoverTextureSmall; }
|
||||
set { _CoverTextureBig = value; }
|
||||
}
|
||||
|
||||
public string Title = String.Empty;
|
||||
@@ -215,8 +205,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
VideoFileName = song.VideoFileName;
|
||||
|
||||
VideoAspect = song.VideoAspect;
|
||||
_CoverSmallLoaded = song._CoverSmallLoaded;
|
||||
_CoverBigLoaded = song._CoverBigLoaded;
|
||||
NotesLoaded = song.NotesLoaded;
|
||||
|
||||
Artist = song.Artist;
|
||||
@@ -751,7 +739,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public void LoadSmallCover()
|
||||
{
|
||||
if (_CoverSmallLoaded)
|
||||
if (_CoverTextureSmall != null)
|
||||
return;
|
||||
if (CoverFileName != "")
|
||||
{
|
||||
@@ -760,8 +748,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
}
|
||||
else
|
||||
_CoverTextureSmall = CBase.Cover.GetNoCover();
|
||||
|
||||
_CoverSmallLoaded = true;
|
||||
}
|
||||
|
||||
private void _CheckFiles()
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
private readonly List<int> _Streams = new List<int>();
|
||||
private int _Actsong = -1;
|
||||
private int _Actsongstream = -1;
|
||||
protected CTexture _Vidtex = new CTexture(-1);
|
||||
protected CTexture _Vidtex;
|
||||
|
||||
protected bool _Initialized;
|
||||
protected int _LastKnownNumSongs;
|
||||
@@ -464,7 +464,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
public virtual void OnShow()
|
||||
{
|
||||
_Actsongstream = -1;
|
||||
_Vidtex = new CTexture(-1);
|
||||
_Vidtex = null;
|
||||
}
|
||||
|
||||
public virtual void OnHide()
|
||||
|
||||
@@ -453,8 +453,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
_TextBG.Draw();
|
||||
|
||||
|
||||
if (_Vidtex.Index != -1 && _Video != -1)
|
||||
if (_Vidtex != null && _Video != -1)
|
||||
{
|
||||
if (_Vidtex.Color.A < 1)
|
||||
_CoverBig.Draw(1f, EAspect.Crop);
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace VocaluxeLib.Menu
|
||||
// ReSharper restore UnusedParameter.Local
|
||||
{
|
||||
FileName = String.Empty;
|
||||
Texture = new CTexture(-1);
|
||||
Texture = null;
|
||||
}
|
||||
}
|
||||
#endregion Profiles
|
||||
|
||||
Reference in new issue
Block a user