BBeck's Profile User Rating: *****

Reputation: 586 Enlightened
Active Posts:
1,308 (1.38 per day)
24-April 12
Profile Views:
Last Active:
User is offline Today, 09:10 AM

Previous Fields

OS Preference:
Favorite Browser:
Internet Explorer
Favorite Processor:
Favorite Gaming Platform:
Your Car:
Who Cares
Dream Kudos:
Expert In:
Game Programming, XNA

Latest Visitors

Icon   BBeck is experimenting in his gaming lab. Don't be alarmed if something explodes.

Posts I've Made

  1. In Topic: XNA - Get Multiple GPU Names.

    Posted 26 Nov 2014

    Interestingly enough, if you drag the window to the second monitor and then use the following code to make it full screen, that other screen becomes the adapter in use and it's then in full screen mode on that other monitor.

                if (KBState.IsKeyDown(Keys.End))
  2. In Topic: XNA - Get Multiple GPU Names.

    Posted 26 Nov 2014

    Incidently, I got curious about why this is setup this way and used the following code in the Update() method to see if the adapter name would change when I drag a window between monitors. The current adapter in use does change when I drag the window to the other monitor although having it on both monitors simultaneously seems to confuse it and it doesn't change until it's 100% over on the other monitor.

                if (KBState.IsKeyDown(Keys.Home))
                    foreach (GraphicsAdapter EnumeratedAdapter in GraphicsAdapter.Adapters)
                        if (EnumeratedAdapter == GraphicsDeviceInUse.Adapter)
                            GraphicsAdapterInUse = EnumeratedAdapter;
                            Console.WriteLine(GraphicsAdapterInUse.DeviceName + " is the current adapter.");
                            LastAdapterFound = EnumeratedAdapter;
                            Console.WriteLine(LastAdapterFound.DeviceName + " is another adapter on this machine.");
  3. In Topic: XNA - Get Multiple GPU Names.

    Posted 26 Nov 2014

    Awesome! The DreamInCode website is actually working from this computer for a change. Just in time for me to post what I found.

    I found the answer, but I don't think you're going to like it.

    First of all, I don't think we're looking for "GPU's" here. The GPU is the CPU of the graphics card and I don't know what kind of graphics card you have, but I think mine (which is fairly high end) only has one GPU. Even if it did have multiple GPUs or cores they probably would not have names but rather numbers.

    So, I assume that what we're looking for here is GraphicsAdapters which "seems" to correspond mostly to outputs from your graphics card. So, the laptop I'm testing on has the graphics card built into the mother board, but it has its own screen as well as a monitor output that can be used simultaneously. I'm typing on the external monitor while Visual Studio is on the main screen. The main screen is also where my XNA code runs.

    Each screen/monitor/video-output/graphics adapter has its own name. To cut to the chase, you're looking at the DeviceDescription which is wrong if you want to know what video-outputs you have going on (which may or may not be running off the same graphics card. What I think you want is the DeviceName rather than description. This will give you every video output on that GraphicsDevice.

    I think multiple graphics cards actually would be multiple GraphicsDevices rather that multiple GraphicsAdapters.

    So, I researched to find out how to use multiple GraphicsAdapters or how to make use of dual monitors in XNA. And I pretty much got back the definitive answer "Don't!". And I think that's your real question. I mean, listing their names is probably only the beginning. I assume you want to use that list to then control the different monitors and what gets drawn on them.

    And I've seen the answer to that question on a couple of websites, but I found a link to a post by Shawn Hargreaves. I don't know if you're familiar with Shawn but he is THE XNA guru. I don't know what he's up to these days because he stopped doing XNA several years ago. But until he stopped he was THE best source for info on XNA on the planet. His old posts have helped me understand some of the most difficult parts of XNA. Out of all the top XNA experts out there, I would say he's numero uno. And he answered the question basically by saying, "Don't do it!" I usually don't like posting links to other forums here, but in this case I think you should get it straight from the horse's mouth.

    To sum it up, he says that you can extend the GraphicsDeviceManager class yourself to support multiple monitors but that unless you're pretty much almost at his level, don't even try it because it's going to be one of the most difficult things you could possibly do in XNA. (Which would explain why there's no info on it on the Internet.)

    I'm pretty disappointed by this myself.

    Also, I'll probably need to find the answer myself in the next 12 months, but in DirectX 11, where it might actually be a little easier. I would like to get to coding DX11 for the Oculus Rift although I have other things higher priority at the moment. That would basically be dual monitors with the Oculus as a second monitor. So, I'm going to have to dig in to this deeper later and find some actual answers. :-(

    Anyway, it appears that the GraphicsDeviceManager is probably the best match to a graphics card. Each screen you draw to is going to definately have to have a back buffer and the back buffer is managed by the GraphicsDeviceManager. So, either the GraphicsDeviceManager has to support multiple backbuffers/screens or you will have to have multiple GraphicsDeviceManagers and the Game1 class doesn't seem to support that.

    Looks like the way XNA was setup, it doesn't support multiple monitors, but if you want to guru it and build that into XNA yourself, you can dig deep into the Game class and the GraphicsDeviceManager and rebuild your own GraphicsDeviceManager class (inherited from XNA's GraphicsDeviceManager) to support multiple monitors.

    Anyway, the following code writes the names of all GraphicsAdapters to the console output. I tested it on my laptop and it returned the names "...\Display1" and "...\\Display2". The adapter description, by the way, seems to be the type of graphics card being used, and so since a graphics card is probably more of a GraphicsDevice or GraphicsDeviceManager, all adapters (graphics outputs) from that single graphics card are going to have the same type of graphics card which is the DeviceDescription. So, DeviceDescription will alway return the exact same thing because the graphics card type is the same for all adapters. The only way you "might" see a difference there is if you had two different types, or brands, of graphics cards installed (and generally even people who run multiple graphics cards match them to be of the same type). The output names are DeviceName. I think this may have been what you were wondering about in your original post.

    Post Script: Going back and reading your original post, it does sound like you have two completely seperate graphics cards and you're trying to get their types (DeviceDescription). That's a little different than my laptop. That being the case, those two cards should be two seperate GraphicsDevices rather than two seperate adapters based on my understanding of how all this works.

    When I stop the code in debug mode, what I find is that the GraphicsDevice is assigned to the Graphics Device Manager between the Game1 contructor and the Initialize() methods. So, it's largely happening out of your control. Furthermore, the class only has one GraphicsDevice. To switch the display, or make use of a second graphic card, I believe you would have to modify the GraphicsDeviceManager to support a second GraphicsDevice. Notice the backbuffer, depth buffer, and stencil buffer are all managed at the GraphicsDeviceManager level and you'll need one of those for every monitor you display to unless you use one and somehow split it to multiple monitors which can all be running at completely different resolutions and aspect ratios.

    My guess is that the reason that Microsoft only "half" implemented this in XNA is that they wanted to support moving a windowed window between multiple monitors, which seems to work quite well. But it looks like they never took it to the next level to really fully support multiple monitor use in XNA. Although to their credit, they seem to have built XNA in a way that you can program multiple monitor support yourself if you've got the chops to do it.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Audio;
    using Microsoft.Xna.Framework.Content;
    using Microsoft.Xna.Framework.GamerServices;
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework.Input;
    using Microsoft.Xna.Framework.Media;
    namespace WindowsGame1
        public class Game1 : Microsoft.Xna.Framework.Game
            GraphicsDeviceManager graphics;
            GraphicsDevice GraphicsDeviceInUse;
            GraphicsAdapter GraphicsAdapterInUse;
            GraphicsAdapter LastAdapterFound;
            SpriteBatch spriteBatch;
            public Game1()
                graphics = new GraphicsDeviceManager(this);
                graphics.PreferredBackBufferWidth = 1280;   //Screen width horizontal
                graphics.PreferredBackBufferHeight = 720;   //Screen width vertical
                graphics.IsFullScreen = false;  //In full screen mode you won't be able to debug and see console output.
                Content.RootDirectory = "Content";
            //Good info at:
            protected override void Initialize()
                GraphicsDeviceInUse = graphics.GraphicsDevice;
                int NumberOfAdapters = GraphicsAdapter.Adapters.Count;
                List<GraphicsAdapter> Monitors = new List<GraphicsAdapter>();
                foreach (GraphicsAdapter EnumeratedAdapter in GraphicsAdapter.Adapters)
                    if (EnumeratedAdapter == GraphicsDeviceInUse.Adapter)
                        GraphicsAdapterInUse = EnumeratedAdapter;
                        LastAdapterFound = EnumeratedAdapter;
                Console.WriteLine("The current adapter is " + GraphicsAdapterInUse.DeviceName + " even though it has a weird name.");
                foreach (GraphicsAdapter EnumeratedAdapter in Monitors)
                    Console.WriteLine("Graphics Adapter Found:" + EnumeratedAdapter.DeviceName+".");
            protected override void LoadContent()
                spriteBatch = new SpriteBatch(GraphicsDeviceInUse);
            protected override void UnloadContent()
            protected override void Update(GameTime gameTime)
                KeyboardState KBState;
                KBState = Keyboard.GetState();
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                if (KBState.IsKeyDown(Keys.Escape)) this.Exit();
            protected override void Draw(GameTime gameTime)
  4. In Topic: XNA - Get Multiple GPU Names.

    Posted 25 Nov 2014

    I think I may have a way to test it. Maybe I can look at the problem tomorrow when I'm at that computer. It has two monitors; so I should be able to test it out on that system.
  5. In Topic: XNA - Get Multiple GPU Names.

    Posted 24 Nov 2014

    So to add on to the previous code, you could do this:

    foreach (string Adapter in AdapterNames)

My Information

Member Title:
Here to help.
Age Unknown
Birthday Unknown
Dallas, Texas, US of A, Planet Earth, Sol System, Milky Way Galaxy
Rock music composition and performance, Grunge Music, Bebop (think Thelonios Monk), Swing (think Cab Calloway), Gaming, Astronomy, RPGs, Scuba, Sail Boats, Furniture Building, Cooking, Rocky Patel Cigars, Character Driven Dramas(like HBO's Deadwood), Story Telling (plot writing), Linguistics, Economics, Target Shooting, Electronics (don't know as much as I'd like to), all aspects of 3D game programing including music, physics, modeling, texturing, annimation, probability, AI, lighting, etc., Texas Holdem' Poker, Learning, Dogs, the love of my life (my pit bull), guns (especially 19th century black powder), putting make-up on ogres, etc.
Programming Languages:
C, C++, C#, Visual Basic, Java, Pascal, T-SQL, HTML, FoxPro, ASP.Net(very little), Assembler, Machine Code(conceptually anyway)

Contact Information

Website URL:
Website URL


Page 1 of 1
  1. Photo

    BBeck Icon

    11 Aug 2013 - 04:27
    Generally, yes. :-)
  2. Photo

    aaron1178 Icon

    10 Aug 2013 - 00:42
    You wouldn't happen to get high marks in written exams would you ;)
Page 1 of 1