Resolution ( full screen vs windowed )

Started by
12 comments, last by Telanor 11 years, 5 months ago
The code you see is all that's being run for resizing. The only window I have that I can resize is the RenderForm, which, as suggested, I tried resizing to no effect. Wouldn't removing the border only be for borderless fullscreen mode?
Advertisement
1) The ui becomes offset and to be able to interact with the UI elements you need to move the mouse to some odd place.[/quote]

The ui becoming offset could suggest that your viewport is wrong. So just for safety you could set the viewport straight after you change its size ..

Device11.ImmediateContext.Rasterizer.SetViewports(viewport);

But when you say that you need to move the mouse to some odd place. hmmm.. Can you put up some screenshots of that ? Is the place where you have to click where you would expect the element to be if it were being rendered in the correct place ? That might suggest that you ui code is wrong, either rendering or hit detection, but maybe not as well.

3) Normally, when you put any program into a FULLSCREEN mode your mouse is unable to leave it, but with our game... it can... why?[/quote]

I can move my mouse to the second display when i switch to fullscreen mode, so I would say that it's normal behaviour. I used to know how to handle that issue with XNA, but I haven't yet worked it out with SlimDX. I think how I did it in XNA was actually just monitor the mouse position and limit it to the window bounds with a setmouseposition() function. I'll look into this for both of us.


However, it looks like you only set the client size of the window when in windowed mode. I'm pretty sure it's necessary that you also set the size of the window when in fullscreen mode. ResizeBuffers will only resize your backbuffer; it's probably get squashed back down to fit on the form surface.


I don't set the window position in fullscreen mode, and I'm pretty sure it works properly. Edit - checked this, and because I'm using SwapChainFlags.None it just adopts the desktop resolution. Just learnt something about resizing the 'front buffer' ... I tried setting the form manually, but that just won't work, it can and will ignore the width height values you pass in. Instead, use
swapChain.ResizeTargets()
Which will also resize your window, and fire a Resize event, so that your backbuffers can adjust.
Even though not direcly an answer to your question maybe a tip:

Don't expect the user to know:
- that it's possible to switch to fullscreen
- that he can change the resolution of your application or know what changing the resolution will do
- what resolution is optimal for his/her computer

You won't belive how often I'm at some computer where the resolution is not selected correctly. Most of the time users don't use the native resolution of their display. Most of the time they don't even know what the native resolution is or how to change the desktop resolution. Sometimes someone else did set up their computer and choose thecorrect resolution, but how would they know what to select in your game?

If you're targeting causual users, just start your application in fullscreen mode with the current desktop resolution. This will work fine most of the time.
Of course it's allways good to provide a resolution as well as a windowed/fullscreen option.

Best luck with your project.

I don't set the window position in fullscreen mode, and I'm pretty sure it works properly. Edit - checked this, and because I'm using SwapChainFlags.None it just adopts the desktop resolution. Just learnt something about resizing the 'front buffer' ... I tried setting the form manually, but that just won't work, it can and will ignore the width height values you pass in. Instead, use

swapChain.ResizeTargets()

Which will also resize your window, and fire a Resize event, so that your backbuffers can adjust.


Well, I'm not sure if you were saying to do this or not, but I tried calling ResizeTarget and letting that in turn call my Resize method. So both ResizeTarget and ResizeBuffers end up being called. My monitor is now properly reporting 1920x1080 as the resolution and the mouse positioning is working correctly. No where have I seen any examples or documentation that stated BOTH of these needed to be called.

This is what worked for me in the end:


public static void ApplySettings()
{
swapChain.SetFullscreenState(Settings.WindowMode == GameSettings.WindowModeSetting.Fullscreen, null);

if(Settings.WindowMode != GameSettings.WindowModeSetting.Fullscreen)
{
Form.ClientSize = new Size(Settings.DisplayMode.Width, Settings.DisplayMode.Height);
Resize(Settings.DisplayMode.Width, Settings.DisplayMode.Height);
}
else
{
var mode = Settings.DisplayMode;
swapChain.ResizeTarget(ref mode);
}
}

private static void Resize(int width, int height)
{
BackBuffer.Dispose();
LinearBackBuffer.Dispose();

swapChain.ResizeBuffers(0, width, height, Format.Unknown, SwapChainFlags.AllowModeSwitch);
Viewport = new Viewport(0, 0, width, height);
Console.WriteLine("Viewport size: {0}x{1}", Viewport.Width, Viewport.Height);

using(var resource = Resource.FromSwapChain<Texture2D>(swapChain, 0))
{
BackBuffer = new RenderTargetView(device, resource);

LinearBackBuffer = new RenderTargetView(device, resource, new RenderTargetViewDescription
{
Dimension = RenderTargetViewDimension.Texture2D,
Format = Format.R8G8B8A8_UNorm
});
}

if(OnResize != null)
OnResize();
}

This topic is closed to new replies.

Advertisement