0

So I've written my own game class, which is initialized like so (BTW, this is F# not 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()

and this is simply how I try to shut the system down:

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

root is the first argument in the constructor, so it is the same object as engine in the first sample. Here's the full error:

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()

InnerException:

And one more thing: not sure if this has anything to do with it, but I've also been getting the following errors immediately when the project launches:

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

Am I doing something wrong or is this an Axiom bug?

PS: I'm running under Windows 8 and Visual Studio 2012 Professional using the OpenGL render system.

Jwosty
  • 3,497
  • 2
  • 22
  • 50
  • You say that 'root' is the first argument of the constructor - can we see the code where this is the case? – Kit Jul 08 '13 at 06:34
  • It looks like this: `type Game(root: Root, window: Window) = ...` – Jwosty Jul 08 '13 at 14:32
  • Also, remember that this is F# which has "default" constructors like the above. It's a bit different than C#, but its pretty much just a constructor with automatic field bindings to arguments. They're used when you don't need any special code. – Jwosty Jul 08 '13 at 14:33

0 Answers0