Sprite issue

May 10, 2012 at 8:37 PM
Edited May 10, 2012 at 8:38 PM

Hi indiefreaks,

First, congratulations and thanks for the great job,

I'm currently having some issues with indiefreaks and the Sprites, and ONLY on wp7 (emulator or devices).

I created an indiefreaks project (I just took the first tutorial code), and added the SpriteObjectManager to create a single sprite. This sprite is the only SceneObject to render in the gamestate. And i'm having an exception, here is the callstack.





> Microsoft.Xna.Framework.dll!Microsoft.Xna.Framework.Helpers.GetExceptionFromResult(uint result) + 0x252 bytes   Microsoft.Xna.Framework.Graphics.dll!Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(uint result) + 0x75 bytes   Microsoft.Xna.Framework.Graphics.dll!Microsoft.Xna.Framework.Graphics.GraphicsHelpers.ThrowExceptionFromResult(uint result) + 0x4 bytes   Microsoft.Xna.Framework.Graphics.dll!Microsoft.Xna.Framework.Graphics.VertexBuffer.SetData<2.5>(int offsetInBytes, 2.5[] data, int startIndex, int elementCount, int vertexStride) + 0x6c bytes   Microsoft.Xna.Framework.Graphics.dll!Microsoft.Xna.Framework.Graphics.VertexBuffer.SetData<2.5>(2.5[] data, int startIndex, int elementCount) + 0xb bytes   SynapseGaming-SunBurn-Indie.dll!2.u.f() + 0x212 bytes   SynapseGaming-SunBurn-Indie.dll!2..f() + 0x34 bytes   SynapseGaming-SunBurn-Indie.dll!SynapseGaming.LightingSystem.Rendering.SpriteContainer.End() + 0x49 bytes   Indiefreaks.Game.Sprites.dll!Indiefreaks.Xna.Rendering.Sprite.SpriteObjectManager.BeginFrameRendering(SynapseGaming.LightingSystem.Core.ISceneState scenestate) + 0xcf bytes   SynapseGaming-SunBurn-Indie.dll!SynapseGaming.LightingSystem.Core.SceneInterface.BeginFrameRendering(SynapseGaming.LightingSystem.Core.ISceneState scenestate) + 0x35 bytes   Indiefreaks.Game.Framework.dll!Indiefreaks.Xna.Core.GameState.BeginFrame(Microsoft.Xna.Framework.GameTime gameTime) + 0x30 bytes   Indiefreaks.Game.Framework.dll!Indiefreaks.Xna.Core.GameState.Indiefreaks.Xna.Core.IDraw.Draw(Microsoft.Xna.Framework.GameTime gameTime) + 0x10 bytes   Indiefreaks.Game.Framework.dll!Indiefreaks.Xna.Core.Application.Draw(Microsoft.Xna.Framework.GameTime gameTime) + 0x6a bytes   Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.DrawFrame() + 0x80 bytes   Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.Tick() + 0x2d7 bytes   Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.HostIdle(object sender, System.EventArgs e) + 0x6 bytes   Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.GameHost.OnIdle() + 0x19 bytes   Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.MobileGameHost.RunOneFrame() + 0xc bytes   Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.MobileGameHost.gameLoopTimer_Tick(object sender, System.EventArgs e) + 0x1e bytes   Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.DispatcherTimerWin32.TimerElapsed(System.IntPtr hWnd, uint uMsg, System.IntPtr nIDEvent, uint uTime) + 0x19 bytes


Additional information: You may not call SetData on a resource while it is actively set on the GraphicsDevice. Unset it from the device before calling SetData.


I tried to do the same without your SpriteObject abstraction, but with the original SpriteContainer, I got the same issue (exactly on SpriteContainer.End() in my gamestate update).


The exactly same logic without indiefreaks but with SunBurn works as a charm.

I tried to explore the code of indiefreaks but you'll certainly know better than me from where it can come from.

I also have noticed that when a console message is on the screen it does not crash until the message disapear.

Here is a project that reproduces the bug : http://www.bitupload.com/3t72g3m5wpyr.

If you don't have the time to look at the code, here is the logic that I do for the Sprite :


// -----in the main class that inherits from Application----------

protected override void InitializeSunburn()
   // [ ... ]
   SunBurn.AddManager(new SpriteObjectManager(SunBurn));
   // [ ... ]

// ----------------------in a game state---------------------------------
public override void Initialize()
            // Get the SpriteObjectManager
            SpriteObjectManager som = (SpriteObjectManager)SunBurn.GetManager<SpriteManager>(true);

            // Create a SpriteContainer
            _spriteSpriteContainer = som.CreateSpriteContainer();
            _spriteSpriteContainer.Visibility = ObjectVisibility.Rendered;
            _spriteSpriteContainer.Mass = 0;    
            // when this message disapear, it crashes
            SystemConsole.AddMessage("Bonjour !", 3);

            // Create a SpriteObject
            _sprite = som.CreateSpriteObject<Sprite>("sprite", "Textures/Character/sprite_material", _spriteSpriteContainer);
            _sprite.Rotation = MathHelper.ToRadians(180);


            // when loading is complete, submit the sprite to the objectManager
            LoadingCompleted += delegate


Do I do something wrong, is it a bug from igf ? Your help is welcomed.

May 10, 2012 at 11:53 PM


First thanks for the kind comments... Always great to see new buddies playing with your stuff ;)

Unfortunatelly, looking at your code, I don't see anything that you aren't doing right.
Could you please tell me where exactly the code throws an exception in your code?

I haven't played with IGF's sprites for a while so I need to dig in and see if anything in SunBurn changed with the recent releases in the way it works.
It seems that the issue is raised because the SpriteContainer.End() is setting the vertexbuffer at a time it shouldn't.

I'll see what I can do.

May 11, 2012 at 1:44 AM

Unfortunetly, I don't have the Debug symbols for IGF and SunBurn, so I can't see from where the exception came from, I were only able to find that SpriteContaire.End() is guilty by doing SunBurn style sprites.

For the moment, I'm developping with a little trick : I've always a message in the console.

Anyway, thanks for the attention, it's nice to see that you are active on the support and the development.

May 22, 2012 at 6:21 PM


After long and hard researches on the question, I've been able to determine that igf is not responsible for these bugs, but sunburn is !

I've posted on SunBurn forum, and they recognized that the problem could be theirs.

Thanks for doing your great job, and thanks to SunBurn too.

Best regards.

May 22, 2012 at 8:55 PM
chanhpomme wrote:


After long and hard researches on the question, I've been able to determine that igf is not responsible for these bugs, but sunburn is !

I've posted on SunBurn forum, and they recognized that the problem could be theirs.

Thanks for doing your great job, and thanks to SunBurn too.

Best regards.

Yeah, I just read your post in their forums and I'm glad it is in their hands as I'm so busy with my current position and son that I have difficulties to find out spare time :/