Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a game for Windows Phone 8 using XNA 4.0 in Visual Studio express 2012. I'm trying to add a background image to the game with a size of 1366x768 (as i believe WP8 only supports up to 720p). Everything stretches![enter image description here][2] well on the other emulators (WVGA and WXGA) until i use the 720p emulator and i get black bars on the sides. (picture) http://i46.tinypic.com/30crj44.png This is all the code i have used so far:

GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    Texture2D Background;

    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";

        graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;

        this.graphics.IsFullScreen = true;

        // Frame rate is 30 fps by default for Windows Phone.
        TargetElapsedTime = TimeSpan.FromTicks(333333);

        // Extend battery life under lock.
        InactiveSleepTime = TimeSpan.FromSeconds(1);
    }

    /// <summary>
    /// Allows the game to perform any initialization it needs to before starting to run.
    /// This is where it can query for any required services and load any non-graphic
    /// related content.  Calling base.Initialize will enumerate through any components
    /// and initialize them as well.
    /// </summary>
    protected override void Initialize()
    {
        // TODO: Add your initialization logic here

        base.Initialize();
    }

    /// <summary>
    /// LoadContent will be called once per game and is the place to load
    /// all of your content.
    /// </summary>
    protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);

        Background = Content.Load<Texture2D>("SkyBackground");

    }

    /// <summary>
    /// UnloadContent will be called once per game and is the place to unload
    /// all content.
    /// </summary>
    protected override void UnloadContent()
    {
        // TODO: Unload any non ContentManager content here
    }

    /// <summary>
    /// Allows the game to run logic such as updating the world,
    /// checking for collisions, gathering input, and playing audio.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Update(GameTime gameTime)
    {
        // Allows the game to exit
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();

        base.Update(gameTime);
    }

    /// <summary>
    /// This is called when the game should draw itself.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);

        // TODO: Add your drawing code here
        spriteBatch.Begin();
        drawBackground();
        spriteBatch.End();

        base.Draw(gameTime);
    }

    private void drawBackground()
    {
        spriteBatch.Draw(Background, GraphicsDevice.Viewport.Bounds, Color.White);
    }

How can i fix this, or is this normal? Any help for a noob like me would be appreciated :)

share|improve this question
    
Do you know what the current screen resolution is of your app and what happens when you change this to 720p or something else? –  Roy T. Jan 1 '13 at 16:21
add comment

2 Answers 2

up vote 4 down vote accepted

It looks like XNA games are always clamped at a maximum resolution of 800x480; even changing the PreferredBackBufferWidth and PreferredBackBufferHeight parameters doesn't prevent it from using a scaled-up + letterboxed framebuffer.

share|improve this answer
1  
How would be able to make games with higher resolutions for WP8? –  JuanB Jan 1 '13 at 17:45
    
Your only choice is to switch over to DirectX, SharpDX or MonoGame. –  r2d2rigo Jan 1 '13 at 19:44
1  
So with XNA i can only make games with resolutions up to 800x480? What happens if the game is played on a phone with a higher resolution? –  JuanB Jan 1 '13 at 19:55
1  
It gets automatically upscaled and letterboxed if the aspect ratio differs: msdn.microsoft.com/en-us/library/windowsphone/develop/… –  r2d2rigo Jan 1 '13 at 20:07
    
Ok, Thank you for your help :) –  JuanB Jan 1 '13 at 20:11
add comment

I've run into this problem before and I've described how to solve it (or to better phrase it, how to work around it) on Nokia Community Wiki article: Fullscreen XNA games on Windows Phone 8 devices.

r2d2rigo is right, you need to change aspect ratio when running on WP8 devices.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.