This project is read-only.

Problem with UI2DRenderer

Apr 30, 2011 at 3:58 AM

Hi,

Im running an Goblin XNA application that is invoked from WPF. Everything works fine. However when I exit from the Goblin App and when I run the application back again from the WPF. The following exception is thrown and thats the code are that its making to. Its actually the source code of UI2DRenderer. Any idea why this is happening?. I would really appriciate some help :)

Object reference not set to an instance of an object.

 public static void Flush(bool clear, int shiftAmount)
        {
            if (spriteBatch == null)
                spriteBatch = new SpriteBatch(State.Device);

            // Start rendering with alpha blending mode, and render back to front
            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);

Thanks

Apr 30, 2011 at 7:14 AM

Which reference is null, is it State.Device?  If so, it would seem like for some reason this Flush function is getting called before the State.InitGoblin (that's where State.Device gets assigned).  Please step through your program to make sure that State.InitGoblin is called before you reach this point.  If that doesn't solve it, please post a StackTrace from your exception; that may help diagnose the problem.

Apr 30, 2011 at 1:10 PM

Hi,

Thanks for the reply. It seems that spritebatch is not re-initilized by the UI2DRenderer.
I have taken a snapshot of the exception http://img543.imageshack.us/i/exception.png/

at Microsoft.Xna.Framework.Graphics.RenderState.set_CullMode(CullMode value) at Microsoft.Xna.Framework.Graphics.SpriteBatch.SetRenderState() at Microsoft.Xna.Framework.Graphics.SpriteBatch.Begin(SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode, Matrix transformMatrix) at Microsoft.Xna.Framework.Graphics.SpriteBatch.Begin(SpriteBlendMode blendMode, SpriteSortMode sortMode, SaveStateMode stateMode) at GoblinXNA.UI.UI2D.UI2DRenderer.Flush(Boolean clear, Int32 shiftAmount) in E:\GoblinXNAv3.5\GoblinXNAv3.5\src\UA first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.Xna.Framework.dll A first chance exception of type 'System.NullReferenceException' occurred in Microsoft.Xna.Framework.dll I\UI2D\UI2DRenderer.cs:line 638 at GoblinXNA.UI.UIRenderer.Draw(Single elapsedTime, Boolean clear, Boolean renderRightEye) in E:\GoblinXNAv3.5\GoblinXNAv3.5\src\UI\UIRenderer.cs:line 393 at GoblinXNA.SceneGraph.Scene.RenderScene(Boolean renderUI) in E:\GoblinXNAv3.5\GoblinXNAv3.5\src\SceneGraph\Scene.cs:line 2401 at GoblinXNA.SceneGraph.Scene.RenderScene() in E:\GoblinXNAv3.5\GoblinXNAv3.5\src\SceneGraph\Scene.cs:line 2345 at GoblinXNA.SceneGraph.Scene.Draw(GameTime gameTime) in E:\GoblinXNAv3.5\GoblinXNAv3.5\src\SceneGraph\Scene.cs:line 2706 at Microsoft.Xna.Framework.Game.Draw(GameTime gameTime) at GT_Goblin.AR.Reality.Draw(GameTime gameTime) in E:\Guitar_Tutor_Codebase\Guitar Tutor\Guitar Tutor\XNA\AR\Reality.cs:line 343


Thanks