diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs
index d2b9b74d..41a323e3 100644
--- a/Vocaluxe/Base/CDraw.cs
+++ b/Vocaluxe/Base/CDraw.cs
@@ -196,13 +196,13 @@ namespace Vocaluxe.Base
public static void DrawTexture(CStatic staticBounds, STexture texture, EAspect aspect)
{
- if (texture.Height <= 0f)
+ if (texture.OrigSize.Height <= 0)
return;
RectangleF bounds = new RectangleF(staticBounds.Rect.X, staticBounds.Rect.Y, staticBounds.Rect.W, staticBounds.Rect.H);
RectangleF rect;
- CHelper.SetRect(bounds, out rect, (float)texture.Width / texture.Height, aspect);
+ CHelper.SetRect(bounds, out rect, texture.OrigAspect, aspect);
DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, staticBounds.Rect.Z),
texture.Color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f));
}
diff --git a/Vocaluxe/Base/CVideo.cs b/Vocaluxe/Base/CVideo.cs
index a8926164..10c59af0 100644
--- a/Vocaluxe/Base/CVideo.cs
+++ b/Vocaluxe/Base/CVideo.cs
@@ -171,10 +171,10 @@ namespace Vocaluxe.Base
float videoTime = _VideoTimer.ElapsedMilliseconds / 1000f;
_Finished = CVideo.Finished(_VideoStream);
- STexture tex = new STexture(-1) {Height = 0};
+ STexture tex = new STexture(-1);
CVideo.GetFrame(_VideoStream, ref tex, videoTime, out videoTime);
- if (tex.Height > 0)
+ if (tex.Index > 0)
{
CDraw.RemoveTexture(ref _VideoTexture);
_VideoTexture = tex;
@@ -182,7 +182,7 @@ namespace Vocaluxe.Base
}
RectangleF bounds = new RectangleF(0f, 0f, CSettings.RenderW, CSettings.RenderH);
RectangleF rect;
- CHelper.SetRect(bounds, out rect, (float)_VideoTexture.Width / _VideoTexture.Height, EAspect.Crop);
+ CHelper.SetRect(bounds, out rect, _VideoTexture.OrigAspect, EAspect.Crop);
CDraw.DrawTexture(_VideoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CSettings.ZFar / 4));
}
diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs
index 7aff044b..48f451bc 100644
--- a/Vocaluxe/Lib/Draw/CDirect3D.cs
+++ b/Vocaluxe/Lib/Draw/CDirect3D.cs
@@ -678,23 +678,21 @@ namespace Vocaluxe.Lib.Draw
///
public STexture CopyScreen()
{
- STexture texture = new STexture(-1);
+ STexture texture = new STexture(-1, _W, _H);
+ texture.W2 = _CheckForNextPowerOf2(_W);
+ texture.H2 = _CheckForNextPowerOf2(_H);
+
+ texture.WidthRatio = (float)texture.OrigSize.Width / texture.W2;
+ texture.HeightRatio = (float)texture.OrigSize.Height / texture.H2;
Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
- Texture tex = new Texture(_Device, _PresentParameters.BackBufferWidth, _PresentParameters.BackBufferHeight, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
+ Texture tex = new Texture(_Device, _W, _H, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
Surface textureSurface = tex.GetSurfaceLevel(0);
- Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0);
+ Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0, new Rectangle(0, 0, _W, _H), new Rectangle(0, 0, _W, _H));
backbufferSurface.Dispose();
lock (_MutexTexture)
{
_D3DTextures.Add(_IDs.Peek(), tex);
-
- texture.Color = new SColorF(1f, 1f, 1f, 1f);
- texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f);
- texture.Width = _W;
- texture.Height = _H;
- texture.W2 = _CheckForNextPowerOf2(texture.Width);
- texture.H2 = _CheckForNextPowerOf2(texture.Height);
texture.Index = _IDs.Dequeue();
_Textures[texture.Index] = texture;
@@ -708,7 +706,8 @@ namespace Vocaluxe.Lib.Draw
/// The texture in which the frame is copied to
public void CopyScreen(ref STexture texture)
{
- if (!_TextureExists(ref texture) || texture.Width != GetScreenWidth() || texture.Height != GetScreenHeight())
+ //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())
{
RemoveTexture(ref texture);
texture = CopyScreen();
@@ -924,9 +923,9 @@ namespace Vocaluxe.Lib.Draw
public STexture AddTexture(int w, int h, byte[] data)
{
- STexture texture = new STexture(-1);
+ STexture texture = new STexture(-1, w, h);
- Texture t = _CreateTexture(w, h, data, ref texture);
+ Texture t = _CreateTexture(data, ref texture);
lock (_MutexTexture)
{
@@ -937,10 +936,10 @@ namespace Vocaluxe.Lib.Draw
return texture;
}
- private Texture _CreateTexture(int w, int h, byte[] data, ref STexture texture)
+ private Texture _CreateTexture(byte[] data, ref STexture texture)
{
- texture.Width = w;
- texture.Height = h;
+ int w = texture.OrigSize.Width;
+ int h = texture.OrigSize.Height;
texture.W2 = _CheckForNextPowerOf2(w);
texture.H2 = _CheckForNextPowerOf2(h);
texture.WidthRatio = (float)w / texture.W2;
@@ -957,14 +956,12 @@ namespace Vocaluxe.Lib.Draw
int rowWidth = 4 * texture.W2;
for (int i = 0; i + rowWidth <= data.Length; i += 4 * w)
{
- rect.Data.Write(data, i, rowWidth);
+ rect.Data.Write(data, i, 4 * w);
rect.Data.Position = rect.Data.Position - rowWidth;
rect.Data.Position += rect.Pitch;
}
t.UnlockRectangle(0);
- texture.Color = new SColorF(1f, 1f, 1f, 1f);
- texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f);
texture.TexturePath = String.Empty;
}
catch (Exception)
@@ -978,12 +975,9 @@ namespace Vocaluxe.Lib.Draw
public STexture EnqueueTexture(int w, int h, byte[] data)
{
- STexture texture = new STexture(-1);
+ STexture texture = new STexture(-1, w, h);
STextureQueue queue = new STextureQueue {Data = data, Height = h, Width = w};
- texture.Height = h;
- texture.Width = w;
-
lock (_MutexTexture)
{
_D3DTextures.Add(_IDs.Peek(), null);
@@ -1010,37 +1004,17 @@ namespace Vocaluxe.Lib.Draw
lock (_MutexTexture)
{
DataRectangle rect = _D3DTextures[texture.Index].LockRectangle(0, LockFlags.Discard);
- int w = texture.Width;
- for (int i = 0; i < data.Length; i += 4 * w)
+ 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 -= 4 * w;
+ rect.Data.Position = rect.Data.Position - rowWidth;
rect.Data.Position += rect.Pitch;
}
_D3DTextures[texture.Index].UnlockRectangle(0);
}
-
- //Flamefire: Unneccesary as height can not be changed by this! (Texture gets copied)
- //Texture.height_ratio = Texture.height / CheckForNextPowerOf2(Texture.height);
- //Texture.width_ratio = Texture.width / CheckForNextPowerOf2(Texture.width);
return true;
-
- /*Surface s = _D3DTextures[Texture.index].GetSurfaceLevel(0);
- DataRectangle d = s.LockRectangle(LockFlags.Discard);
-
- for (int i = 0; i < Data.Length; )
- {
- d.Data.Write(Data, i, 4 * (int)Texture.width);
- i += 4 * (int)Texture.width;
- d.Data.Position = d.Data.Position - 4 * (int)Texture.width;
- d.Data.Position += d.Pitch;
- }
-
- Texture.height_ratio = Texture.height / NextPowerOfTwo(Texture.height);
- Texture.width_ratio = Texture.width / NextPowerOfTwo(Texture.width);
-
- s.UnlockRectangle();
- return true; */
}
return false;
}
@@ -1351,11 +1325,15 @@ namespace Vocaluxe.Lib.Draw
if (!_Textures.ContainsKey(q.ID))
continue;
STexture texture = _Textures[q.ID];
+ if (q.Width == texture.OrigSize.Width && q.Height == texture.OrigSize.Height)
+ {
+ Texture t = _CreateTexture(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;
+ _Textures[texture.Index] = texture;
+ }
+ else
+ CLog.LogError("Wrong texture size in queue!");
}
}
}
diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs
index 1a8a5f80..ade2012b 100644
--- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs
+++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs
@@ -291,18 +291,11 @@ namespace Vocaluxe.Lib.Draw
public STexture CopyScreen()
{
- STexture texture = new STexture(0);
Bitmap bmp = new Bitmap(_Backbuffer);
_Bitmaps.Add(bmp);
-
- texture.Index = _Bitmaps.Count - 1;
-
- texture.Width = bmp.Width;
- texture.Height = bmp.Height;
+ STexture texture = new STexture(_Bitmaps.Count - 1, bmp.Width, bmp.Height);
// Add to Texture List
- texture.Color = new SColorF(1f, 1f, 1f, 1f);
- texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f);
_Textures.Add(texture);
return texture;
@@ -310,7 +303,7 @@ namespace Vocaluxe.Lib.Draw
public void CopyScreen(ref STexture texture)
{
- if (texture.Index == 0 || texture.Width != GetScreenWidth() || texture.Height != GetScreenHeight())
+ if (texture.Index == 0 || texture.W2 != GetScreenWidth() || texture.H2 != GetScreenHeight())
{
RemoveTexture(ref texture);
texture = CopyScreen();
@@ -344,10 +337,9 @@ namespace Vocaluxe.Lib.Draw
{
Bitmap bmp2 = new Bitmap(bmp);
_Bitmaps.Add(bmp2);
- STexture texture = new STexture {Index = _Bitmaps.Count - 1, Width = bmp.Width, Height = bmp.Height, Color = new SColorF(1f, 1f, 1f, 1f)};
+ STexture texture = new STexture(_Bitmaps.Count - 1, bmp.Width, bmp.Height);
// Add to Texture List
- texture.Rect = new SRectF(0f, 0f, texture.Width, texture.Height, 0f);
texture.TexturePath = String.Empty;
_Textures.Add(texture);
diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs
index 653dc770..0047ecf1 100644
--- a/Vocaluxe/Lib/Draw/COpenGL.cs
+++ b/Vocaluxe/Lib/Draw/COpenGL.cs
@@ -490,23 +490,20 @@ namespace Vocaluxe.Lib.Draw
public STexture CopyScreen()
{
- STexture texture = new STexture(-1);
-
+ STexture texture = new STexture(-1, _W, _H);
int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id);
texture.ID = id;
- texture.Width = _W;
- texture.Height = _H;
- texture.W2 = MathHelper.NextPowerOfTwo(texture.Width);
- texture.H2 = MathHelper.NextPowerOfTwo(texture.Height);
+ texture.W2 = MathHelper.NextPowerOfTwo(texture.OrigSize.Width);
+ texture.H2 = MathHelper.NextPowerOfTwo(texture.OrigSize.Height);
- texture.WidthRatio = (float)texture.Width / texture.W2;
- texture.HeightRatio = (float)texture.Height / texture.H2;
+ texture.WidthRatio = (float)texture.OrigSize.Width / texture.W2;
+ texture.HeightRatio = (float)texture.OrigSize.Height / texture.H2;
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
- GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, _X, _Y, texture.Width, texture.Height);
+ GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, _X, _Y, _W, _H);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
@@ -514,8 +511,6 @@ namespace Vocaluxe.Lib.Draw
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);
lock (_MutexTexture)
{
@@ -528,7 +523,8 @@ namespace Vocaluxe.Lib.Draw
public void CopyScreen(ref STexture texture)
{
- if (!_TextureExists(ref texture) || Math.Abs(texture.Width - GetScreenWidth()) > 1 || Math.Abs(texture.Height - GetScreenHeight()) > 1)
+ //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())
{
RemoveTexture(ref texture);
texture = CopyScreen();
@@ -537,7 +533,7 @@ namespace Vocaluxe.Lib.Draw
{
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
- GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, texture.Width, texture.Height);
+ GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, texture.OrigSize.Width, texture.OrigSize.Height);
GL.BindTexture(TextureTarget.Texture2D, 0);
}
@@ -679,10 +675,8 @@ namespace Vocaluxe.Lib.Draw
public STexture AddTexture(Bitmap bmp)
{
- STexture texture = new STexture(-1);
-
if (bmp.Height == 0 || bmp.Width == 0)
- return texture;
+ return new STexture(-1);
int maxSize;
switch (CConfig.TextureQuality)
@@ -726,13 +720,12 @@ namespace Vocaluxe.Lib.Draw
h = maxSize;
}
+ STexture texture = new STexture(-1, w, h);
+
int id = GL.GenTexture();
GL.BindTexture(TextureTarget.Texture2D, id);
texture.ID = id;
- texture.Width = w;
- texture.Height = h;
-
texture.W2 = MathHelper.NextPowerOfTwo(w);
texture.H2 = MathHelper.NextPowerOfTwo(h);
try
@@ -773,8 +766,6 @@ namespace Vocaluxe.Lib.Draw
// 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)
@@ -788,9 +779,9 @@ namespace Vocaluxe.Lib.Draw
public STexture AddTexture(int w, int h, byte[] data)
{
- STexture texture = new STexture(-1);
+ STexture texture = new STexture(-1, w, h);
- _CreateTexture(w, h, data, ref texture);
+ _CreateTexture(data, ref texture);
lock (_MutexTexture)
{
@@ -801,8 +792,10 @@ namespace Vocaluxe.Lib.Draw
return texture;
}
- private void _CreateTexture(int w, int h, byte[] data, ref STexture texture)
+ private void _CreateTexture(byte[] data, ref STexture texture)
{
+ int w = texture.OrigSize.Width;
+ int h = texture.OrigSize.Height;
if (_UsePBO)
{
try
@@ -823,13 +816,11 @@ namespace Vocaluxe.Lib.Draw
GL.BindTexture(TextureTarget.Texture2D, id);
texture.ID = id;
- texture.Width = w;
- texture.Height = h;
- texture.W2 = MathHelper.NextPowerOfTwo(texture.Width);
- texture.H2 = MathHelper.NextPowerOfTwo(texture.Height);
+ texture.W2 = MathHelper.NextPowerOfTwo(w);
+ texture.H2 = MathHelper.NextPowerOfTwo(h);
- texture.WidthRatio = (float)texture.Width / texture.W2;
- texture.HeightRatio = (float)texture.Height / texture.H2;
+ texture.WidthRatio = (float)w / texture.W2;
+ texture.HeightRatio = (float)h / texture.H2;
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
@@ -847,19 +838,14 @@ namespace Vocaluxe.Lib.Draw
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;
}
public STexture EnqueueTexture(int w, int h, byte[] data)
{
- STexture texture = new STexture(-1);
+ STexture texture = new STexture(-1, w, h);
STextureQueue queue = new STextureQueue {Data = data, Height = h, Width = w};
- texture.Height = h;
- texture.Width = w;
-
lock (_MutexTexture)
{
texture.Index = _IDs.Dequeue();
@@ -887,7 +873,7 @@ namespace Vocaluxe.Lib.Draw
GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer);
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
- GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.Width, texture.Height, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
+ 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);
@@ -897,7 +883,7 @@ namespace Vocaluxe.Lib.Draw
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
- GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.Width, texture.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data);
+ 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);
@@ -976,100 +962,100 @@ namespace Vocaluxe.Lib.Draw
if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y)
return;
- if (_TextureExists(ref texture))
+ if (!_TextureExists(ref texture))
+ return;
+
+ 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 * 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;
+ 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;
+
+ GL.Enable(EnableCap.Blend);
+ GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
+
+ 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 * 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;
- 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;
-
- GL.Enable(EnableCap.Blend);
- GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
-
- 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);
- }
-
- if (!mirrored)
- {
- GL.Begin(BeginMode.Quads);
-
- GL.TexCoord2(x1, y1);
- GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset);
-
- GL.TexCoord2(x1, y2);
- GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset);
-
- GL.TexCoord2(x2, y2);
- GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset);
-
- GL.TexCoord2(x2, y1);
- GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset);
-
- GL.End();
- }
- else
- {
- GL.Begin(BeginMode.Quads);
-
- GL.TexCoord2(x2, y2);
- GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset);
-
- GL.TexCoord2(x2, y1);
- GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset);
-
- GL.TexCoord2(x1, y1);
- GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset);
-
- 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);
}
+
+ if (!mirrored)
+ {
+ GL.Begin(BeginMode.Quads);
+
+ GL.TexCoord2(x1, y1);
+ GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset);
+
+ GL.TexCoord2(x1, y2);
+ GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset);
+
+ GL.TexCoord2(x2, y2);
+ GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset);
+
+ GL.TexCoord2(x2, y1);
+ GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset);
+
+ GL.End();
+ }
+ else
+ {
+ GL.Begin(BeginMode.Quads);
+
+ GL.TexCoord2(x2, y2);
+ GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset);
+
+ GL.TexCoord2(x2, y1);
+ GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset);
+
+ GL.TexCoord2(x1, y1);
+ GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset);
+
+ 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);
}
public void DrawTexture(STexture texture, SRectF rect, SColorF color, float begin, float end)
@@ -1220,9 +1206,14 @@ namespace Vocaluxe.Lib.Draw
if (texture.Index < 1)
continue;
- _CreateTexture(q.Width, q.Height, q.Data, ref texture);
+ if (q.Width == texture.OrigSize.Width && q.Height == texture.OrigSize.Height)
+ {
+ _CreateTexture(q.Data, ref texture);
- _Textures[texture.Index] = texture;
+ _Textures[texture.Index] = texture;
+ }
+ else
+ CLog.LogError("Wrong texture size in queue!");
}
}
}
diff --git a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs
index 7beeb29c..77f6592a 100644
--- a/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs
+++ b/Vocaluxe/Lib/Video/CVideoDecoderFFmpeg.cs
@@ -661,7 +661,7 @@ namespace Vocaluxe.Lib.Video
if (num >= 0)
{
- if (frame.Index == -1 || _Width != frame.Width || _Height != frame.Height)
+ if (frame.Index == -1 || _Width != frame.OrigSize.Width || _Height != frame.OrigSize.Height)
{
CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, _FrameBuffer[num].Data);
diff --git a/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs b/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs
index 5bfcf8a5..4c411cc2 100644
--- a/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs
+++ b/Vocaluxe/Lib/Video/CVideoDecoderGstreamer.cs
@@ -121,7 +121,7 @@ namespace Vocaluxe.Lib.Video
{
if (data == null)
return;
- if (frame.Index == -1 || width != frame.Width || height != frame.Height || data.Length == 0)
+ if (frame.Index == -1 || width != frame.OrigSize.Width || height != frame.OrigSize.Height || data.Length == 0)
{
CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(width, height, data);
diff --git a/Vocaluxe/Lib/Webcam/CAForgeNet.cs b/Vocaluxe/Lib/Webcam/CAForgeNet.cs
index 14ef1782..e2589dfe 100644
--- a/Vocaluxe/Lib/Webcam/CAForgeNet.cs
+++ b/Vocaluxe/Lib/Webcam/CAForgeNet.cs
@@ -56,7 +56,7 @@ namespace Vocaluxe.Lib.Webcam
{
lock (_MutexData)
{
- if (frame.Index == -1 || _Width != frame.Width || _Height != frame.Height)
+ if (frame.Index == -1 || _Width != frame.OrigSize.Width || _Height != frame.OrigSize.Height)
{
CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, _Data);
diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs
index 3f2367bd..e5d3e81c 100644
--- a/Vocaluxe/Screens/CScreenCredits.cs
+++ b/Vocaluxe/Screens/CScreenCredits.cs
@@ -50,8 +50,8 @@ namespace Vocaluxe.Screens
_Image = image;
_ImgDot = imgDot;
_Particle = particle;
- _ParticleOffsetX = (int)Math.Round(particleOffsetX * image.Rect.W / image.Texture.Width - particle.Rect.W / 2);
- _ParticleOffsetY = (int)Math.Round(particleOffsetY * image.Rect.H / image.Texture.Height - particle.Rect.H / 2);
+ _ParticleOffsetX = (int)Math.Round(particleOffsetX * image.Rect.W / image.Texture.OrigSize.Width - particle.Rect.W / 2);
+ _ParticleOffsetY = (int)Math.Round(particleOffsetY * image.Rect.H / image.Texture.OrigSize.Height - particle.Rect.H / 2);
Active = true;
}
@@ -317,7 +317,8 @@ namespace Vocaluxe.Screens
base.OnShow();
//Vocaluxe-Logo
- _Logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((float)(CSettings.RenderW - _TexLogo.Width) / 2, -270, _TexLogo.Width, _TexLogo.Height, -2));
+ _Logo = GetNewStatic(_TexLogo, new SColorF(1, 1, 1, 1),
+ new SRectF((float)(CSettings.RenderW - _TexLogo.OrigSize.Width) / 2, -270, _TexLogo.OrigSize.Width, _TexLogo.OrigSize.Height, -2));
//Little stars for logo
int numstars = (int)(_Logo.Rect.W * 0.25f / 2f);
diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs
index c6dbd9d4..166dd841 100644
--- a/Vocaluxe/Screens/CScreenSing.cs
+++ b/Vocaluxe/Screens/CScreenSing.cs
@@ -469,7 +469,7 @@ namespace Vocaluxe.Screens
background = _Background;
RectangleF bounds = new RectangleF(0, 0, CSettings.RenderW, CSettings.RenderH);
RectangleF rect;
- CHelper.SetRect(bounds, out rect, (float)background.Width / background.Height, aspect);
+ 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));
diff --git a/VocaluxeLib/Menu/CBackground.cs b/VocaluxeLib/Menu/CBackground.cs
index c63aeb24..073325ea 100644
--- a/VocaluxeLib/Menu/CBackground.cs
+++ b/VocaluxeLib/Menu/CBackground.cs
@@ -203,11 +203,11 @@ namespace VocaluxeLib.Menu
private bool _DrawTexture()
{
STexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
- if (texture.Height > 0)
+ if (texture.OrigSize.Height > 1)
{
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect;
- CHelper.SetRect(bounds, out rect, (float)texture.Width / texture.Height, EAspect.Crop);
+ CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4));
return true;
@@ -218,11 +218,11 @@ namespace VocaluxeLib.Menu
private bool _DrawVideo()
{
STexture videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID);
- if (videoTexture.Height > 0)
+ if (videoTexture.OrigSize.Height > 1)
{
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect;
- CHelper.SetRect(bounds, out rect, (float)videoTexture.Width / videoTexture.Height, EAspect.Crop);
+ CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(videoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4));
return true;
@@ -233,11 +233,11 @@ namespace VocaluxeLib.Menu
private bool _DrawBackgroundMusicVideo()
{
STexture videoTexture = CBase.BackgroundMusic.GetVideoTexture();
- if (videoTexture.Height > 0)
+ if (videoTexture.OrigSize.Height > 1)
{
RectangleF bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect;
- CHelper.SetRect(bounds, out rect, (float)videoTexture.Width / videoTexture.Height, EAspect.Crop);
+ CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(videoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4));
return true;
diff --git a/VocaluxeLib/Menu/CStatic.cs b/VocaluxeLib/Menu/CStatic.cs
index d5a1f6f3..3a56a25f 100644
--- a/VocaluxeLib/Menu/CStatic.cs
+++ b/VocaluxeLib/Menu/CStatic.cs
@@ -253,7 +253,7 @@ namespace VocaluxeLib.Menu
{
RectangleF bounds2 = new RectangleF(bounds.X, bounds.Y, bounds.W, bounds.H);
RectangleF rect2;
- CHelper.SetRect(bounds2, out rect2, (float)texture.Width / texture.Height, aspect);
+ CHelper.SetRect(bounds2, out rect2, texture.OrigAspect, aspect);
rect.X = rect2.X;
rect.Y = rect2.Y;
diff --git a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs
index 4fab9280..f5e68c61 100644
--- a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs
+++ b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs
@@ -481,7 +481,7 @@ namespace VocaluxeLib.Menu.SingNotes
//Width of each of the ends (round parts)
//Need 2 of them so use minimum
- float endsW = Math.Min(noteRect.H * noteBegin.Width / noteBegin.Height, noteRect.W / 2);
+ float endsW = Math.Min(noteRect.H * noteBegin.OrigAspect, noteRect.W / 2);
CBase.Drawing.DrawTexture(noteBegin, new SRectF(noteRect.X, noteRect.Y, endsW, noteRect.H, noteRect.Z), color);
@@ -526,7 +526,7 @@ namespace VocaluxeLib.Menu.SingNotes
STexture noteBackgroundMiddle = CBase.Theme.GetSkinTexture(_Theme.SkinBackgroundMiddleName, _PartyModeID);
STexture noteBackgroundEnd = CBase.Theme.GetSkinTexture(_Theme.SkinBackgroundRightName, _PartyModeID);
- float dx = noteBackgroundBegin.Width * r.H / noteBackgroundBegin.Height;
+ float dx = r.H * noteBackgroundBegin.OrigAspect;
if (2 * dx > r.W)
dx = r.W / 2;
@@ -618,7 +618,7 @@ namespace VocaluxeLib.Menu.SingNotes
);
STexture noteBegin = CBase.Theme.GetSkinTexture(_Theme.SkinLeftName, _PartyModeID);
- float dx = noteBegin.Width * r.H / noteBegin.Height;
+ float dx = r.H * noteBegin.OrigAspect;
if (2 * dx > r.W)
dx = r.W / 2;
diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs
index b5a65b20..cad9f32f 100644
--- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs
+++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs
@@ -459,7 +459,7 @@ namespace VocaluxeLib.Menu.SongMenu
_CoverBig.Draw(1f, EAspect.Crop);
RectangleF bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H);
RectangleF rect;
- CHelper.SetRect(bounds, out rect, (float)_Vidtex.Width / _Vidtex.Height, EAspect.Crop);
+ CHelper.SetRect(bounds, out rect, _Vidtex.OrigAspect, EAspect.Crop);
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);
diff --git a/VocaluxeLib/Menu/Structs.cs b/VocaluxeLib/Menu/Structs.cs
index 59ce099c..9af269b8 100644
--- a/VocaluxeLib/Menu/Structs.cs
+++ b/VocaluxeLib/Menu/Structs.cs
@@ -108,32 +108,47 @@ namespace VocaluxeLib.Menu
public string TexturePath;
- public int Width;
- public int Height;
+ ///
+ /// Original size (e.g. of bmp)
+ ///
+ public readonly Size OrigSize;
+ public float OrigAspect
+ {
+ get { return (float)OrigSize.Width / OrigSize.Height; }
+ }
+
+ ///
+ /// Current size when drawn
+ ///
public SRectF Rect;
- public int W2; //power of 2 width
- public int H2; //power of 2 height
+ ///
+ /// Internal texture width (on device), a power of 2 if necessary
+ ///
+ public int W2;
+ ///
+ /// Internal texture height (on device), a power of 2 if necessary
+ ///
+ public int H2;
public float WidthRatio;
public float HeightRatio;
public SColorF Color;
- public STexture(int index)
+ public STexture(int index, int origWidth = 1, int origHeight = 1)
{
Index = index;
PBO = 0;
ID = -1;
TexturePath = String.Empty;
- Width = 1;
- Height = 1;
- Rect = new SRectF(0f, 0f, 1f, 1f, 0f);
+ OrigSize = new Size(origWidth, origHeight);
+ Rect = new SRectF(0f, 0f, origWidth, origHeight, 0f);
- W2 = 1;
- H2 = 1;
- WidthRatio = 0.5f;
- HeightRatio = 0.5f;
+ W2 = origWidth;
+ H2 = origHeight;
+ WidthRatio = 1;
+ HeightRatio = 1;
Color = new SColorF(1f, 1f, 1f, 1f);
}