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

Getting the Winform sample to work with PerfHud from NVidia

Last post 1/8/2009 10:33 PM by Steve Montgomery. 0 replies.
  • 1/8/2009 10:33 PM

    Getting the Winform sample to work with PerfHud from NVidia

    I don't know if anyone else is trying to get PerfHud from NVidia working with the Winform sample, but I figured out how to do it and thought I would share my findings.

    In the WinForm code, you create a control that is used to display the graphics in a form.  If you leave that unchanged, PerfHud won't work with it because the WinForm code initializes the default hardware adapter.  We need to change the code to initialize the PerfHud reference adapter.  So basically what we are going to do is to replace the
                graphicsDevice = new GraphicsDevice(curAdapter, 
                                                    deviceType, 
                                                    windowHandle, 
                                                    parameters); 


    with this code:

                GraphicsAdapter curAdapter = GraphicsAdapter.DefaultAdapter; 
                DeviceType deviceType = DeviceType.Hardware; 
     
                foreach (GraphicsAdapter adapter in GraphicsAdapter.Adapters) 
                { 
                    if(adapter.Description.Contains("PerfHUD")) 
                    { 
                        curAdapter = adapter; 
                        deviceType = DeviceType.Reference; 
     
                    } 
                } 
     
                graphicsDevice = new GraphicsDevice(curAdapter, 
                                                    deviceType, 
                                                    windowHandle, 
                                                    parameters); 

    Basically, what this does is look through all available adapters to see if the PerfHUD adapter is there.  If it is, it creates the graphics device using that adapter.  Otherwise, it uses the default adapter.  Just add this and build your project.  To use PerfHUD, you will need to drag the executeable for your project onto the PerfHUD icon on your desktop and everything should work.

    By the way, you can get PerfHUD in the developer zone community at the NVidia website.

    Hope this helps someone.
Page 1 of 1 (1 items) Previous Next