use data queque when loading cover

This commit is contained in:
Alexander Eckart committed 2012-03-14 22:26:20 +01:00
1 parent a78b61bbe7
commit 0d9033d21e
9 files changed
+237 -44

No files matched your search

+4 -2
View File
@@ -1008,7 +1008,7 @@ namespace Vocaluxe.Base
result = true; result = true;
reader.Read(); reader.Read();
byte[] data = GetBytes(reader); byte[] data = GetBytes(reader);
tex = CDraw.AddTexture(w, h, ref data); tex = CDraw.QuequeTexture(w, h, ref data);
} }
} }
else else
@@ -1053,7 +1053,7 @@ namespace Vocaluxe.Base
Graphics g = Graphics.FromImage(bmp); Graphics g = Graphics.FromImage(bmp);
g.DrawImage(origin, new Rectangle(0, 0, w, h)); g.DrawImage(origin, new Rectangle(0, 0, w, h));
g.Dispose(); g.Dispose();
tex = CDraw.AddTexture(bmp);
byte[] data = new byte[w * h * 4]; byte[] data = new byte[w * h * 4];
BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
@@ -1061,6 +1061,8 @@ namespace Vocaluxe.Base
bmp.UnlockBits(bmp_data); bmp.UnlockBits(bmp_data);
bmp.Dispose(); bmp.Dispose();
tex = CDraw.QuequeTexture(w, h, ref data);
command.CommandText = "INSERT INTO Cover (Path, width, height) " + command.CommandText = "INSERT INTO Cover (Path, width, height) " +
"VALUES (@path, " + w.ToString() + ", " + h.ToString() + ")"; "VALUES (@path, " + w.ToString() + ", " + h.ToString() + ")";
command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = CoverPath; command.Parameters.Add("@path", System.Data.DbType.String, 0).Value = CoverPath;
+5
View File
@@ -156,6 +156,11 @@ namespace Vocaluxe.Base
return _Draw.AddTexture(W, H, ref Data); return _Draw.AddTexture(W, H, ref Data);
} }
public static STexture QuequeTexture(int W, int H, ref byte[] Data)
{
return _Draw.QuequeTexture(W, H, ref Data);
}
public static bool UpdateTexture(ref STexture Texture, ref byte[] Data) public static bool UpdateTexture(ref STexture Texture, ref byte[] Data)
{ {
return _Draw.UpdateTexture(ref Texture, ref Data); return _Draw.UpdateTexture(ref Texture, ref Data);
+1 -1
View File
@@ -133,7 +133,7 @@ namespace Vocaluxe.Base
sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
//size = g.MeasureString(chr.ToString(), fo); //size = g.MeasureString(chr.ToString(), fo);
float h_style = sizeB.Height; float h_style = sizeB.Height;
g.Dispose();
return h_normal / h_style; return h_normal / h_style;
} }
} }
+21
View File
@@ -826,11 +826,32 @@ namespace Vocaluxe.Base
CLog.StopBenchmark(2, "Sort Songs"); CLog.StopBenchmark(2, "Sort Songs");
Category = -1; Category = -1;
_SongsLoaded = true; _SongsLoaded = true;
if (CConfig.Renderer == ERenderer.TR_CONFIG_OPENGL)
{
CLog.StartBenchmark(2, "Load Cover");
for (int i = 0; i < _Songs.Count; i++)
{
CSong song = _Songs[i];
song.ReadNotes();
STexture texture = song.CoverTextureSmall;
song.CoverTextureBig = texture;
_CoverLoadIndex++;
}
_CoverLoaded = true;
CDataBase.CommitCovers();
CLog.StopBenchmark(2, "Load Cover");
}
CLog.StopBenchmark(1, "Load Songs "); CLog.StopBenchmark(1, "Load Songs ");
} }
public static void LoadCover(long WaitTime, int NumLoads) public static void LoadCover(long WaitTime, int NumLoads)
{ {
if (CConfig.Renderer == ERenderer.TR_CONFIG_OPENGL)
return; //should be removed as soon as the other renderer are ready for queque
if (!SongsLoaded) if (!SongsLoaded)
return; return;
+5
View File
@@ -625,6 +625,11 @@ namespace Vocaluxe.Lib.Draw
return AddTexture(W, H , ref PointerData); return AddTexture(W, H , ref PointerData);
} }
public STexture QuequeTexture(int W, int H, ref byte[] Data)
{
return AddTexture(W, H, ref Data);
}
public STexture AddTexture(int W, int H, ref byte[] Data) public STexture AddTexture(int W, int H, ref byte[] Data)
{ {
STexture texture = new STexture(-1); STexture texture = new STexture(-1);
+5
View File
@@ -400,6 +400,11 @@ namespace Vocaluxe.Lib.Draw
return new STexture(-1); return new STexture(-1);
} }
public STexture QuequeTexture(int W, int H, ref byte[] Data)
{
return AddTexture(W, H, ref Data);
}
public STexture AddTexture(int W, int H, ref byte[] Data) public STexture AddTexture(int W, int H, ref byte[] Data)
{ {
Bitmap bmp = new Bitmap(W, H); Bitmap bmp = new Bitmap(W, H);
+189 -39
View File
@@ -18,14 +18,21 @@ using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Draw namespace Vocaluxe.Lib.Draw
{ {
public struct SClientRect struct SClientRect
{ {
public Point location; public Point location;
public int width; public int width;
public int height; public int height;
}; };
struct STextureQueque
{
public int ID;
public int width;
public int height;
public byte[] data;
}
class COpenGL : Form, IDraw class COpenGL : Form, IDraw
{ {
#region private vars #region private vars
@@ -40,14 +47,18 @@ namespace Vocaluxe.Lib.Draw
private bool _fullscreen = false; private bool _fullscreen = false;
private List<STexture> _Textures; private List<STexture> _Textures;
private List<int> _IDs;
private List<int> _GLList; private List<int> _GLList;
private List<STextureQueque> _Queque;
private Object MutexTexture = new Object();
private int h = 1; private int h = 1;
private int w = 1; private int w = 1;
private int y = 0; private int y = 0;
private int x = 0; private int x = 0;
private bool _UsePBO = true; private bool _UsePBO = false;
#endregion private vars #endregion private vars
@@ -57,6 +68,13 @@ namespace Vocaluxe.Lib.Draw
_Textures = new List<STexture>(); _Textures = new List<STexture>();
_GLList = new List<int>(); _GLList = new List<int>();
_Queque = new List<STextureQueque>();
_IDs = new List<int>();
for (int i = 1; i < 1000000; i++)
{
_IDs.Add(i);
}
//Check AA Mode //Check AA Mode
CConfig.AAMode = (EAntiAliasingModes)CheckAntiAliasingMode((int)CConfig.AAMode); CConfig.AAMode = (EAntiAliasingModes)CheckAntiAliasingMode((int)CConfig.AAMode);
@@ -454,6 +472,8 @@ namespace Vocaluxe.Lib.Draw
if ((CSettings.bFullScreen && !_fullscreen) || (!CSettings.bFullScreen && _fullscreen)) if ((CSettings.bFullScreen && !_fullscreen) || (!CSettings.bFullScreen && _fullscreen))
ToggleFullScreen(); ToggleFullScreen();
CheckQueque();
if (CTime.IsRunning()) if (CTime.IsRunning())
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds()); delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
@@ -513,7 +533,7 @@ namespace Vocaluxe.Lib.Draw
int id = GL.GenTexture(); int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id); GL.BindTexture(TextureTarget.Texture2D, id);
texture.index = id; texture.ID = id;
texture.width = w; texture.width = w;
texture.height = h; texture.height = h;
@@ -537,21 +557,27 @@ namespace Vocaluxe.Lib.Draw
// Add to Texture List // Add to Texture List
texture.color = new SColorF(1f, 1f, 1f, 1f); texture.color = new SColorF(1f, 1f, 1f, 1f);
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f); texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
_Textures.Add(texture);
lock (MutexTexture)
{
texture.index = _IDs[0];
_IDs.RemoveAt(0);
_Textures.Add(texture);
}
return texture; return texture;
} }
public void CopyScreen(ref STexture Texture) public void CopyScreen(ref STexture Texture)
{ {
if (!_TextureExists(Texture) || (Texture.width != GetScreenWidth()) || (Texture.height != GetScreenHeight())) if (!_TextureExists(ref Texture) || (Texture.width != GetScreenWidth()) || (Texture.height != GetScreenHeight()))
{ {
RemoveTexture(ref Texture); RemoveTexture(ref Texture);
Texture = CopyScreen(); Texture = CopyScreen();
} }
else else
{ {
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.ID);
GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0,
(int)Texture.width, (int)Texture.height); (int)Texture.width, (int)Texture.height);
@@ -658,10 +684,6 @@ namespace Vocaluxe.Lib.Draw
if (bmp.Height == 0 || bmp.Width == 0) if (bmp.Height == 0 || bmp.Width == 0)
return texture; return texture;
int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id);
texture.index = id;
int MaxSize; int MaxSize;
switch (CConfig.TextureQuality) switch (CConfig.TextureQuality)
{ {
@@ -700,6 +722,10 @@ namespace Vocaluxe.Lib.Draw
h = MaxSize; h = MaxSize;
} }
int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id);
texture.ID = id;
texture.width = w; texture.width = w;
texture.height = h; texture.height = h;
@@ -711,7 +737,8 @@ namespace Vocaluxe.Lib.Draw
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height)); g.DrawImage(bmp, new Rectangle(0, 0, bmp2.Width, bmp2.Height));
g.Dispose();
texture.width_ratio = 1f; texture.width_ratio = 1f;
texture.height_ratio = 1f; texture.height_ratio = 1f;
@@ -742,6 +769,12 @@ namespace Vocaluxe.Lib.Draw
texture.color = new SColorF(1f, 1f, 1f, 1f); texture.color = new SColorF(1f, 1f, 1f, 1f);
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f); texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
texture.TexturePath = String.Empty; texture.TexturePath = String.Empty;
lock (MutexTexture)
{
texture.index = _IDs[0];
_IDs.RemoveAt(0);
}
_Textures.Add(texture); _Textures.Add(texture);
return texture; return texture;
@@ -768,7 +801,7 @@ namespace Vocaluxe.Lib.Draw
int id = GL.GenTexture(); int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id); GL.BindTexture(TextureTarget.Texture2D, id);
texture.index = id; texture.ID = id;
texture.width = W; texture.width = W;
texture.height = H; texture.height = H;
@@ -801,6 +834,12 @@ namespace Vocaluxe.Lib.Draw
texture.color = new SColorF(1f, 1f, 1f, 1f); texture.color = new SColorF(1f, 1f, 1f, 1f);
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f); texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
texture.TexturePath = String.Empty; texture.TexturePath = String.Empty;
lock (MutexTexture)
{
texture.index = _IDs[0];
_IDs.RemoveAt(0);
}
_Textures.Add(texture); _Textures.Add(texture);
return texture; return texture;
@@ -828,7 +867,7 @@ namespace Vocaluxe.Lib.Draw
int id = GL.GenTexture(); int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id); GL.BindTexture(TextureTarget.Texture2D, id);
texture.index = id; texture.ID = id;
texture.width = W; texture.width = W;
texture.height = H; texture.height = H;
@@ -861,14 +900,41 @@ namespace Vocaluxe.Lib.Draw
texture.color = new SColorF(1f, 1f, 1f, 1f); texture.color = new SColorF(1f, 1f, 1f, 1f);
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f); texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
texture.TexturePath = String.Empty; texture.TexturePath = String.Empty;
lock (MutexTexture)
{
texture.index = _IDs[0];
_IDs.RemoveAt(0);
}
_Textures.Add(texture); _Textures.Add(texture);
return texture; return texture;
} }
public STexture QuequeTexture(int W, int H, ref byte[] Data)
{
STexture texture = new STexture(-1);
STextureQueque queque = new STextureQueque();
queque.data = Data;
queque.height = H;
queque.width = W;
lock (MutexTexture)
{
texture.index = _IDs[0];
_IDs.RemoveAt(0);
queque.ID = texture.index;
_Queque.Add(queque);
_Textures.Add(texture);
}
return texture;
}
public bool UpdateTexture(ref STexture Texture, IntPtr Data) public bool UpdateTexture(ref STexture Texture, IntPtr Data)
{ {
if (_TextureExists(Texture)) if (_TextureExists(ref Texture))
{ {
if (_UsePBO) if (_UsePBO)
{ {
@@ -884,7 +950,7 @@ namespace Vocaluxe.Lib.Draw
GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer); GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer);
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.ID);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)Texture.width, (int)Texture.height, GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)Texture.width, (int)Texture.height,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
@@ -899,7 +965,7 @@ namespace Vocaluxe.Lib.Draw
} }
} }
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.ID);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)Texture.width, (int)Texture.height, GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)Texture.width, (int)Texture.height,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, Data); OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, Data);
@@ -923,7 +989,7 @@ namespace Vocaluxe.Lib.Draw
public bool UpdateTexture(ref STexture Texture, ref byte[] Data) public bool UpdateTexture(ref STexture Texture, ref byte[] Data)
{ {
if (_TextureExists(Texture)) if (_TextureExists(ref Texture))
{ {
if (_UsePBO) if (_UsePBO)
{ {
@@ -936,7 +1002,7 @@ namespace Vocaluxe.Lib.Draw
GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer); GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer);
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.ID);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)Texture.width, (int)Texture.height, GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)Texture.width, (int)Texture.height,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
@@ -952,7 +1018,7 @@ namespace Vocaluxe.Lib.Draw
} }
} }
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.ID);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)Texture.width, (int)Texture.height, GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, (int)Texture.width, (int)Texture.height,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, Data); OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, Data);
@@ -978,30 +1044,41 @@ namespace Vocaluxe.Lib.Draw
{ {
if ((Texture.index > 0) && (_Textures.Count > 0)) if ((Texture.index > 0) && (_Textures.Count > 0))
{ {
for (int i = 0; i < _Textures.Count; i++) lock (MutexTexture)
{ {
if (_Textures[i].index == Texture.index) for (int i = 0; i < _Textures.Count; i++)
{ {
GL.DeleteTexture(Texture.index); if (_Textures[i].index == Texture.index)
if (Texture.PBO > 0) {
GL.DeleteBuffers(1, ref Texture.PBO); _IDs.Add(Texture.index);
_Textures.RemoveAt(i);
Texture.index = -1; GL.DeleteTexture(Texture.ID);
break; if (Texture.PBO > 0)
GL.DeleteBuffers(1, ref Texture.PBO);
_Textures.RemoveAt(i);
Texture.index = -1;
Texture.ID = -1;
break;
}
} }
} }
} }
} }
private bool _TextureExists(STexture Texture) private bool _TextureExists(ref STexture Texture)
{ {
if ((Texture.index > 0) && (_Textures.Count > 0)) lock (MutexTexture)
{ {
for (int i = 0; i < _Textures.Count; i++) for (int i = 0; i < _Textures.Count; i++)
{ {
if (_Textures[i].index == Texture.index) if (Texture.index == _Textures[i].index)
{ {
return true; if (_Textures[i].ID > 0)
{
Texture = _Textures[i];
return true;
}
break;
} }
} }
} }
@@ -1044,14 +1121,14 @@ namespace Vocaluxe.Lib.Draw
if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y) if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y)
return; return;
if (_TextureExists(Texture)) if (_TextureExists(ref Texture))
{ {
int list = GL.GenLists(1); int list = GL.GenLists(1);
_GLList.Add(list); _GLList.Add(list);
GL.NewList(list, ListMode.Compile); GL.NewList(list, ListMode.Compile);
{ {
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.ID);
float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio; float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio;
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio; float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio;
@@ -1149,14 +1226,14 @@ namespace Vocaluxe.Lib.Draw
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end) public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end)
{ {
if (_TextureExists(Texture)) if (_TextureExists(ref Texture))
{ {
int list = GL.GenLists(1); int list = GL.GenLists(1);
_GLList.Add(list); _GLList.Add(list);
GL.NewList(list, ListMode.Compile); GL.NewList(list, ListMode.Compile);
{ {
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.ID);
GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.Blend);
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
@@ -1200,14 +1277,14 @@ namespace Vocaluxe.Lib.Draw
if (height > bounds.H) if (height > bounds.H)
height = bounds.H; height = bounds.H;
if (_TextureExists(Texture)) if (_TextureExists(ref Texture))
{ {
int list = GL.GenLists(1); int list = GL.GenLists(1);
_GLList.Add(list); _GLList.Add(list);
GL.NewList(list, ListMode.Compile); GL.NewList(list, ListMode.Compile);
{ {
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.ID);
float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio; float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio;
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio; float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio;
@@ -1291,6 +1368,79 @@ namespace Vocaluxe.Lib.Draw
{ {
return _Textures.Count; return _Textures.Count;
} }
private void CheckQueque()
{
lock (MutexTexture)
{
if (_Queque.Count == 0)
return;
STextureQueque q = _Queque[0];
STexture texture = new STexture(-1);
int index = -1;
for (int i = 0; i < _Textures.Count; i++)
{
if (_Textures[i].index == q.ID)
{
texture = _Textures[i];
index = i;
break;
}
}
if (texture.index < 1)
return;
if (_UsePBO)
{
try
{
GL.GenBuffers(1, out texture.PBO);
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO);
GL.BufferData(BufferTarget.PixelUnpackBuffer, (IntPtr)q.data.Length, IntPtr.Zero, BufferUsageHint.StreamDraw);
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
}
catch (Exception)
{
//throw;
_UsePBO = false;
}
}
int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id);
texture.ID = id;
texture.width = q.width;
texture.height = q.height;
texture.w2 = (float)MathHelper.NextPowerOfTwo(texture.width);
texture.h2 = (float)MathHelper.NextPowerOfTwo(texture.height);
texture.width_ratio = texture.width / texture.w2;
texture.height_ratio = texture.height / texture.h2;
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.w2, (int)texture.h2, 0,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, q.width, q.height,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, q.data);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.BindTexture(TextureTarget.Texture2D, 0);
// Add to Texture List
texture.color = new SColorF(1f, 1f, 1f, 1f);
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
texture.TexturePath = String.Empty;
_Textures[index] = texture;
_Queque.RemoveAt(0);
}
}
#endregion Textures #endregion Textures
#endregion implementation #endregion implementation
+5 -2
View File
@@ -67,6 +67,7 @@ namespace Vocaluxe.Lib.Draw
{ {
public int index; public int index;
public int PBO; public int PBO;
public int ID;
public string TexturePath; public string TexturePath;
@@ -85,10 +86,11 @@ namespace Vocaluxe.Lib.Draw
{ {
index = Index; index = Index;
PBO = 0; PBO = 0;
ID = -1;
TexturePath = String.Empty; TexturePath = String.Empty;
width = 0f; width = 1f;
height = 0f; height = 1f;
rect = new SRectF(0f, 0f, 1f, 1f, 0f); rect = new SRectF(0f, 0f, 1f, 1f, 0f);
w2 = 2f; w2 = 2f;
@@ -136,6 +138,7 @@ namespace Vocaluxe.Lib.Draw
STexture AddTexture(Bitmap Bitmap); STexture AddTexture(Bitmap Bitmap);
STexture AddTexture(int W, int H, IntPtr Data); STexture AddTexture(int W, int H, IntPtr Data);
STexture AddTexture(int W, int H, ref byte[] Data); STexture AddTexture(int W, int H, ref byte[] Data);
STexture QuequeTexture(int W, int H, ref byte[] Data);
bool UpdateTexture(ref STexture Texture, ref byte[] Data); bool UpdateTexture(ref STexture Texture, ref byte[] Data);
bool UpdateTexture(ref STexture Texture, IntPtr Data); bool UpdateTexture(ref STexture Texture, IntPtr Data);
+2
View File
@@ -135,6 +135,7 @@ namespace Vocaluxe.Screens
} }
CLog.StartBenchmark(3, "Load Cover"); CLog.StartBenchmark(3, "Load Cover");
_SongLoaderThread.IsBackground = true;
_SongLoaderThread.Start(); _SongLoaderThread.Start();
_timer.Start(); _timer.Start();
@@ -306,6 +307,7 @@ namespace Vocaluxe.Screens
_Finished = CVideo.VdFinished(_VideoStream); _Finished = CVideo.VdFinished(_VideoStream);
STexture tex = new STexture(-1); STexture tex = new STexture(-1);
tex.height = 0f;
CVideo.VdGetFrame(_VideoStream, ref tex, VideoTime, ref VideoTime); CVideo.VdGetFrame(_VideoStream, ref tex, VideoTime, ref VideoTime);
if (tex.height > 0) if (tex.height > 0)