diff --git a/Output/Themes/Ambient/Screens/ScreenNames.xml b/Output/Themes/Ambient/Screens/ScreenNames.xml
index 0daa48e9..3fff5c64 100644
--- a/Output/Themes/Ambient/Screens/ScreenNames.xml
+++ b/Output/Themes/Ambient/Screens/ScreenNames.xml
@@ -534,7 +534,7 @@
TextColor
- TextColor
+ TextSColor
32,00
diff --git a/Output/Themes/Ambient/Screens/ScreenSing.xml b/Output/Themes/Ambient/Screens/ScreenSing.xml
index 0e206c1d..5c85960a 100644
--- a/Output/Themes/Ambient/Screens/ScreenSing.xml
+++ b/Output/Themes/Ambient/Screens/ScreenSing.xml
@@ -119,10 +119,7 @@
9
- 0,68
- 0,89
- 0,97
- 0,40
+ TimeBar
@@ -138,7 +135,7 @@
9
- StaticColor
+ TimeBarSentence
diff --git a/Output/Themes/Ambient/Skin Blue.xml b/Output/Themes/Ambient/Skin Blue.xml
index 585aff80..33203fdf 100644
--- a/Output/Themes/Ambient/Skin Blue.xml
+++ b/Output/Themes/Ambient/Skin Blue.xml
@@ -178,6 +178,18 @@
0,300
1,000
+
+ 0,800
+ 0,950
+ 1,000
+ 0,500
+
+
+ 0,800
+ 0,950
+ 1,000
+ 0,850
+
[Blue]BG_Default.png
diff --git a/Output/Themes/Ambient/Skin Green.xml b/Output/Themes/Ambient/Skin Green.xml
index c1fb83b1..3a59c0b6 100644
--- a/Output/Themes/Ambient/Skin Green.xml
+++ b/Output/Themes/Ambient/Skin Green.xml
@@ -178,6 +178,18 @@
0,300
1,000
+
+ 0,800
+ 0,950
+ 1,000
+ 0,500
+
+
+ 0,800
+ 0,950
+ 1,000
+ 0,850
+
[Green]BG_Default.png
diff --git a/Output/Themes/Ambient/Skin Red.xml b/Output/Themes/Ambient/Skin Red.xml
index bf15aab2..25b2f9fd 100644
--- a/Output/Themes/Ambient/Skin Red.xml
+++ b/Output/Themes/Ambient/Skin Red.xml
@@ -178,6 +178,18 @@
0,300
1,000
+
+ 0,800
+ 0,950
+ 1,000
+ 0,500
+
+
+ 0,800
+ 0,950
+ 1,000
+ 0,850
+
[Red]BG_Default.png
diff --git a/Output/Themes/Ambient/Skin Yellow.xml b/Output/Themes/Ambient/Skin Yellow.xml
index a72e0825..25c7bb21 100644
--- a/Output/Themes/Ambient/Skin Yellow.xml
+++ b/Output/Themes/Ambient/Skin Yellow.xml
@@ -178,6 +178,18 @@
0,300
1,000
+
+ 0,800
+ 0,950
+ 1,000
+ 0,500
+
+
+ 0,800
+ 0,950
+ 1,000
+ 0,850
+
[Yellow]BG_Default.png
diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs
index b4512ecc..6beb8278 100644
--- a/Vocaluxe/Base/CConfig.cs
+++ b/Vocaluxe/Base/CConfig.cs
@@ -162,7 +162,7 @@ namespace Vocaluxe.Base
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
// Graphics
- public static ERenderer Renderer = ERenderer.TR_CONFIG_OPENGL;
+ public static ERenderer Renderer = ERenderer.TR_CONFIG_DIRECT3D;
public static ETextureQuality TextureQuality = ETextureQuality.TR_CONFIG_TEXTURE_MEDIUM;
public static float MaxFPS = 60f;
diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs
index d17bc699..19906005 100644
--- a/Vocaluxe/Base/CSettings.cs
+++ b/Vocaluxe/Base/CSettings.cs
@@ -47,7 +47,7 @@ namespace Vocaluxe.Base
public const int iVersionSub = 0; // steps
public const ERevision VersionRevision = ERevision.Beta;
- public const int iBuild = 55; // Increase on every published version! Never Reset!
+ public const int iBuild = 57; // Increase on every published version! Never Reset!
public const int iDatabaseHighscoreVersion = 1;
public const int iDatabaseCoverVersion = 1;
@@ -61,6 +61,7 @@ namespace Vocaluxe.Base
public static int zFar = 100;
public static bool bFullScreen = false;
+ public static int iVertexBufferElements = 10000;
public const string sIcon = "Vocaluxe.ico";
public const string sLogo = "Logo.png";
diff --git a/Vocaluxe/Base/CSound.cs b/Vocaluxe/Base/CSound.cs
index ff4a30ff..e7956ecb 100644
--- a/Vocaluxe/Base/CSound.cs
+++ b/Vocaluxe/Base/CSound.cs
@@ -497,7 +497,7 @@ namespace Vocaluxe.Base
{
get
{
- long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency;
+ double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
long ticks = _Timer.ElapsedTicks;
float dt = _Timer.ElapsedMilliseconds / 1000f;
@@ -577,7 +577,7 @@ namespace Vocaluxe.Base
{
get
{
- long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency;
+ double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
long ticks = _STimer.ElapsedTicks;
float dt = _STimer.ElapsedMilliseconds / 1000f;
@@ -613,7 +613,7 @@ namespace Vocaluxe.Base
{
_STimer.Stop();
- long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency;
+ double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
long ticks = _STimer.ElapsedTicks;
float dt = _STimer.ElapsedMilliseconds / 1000f;
diff --git a/Vocaluxe/Base/CUtility.cs b/Vocaluxe/Base/CUtility.cs
index ef4e94dd..909dc798 100644
--- a/Vocaluxe/Base/CUtility.cs
+++ b/Vocaluxe/Base/CUtility.cs
@@ -119,7 +119,7 @@ namespace Vocaluxe.Base
{
private static Stopwatch _Stopwatch = new Stopwatch();
private static float _fps = 0.0f;
- private static long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency;
+ private static double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
public static void Reset()
{
@@ -149,7 +149,7 @@ namespace Vocaluxe.Base
{
long ticks = _Stopwatch.ElapsedTicks;
if (Stopwatch.IsHighResolution && ticks != 0)
- return (float)(((double)nanosecPerTick * (double)ticks) / (1000.0 * 1000.0));
+ return (float)((nanosecPerTick * ticks) / (1000.0 * 1000.0));
else
return (float)_Stopwatch.ElapsedMilliseconds;
}
diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs
index 68e62185..07fb2e5c 100644
--- a/Vocaluxe/Lib/Draw/CDirect3D.cs
+++ b/Vocaluxe/Lib/Draw/CDirect3D.cs
@@ -34,22 +34,25 @@ namespace Vocaluxe.Lib.Draw
private Size _OldSize;
private Size _SizeBeforeMinimize;
- private List _Textures;
+ private Dictionary _Textures;
private List _D3DTextures;
private List _Queque;
private Object MutexTexture = new Object();
private VertexBuffer _VertexBuffer;
+ private IndexBuffer _IndexBuffer;
private int h = 1;
private int w = 1;
private int y = 0;
private int x = 0;
- private Bitmap blankMap;
private STexture blankTexture;
- private Texture transparentTexture;
+
+ private Queue _Vertices;
+ private Queue _VerticesTextures;
+ private Queue _VerticesRotationMatrices;
#endregion private vars
@@ -59,10 +62,14 @@ namespace Vocaluxe.Lib.Draw
public CDirect3D()
{
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon));
- _Textures = new List();
+ _Textures = new Dictionary();
_D3DTextures = new List();
_Queque = new List();
+ _Vertices = new Queue();
+ _VerticesTextures = new Queue();
+ _VerticesRotationMatrices = new Queue();
+
_Keys = new CKeys();
_D3D = new Direct3D();
@@ -164,13 +171,12 @@ namespace Vocaluxe.Lib.Draw
//This creates a new white texture and adds it to the texture pool
//This texture is used for the DrawRect method
- blankMap = new Bitmap(1, 1);
+ Bitmap blankMap = new Bitmap(1, 1);
Graphics g = Graphics.FromImage(blankMap);
g.Clear(Color.White);
g.Dispose();
blankTexture = AddTexture(blankMap);
- transparentTexture = new Texture(_Device, 1, 1, 0, Usage.None, Format.A8R8G8B8, Pool.Managed);
blankMap.Dispose();
}
@@ -201,7 +207,30 @@ namespace Vocaluxe.Lib.Draw
this.ClientSize = this.ClientSize;
RResize();
}
+
+ protected override void WndProc(ref Message m)
+ {
+ switch (m.Msg)
+ {
+ case 0x112: // WM_SYSCOMMAND
+ switch ((int)m.WParam & 0xFFF0)
+ {
+ case 0xF100: // SC_KEYMENU
+ m.Result = IntPtr.Zero;
+ break;
+ default:
+ base.WndProc(ref m);
+ break;
+ }
+ break;
+ default:
+ base.WndProc(ref m);
+ break;
+ }
+ }
#endregion form events
+
+ #region resize
///
/// Resizes the viewport
///
@@ -257,15 +286,29 @@ namespace Vocaluxe.Lib.Draw
//Real fullscreen could be gained setting _PresentParameters.Windowed = true
//And calling Reset() and Init() after
_OldSize = this.ClientSize;
- this.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
+
+ int ScreenNr = 0;
+ for (int i = 0; i < Screen.AllScreens.Length; i++)
+ {
+ Screen scr = Screen.AllScreens[i];
+ if (scr.Bounds.Top <= this.Top && scr.Bounds.Left <= this.Left)
+ ScreenNr = i;
+ }
+
+ this.ClientSize = new Size(Screen.AllScreens[ScreenNr].Bounds.Width, Screen.AllScreens[ScreenNr].Bounds.Height);
this.FormBorderStyle = FormBorderStyle.None;
CenterToScreen();
_fullscreen = true;
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
- RResize();
- Cursor.Hide();
- _Mouse.Visible = true;
+ if (this.WindowState == FormWindowState.Maximized)
+ {
+ this.WindowState = FormWindowState.Normal;
+ RResize();
+ this.WindowState = FormWindowState.Maximized;
+ }
+ else
+ RResize();
CConfig.SaveConfig();
}
@@ -280,11 +323,9 @@ namespace Vocaluxe.Lib.Draw
_fullscreen = false;
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
- Cursor.Hide();
- _Mouse.Visible = true;
-
CConfig.SaveConfig();
}
+ #endregion resize
#region mouse event handlers
private void OnMouseMove(object sender, MouseEventArgs e)
@@ -345,7 +386,7 @@ namespace Vocaluxe.Lib.Draw
#endregion keyboard event handlers
#region implementation
-
+ #region main stuff
///
/// Inits the Device
///
@@ -357,7 +398,7 @@ namespace Vocaluxe.Lib.Draw
this.Text = CSettings.GetFullVersionText();
Matrix translate = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
Matrix projection = Matrix.OrthoOffCenterLH(-CSettings.iRenderW / 2, CSettings.iRenderW / 2, -CSettings.iRenderH / 2, CSettings.iRenderH / 2, CSettings.zNear, CSettings.zFar);
- _VertexBuffer = new VertexBuffer(_Device, 4 * Marshal.SizeOf(typeof(TexturedColoredVertex)), Usage.WriteOnly | Usage.Dynamic, VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
+ _VertexBuffer = new VertexBuffer(_Device, CSettings.iVertexBufferElements * (4 * Marshal.SizeOf(typeof(TexturedColoredVertex))), Usage.WriteOnly | Usage.Dynamic, VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(TexturedColoredVertex)));
_Device.VertexDeclaration = TexturedColoredVertex.GetDeclaration(_Device);
_Device.SetTransform(TransformState.Projection, projection);
@@ -377,6 +418,21 @@ namespace Vocaluxe.Lib.Draw
_Device.SetTextureStageState(0, TextureStage.AlphaArg1, TextureArgument.Texture);
_Device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.Diffuse);
_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
+
+ int[] indices = new int[6];
+ indices[0] = 0;
+ indices[1] = 1;
+ indices[2] = 2;
+ indices[3] = 0;
+ indices[4] = 2;
+ indices[5] = 3;
+
+ _IndexBuffer = new IndexBuffer(_Device, 6 * sizeof(int), Usage.WriteOnly, Pool.Managed, false);
+
+ DataStream stream = _IndexBuffer.Lock(0, 0, LockFlags.None);
+ stream.WriteRange(indices);
+ _IndexBuffer.Unlock();
+ _Device.Indices = _IndexBuffer;
return true;
}
else
@@ -409,6 +465,7 @@ namespace Vocaluxe.Lib.Draw
_Device.BeginScene();
CheckQueque();
_Run = _Run && CGraphics.Draw();
+ RenderVertexBuffer();
//We finished drawing the frame
_Device.EndScene();
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
@@ -440,7 +497,7 @@ namespace Vocaluxe.Lib.Draw
if (CTime.IsRunning())
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
- if (delay >= 1)
+ if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
System.Threading.Thread.Sleep(delay);
//Calculate the FPS Rate and restart the timer after a frame
CTime.CalculateFPS();
@@ -459,6 +516,7 @@ namespace Vocaluxe.Lib.Draw
//Dispose all objects in the default pool, those need to be recreated
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
_VertexBuffer.Dispose();
+ _IndexBuffer.Dispose();
_Device.Reset(_PresentParameters);
}
@@ -471,11 +529,12 @@ namespace Vocaluxe.Lib.Draw
//Dispose all textures
for (int i = 0; i < _D3DTextures.Count; i++)
{
- if(_D3DTextures[i] != null)
+ if (_D3DTextures[i] != null)
_D3DTextures[i].Dispose();
}
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
_VertexBuffer.Dispose();
+ _IndexBuffer.Dispose();
_Device.Dispose();
_D3D.Dispose();
return true;
@@ -523,6 +582,55 @@ namespace Vocaluxe.Lib.Draw
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
}
+ ///
+ /// Adds a quad a list which will be added and rendered to the vertexbuffer when calling RenderToVertexBuffer to reduce vertexbuffer calls each frame to a minimum
+ ///
+ /// A TexturedColoredVertex array containg 4 vertices
+ /// The texture the vertex should be textured with
+ /// The vertices' rotation
+ private void AddToVertexBuffer(TexturedColoredVertex[] vertices, Texture tex, Matrix rotation)
+ {
+ //The vertexbuffer is full, so we need to flush it before we can continue
+ if (_Vertices.Count >= CSettings.iVertexBufferElements)
+ RenderVertexBuffer();
+ _Vertices.Enqueue(vertices[0]);
+ _Vertices.Enqueue(vertices[1]);
+ _Vertices.Enqueue(vertices[2]);
+ _Vertices.Enqueue(vertices[3]);
+ _VerticesTextures.Enqueue(tex);
+ _VerticesRotationMatrices.Enqueue(rotation);
+ }
+
+ ///
+ /// Renders the vertex buffer
+ ///
+ private void RenderVertexBuffer()
+ {
+ if (_Vertices.Count > 0)
+ {
+ //The vertex buffer locks are slow actions, its better to lock once per frame and write all vertices to the buffer at once
+ DataStream stream = _VertexBuffer.Lock(0, _Vertices.Count * Marshal.SizeOf(typeof(TexturedColoredVertex)), LockFlags.Discard);
+ stream.WriteRange(_Vertices.ToArray());
+ _VertexBuffer.Unlock();
+ stream.Dispose();
+
+ for (int i = 0; i < _Vertices.Count; i += 4)
+ {
+ //Apply rotation
+ _Device.SetTransform(TransformState.World, _VerticesRotationMatrices.Dequeue());
+ //Apply texture
+ _Device.SetTexture(0, _VerticesTextures.Dequeue());
+ //Draw 2 triangles from vertexbuffer
+ _Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, i, 0, 4, 0, 2);
+ }
+ //Clear the queues for the next frame
+ _Vertices.Clear();
+ _VerticesTextures.Clear();
+ _VerticesRotationMatrices.Clear();
+ }
+ }
+#endregion main stuff
+
#region Basic Draw Methods
///
@@ -534,24 +642,51 @@ namespace Vocaluxe.Lib.Draw
}
///
- /// Not implemented yet
- ///
- ///
+ /// Copies the current frame into a texture
+ /// A texture holding the current frame
public STexture CopyScreen()
{
- //FIXME
STexture texture = new STexture(-1);
+
+ Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
+ Texture tex = new Texture(_Device, _PresentParameters.BackBufferWidth, _PresentParameters.BackBufferHeight, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
+ Surface textureSurface = tex.GetSurfaceLevel(0);
+ Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0);
+ backbufferSurface.Dispose();
+ _D3DTextures.Add(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 = NextPowerOfTwo(texture.width);
+ texture.h2 = NextPowerOfTwo(texture.height);
+ texture.index = _D3DTextures.Count - 1;
+
+ lock (MutexTexture)
+ {
+ _Textures[texture.index] = texture;
+ }
return texture;
}
///
- /// Not implemented yet
+ /// Copies the current frame into a texture
///
- ///
+ /// The texture in which the frame is copied to
public void CopyScreen(ref STexture Texture)
{
- //FIXME
- return;
+ if (!_TextureExists(ref Texture) || (Texture.width != GetScreenWidth()) || (Texture.height != GetScreenHeight()))
+ {
+ RemoveTexture(ref Texture);
+ Texture = CopyScreen();
+ }
+ else
+ {
+ Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
+ Surface textureSurface = _D3DTextures[Texture.index].GetSurfaceLevel(0);
+ Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0);
+ }
}
///
@@ -627,18 +762,11 @@ namespace Vocaluxe.Lib.Draw
/// The coordinates in a SRectF struct
public void DrawColor(SColorF color, SRectF rect)
{
- //blankMap = new Bitmap(1, 1);
- //Graphics g = Graphics.FromImage(blankMap);
- //g.Clear(Color.White);
- //g.Dispose();
- //blankTexture = AddTexture(blankMap);
- //blankMap.Dispose();
-
DrawTexture(blankTexture, rect, color);
- //RemoveTexture(ref blankTexture);
}
#endregion Basic Draw Methods
#region Textures
+ #region adding
///
/// Adds a texture and stores it in the VRam
@@ -665,17 +793,6 @@ namespace Vocaluxe.Lib.Draw
return new STexture(-1);
}
- ///
- /// Calculates the next power of two
- ///
- /// The value of which the next power of two will be calculated
- /// The next power of two
- private static float NextPowerOfTwo(float n)
- {
- if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
- return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
- }
-
///
/// Adds a texture and stores it in the Vram
///
@@ -764,7 +881,7 @@ namespace Vocaluxe.Lib.Draw
rect.Data.Position += rect.Pitch;
}
t.UnlockRectangle(0);
-
+
bmp2.Dispose();
bmp_data = null;
@@ -776,9 +893,8 @@ namespace Vocaluxe.Lib.Draw
{
_D3DTextures.Add(t);
texture.index = _D3DTextures.Count - 1;
- _Textures.Add(texture);
+ _Textures[texture.index] = texture;
}
-
return texture;
}
@@ -807,6 +923,8 @@ namespace Vocaluxe.Lib.Draw
queque.data = Data;
queque.height = H;
queque.width = W;
+ texture.height = H;
+ texture.width = W;
lock (MutexTexture)
{
@@ -814,7 +932,7 @@ namespace Vocaluxe.Lib.Draw
texture.index = _D3DTextures.Count - 1;
queque.ID = texture.index;
_Queque.Add(queque);
- _Textures.Add(texture);
+ _Textures[texture.index] = texture;
}
return texture;
}
@@ -848,11 +966,13 @@ namespace Vocaluxe.Lib.Draw
{
_D3DTextures.Add(t);
texture.index = _D3DTextures.Count - 1;
- _Textures.Add(texture);
+ _Textures[texture.index] = texture;
}
return texture;
}
+ #endregion adding
+ #region updating
///
/// Updates the data of a texture
///
@@ -894,6 +1014,7 @@ namespace Vocaluxe.Lib.Draw
else
return false;
}
+ #endregion updating
///
/// Checks if a texture exists
@@ -904,16 +1025,12 @@ namespace Vocaluxe.Lib.Draw
{
lock (MutexTexture)
{
- for (int i = 0; i < _Textures.Count; i++)
+ if (_Textures.ContainsKey(Texture.index))
{
- if (Texture.index == _Textures[i].index)
+ if (_Textures[Texture.index].index >= 0)
{
- if (_Textures[i].index >= 0)
- {
- Texture = _Textures[i];
- return true;
- }
- break;
+ Texture = _Textures[Texture.index];
+ return true;
}
}
}
@@ -930,21 +1047,16 @@ namespace Vocaluxe.Lib.Draw
{
if ((Texture.index >= 0) && (_Textures.Count > 0))
{
- for (int i = 0; i < _Textures.Count; i++)
- {
- if (_Textures[i].index == Texture.index)
- {
- _D3DTextures[Texture.index].Dispose();
- _D3DTextures[Texture.index] = null;
- _Textures.RemoveAt(i);
- Texture.index = -1;
- Texture.ID = -1;
- }
- }
+ _D3DTextures[Texture.index].Dispose();
+ _D3DTextures[Texture.index] = null;
+ _Textures.Remove(Texture.index);
+ Texture.index = -1;
+ Texture.ID = -1;
}
}
}
+ #region drawing
///
/// Draws a texture
///
@@ -1016,6 +1128,9 @@ namespace Vocaluxe.Lib.Draw
{
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index) && _TextureExists(ref Texture))
{
+ if (_D3DTextures[Texture.index] == null)
+ return;
+
//Calculate the position
float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio;
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio;
@@ -1058,69 +1173,34 @@ namespace Vocaluxe.Lib.Draw
rx2 -= 0.5f;
ry2 -= 0.5f;
- if (color.R >= 1f)
- color.R = 1f;
- if (color.B >= 1f)
- color.B = 1f;
- if (color.G >= 1f)
- color.G = 1f;
-
- //Apply rotation
- //FIXME: Rotated textures get distorted when they hit the border of the window
- if (rect.Rotation != 0)
- {
- rect.Rotation = rect.Rotation * (float)Math.PI / 180;
- float centerX = (rx1 + rx2) / 2f;
- float centerY = -(ry1 + ry2) / 2f;
-
- Matrix originTranslation = _Device.GetTransform(TransformState.World);
- Matrix translationA = Matrix.Translation(-centerX, -centerY, 0);
- Matrix rotation = Matrix.RotationZ(-rect.Rotation);
- Matrix translationB = Matrix.Translation(centerX, centerY, 0);
-
- //Multiplicate the matrices to get the real world matrix,
- //First shift the texture into the center
- //Rotate it and shift it back to the origin position
- //Apply the originTranslation after
- Matrix result = translationA * rotation * translationB * originTranslation;
-
- _Device.SetTransform(TransformState.World, result);
- }
+ 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.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
- //Create new vertices and write them into a vertexbuffer
- DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
if (!mirrored)
{
- stream.WriteRange(new[] {
- new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb()),
- });
+ TexturedColoredVertex[] vert = new TexturedColoredVertex[4];
+ vert[0] = new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb());
+ vert[1] = new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
+ vert[2] = new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
+ vert[3] = new TexturedColoredVertex(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
{
- stream.WriteRange(new[] {
- new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y1), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y2), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y2), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y1), c.ToArgb()),
- });
- }
- _VertexBuffer.Unlock();
- stream.Dispose();
- //Set the texture
- _Device.SetTexture(0, _D3DTextures[Texture.index]);
- //Draw 2 triangles to build a quad
- _Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
-
- //Reapply old matrices if the texture was rotated
- if (rect.Rotation != 0)
- {
- Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
- _Device.SetTransform(TransformState.World, originTranslation);
+ TexturedColoredVertex[] vert = new TexturedColoredVertex[4];
+ vert[0] = new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y1), c.ToArgb());
+ vert[1] = new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y2), c.ToArgb());
+ vert[2] = new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y2), c.ToArgb());
+ vert[3] = new TexturedColoredVertex(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));
}
}
}
@@ -1138,6 +1218,9 @@ namespace Vocaluxe.Lib.Draw
{
if (_TextureExists(ref Texture))
{
+ if (_D3DTextures[Texture.index] == null)
+ return;
+
float x1 = 0f + begin * Texture.width_ratio;
float x2 = Texture.width_ratio * end;
float y1 = 0f;
@@ -1156,49 +1239,12 @@ namespace Vocaluxe.Lib.Draw
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
- //Apply rotation
- //FIXME: Rotated textures get distorted when they hit the border of the window
- if (rect.Rotation != 0)
- {
- rect.Rotation = rect.Rotation * (float)Math.PI / 180;
- float centerX = (rx1 + rx2) / 2f;
- float centerY = -(ry1 + ry2) / 2f;
-
- Matrix originTranslation = _Device.GetTransform(TransformState.World);
- Matrix translationA = Matrix.Translation(-centerX, -centerY, 0);
- Matrix rotation = Matrix.RotationZ(-rect.Rotation);
- Matrix translationB = Matrix.Translation(centerX, centerY, 0);
-
- //Multiplicate the matrices to get the real world matrix,
- //First shift the texture into the center
- //Rotate it and shift it back to the origin position
- //Apply the originTranslation after
- Matrix result = translationA * rotation * translationB * originTranslation;
-
- _Device.SetTransform(TransformState.World, result);
- }
-
- //Create new vertices and write them into a vertexbuffer
- DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
- stream.WriteRange(new[] {
- new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb()),
- });
- _VertexBuffer.Unlock();
- stream.Dispose();
- //Set the texture
- _Device.SetTexture(0, _D3DTextures[Texture.index]);
- //Draw 2 triangles to build a quad
- _Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
-
- //Reapply old matrices if the texture was rotated
- if (rect.Rotation != 0)
- {
- Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
- _Device.SetTransform(TransformState.World, originTranslation);
- }
+ TexturedColoredVertex[] vert = new TexturedColoredVertex[4];
+ vert[0] = new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb());
+ vert[1] = new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
+ vert[2] = new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
+ vert[3] = new TexturedColoredVertex(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));
}
}
@@ -1215,6 +1261,9 @@ namespace Vocaluxe.Lib.Draw
{
if (_TextureExists(ref Texture))
{
+ if (_D3DTextures[Texture.index] == null)
+ return;
+
if (rect.W == 0f || rect.H == 0f || bounds.H == 0f || bounds.W == 0f || color.A == 0f || height <= 0f)
return;
@@ -1270,55 +1319,19 @@ namespace Vocaluxe.Lib.Draw
rx2 -= 0.5f;
ry2 -= 0.5f;
- //Apply rotation
- //FIXME: Rotated textures get distorted when they hit the border of the window
- if (rect.Rotation != 0)
- {
- rect.Rotation = rect.Rotation * (float)Math.PI / 180;
- float centerX = (rx1 + rx2) / 2f;
- float centerY = -(ry1 + ry2) / 2f;
-
- Matrix originTranslation = _Device.GetTransform(TransformState.World);
- Matrix translationA = Matrix.Translation(-centerX, -centerY, 0);
- Matrix rotation = Matrix.RotationZ(-rect.Rotation);
- Matrix translationB = Matrix.Translation(centerX, centerY, 0);
-
- //Multiplicate the matrices to get the real world matrix,
- //First shift the texture into the center
- //Rotate it and shift it back to the origin position
- //Apply the originTranslation after
- Matrix result = translationA * rotation * translationB * originTranslation;
-
- _Device.SetTransform(TransformState.World, result);
- }
-
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
Color transparent = Color.FromArgb(0, (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
- //Create new vertices and write them into a vertexbuffer
- DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
- stream.WriteRange(new[] {
- new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb()),
- new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()),
- });
- _VertexBuffer.Unlock();
- stream.Dispose();
- //Set the texture
- _Device.SetTexture(0, _D3DTextures[Texture.index]);
- //Draw 2 triangles to build a quad
- _Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
-
- //Reapply old matrices if the texture was rotated
- if (rect.Rotation != 0)
- {
- Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
- _Device.SetTransform(TransformState.World, originTranslation);
- }
+ TexturedColoredVertex[] vert = new TexturedColoredVertex[4];
+ vert[0] = new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
+ vert[1] = new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb());
+ vert[2] = new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb());
+ vert[3] = new TexturedColoredVertex(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
private void CheckQueque()
{
@@ -1329,17 +1342,8 @@ namespace Vocaluxe.Lib.Draw
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 (_Textures.ContainsKey(q.ID))
+ texture = _Textures[q.ID];
if (texture.index < 0)
return;
@@ -1368,7 +1372,7 @@ namespace Vocaluxe.Lib.Draw
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
texture.TexturePath = String.Empty;
- _Textures[index] = texture;
+ _Textures[texture.index] = texture;
_Queque.RemoveAt(0);
}
}
@@ -1384,6 +1388,42 @@ namespace Vocaluxe.Lib.Draw
#endregion Textures
#endregion implementation
+ #region utility
+ ///
+ /// Calculates the next power of two
+ ///
+ /// The value of which the next power of two will be calculated
+ /// The next power of two
+ private static float NextPowerOfTwo(float n)
+ {
+ if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
+ return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
+ }
+
+ private Matrix CalculateRotationMatrix(float rot, float rx1, float rx2, float ry1, float ry2)
+ {
+ Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
+ if (rot != 0)
+ {
+ float rotation = rot * (float)Math.PI / 180;
+ float centerX = (rx1 + rx2) / 2f;
+ float centerY = -(ry1 + ry2) / 2f;
+
+ Matrix translationA = Matrix.Translation(-centerX, -centerY, 0);
+ Matrix rotationMat = Matrix.RotationZ(-rotation);
+ Matrix translationB = Matrix.Translation(centerX, centerY, 0);
+
+ //Multiplicate the matrices to get the real world matrix,
+ //First shift the texture into the center
+ //Rotate it and shift it back to the origin position
+ //Apply the originTranslation after
+ Matrix result = translationA * rotationMat * translationB * originTranslation;
+ return result;
+ }
+ return originTranslation;
+ }
+ #endregion utility
+
#region TexturedColoredVertex
public struct TexturedColoredVertex
{
diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs
index c0779426..c94f0073 100644
--- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs
+++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs
@@ -153,6 +153,27 @@ namespace Vocaluxe.Lib.Draw
_Run = false;
}
+ protected override void WndProc(ref Message m)
+ {
+ switch (m.Msg)
+ {
+ case 0x112: // WM_SYSCOMMAND
+ switch ((int)m.WParam & 0xFFF0)
+ {
+ case 0xF100: // SC_KEYMENU
+ m.Result = IntPtr.Zero;
+ break;
+ default:
+ base.WndProc(ref m);
+ break;
+ }
+ break;
+ default:
+ base.WndProc(ref m);
+ break;
+ }
+ }
+
private void OnKeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
{
_Keys.KeyDown(e);
diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs
index f12be76d..7809edce 100644
--- a/Vocaluxe/Lib/Draw/COpenGL.cs
+++ b/Vocaluxe/Lib/Draw/COpenGL.cs
@@ -46,7 +46,7 @@ namespace Vocaluxe.Lib.Draw
private SClientRect _restore;
private bool _fullscreen = false;
- private List _Textures;
+ private Dictionary _Textures;
private Queue _IDs;
private List _Queque;
@@ -65,7 +65,7 @@ namespace Vocaluxe.Lib.Draw
{
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon));
- _Textures = new List();
+ _Textures = new Dictionary();
_Queque = new List();
_IDs = new Queue(1000000);
@@ -121,7 +121,6 @@ namespace Vocaluxe.Lib.Draw
control.MouseEnter += new EventHandler(this.OnMouseEnter);
this.ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH);
- //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Opaque, true);
this.CenterToScreen();
}
@@ -285,8 +284,15 @@ namespace Vocaluxe.Lib.Draw
this.DesktopBounds = new Rectangle(Screen.AllScreens[ScreenNr].Bounds.Location,
new Size(Screen.AllScreens[ScreenNr].Bounds.Width, Screen.AllScreens[ScreenNr].Bounds.Height));
- this.TopMost = true;
- this.Show();
+
+ if (this.WindowState == FormWindowState.Maximized)
+ {
+ this.WindowState = FormWindowState.Normal;
+ RResize();
+ this.WindowState = FormWindowState.Maximized;
+ }
+ else
+ RResize();
CConfig.SaveConfig();
}
@@ -299,8 +305,6 @@ namespace Vocaluxe.Lib.Draw
this.FormBorderStyle = FormBorderStyle.Sizable;
this.DesktopBounds = new Rectangle(_restore.location, new Size(_restore.width, _restore.height));
- this.TopMost = false;
-
CConfig.SaveConfig();
}
#endregion Helpers
@@ -333,6 +337,27 @@ namespace Vocaluxe.Lib.Draw
control.ClientSize = this.ClientSize;
RResize();
}
+
+ protected override void WndProc(ref Message m)
+ {
+ switch (m.Msg)
+ {
+ case 0x112: // WM_SYSCOMMAND
+ switch ((int)m.WParam & 0xFFF0)
+ {
+ case 0xF100: // SC_KEYMENU
+ m.Result = IntPtr.Zero;
+ break;
+ default:
+ base.WndProc(ref m);
+ break;
+ }
+ break;
+ default:
+ base.WndProc(ref m);
+ break;
+ }
+ }
#endregion form events
#region mouse event handlers
@@ -419,7 +444,7 @@ namespace Vocaluxe.Lib.Draw
#region implementation
-
+ #region main stuff
public bool Init()
{
this.Text = CSettings.GetFullVersionText();
@@ -448,7 +473,7 @@ namespace Vocaluxe.Lib.Draw
CSettings.bFullScreen = true;
EnterFullScreen();
}
-
+
while (_Run)
{
Application.DoEvents();
@@ -456,12 +481,11 @@ namespace Vocaluxe.Lib.Draw
if (_Run)
{
ClearScreen();
-
_Run = _Run && CGraphics.Draw();
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
control.SwapBuffers();
-
+
if ((CSettings.bFullScreen && !_fullscreen) || (!CSettings.bFullScreen && _fullscreen))
ToggleFullScreen();
@@ -469,8 +493,8 @@ namespace Vocaluxe.Lib.Draw
if (CTime.IsRunning())
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
-
- if (delay >= 1)
+
+ if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
System.Threading.Thread.Sleep(delay);
CTime.CalculateFPS();
@@ -483,11 +507,13 @@ namespace Vocaluxe.Lib.Draw
public bool Unload()
{
- while (_Textures.Count > 0)
+ STexture[] textures = new STexture[_Textures.Count];
+ _Textures.Values.CopyTo(textures, 0);
+ for (int i = 0; i < _Textures.Count; i++ )
{
- STexture tex = _Textures[0];
- RemoveTexture(ref tex);
+ RemoveTexture(ref textures[i]);
}
+
return true;
}
@@ -513,7 +539,8 @@ namespace Vocaluxe.Lib.Draw
CFonts.Style = text.Style;
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
}
-
+ #endregion main stuff
+
#region Basic Draw Methods
public void ClearScreen()
{
@@ -554,7 +581,7 @@ namespace Vocaluxe.Lib.Draw
lock (MutexTexture)
{
texture.index = _IDs.Dequeue();
- _Textures.Add(texture);
+ _Textures[texture.index] = texture;
}
return texture;
@@ -637,6 +664,8 @@ namespace Vocaluxe.Lib.Draw
#endregion Basic Draw Methods
#region Textures
+
+ #region adding
public STexture AddTexture(string TexturePath)
{
if (System.IO.File.Exists(TexturePath))
@@ -758,7 +787,7 @@ namespace Vocaluxe.Lib.Draw
lock (MutexTexture)
{
texture.index = _IDs.Dequeue();
- _Textures.Add(texture);
+ _Textures[texture.index] = texture;
}
return texture;
@@ -822,7 +851,7 @@ namespace Vocaluxe.Lib.Draw
lock (MutexTexture)
{
texture.index = _IDs.Dequeue();
- _Textures.Add(texture);
+ _Textures[texture.index] = texture;
}
return texture;
@@ -887,7 +916,7 @@ namespace Vocaluxe.Lib.Draw
lock (MutexTexture)
{
texture.index = _IDs.Dequeue();
- _Textures.Add(texture);
+ _Textures[texture.index] = texture;
}
return texture;
@@ -901,18 +930,22 @@ namespace Vocaluxe.Lib.Draw
queque.data = Data;
queque.height = H;
queque.width = W;
+ texture.height = H;
+ texture.width = W;
lock (MutexTexture)
{
texture.index = _IDs.Dequeue();
queque.ID = texture.index;
_Queque.Add(queque);
- _Textures.Add(texture);
+ _Textures[texture.index] = texture;
}
return texture;
}
+ #endregion adding
+ #region updating
public bool UpdateTexture(ref STexture Texture, IntPtr Data)
{
if (_TextureExists(ref Texture))
@@ -1020,6 +1053,7 @@ namespace Vocaluxe.Lib.Draw
}
return false;
}
+ #endregion updating
public void RemoveTexture(ref STexture Texture)
{
@@ -1027,21 +1061,13 @@ namespace Vocaluxe.Lib.Draw
{
lock (MutexTexture)
{
- for (int i = 0; i < _Textures.Count; i++)
- {
- if (_Textures[i].index == Texture.index)
- {
- _IDs.Enqueue(Texture.index);
-
- GL.DeleteTexture(Texture.ID);
- if (Texture.PBO > 0)
- GL.DeleteBuffers(1, ref Texture.PBO);
- _Textures.RemoveAt(i);
- Texture.index = -1;
- Texture.ID = -1;
- break;
- }
- }
+ _IDs.Enqueue(Texture.index);
+ GL.DeleteTexture(Texture.ID);
+ if (Texture.PBO > 0)
+ GL.DeleteBuffers(1, ref Texture.PBO);
+ _Textures.Remove(Texture.index);
+ Texture.index = -1;
+ Texture.ID = -1;
}
}
}
@@ -1050,22 +1076,19 @@ namespace Vocaluxe.Lib.Draw
{
lock (MutexTexture)
{
- for (int i = 0; i < _Textures.Count; i++)
+ if(_Textures.ContainsKey((Texture.index)))
{
- if (Texture.index == _Textures[i].index)
+ if(_Textures[Texture.index].ID > 0)
{
- if (_Textures[i].ID > 0)
- {
- Texture = _Textures[i];
- return true;
- }
- break;
+ Texture = _Textures[Texture.index];
+ return true;
}
}
}
return false;
}
+ #region drawing
public void DrawTexture(STexture Texture)
{
DrawTexture(Texture, Texture.rect, Texture.color);
@@ -1323,6 +1346,7 @@ namespace Vocaluxe.Lib.Draw
GL.BindTexture(TextureTarget.Texture2D, 0);
}
}
+ #endregion drawing
public int TextureCount()
{
@@ -1338,15 +1362,9 @@ namespace Vocaluxe.Lib.Draw
STextureQueque q = _Queque[0];
STexture texture = new STexture(-1);
- int index = -1;
- for (int i = 0; i < _Textures.Count; i++)
+ if (_Textures.ContainsKey(q.ID))
{
- if (_Textures[i].index == q.ID)
- {
- texture = _Textures[i];
- index = i;
- break;
- }
+ texture = _Textures[q.ID];
}
if (texture.index < 1)
@@ -1386,9 +1404,15 @@ namespace Vocaluxe.Lib.Draw
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.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
@@ -1396,12 +1420,11 @@ namespace Vocaluxe.Lib.Draw
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
texture.TexturePath = String.Empty;
- _Textures[index] = texture;
+ _Textures[texture.index] = texture;
q.data = null;
_Queque.RemoveAt(0);
}
}
-
#endregion Textures
#endregion implementation
diff --git a/Vocaluxe/Menu/CGraphics.cs b/Vocaluxe/Menu/CGraphics.cs
index d924c584..cd3148de 100644
--- a/Vocaluxe/Menu/CGraphics.cs
+++ b/Vocaluxe/Menu/CGraphics.cs
@@ -249,12 +249,9 @@ namespace Vocaluxe.Menu
for (int i = 0; i < Screens.Length; i++)
{
- if (Enum.GetNames(typeof(EScreens))[i] != Enum.GetName(typeof(EScreens), (int)EScreens.ScreenCredits))
- {
- CLog.StartBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
- Screens[i].LoadTheme();
- CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
- }
+ CLog.StartBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
+ Screens[i].LoadTheme();
+ CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
}
}
@@ -263,10 +260,7 @@ namespace Vocaluxe.Menu
ReloadCursor();
for (int i = 0; i < Screens.Length; i++)
{
- if (Enum.GetNames(typeof(EScreens))[i] != Enum.GetName(typeof(EScreens), (int)EScreens.ScreenCredits))
- {
- Screens[i].ReloadTheme();
- }
+ Screens[i].ReloadTheme();
}
}
@@ -275,10 +269,7 @@ namespace Vocaluxe.Menu
ReloadCursor();
for (int i = 0; i < Screens.Length; i++)
{
- if (Enum.GetNames(typeof(EScreens))[i] != Enum.GetName(typeof(EScreens), (int)EScreens.ScreenCredits))
- {
- Screens[i].ReloadTextures();
- }
+ Screens[i].ReloadTextures();
}
}
@@ -287,10 +278,7 @@ namespace Vocaluxe.Menu
CTheme.SaveTheme();
for (int i = 0; i < Screens.Length; i++)
{
- if (Enum.GetNames(typeof(EScreens))[i] != Enum.GetName(typeof(EScreens), (int)EScreens.ScreenCredits))
- {
- Screens[i].SaveTheme();
- }
+ Screens[i].SaveTheme();
}
}
diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs
index e1b988b4..fab7271c 100644
--- a/Vocaluxe/Screens/CScreenCredits.cs
+++ b/Vocaluxe/Screens/CScreenCredits.cs
@@ -33,7 +33,6 @@ namespace Vocaluxe.Screens
// Version number for theme files. Increment it, if you've changed something on the theme files!
const int ScreenVersion = 1;
-
private CStatic logo;
private CParticleEffect starsRed;
private CParticleEffect starsBlue;
@@ -45,6 +44,18 @@ namespace Vocaluxe.Screens
private List paragraphs;
private List paragraphTexts;
+
+ private STexture _TexLogo;
+ private STexture _TexPerfectNoteStar;
+
+ private STexture _TexNameBrunzel;
+ private STexture _TexNameDarkice;
+ private STexture _TexNameFlokuep;
+ private STexture _TexNameMesand;
+ private STexture _TexNameBohning;
+ private STexture _TexNameBabene03;
+ private STexture _TexNamePantero;
+ private STexture _TexNamePinky007;
public CScreenCredits()
{
@@ -96,6 +107,81 @@ namespace Vocaluxe.Screens
paragraphs.Add(words);
}
+ public override void LoadTheme()
+ {
+ //Vocaluxe-Logo
+ CDataBase.GetCreditsRessource("Logo_voc.png", ref _TexLogo);
+
+ //Little stars for logo
+ CDataBase.GetCreditsRessource("PerfectNoteStar.png", ref _TexPerfectNoteStar);
+
+ //brunzel
+ CDataBase.GetCreditsRessource("brunzel.png", ref _TexNameBrunzel);
+
+ //Darkice
+ CDataBase.GetCreditsRessource("Darkice.png", ref _TexNameDarkice);
+
+ //flokuep
+ CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep);
+
+ //bohning
+ CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning);
+
+ //mesand
+ CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand);
+
+ //babene03
+ CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03);
+
+ //pantero
+ CDataBase.GetCreditsRessource("pantero.png", ref _TexNamePantero);
+
+ //Pinky007
+ CDataBase.GetCreditsRessource("Pinky007.png", ref _TexNamePinky007);
+
+ //Prepare Text
+ int lastY = 280;
+ for (int i = 0; i < paragraphs.Count; i++)
+ {
+ string line = "";
+ for (int e = 0; e < paragraphs[i].Length; e++)
+ {
+ if (paragraphs[i][e] != null)
+ {
+ string newline = line + " " + paragraphs[i][e];
+ CText text = new CText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
+ if (CDraw.GetTextBounds(text).Width < (CSettings.iRenderW - 220))
+ {
+ line = line + " " + paragraphs[i][e];
+
+ //Check if all words are used
+ if ((e + 1) == paragraphs[i].Length)
+ {
+ text.Text = line;
+ paragraphTexts.Add(text);
+ line = "";
+ lastY += 40;
+ }
+ }
+ else
+ {
+ paragraphTexts.Add(text);
+ line = " " + paragraphs[i][e];
+ lastY += 27;
+ }
+ }
+ }
+ }
+ }
+
+ public override void ReloadTheme() {}
+
+ public override void SaveTheme() {}
+
+ public override void UnloadTextures() {}
+
+ public override void ReloadTextures() {}
+
public override bool HandleInput(KeyEvent KeyEvent)
{
if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode))
@@ -150,137 +236,92 @@ namespace Vocaluxe.Screens
public override void OnShow()
{
- STexture tex = new STexture();
- STexture particleTex = new STexture();
+ base.OnShow();
//Vocaluxe-Logo
- CDataBase.GetCreditsRessource("Logo_voc.png", ref tex);
- logo = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF((CSettings.iRenderW - tex.width)/2, -270 , tex.width, tex.height, -2));
-
+ logo = new CStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((CSettings.iRenderW - _TexLogo.width) / 2, -270, _TexLogo.width, _TexLogo.height, -2));
+
//Little stars for logo
- CDataBase.GetCreditsRessource("PerfectNoteStar.png", ref particleTex);
- int numstars = (int)(logo.Rect.W * 0.25f /2f);
- starsRed = new CParticleEffect(numstars, new SColorF(1, 0, 0, 1), new SRectF(logo.Rect.X, logo.Rect.Y, logo.Rect.W, logo.Rect.H, -1), particleTex, 35, EParticeType.Star);
- starsBlue = new CParticleEffect(numstars, new SColorF(0.149f, 0.415f, 0.819f, 1), new SRectF(logo.Rect.X, logo.Rect.Y, logo.Rect.W, logo.Rect.H, -1), particleTex, 35, EParticeType.Star);
+ int numstars = (int)(logo.Rect.W * 0.25f / 2f);
+ starsRed = new CParticleEffect(numstars, new SColorF(1, 0, 0, 1), new SRectF(logo.Rect.X, logo.Rect.Y, logo.Rect.W, logo.Rect.H, -1), _TexPerfectNoteStar, 35, EParticeType.Star);
+ starsBlue = new CParticleEffect(numstars, new SColorF(0.149f, 0.415f, 0.819f, 1), new SRectF(logo.Rect.X, logo.Rect.Y, logo.Rect.W, logo.Rect.H, -1), _TexPerfectNoteStar, 35, EParticeType.Star);
//Credit names
_CreditNames = new List();
-
CCreditName CreditEntry = new CCreditName();
//brunzel
- CDataBase.GetCreditsRessource("brunzel.png", ref tex);
CCreditName CreditEntryBrunzel = new CCreditName();
- CreditEntryBrunzel.image = new CStatic(tex, new SColorF(1,1,1,1), new SRectF(-450, 580, 400, 120, -4));
+ CreditEntryBrunzel.image = new CStatic(_TexNameBrunzel, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4));
CreditEntryBrunzel.particleRect = new SRectF(CreditEntryBrunzel.image.Rect.X + 342, CreditEntryBrunzel.image.Rect.Y + 4, 30, 30, -5);
- CreditEntryBrunzel.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryBrunzel.particleRect, particleTex, 35, EParticeType.Star);
+ CreditEntryBrunzel.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryBrunzel.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star);
CreditEntryBrunzel.active = true;
CreditEntryBrunzel.direction = EDirection.Left;
_CreditNames.Add(CreditEntryBrunzel);
//Darkice
- CDataBase.GetCreditsRessource("Darkice.png", ref tex);
CCreditName CreditEntryDarkice = new CCreditName();
- CreditEntryDarkice.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 400, 120, -4));
+ CreditEntryDarkice.image = new CStatic(_TexNameDarkice, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 400, 120, -4));
CreditEntryDarkice.particleRect = new SRectF(CreditEntryDarkice.image.Rect.X + 242, CreditEntryDarkice.image.Rect.Y + 23, 30, 30, -5);
- CreditEntryDarkice.particle = new CParticleEffect(8, new SColorF(0.149f, 0.415f ,0.819f, 1), CreditEntryDarkice.particleRect, particleTex, 35, EParticeType.Star);
+ CreditEntryDarkice.particle = new CParticleEffect(8, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryDarkice.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star);
CreditEntryDarkice.active = true;
CreditEntryDarkice.direction = EDirection.Right;
_CreditNames.Add(CreditEntryDarkice);
//flokuep
- CDataBase.GetCreditsRessource("flokuep.png", ref tex);
CCreditName CreditEntryFlokuep = new CCreditName();
- CreditEntryFlokuep.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4));
- CreditEntryFlokuep.particleRect = new SRectF(CreditEntryFlokuep.image.Rect.X + 141, CreditEntryFlokuep.image.Rect.Y-2, 30, 30, -5);
- CreditEntryFlokuep.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryFlokuep.particleRect, particleTex, 35, EParticeType.Star);
+ CreditEntryFlokuep.image = new CStatic(_TexNameFlokuep, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4));
+ CreditEntryFlokuep.particleRect = new SRectF(CreditEntryFlokuep.image.Rect.X + 141, CreditEntryFlokuep.image.Rect.Y - 2, 30, 30, -5);
+ CreditEntryFlokuep.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryFlokuep.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star);
CreditEntryFlokuep.active = true;
CreditEntryFlokuep.direction = EDirection.Left;
_CreditNames.Add(CreditEntryFlokuep);
//bohning
- CDataBase.GetCreditsRessource("bohning.png", ref tex);
CCreditName CreditEntryBohning = new CCreditName();
- CreditEntryBohning.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
+ CreditEntryBohning.image = new CStatic(_TexNameBohning, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
CreditEntryBohning.particleRect = new SRectF(CreditEntryBohning.image.Rect.X + 172, CreditEntryBohning.image.Rect.Y + 16, 10, 10, -5);
- CreditEntryBohning.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f ,0.819f, 1), CreditEntryBohning.particleRect, particleTex, 25, EParticeType.Star);
+ CreditEntryBohning.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryBohning.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
CreditEntryBohning.active = true;
CreditEntryBohning.direction = EDirection.Right;
_CreditNames.Add(CreditEntryBohning);
//mesand
- CDataBase.GetCreditsRessource("mesand.png", ref tex);
CCreditName CreditEntryMesand = new CCreditName();
- CreditEntryMesand.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
+ CreditEntryMesand.image = new CStatic(_TexNameMesand, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
CreditEntryMesand.particleRect = new SRectF(CreditEntryMesand.image.Rect.X + 240, CreditEntryMesand.image.Rect.Y - 2, 10, 10, -5);
- CreditEntryMesand.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntryMesand.particleRect, particleTex, 25, EParticeType.Star);
+ CreditEntryMesand.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntryMesand.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
CreditEntryMesand.active = true;
CreditEntryMesand.direction = EDirection.Left;
_CreditNames.Add(CreditEntryMesand);
//babene03
- CDataBase.GetCreditsRessource("babene03.png", ref tex);
CCreditName CreditEntryBabene03 = new CCreditName();
- CreditEntryBabene03.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
+ CreditEntryBabene03.image = new CStatic(_TexNameBabene03, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
CreditEntryBabene03.particleRect = new SRectF(CreditEntryBabene03.image.Rect.X + 7, CreditEntryBabene03.image.Rect.Y + 4, 10, 10, -5);
- CreditEntryBabene03.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f ,0.819f, 1), CreditEntryBabene03.particleRect, particleTex, 25, EParticeType.Star);
+ CreditEntryBabene03.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryBabene03.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
CreditEntryBabene03.active = true;
CreditEntryBabene03.direction = EDirection.Right;
_CreditNames.Add(CreditEntryBabene03);
//pantero
- CDataBase.GetCreditsRessource("pantero.png", ref tex);
CCreditName CreditEntrypantero = new CCreditName();
- CreditEntrypantero.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
+ CreditEntrypantero.image = new CStatic(_TexNamePantero, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
CreditEntrypantero.particleRect = new SRectF(CreditEntrypantero.image.Rect.X + 140, CreditEntrypantero.image.Rect.Y + 15, 10, 10, -5);
- CreditEntrypantero.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntrypantero.particleRect, particleTex, 25, EParticeType.Star);
+ CreditEntrypantero.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntrypantero.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
CreditEntrypantero.active = true;
CreditEntrypantero.direction = EDirection.Left;
_CreditNames.Add(CreditEntrypantero);
-
+
//Pinky007
- CDataBase.GetCreditsRessource("Pinky007.png", ref tex);
CCreditName CreditEntryPinky007 = new CCreditName();
- CreditEntryPinky007.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
+ CreditEntryPinky007.image = new CStatic(_TexNamePinky007, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
CreditEntryPinky007.particleRect = new SRectF(CreditEntryPinky007.image.Rect.X + 42, CreditEntryPinky007.image.Rect.Y + 15, 10, 10, -5);
- CreditEntryPinky007.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f ,0.819f, 1), CreditEntryPinky007.particleRect, particleTex, 25, EParticeType.Star);
+ CreditEntryPinky007.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryPinky007.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
CreditEntryPinky007.active = true;
CreditEntryPinky007.direction = EDirection.Right;
_CreditNames.Add(CreditEntryPinky007);
- //Prepare Text
- int lastY = 280;
- for (int i = 0; i < paragraphs.Count; i++)
- {
- string line = "";
- for (int e = 0; e < paragraphs[i].Length; e++ )
- {
- if (paragraphs[i][e] != null)
- {
- string newline = line + " " + paragraphs[i][e];
- CText text = new CText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
- if (CDraw.GetTextBounds(text).Width < (CSettings.iRenderW - 220))
- {
- line = line + " " + paragraphs[i][e];
-
- //Check if all words are used
- if ((e + 1) == paragraphs[i].Length)
- {
- text.Text = line;
- paragraphTexts.Add(text);
- line = "";
- lastY += 40;
- }
- }
- else
- {
- paragraphTexts.Add(text);
- line = " "+paragraphs[i][e];
- lastY += 27;
- }
- }
- }
- }
TextTimer.Reset();
LogoTimer.Reset();
CreditsTimer.Reset();
diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs
index ed031a09..b66a5f79 100644
--- a/Vocaluxe/Screens/CScreenHighscore.cs
+++ b/Vocaluxe/Screens/CScreenHighscore.cs
@@ -186,6 +186,7 @@ namespace Vocaluxe.Screens
_Round = 0;
_Pos = 0;
_Scores = new List();
+ _NewEntryIDs.Clear();
AddScoresToDB();
LoadScores();