XNA Creators Club Online
Page 1 of 1 (11 items)
Sort Posts: Previous Next

VS2008 stopped working with SpriteFonts. Help!

Last post 7/3/2009 8:43 AM by Kevin Gadd. 10 replies.
  • 11/19/2008 3:43 AM

    VS2008 stopped working with SpriteFonts. Help!

    Hi everyone

    I have a project that I have not played with for a few days. Today I've gone back to work on it.
    Opening the file and trying to run it, I get an ArguementException error.

    ArguementException was unhandled
    The device does not support creating a texture of the given format with the given TextureUsage.
    Parameter name:format


    I tried to open a new XNA project and nade a new SpriteFont.
    I'm getting the same error.

    But if I take out the SpriteFont in both projects, then the code runs fine.


    I tried to open a previous build of the game, but it is crashing on opening.

    I re-installed XNA3.0 but I am still getting the error.


    How can I fix this? SpriteFonts play a big role in this project.
  • 11/19/2008 5:02 PM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    I would be suspicious that something has gone wrong with your graphics driver since when this was last working. Did you install any driver updates, or change any system settings?
    XNA Framework Developer - blog - homepage
  • 11/20/2008 10:03 AM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    I hadn't touched my graphics card drivers so I'm not sure how it suddenly became an issue.

    Installed the latest Catalyst drivers though and the problem has now gone :) yay!

    Thanks!
  • 11/20/2008 1:25 PM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    OK, and it's now doing the same. Same error again.
  • 11/20/2008 4:24 PM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    That definitely sounds like a machine or driver problem. I would guess that rebooting fixes it again?
    XNA Framework Developer - blog - homepage
  • 11/20/2008 11:49 PM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    No, tried that one quite a few times. :(

    I wonder why it worked for 2 tests then suddenly stopped...
  • 11/21/2008 1:57 PM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    Does this help at all?

    Dont want to go and get a new video card to try if it's not actually a video card issue. After all, it was working perfectly and suddenly stopped without me doing any adjustments or driver updates.

    System.ArgumentException was unhandled
      Message="The device does not support creating a texture of the given format with the given TextureUsage.\r\nParameter name: format"
      Source="Microsoft.Xna.Framework"
      ParamName="format"
      StackTrace:
           at Microsoft.Xna.Framework.Graphics.Texture2D.CreateTexture(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Int32 numberLevels, UInt32 usage, _D3DPOOL pool, SurfaceFormat format)
           at Microsoft.Xna.Framework.Graphics.Texture2D..ctor(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Int32 numberLevels, TextureUsage usage, SurfaceFormat format)
           at Microsoft.Xna.Framework.Content.Texture2DReader.Read(ContentReader input, Texture2D existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.InvokeReader[T](ContentTypeReader reader, Object existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.ReadObjectInternal[T](Object existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()
           at Microsoft.Xna.Framework.Content.SpriteFontReader.Read(ContentReader input, SpriteFont existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.InvokeReader[T](ContentTypeReader reader, Object existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.ReadObjectInternal[T](Object existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()
           at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()
           at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
           at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
           at WindowsGame3.Game1.LoadContent() in C:\Users\Richard\Documents\Visual Studio 2008\Projects\WindowsGame3\WindowsGame3\Game1.cs:line 54
           at Microsoft.Xna.Framework.Game.Initialize()
           at WindowsGame3.Game1.Initialize() in C:\Users\Richard\Documents\Visual Studio 2008\Projects\WindowsGame3\WindowsGame3\Game1.cs:line 42
           at Microsoft.Xna.Framework.Game.Run()
           at WindowsGame3.Program.Main(String[ args) in C:\Users\Richard\Documents\Visual Studio 2008\Projects\WindowsGame3\WindowsGame3\Program.cs:line 14
      InnerException:

  • 11/21/2008 5:56 PM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    I find it hard to imagine how this could be anything other than a driver problem.

    If you want to understand more about exactly why it is failing, it would be interesting to find out the size and format of the texture that is being returned by the SpriteFontProcessor. The easiest way to do that would be to make a new processor that derives from SpriteFontProcessor, switch your font to use that, insert a Debugger.Launch call after the base.Process call, and look at the TextureContent object in the watch window.

    I would be surprised if there is anything unusual in there, but this would prove whether the problem is in how the content is being built, or at runtime when it comes to be loaded.
    XNA Framework Developer - blog - homepage
  • 3/11/2009 5:29 PM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    I'm having the same issue here. The details are below. The line that fails is this one:

        GameManager.Current.Game.Content.Load<SpriteFont>(path);

    I'm using XNA 3.0, and it "suddenly" started to fail. If I comment out the line, I've got the same error message when loading a model that previously worked.

    I'll be trying this on other computers soon, and I tried your suggestion. The texture is 256x256, there is 65 536 entries in "PixelData", and blockSize is 16.

    System.ArgumentException was unhandled
      Message="The device does not support creating a texture of the given format with the given TextureUsage.\r\nParameter name: format"
      Source="Microsoft.Xna.Framework"
      ParamName="format"
      StackTrace:
           at Microsoft.Xna.Framework.Graphics.Texture2D.CreateTexture(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Int32 numberLevels, UInt32 usage, _D3DPOOL pool, SurfaceFormat format)
           at Microsoft.Xna.Framework.Graphics.Texture2D..ctor(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Int32 numberLevels, TextureUsage usage, SurfaceFormat format)
           at Microsoft.Xna.Framework.Content.Texture2DReader.Read(ContentReader input, Texture2D existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.InvokeReader[T](ContentTypeReader reader, Object existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.ReadObjectInternal[T](Object existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()
           at Microsoft.Xna.Framework.Content.SpriteFontReader.Read(ContentReader input, SpriteFont existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.InvokeReader[T](ContentTypeReader reader, Object existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.ReadObjectInternal[T](Object existingInstance)
           at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()
           at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()
           at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
           at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
           at ChristianRondeau.Xna.Framework.Game.FontManager.Load(String name, String path) in D:\Personnel\XNA\ChristianRondeau.Xna\ChristianRondeau.Xna.Framework.Game\FontManager.cs:line 17
           at ChristianRondeau.Xna.Sample.Windows.SampleGame.LoadContent() in D:\Personnel\XNA\ChristianRondeau.Xna\ChristianRondeau.Xna.Sample\SampleGame.cs:line 45
           at Microsoft.Xna.Framework.Game.Initialize()
           at ChristianRondeau.Xna.Framework.Game.GameBase.Initialize() in D:\Personnel\XNA\ChristianRondeau.Xna\ChristianRondeau.Xna.Framework.Game\GameBase.cs:line 25
           at ChristianRondeau.Xna.Sample.Windows.SampleGame.Initialize() in D:\Personnel\XNA\ChristianRondeau.Xna\ChristianRondeau.Xna.Sample\SampleGame.cs:line 31
           at Microsoft.Xna.Framework.Game.Run()
           at ChristianRondeau.Xna.Sample.Windows.Program.Main(String[] args) in D:\Personnel\XNA\ChristianRondeau.Xna\ChristianRondeau.Xna.Sample\Program.cs:line 15
      InnerException:

    Thank you for your help,

    Christian Rondeau
  • 6/25/2009 1:23 AM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    I think I'm having the same problem.

    An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.Xna.Framework.dll

    Additional information: The device does not support creating a texture of the given format with the given TextureUsage.

    I am new here and I was trying the tutroial 2D game, I got to the step where you add the score and this happened.
  • 7/3/2009 8:43 AM In reply to

    Re: VS2008 stopped working with SpriteFonts. Help!

    There's already a bug for this on Connect, so I'm sure Microsoft will fix it eventually.

    Regardless, I had to work around this today so that I could get my game running under emulation (mostly for testing purposes, to make sure that it worked on newer operating systems, fresh installs, etc). The solution I came up with is a terrifying hack, but it works.

    Since the default SpriteFont content pipeline processor is not a sealed class, you can derive from it, and override the Process method. Once you've got that working, the only remaining piece of the puzzle is how you disable the DXT compression. A little glancing in Reflector and a little fiddling resulted in this terrifying, but functional hack:
        [ContentProcessor(DisplayName="Uncompressed Sprite Font Description Processor")] 
        public class UncompressedFontDescriptionProcessor : FontDescriptionProcessor { 
            public override SpriteFontContent Process (FontDescription input, ContentProcessorContext context) { 
                var t = context.GetType(); 
                var f = t.GetField("targetPlatform", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); 
                var oldPlatform = f.GetValue(context); 
                // HACK!!!!!!!!!!!!!!!!1 
                f.SetValue(context, TargetPlatform.Zune); 
     
                var result = base.Process(input, context); 
     
                f.SetValue(context, oldPlatform); 
     
                return result; 
            } 
        } 
     

    If you're struggling with this issue because your video driver/video configuration doesn't support DXT3, hopefully this content processor will help you out. I was able to get my game to start up on the emulated video driver once I applied this content processor to both of my SpriteFonts, since I was no longer using any compressed textures.

    Hopefully Microsoft will address this in a future version of the Framework with a texture compression setting for SpriteFonts. :)

    Some more detail for the XNA team: Don't feel bad about SpriteFonts not working for me in compressed mode; it's clearly a bug/missing feature in the emulated video support in the setup I'm using (VirtualBox 3.0 + WineD3D). Viewing the Direct3D CAPS in the Caps tool from the DirectX SDK clearly shows that my emulated driver does not support DXT3, so it's no surprise that loading this SpriteFont fails due to it having a compressed texture. The error feedback in this case is fairly easy to understand, I think, so the only real problem here is that there's no way to disable compression for SpriteFonts. I strongly suggest exposing such an option, so that developers using XNA to build PC games have a way to support customers that, for whatever reason, cannot use DXT-compressed textures.
    Kevin Gadd, Squared Interactive
    Development Blog | Twitter
    Help playtest my game, Inferus!
Page 1 of 1 (11 items) Previous Next