Over a million developers have joined DZone.

Using PerfHUD with XNA

· Mobile Zone

Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud, brought to you in partnership with IBM.

I am definitely a fan of ATI cards. Had a few Geforces but didn’t liked them very much. I actually noticed image quality decrease when switching from an old Radeon 9800 to a Geforce 8k something. I’m very happy with my Radeon 4890, now for the downside, PerfHUD, a very handy tool for Game Developers is only available for NVIDIA chipsets and although ATI has it’s own GPUPerfStudio it’s not the same thing.
Anyway for those who have one and are developing for XNA you may have noticed that it doesn’t run PerfHUD out of the box.
You will get an error, something like:
“This applications is not configured for using PerfHUD. Consult the User’s Guide for more information”


Luckily there’s a little trick we can use to fix this, first we create a new class:

// class that inherits from GraphicsDeviceManager
public class PerfHUDGraphicDeviceManager : GraphicsDeviceManager
        public PerfHUDGraphicDeviceManager(Game game)
            : base(game) // Pass game to base class
        // We override the RankDevices to search for a PerfHUD
        protected override void RankDevices(List foundDevices)
            bool has_perfHud = false;
            foreach (var device in foundDevices)
                if (device.Adapter.Description.Contains("PerfHUD"))
                    has_perfHud = true;
            // Found PerfHUD
            if (has_perfHud)
                var temp = foundDevices.OrderBy(
                    (gdi) => !(gdi.Adapter.Description.Contains("PerfHUD"))
                foreach (var dev in foundDevices)
                    dev.DeviceType = DeviceType.Reference;

This class basically searches for PerfHUD, so when you open it with it this class detects that the software exists and allows it’s usage. If not found, the regular GraphicDeviceManager is used. Now instead of creating a new GraphicsDeviceManager() on your Game class just do something like:

public class Game1 : Game
		public Game1()
                    new PerfHUDGraphicDeviceManager(this);


I hope this helps.

The Mobile Zone is brought to you in partnership with Strongloop and IBM.  Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud.


Published at DZone with permission of David Amador, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}