diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 07fb2e5c..2a6de382 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -73,6 +73,13 @@ namespace Vocaluxe.Lib.Draw _Keys = new CKeys(); _D3D = new Direct3D(); + if (_D3D == null) + { + MessageBox.Show("No DirectX runtimes were found, please download and install them from http://www.microsoft.com/download/en/details.aspx?id=8109"); + CLog.LogError("No DirectX runtimes were found, please download and install them from http://www.microsoft.com/download/en/details.aspx?id=8109"); + Environment.Exit(Environment.ExitCode); + } + this.Paint += new PaintEventHandler(this.OnPaintEvent); this.Closing += new CancelEventHandler(this.OnClosingEvent); this.Resize += new EventHandler(this.OnResizeEvent); @@ -167,17 +174,14 @@ namespace Vocaluxe.Lib.Draw flags = CreateFlags.SoftwareVertexProcessing; _Device = new Device(_D3D, _D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware, Handle, flags, _PresentParameters); + if (_Device.Disposed || _D3D.Disposed || _Device == null || _D3D == null) + { + MessageBox.Show("Something went wrong with device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109"); + CLog.LogError("Something went wrong with device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109"); + Environment.Exit(Environment.ExitCode); + } + this.CenterToScreen(); - - //This creates a new white texture and adds it to the texture pool - //This texture is used for the DrawRect method - Bitmap blankMap = new Bitmap(1, 1); - Graphics g = Graphics.FromImage(blankMap); - g.Clear(Color.White); - g.Dispose(); - blankTexture = AddTexture(blankMap); - - blankMap.Dispose(); } #region form events @@ -204,7 +208,6 @@ namespace Vocaluxe.Lib.Draw protected override void OnResize(EventArgs e) { base.OnResize(e); - this.ClientSize = this.ClientSize; RResize(); } @@ -419,7 +422,7 @@ namespace Vocaluxe.Lib.Draw _Device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.Diffuse); _Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate); - int[] indices = new int[6]; + Int16[] indices = new Int16[6]; indices[0] = 0; indices[1] = 1; indices[2] = 2; @@ -427,12 +430,22 @@ namespace Vocaluxe.Lib.Draw indices[4] = 2; indices[5] = 3; - _IndexBuffer = new IndexBuffer(_Device, 6 * sizeof(int), Usage.WriteOnly, Pool.Managed, false); + _IndexBuffer = new IndexBuffer(_Device, 6 * sizeof(int), Usage.WriteOnly, Pool.Managed, true); DataStream stream = _IndexBuffer.Lock(0, 0, LockFlags.None); stream.WriteRange(indices); _IndexBuffer.Unlock(); _Device.Indices = _IndexBuffer; + + //This creates a new white texture and adds it to the texture pool + //This texture is used for the DrawRect method + Bitmap blankMap = new Bitmap(1, 1); + Graphics g = Graphics.FromImage(blankMap); + g.Clear(Color.White); + g.Dispose(); + blankTexture = AddTexture(blankMap); + + blankMap.Dispose(); return true; } else diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 42fb3b06..c336e187 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -63,7 +63,7 @@ namespace Vocaluxe.Screens { JumpTo(KeyEvent.Unicode); return true; - }*/ + } */ } else { @@ -304,11 +304,10 @@ namespace Vocaluxe.Screens id = CSongs.VisibleSongs[song].ID; } - // here is a fault: SetSelectedSong should point to the visible index - Vocaluxe.Lib.Song.CSong s = Array.Find(CSongs.VisibleSongs, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)); - if (s != null && s.ID > -1) + int visibleID = Array.FindIndex(CSongs.VisibleSongs, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)); + if (visibleID > -1) { - id = s.ID; + id = visibleID; SongMenus[htSongMenus(SongMenu)].SetSelectedSong(id); } } @@ -345,4 +344,4 @@ namespace Vocaluxe.Screens SongMenus[htSongMenus(SongMenu)].OnShow(); } } -} +} \ No newline at end of file