DCSIMG
Where am I? - Alex Golesh's Blog About Silverlight Development

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

 

sign_speaker2Enjoy,

Alex

Published Tuesday, March 25, 2008 12:30 PM by Alex Golesh

Comments

# re: Where am I?

I would be better to regex check for XPS/XVS string. Not all XBoxes have latest version of pixel shader profile

msdn2.microsoft.com/.../microsoft.xna.framework.graphics.shaderprofile.aspx

Tuesday, March 25, 2008 3:26 PM by Tamir Khason

# re: Where am I?

Why make string comparison, if you have enum?

All Xboxes 360 have same pixel shader specifications as baseline (XPS_3_0/XVS_3_0) or better... And on old XBox XNA will not run anyway.

Tuesday, March 25, 2008 4:18 PM by Alex Golesh

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: