-
|
|
User's XBox TV resolution
|
I understand that I can set a screen resolution and the XBox 360 will make it fit the user's television, but is there a way to determine the user's TV setting first and make my XNA program match that? In otherwords, if a user's XBox is connected to an old TV, I need to choose a 4:3 aspect ratio. If their XBox is set up for and connected to a wide screen TV I need to choose a 16:9 ratio. Some XBoxes are even connected to VGA monitors with other aspect ratios like 5:4. If I assume a screen size that's different, some users will get black bars. David
|
|
-
|
|
Re: User's XBox TV resolution
|
I haven't tried, but try reading from PrefferedScreenWidth/Height after all the graphics devices have been initialized.
|
|
-
-
- (243)
-
premium membership
MVP
-
Posts
126
|
Re: User's XBox TV resolution
|
float aspectRatio = (float)graphics.GraphicsDevice.Viewport.Width / (float)graphics.GraphicsDevice.Viewport.Height; Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspectRatio, 1.0f, 10000.0f, out projection); Instead of you setting the aspect ratio explicitly by setting the preferred backbuffer width and height, you can just get the default aspect ratio and then base your code off of the aspect ratio 1.6 or whatever. If you use a preferred back buffer width / height then you will get black bars if the TV doesn't match. The Xbox 360 will honor your back buffer request.
Chad Carter Microsoft XNA Game Studio 3.0 Unleashed - Book contains information on 2D, 3D, HLSL, Content Pipeline, XACT, Particle Systems, AI, Physics, Game States, Performance, Zune and 4 full games (2 of which are multiplayer)! TwitterXNA Essentials
|
|
-
|
|
Re: User's XBox TV resolution
|
Thanks for the replies. Unless changed, the GraphicsDevice.Viewport starts as 800 x 600. After configuring an XBox for one's TV via the System blade, choosing Console Settings/Display/HDTV Settings or Screen Format, commercial games can reconfigure themselves accordingly. It would be nice to write our XNA games to work this way as well, but I guess the XBox system configuration isn't available in the XNA framework. Perhaps it will be in a future version. David
|
|
-
|
|
Re: User's XBox TV resolution
|
There is also GraphicsDevice.DisplayMode.Height and GraphicsDevice.DisplayMode.Width which I believe is the current resolution of the display device which, on the Xbox360 is set in the System Blade.
|
|
-
|
|
Re: User's XBox TV resolution
|
Thanks, Xgalaxy! That worked perfectly. Now I don't have to annoy my users with an additional resolution preference screen or a wrong aspect ratio. David
|
|
-
|
|
Re: User's XBox TV resolution
|
I'm still living in the stone ages and just have a regular non-HD non-Widescreen TV. sigh. I'm almost too depressed to ask my question now ... but here it goes: Is there anyway to test how the Xbox 360 handles code on both types of TVs (widescreen and normal)? In case that isn't clear, I would like to know how the following code would work on a widescreen tv. float aspectRatio = (float)graphics.GraphicsDevice.Viewport.Width / (float)graphics.GraphicsDevice.Viewport.Height; Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspectRatio, 1.0f, 10000.0f, out projection); Does it always use 800/600 if not set? If so what about this? float aspectRatio = (float)graphics.GraphicsDevice.DisplayMode.Width / (float)graphics.GraphicsDevice.DisplayMode.Height; Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, aspectRatio, 1.0f, 10000.0f, out projection); Does that always use 640/480? (All assuming that the backbuffer is not being set). I'm trying to determine how to accomplish what David described. Thanks! (Oh and P.S. If there are any Microsoft people around, could you check out my hread in the XACT forums about playlists ... I'm thinking that forum isn't getting any love ... but I could be mistaken) ... (sorry for the off topic)
|
|
-
-
- (10849)
-
Team XNA
-
Posts
8.007
|
Re: User's XBox TV resolution
|
Xbox always really wants to be in a widescreen mode - it will kind of grudgingly run in a 4/3 aspect ratio, but is never really very happy about that :-) You can test the widecreen behavior on a regular TV. Just set a widescreen backbuffer resolution, for instance 1280x720 or 853x480, and it will automatically letterbox the output for you, so you can see exactly how things would look on a widescreen TV (it doesn't letterbox the other way, though: if your game sets a 4x3 backbuffer resolution and then someone runs it on a widescreen TV, that will just get stretched). XACT, huh? :-) Not my main area of expertise but I'll take a look.
XNA Framework Developer -
blog - homepage
|
|
-
|
|
Re: User's XBox TV resolution
|
I now use the following code to set the viewport size. device = graphics.GraphicsDevice; #if XBOX360 // Get users screen preference graphics.PreferredBackBufferWidth = device.DisplayMode.Width; graphics.PreferredBackBufferHeight = device.DisplayMode.Height; graphics.IsFullScreen = true; graphics.ApplyChanges(); #else graphics.PreferredBackBufferWidth = 853; graphics.PreferredBackBufferHeight = 480; graphics.IsFullScreen = false; graphics.ApplyChanges(); Window.Title = "HolliDance"; #endif
I can experiment with different window sizes on the PC and still run XBox code in its user set resolution. David
|
|
-
|
|
Re: User's XBox TV resolution
|
BeachSpiker: I now use the following code to set the viewport size. device = graphics.GraphicsDevice; #if XBOX360 // Get users screen preference graphics.PreferredBackBufferWidth = device.DisplayMode.Width; graphics.PreferredBackBufferHeight = device.DisplayMode.Height; graphics.IsFullScreen = true; graphics.ApplyChanges(); #else graphics.PreferredBackBufferWidth = 853; graphics.PreferredBackBufferHeight = 480; graphics.IsFullScreen = false; graphics.ApplyChanges(); Window.Title = "HolliDance"; #endif
I can experiment with different window sizes on the PC and still run XBox code in its user set resolution. David
Thank you Shawn and David! Shawn, I have set the backbuffer but my key issue is trying to let the Xbox run at what ever the user has selected. So the quoted code from David above .... I always get 640 when I query this property: device.DisplayMode.Width and 480 for this property: device.DisplayMode.Height On a widescreen TV do those values return something else? If so, what? (And is it different depending on different HDTV settings --- this may very obvious but I'm not up to snuff on HDTV) ... I do see now that hte resolution you mentioned shawn is 853x480 and 1280x720 ... and 480 and 720 being HDTV settings perhaps those are the values returned by DisplayMode.Width/Height ? Sorry for being thick on this one.
|
|
-
-
- (10849)
-
Team XNA
-
Posts
8.007
|
Re: User's XBox TV resolution
|
The Xbox could return all kinds of different resolutions depending on the display mode settings. Most often you will see one of these: 640x480 (for regular TV's, or HDTV set to 480p mode) 1280x720 (for HDTV in 720p mode) 1920x1080 (for HDRV in 1080i mode) But other resolutions are possible as well if they are using a VGA cable connected directly to a monitor. The general advice for Xbox games is not to try to copy the raw display resolution, though. This applies both for native games and XNA titles. Games are recommended to just pick whatever resolution they want to render in, and always render at that resolution, letting the Xbox take care of scaling it to match the output device. Generally I'd recommend 1280x720, because this looks great for people with HDTV, and will give nice antialising when Xbox scales it down for people running in 640x480 mode, but it is also fine to just render everything at 640x480 and let Xbox scale up for the HDTV users.
XNA Framework Developer -
blog - homepage
|
|
-
|
|
Re: User's XBox TV resolution
|
Thank you very much Shawn! Excellent info (as always!) Does the Viewport also get other values besides the 800x600 or is it always that regardless of the users TV? (If I read your post right then if the user has a 720p HDTV then the DisplayMode settings will get 1280 and 720 ... curious as to if the defaul Viewport sticks at 800x600 regardless) Thanks again!
|
|
-
|
|
Re: User's XBox TV resolution
|
When I installed my XBox 360, I told it my TV could support 480i, 480p, 720p, and 1080i. When it powers up it runs at the best of these, 1080i. When HolliDance launches, it now sees the resolution as being 1920x1080 (which I can override if needed). The fact that your XBox reports 640x480 reflects your TV's resolution. The initial values for the preferred viewport are still 600x800. There are two approaches to dealing with different types of TV's or monitors. Do you design you game to a specific resolution and aspect ratio and let the XBox figure out how to best display your game, or do you determine a user's XBox 'native' display and conform to that? Conforming to a native resolution offers a few benefits. The obvious one is an elimination of black bars. Another benefit is being able to scale your game graphics according to window size. For example, since Holli is really hard on graphics cards, I'm seeing a noticeable loss of frame rate in HDTV (although I haven't finished optimizing the code yet ), I plan on reducing the number of lights and perhaps using lower resolution prop models in HDTV to compensate. Making a game flexible, however, requires a bit more coding. This is particularly true for 2D displays. 3D is easily adapted to different aspect ratios (the XBox goes from 1.25 to 1.7777.. by the way), but 2D requires manual adjustment of the various element locations. David
|
|
-
|
|
Re: User's XBox TV resolution
|
I am wondering, if there is any way to detect, if the TV is running 480p (Normal) or 480p (Widescreen)? I do not see a solution in this thread, that would allow programming an optimal solution for both. If I would use a widescreen screen buffer, then a normal TV would be letterboxed, and if I would use a non-widescreen screen buffer, the objects would be streched. I can adjust the aspect ratio of my sprites in the game, and I do so to optimally display standard TV (640x480) or obvious widescreen formats (720p, 1080i or 1080p) - based on the graphics.GraphicsDevice.DisplayMode.Height value. But for 480p (Normal) or 480p (Widescreen) this value is indistinguishable. Any suggestions?
|
|
-
-
- (344)
-
premium membership
-
Posts
120
|
Re: User's XBox TV resolution
|
Hi, I have being using the code posted by BeachSpiker but I am wondering if my game is really running on 720p. When debbuging the PreferredBackBuffer says so, but my particle system shows bigger sprites than the PC version of my game. Other sprites looks the same size on both platforms, only the particles get enlarged.
I also think that the PC version looks nicer, so I am a little suspicios about my game being High Definition. ¿Could it be possible that the XBOX is just scaling my game from a lower resolution to the 720p resolution? The TV says it is on 720p.
How can I be really sure that I am rendering HD? Thanks in advance.
|
|
-
|
|
Re: User's XBox TV resolution
|
Baltico X:
I also think that the PC version looks nicer, so I am a little suspicios about my game being High Definition. ¿Could it be possible that the XBOX is just scaling my game from a lower resolution to the 720p resolution? The TV says it is on 720p.
How can I be really sure that I am rendering HD? Thanks in advance.
I would put a breakpoint in after ApplyChanges and run it int he debugger. Once it breaks, directly look at the contents of the graphics variable - you should see the current resolution there. It might just be that you are seeing different default renderstates - I'm currently seeing a problem with a fullscreen quad on the 360 that works fine on my PC...
|
|
-
-
- (7787)
-
premium membership
MVP
-
Posts
5.916
|
Re: User's XBox TV resolution
|
I plan on reducing the number of lights and perhaps using lower resolution prop models in HDTV to compensate.
That sounds like a bad idea -- why would HDTV get a lower quality experience? I would suggest picking a resolution (if you're fill rate limited, try 1280x720 or even 848x480) and making sure that resolution works well, and then let the XBOX scale up to bigger displays. I would very much prefer that to having my experience dumbed down just because my display is 1080p. In fact, if you want a funky back buffer size, how about 960x540? It will letterbox to nice anti-aliasing on 4:3 TVs, and look somewhat better than 480 modes on HDTV, while still not using the fill rate of 1280x720.
Jon Watte, Direct3D MVP Tweets, occasionallykW X-port 3ds Max .X exporter kW Animation source code
|
|
-
|
|
Re: User's XBox TV resolution
|
BeachSpiker -
I am sure this is due to my own brainfart, but I can't get your example code to run.
I'm getting hung up on declaring device;
I'm getting the error that device does not exist in that context. I just can't seem to figure out what to declare it as --
graphics = new GraphicsDeviceManager(this);
device = graphics.GraphicsDevice;
graphics.PreferredBackBufferWidth = device.DisplayMode.Width;
graphics.PreferredBackBufferHeight = device.DisplayMode.Height;
graphics.IsFullScreen = true;
graphics.ApplyChanges();
Removing all of these references to device and setting 1280x720 looks very good for me on both regular and fullscreen TVs.
But I'd like to further understand what you were talking about here, since it didn't work for me.
Thanks!
|
|
-
-
- (0)
-
premium membership
-
Posts
34
|
Re: User's XBox TV resolution
|
the line
| device = graphics.GraphicsDevice |
should be
| GraphicsDevice device = graphics.GraphicsDevice |
And if you want to use the current screen resolution on both windows and XBOX you're better of using this:
| graphics = new GraphicsDeviceManager(this); |
|
| #if !XBOX |
| // Windows specific code |
| graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; |
| graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; |
|
| #else |
| // XBOX360 specific code |
| graphics.PreferredBackBufferWidth = this.Window.ClientBounds.Width; |
| graphics.PreferredBackBufferHeight = this.Window.ClientBounds.Height; |
|
| #endif |
| |
| graphics.IsFullScreen = true; |
| graphics.ApplyChanges(); |
|
|
|