Setting the Fullscreen Resolution
How can I set the fullscreen resolution to 320 x 240?
How can I set the fullscreen resolution to 320 x 240?
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?
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?
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?
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.
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.
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.
@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.