From fa035cb4df307988a440367621eaa6e5b1e1bf86 Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Thu, 1 Dec 2011 10:31:25 +0000 Subject: [PATCH] added some more logging and exception handling to trace errors on linux --- ANX.Framework/Game.cs | 24 ++++++++++++------- ANX.Framework/NonXNA/AddInSystemFactory.cs | 2 +- .../ANX.Framework.Windows.GL3.csproj | 4 ++++ .../ANX.Framework.Windows.GL3/Creator.cs | 4 ++++ .../Properties/AssemblyInfo.cs | 4 ++-- .../WindowsGameHost.cs | 7 ++++++ Samples/WindowsGame/WindowsGame.csproj | 4 ++++ 7 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ANX.Framework/Game.cs b/ANX.Framework/Game.cs index 0de64cb4..80aafd63 100644 --- a/ANX.Framework/Game.cs +++ b/ANX.Framework/Game.cs @@ -168,15 +168,23 @@ namespace ANX.Framework logger.Info("creating GameHost"); - //TODO: error handling if creator is null - this.host = AddInSystemFactory.Instance.GetDefaultCreator().CreateGameHost(this); + IRenderSystemCreator creator = AddInSystemFactory.Instance.GetDefaultCreator(); + if (creator != null) + { + this.host = creator.CreateGameHost(this); - this.host.Activated += new EventHandler(this.HostActivated); - this.host.Deactivated += new EventHandler(this.HostDeactivated); - this.host.Suspend += new EventHandler(this.HostSuspend); - this.host.Resume += new EventHandler(this.HostResume); - this.host.Idle += new EventHandler(this.HostIdle); - this.host.Exiting += new EventHandler(this.HostExiting); + this.host.Activated += new EventHandler(this.HostActivated); + this.host.Deactivated += new EventHandler(this.HostDeactivated); + this.host.Suspend += new EventHandler(this.HostSuspend); + this.host.Resume += new EventHandler(this.HostResume); + this.host.Idle += new EventHandler(this.HostIdle); + this.host.Exiting += new EventHandler(this.HostExiting); + } + else + { + logger.Error("could not fetch RenderSystem creator to create a game host..."); + throw new NullReferenceException("could not fetch RenderSystem creator"); + } logger.Info("creating ContentManager"); this.content = new ContentManager(this.gameServices); diff --git a/ANX.Framework/NonXNA/AddInSystemFactory.cs b/ANX.Framework/NonXNA/AddInSystemFactory.cs index 3aba855c..7d1258a6 100644 --- a/ANX.Framework/NonXNA/AddInSystemFactory.cs +++ b/ANX.Framework/NonXNA/AddInSystemFactory.cs @@ -224,7 +224,7 @@ namespace ANX.Framework.NonXNA return defaultCreators[type] as T; } - return default(T); + throw new AddInLoadingException(String.Format("couldn't find a DefaultCreator of type '{0}'", type.FullName)); } public void SetDefaultCreator(T creator) where T : class, ICreator diff --git a/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj b/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj index a1229110..bc238d0b 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj +++ b/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj @@ -34,6 +34,10 @@ x86 + + False + ..\..\lib\NLog\NLog.dll + ..\..\lib\OpenTK\OpenTK.dll diff --git a/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs b/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs index 88df3cf1..efe37e0a 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs @@ -6,6 +6,7 @@ using ANX.Framework.Graphics; using ANX.Framework.NonXNA; using ANX.Framework.NonXNA.RenderSystem; using OpenTK; +using NLog; #region License @@ -61,6 +62,8 @@ namespace ANX.Framework.Windows.GL3 /// public class Creator : IRenderSystemCreator { + private static Logger logger = LogManager.GetCurrentClassLogger(); + #region Public /// /// Name of the Creator implementation. @@ -101,6 +104,7 @@ namespace ANX.Framework.Windows.GL3 #region CreateGameHost public GameHost CreateGameHost(Game game) { + logger.Info("creating OpenGL3 GameHost"); return new WindowsGameHost(game); } #endregion diff --git a/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs b/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs index 75841c3c..bfd713e3 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs @@ -32,7 +32,7 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.5.4.0")] -[assembly: AssemblyFileVersion("0.5.4.0")] +[assembly: AssemblyVersion("0.5.5.0")] +[assembly: AssemblyFileVersion("0.5.5.0")] [assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")] diff --git a/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameHost.cs b/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameHost.cs index df564c86..421c72b3 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameHost.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameHost.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; +using NLog; #region License @@ -53,6 +54,8 @@ namespace ANX.Framework.Windows.GL3 { public class WindowsGameHost : GameHost { + private static Logger logger = LogManager.GetCurrentClassLogger(); + #region Private private Game game; private WindowsGameWindow gameWindow; @@ -75,7 +78,11 @@ namespace ANX.Framework.Windows.GL3 { isQuitting = false; game = setGame; + + logger.Info("creating a new GameWindow"); gameWindow = new WindowsGameWindow(); + + logger.Info("hook up GameWindow events"); gameWindow.Activated += delegate { OnActivated(); diff --git a/Samples/WindowsGame/WindowsGame.csproj b/Samples/WindowsGame/WindowsGame.csproj index 74a627b0..c62727fd 100644 --- a/Samples/WindowsGame/WindowsGame.csproj +++ b/Samples/WindowsGame/WindowsGame.csproj @@ -103,6 +103,10 @@ {5CA3CDF5-4D2C-42AC-AD08-641BD3992B75} ANX.InputSystem.OpenTK + + {DB88DDEB-7281-405D-8FCA-5681B6B2BD7A} + ANX.InputSystem.Recording + {E5D69E75-D77C-493F-BBDA-6F9E73B82549} ANX.InputSystem.Windows.Kinect