views:

78

answers:

0

In an effort to program an XNA game in a landscape orientation I found a post on this site: http://www.smartypantscoding.com/creating-a-windows-phone-7-xna-game-in-landscape-orientation. After implementing the code it took my simple graphic and indeed transformed the orientation. However, mysteriously the renderTarget is losing its reference to the graphics device that the emulator is using, or at least I thought. So I used the debugger to delve deeper into the program and I found to my amazement that visual studio considered Render.Graphics device to be a different than graphics.GraphicsDevice. Leading to the following error:

System.InvalidOperationException was unhandled

Message=Resources can only be used on the GraphicsDevice that they were created on. This resource was not created on this GraphicsDevice.

StackTrace:

   at Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetRenderTargets(RenderTargetBinding[] renderTargets)

   at Microsoft.Xna.Framework.Graphics.GraphicsDevice.SetRenderTarget(RenderTarget2D renderTarget)

   at BDB_Mobile.Game1.Draw(GameTime gameTime)

   at Microsoft.Xna.Framework.Game.DrawFrame()

   at Microsoft.Xna.Framework.Game.Tick()

   at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)

   at Microsoft.Xna.Framework.GameHost.OnIdle()

   at Microsoft.Xna.Framework.MobileGameHost.RunOneFrame()

   at Microsoft.Xna.Framework.MobileGameHost.gameLoopTimer_Tick(Object sender, EventArgs e)

   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)

   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

Any thoughts as to why the graphics device reference would change?

Thank you.