Where am I?
If you developing games using XNA game studio, many times you need to know where your code is running - on PC or on Xbox 360 hardware... Unfortunately, there is no any out-of-the box functionality provided by XNA Framework to check platform, but here is the solution: XBox 360 the only device, which supports special 3rd mode for Pixel & Shaders version 3 on its Shader profile and this could be checked out.
Here is the sample code:
1: bool isXbox = false;
2:
3: //Lets get graphics device for current game
4: GraphicsDeviceManager graphics;
5: graphics = new GraphicsDeviceManager(this);
6: GraphicsDevice graphics = graphics.GraphicsDevice;
7:
8: //Once we have graphics device, we could check its capabilities
9: if (graphics.GraphicsDeviceCapabilities.MaxPixelShaderProfile == ShaderProfile.XPS_3_0 ||
10: graphics.GraphicsDeviceCapabilities.MaxPixelShaderProfile == ShaderProfile.XVS_3_0)
11: //XBox 360 is the only device, which will support this ShaderProfiles
12: isXbox = true;
13:
14: //Rest of your game code goes here....
Want to know more about XNA game development? See me at TechEd 08, developing XBox 360 game on stage - DEV335: Game Development Using Microsoft’s Latest Technologies
Enjoy,
Alex