0

所以我编写了自己的游戏类,它是这样初始化的(顺便说一句,这是 F# 而不是 C#):

static member RunGame() =
  use engine = new Root()
  // For now, always use OpenGL
  engine.RenderSystem <- engine.RenderSystems.["OpenGL"]
  use renderWindow = engine.Initialize(true)
  let game = new Game(engine, renderWindow)
  game.Load()
  engine.FrameStarted.Add(game.HandleInput)
  engine.FrameRenderingQueued.Add(game.OnRenderFrame)
  engine.StartRendering()            // The error is thrown somewhere inside here
  game.Unload()

这就是我尝试关闭系统的方式:

static member this.HandleInput(e: FrameEventArgs) =
  input.Capture()
  if input.IsKeyPressed(KeyCodes.Escape) then
    root.Shutdown

root是构造函数中的第一个参数,因此它与第一个示例中的对象相同engine。这是完整的错误:

System.NullReferenceException was unhandled
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=Axiom
  StackTrace:
       at Axiom.Graphics.RenderTarget.Update(Boolean swapBuffers)
       at Axiom.Graphics.RenderSystem.UpdateAllRenderTargets(Boolean swapBuffers)
       at Axiom.Core.Root.UpdateAllRenderTargets()
       at Axiom.Core.Root.RenderOneFrame()
       at Axiom.Core.Root.StartRendering()
       at MiningGameTest.Game.RunGame() in H:\Projects\FSharp\MiningGameTest\MiningGameTest\Game.fs:line 22
       at MiningGameTest.Host.Axiom.Program.Main(String[] args) in h:\Projects\FSharp\MiningGameTest\MiningGameTest.Host.Axiom\Program.cs:line 14
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

内部异常:

还有一件事:不确定这是否与它有关,但是当项目启动时我也立即收到以下错误:

A first chance exception of type 'System.DllNotFoundException' occurred in FreeImageNET.dll
A first chance exception of type 'System.DllNotFoundException' occurred in OpenTK.dll
A first chance exception of type 'System.TypeInitializationException' occurred in OpenTK.dll
A first chance exception of type 'System.DllNotFoundException' occurred in OpenTK.dll
A first chance exception of type 'System.NullReferenceException' occurred in Axiom.dll

我做错了什么还是这是一个 Axiom 错误?

PS:我使用 OpenGL 渲染系统在 Windows 8 和 Visual Studio 2012 Professional 下运行。

4

0 回答 0