Setting the Fullscreen Resolution

Hello all, I have a very simple question that I can't seem to find a direct answer to. My Game's GraphicsComponent's backfuffer is set to 320 x 240. The game window is also 320 x 240. When I swtich to fullscreen by setting the GraphicsComponent's IsFullscreen property to true the fullscreen resolution seems to be 640 x 480. My graphics appear up in the top-left corner.

How can I set the fullscreen resolution to 320 x 240?

[432 byte] By [Maxamor] at [2007-12-25]
# 1
Pretty sure you can't on modern hardware.
You could render to a 320x240 target, and then stretch that out to cover the 640x480 screen. Why don't you just render in 640x480 in the first place though? It's exactly twice as big in both dimensions, it should be trivial to switch.
KrisNye at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 2
The reason I'm not rendering at 640 x 480 is because I am making a 2d, tile-based game. I don't want to draw any more of the leven than I am already. Rather than stretching everything by 2 it would be easier to just continue rendering them at regular size and stretching the image to the desired resolution.

Thanks for your help.

EDIT: I can't seem to figure out how to stretch my resulting image each frame. Can't I just modify my viewport or something?

Maxamor at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 3
If you'd like to stretch your image, look into the GraphicsDevice.StretchRectangle method.
DerekNedelman at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 4
I am doing the following:

graphics.GraphicsDevice.StretchRectangle(graphics.GraphicsDevice.GetBackBuffer(0, 0),
new Rectangle(0, 0, 320, 240),
graphics.GraphicsDevice.GetRenderTarget(0),
new Rectangle(0, 0, 640, 480),
TextureFilter.None);

I know I shouldn't hardcode the destination rectangle but just for the sake of getting this working I am doing so.

Where exactly should I place this call? I've tried between GraphicsDevice.BeginScene() and GraphicsDevice.EndScene(), I get InvalidCallException.

If I place it between EndScene() and Present() I also get the same exception.

Where can I make the call safely?

I have read the requirements from the API, but I still can't get this working.

GraphicsDevice device = graphics.GraphicsDevice;

using (Texture2D dstTexture = new Texture2D(
device,
device.Viewport.Width,
device.Viewport.Height,
1,
ResourceUsage.RenderTarget,
SurfaceFormat.Color,
ResourcePool.Default))
{
using (Surface dstSurface = dstTexture.GetSurfaceLevel(0))
using (Surface srcSurface = device.GetBackBuffer(0, 0))
{
device.StretchRectangle(
srcSurface, null,
dstSurface, null,
TextureFilter.None);
}
}

I can render and stretch to another texture, but if I try to set the dstSurface to device.GetRenterTarget() I get the InvalidCallException.

I find it hard to believe that nobody has had to do this before. I'm very leary of having to make multiple copies of these surfaces to stretch a rectangle to the correct size.

Any ideas?

Maxamor at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 5

I have also been suggessted to possibly use a camera to achieve this effect. I am having problems identifying how to change the view settings at all! Do I need to use an effect just to change the view around?

Would this event work for my 2d situation?

Maxamor at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 6
Sounds like you'd benefit from the suck-it-up technique. The resolution is sorta trivial, and I'm sure your game and still be good if the resolution is at 640x480. Or, if you really need 320x240, maybe you should consider another framework.
mpipeagain at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 7
I came up with a working solution.

When the device is created, I create an additional Texture2D Render Target that is the dimensions of the viewport.

After all of my rendering at 320x240 is done, I use the StretchRectangle() method as described eralier to draw my backbuffer to this alternate Render Targate at the correct size.

Following that, I use the SpriteBatch.Draw() method to draw the screen like a sprite at the size of the viewport.

It works. I shouldn't have to "suck it up" if I want to use a small area of the screen.

Maxamor at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 8

I tackled something like this a little differently. I created a ScaledSpriteBatch class which inherits from SpriteBatch and given a base resolution (in your case 320x240) it calculates the actual destination rect or vector from the one supplied in the Draw() method. So I implemented my own override of each Draw() method and recalculate the destination and then call the base SpriteBatch draw method. Seems to work well, although the StretchRectangle technique may be more efficient, not sure.

BillReiss at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 9

I literally cut and pasted the "How to: Display a Game in Full Screen Mode " tutorial into VSE and got a "NoSuitableGraphicsDeviceException".

I'm developing on my Dell Inspiron 9300 notebook which has am NVidia 6800 Ultra video card. You would think that running fullscreen would be trivial especially since I cut and pasted the tutorial.

Anyone else having problems?

FYI...I tried setting the AllowMultiSampling to false and it made no difference.

Schnoogs at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 10
Sounds like a bug... submit it into connect.
TheZMan at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 11

@Schnoog

ensure that you have the latest drivers from the dell site and have installed the october version of the directx sdk, as I found this exact problem myself.

PeterD. at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...