diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index f1b0b6bc..5d1bb3e0 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -1344,21 +1344,19 @@ namespace Vocaluxe.Lib.Draw { lock (_MutexTexture) { - if (_Queue.Count == 0) - return; + while (_Queue.Count > 0) + { + STextureQueue q = _Queue[0]; + _Queue.RemoveAt(0); + if (!_Textures.ContainsKey(q.ID)) + continue; + STexture texture = _Textures[q.ID]; - STextureQueue q = _Queue[0]; - STexture texture; - if (_Textures.ContainsKey(q.ID)) - texture = _Textures[q.ID]; - else - return; + Texture t = _CreateTexture(q.Width, q.Height, q.Data, ref texture); + _D3DTextures[q.ID] = t; - Texture t = _CreateTexture(q.Width, q.Height, q.Data, ref texture); - _D3DTextures[q.ID] = t; - - _Textures[texture.Index] = texture; - _Queue.RemoveAt(0); + _Textures[texture.Index] = texture; + } } } diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index b866787c..83ce5c70 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -790,6 +790,19 @@ namespace Vocaluxe.Lib.Draw { STexture texture = new STexture(-1); + _CreateTexture(w, h, data, ref texture); + + lock (_MutexTexture) + { + texture.Index = _IDs.Dequeue(); + _Textures[texture.Index] = texture; + } + + return texture; + } + + private void _CreateTexture(int w, int h, byte[] data, ref STexture texture) + { if (_UsePBO) { try @@ -823,28 +836,20 @@ namespace Vocaluxe.Lib.Draw GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, 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.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.Linear); - //GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); + GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear); //GL.GenerateMipmap(GenerateMipmapTarget.Texture2D); - //GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); + GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); 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; - - lock (_MutexTexture) - { - texture.Index = _IDs.Dequeue(); - _Textures[texture.Index] = texture; - } - - return texture; } public STexture EnqueueTexture(int w, int h, byte[] data) @@ -1204,68 +1209,21 @@ namespace Vocaluxe.Lib.Draw { lock (_MutexTexture) { - if (_Queue.Count == 0) - return; - - STextureQueue q = _Queue[0]; - STexture texture = new STexture(-1); - if (_Textures.ContainsKey(q.ID)) - texture = _Textures[q.ID]; - - if (texture.Index < 1) - return; - - if (_UsePBO) + while (_Queue.Count > 0) { - 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; - } + STextureQueue q = _Queue[0]; + _Queue.RemoveAt(0); + STexture texture = new STexture(-1); + if (_Textures.ContainsKey(q.ID)) + texture = _Textures[q.ID]; + + if (texture.Index < 1) + continue; + + _CreateTexture(q.Width, q.Height, q.Data, ref texture); + + _Textures[texture.Index] = texture; } - - int id = GL.GenTexture(); - GL.BindTexture(TextureTarget.Texture2D, id); - texture.ID = id; - - texture.Width = q.Width; - texture.Height = q.Height; - texture.W2 = MathHelper.NextPowerOfTwo(texture.Width); - texture.H2 = MathHelper.NextPowerOfTwo(texture.Height); - - texture.WidthRatio = texture.Width / texture.W2; - texture.HeightRatio = texture.Height / texture.H2; - - GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)texture.W2, (int)texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero); - - GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, q.Width, q.Height, PixelFormat.Bgra, PixelType.UnsignedByte, q.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.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D); - - 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[texture.Index] = texture; - q.Data = null; - _Queue.RemoveAt(0); } } #endregion Textures diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 542e4d67..3c234a73 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -463,7 +463,7 @@ namespace VocaluxeLib.Menu.SongMenu SRectF vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z); SRectF vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f); - CBase.Drawing.DrawTexture(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds, false); + CBase.Drawing.DrawTexture(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds); CBase.Drawing.DrawTextureReflection(_Vidtex, vidRect, _Vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); } else