Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline fool  
#1 Posted : Sunday, May 6, 2012 7:27:27 AM(UTC)
fool

Joined: 8/24/2011(UTC)
Posts: 34
Location: New Zealand

Thanks: 4 times
Two questions re fullscreen mode:

* How can I start out in fullscreen mode using the current desktop resolution, i.e. avoiding a resolution change?

When enabling Settings.Extra.IsFullscreen (in config), it looks like it also uses Settings.Resolution to change the video resolution, and failing that it falls back to the current desktop resolution, *but* in that case the Application.Window.ViewportPixelWidth & Height, and ScreenSpace.DrawArea (equivalent after conversion to pixel space), still use the provided Settings.Resolution, which means you're left rendering in just the top-left corner of the desktop. Ideally there should be a sentinel value that means 'use the current resolution' and which then updates Application.Window.ViewportPixel* and ScreenSpace.DrawArea accordingly - I've tried (0, 0) and (-1, -1), but they didn't have the desired effect.

* How can I toggle fullscreen mode at runtime?

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline Benjamin  
#2 Posted : Sunday, May 6, 2012 1:14:19 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Automatically choosing the desktop resolution with (-1, -1) should work, must be a bug when it does not have the desired effect. (now fixed, see below)

The forum user Internetfreak was also trying out fullscreen mode and switching, maybe you can find older posts from him. I think it works in general, but there are smaller issues that have not been fixed yet. I think it is currently required to restart the app (or at least the graphic module and everything that is linked to it) to make it work.

I just added a little unit test to test fullscreen mode (in Delta.Rendering.BasicTests Tutorials.cs):
Code:

		#region FullscreenMode (Static)
		/// <summary>
		/// Tutorial: Simple Rendering Tutorial 12: Test fullscreen mode
		/// Difficulty: Easy
		/// Description: Will start the app in fullscreen mode using the desktop
		/// resolution and draws two lines like the DrawLines tutorial.
		/// Image: http://DeltaEngine.net/Icons/RenderingTutorial12.png
		/// </summary>
		[Test, Category("Visual")]
		public static void FullscreenMode()
		{
			// This will set IsFullscreen=True and Resolution=0, 0 in Settings.xml!
			Settings.Extra.SetFullscreenModeWithDesktopResolution();
			// Do not save the settings, we don't want fullscreen for everything now.
			Application.Closing += Settings.DoNotSave;

			Application.Start(delegate
			{
				Line.Draw(new Point(0, 0), new Point(1, 1), Color.Red);
				Line.Draw(new Point(1, 0), new Point(0, 1), Color.Green);
			});
		}
		#endregion


I had to make some minor changes to allow setting the resolution in code. If you want to try it out yourself without waiting for the next nightly release you can just add the following line to OpenTKGraphics.cs:
Code:

			if (Settings.Extra.IsFullscreen)
			{
				// Test: Set the desktop resolution!
				Application.Window.Resize(
					DisplayDevice.Default.Width, DisplayDevice.Default.Height);
...


I added some fallback code and lots of safety checks to make sure it works in all conditions, but basically Application.Window.Resize can be used to set the resolution and the rest of the graphics constructor will then use this resolution for fullscreen mode (if Settings.Extra.IsFullscreen is set). The same way toggling fullscreen mode can be implemented, but this has not been tested at all and lots of issues will arise. Just ask again if you need help with toggling fullscreen mode or just restart the app like Internetfreak did ^^

Edited by user Sunday, May 6, 2012 1:15:05 PM(UTC)  | Reason: Not specified

Offline fool  
#3 Posted : Monday, May 7, 2012 6:05:49 AM(UTC)
fool

Joined: 8/24/2011(UTC)
Posts: 34
Location: New Zealand

Thanks: 4 times
Specifying "<Resolution>-1, -1</Resolution>" in Settings.xml now uses the desktop resolution, but a log file is generated with the following:

Code:

00.010 Warning: viewportPixelWidth 0 is invalid for CalculateAspectRatio, using default value of 1024 instead!
	at Delta.Engine.ScreenSpace.CalculateAspectRatio(System.Single viewportPixelWidth, System.Single viewportPixelHeight)
	at Delta.Engine.Settings.LoadXml(Delta.Utilities.Xml.XmlNode node)
	at Delta.Engine.Settings.Load()
	at Delta.Engine.Settings.ejKGcDdHmLepcxx4cSp()
	at Delta.Engine.Settings..cctor()
	at Delta.Engine.Dynamic.DependencyFinder.CheckIfAllAssembliesAreUpToDate()
	at Delta.Engine.Dynamic.TypeListManager.lsVfOZDw9pTDkkPl2H6()
00.015 Warning: viewportPixelHeight 0 is invalid for CalculateAspectRatio, using default value of 768 instead!
	at Delta.Engine.ScreenSpace.ak02mjj9qt3LjlJ93C3(System.Object )
	at Delta.Engine.ScreenSpace.CalculateAspectRatio(System.Single viewportPixelWidth, System.Single viewportPixelHeight)
	at Delta.Engine.Settings.LoadXml(Delta.Utilities.Xml.XmlNode node)
	at Delta.Engine.Settings.Load()
	at Delta.Engine.Settings.ejKGcDdHmLepcxx4cSp()
	at Delta.Engine.Settings..cctor()
	at Delta.Engine.Dynamic.DependencyFinder.CheckIfAllAssembliesAreUpToDate()
	at Delta.Engine.Dynamic.TypeListManager.lsVfOZDw9pTDkkPl2H6()


My desktop resolution is 2560 x 1440.
Offline Benjamin  
#4 Posted : Monday, May 7, 2012 8:34:46 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
That is my resolution too ^^

Strange that I did not get that myself. I guess I did not have 0, 0 in the Settings.xml at load time (I modified it later in code). The warning actually makes sense to prevent creating 0, 0 windows or calculating the aspect ratio for 0/0.

I have commented out the warning for now, the bug is pretty old (from 2010) and should not happen anymore anyway.
Offline fool  
#5 Posted : Monday, May 7, 2012 10:11:31 AM(UTC)
fool

Joined: 8/24/2011(UTC)
Posts: 34
Location: New Zealand

Thanks: 4 times
Isn't there a subtle problem here that the aspect ratio will be incorrect? Or is it recalculated once the current desktop resolution is used?
Offline Benjamin  
#6 Posted : Monday, May 7, 2012 10:20:54 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
The aspect ratio is always updated whenever the resolution changes. There might be problems if some UI is setup with a different aspect ratio, but the events should trigger correcting these when a resize happens. Other than that the aspect ratio is not cached anywhere.
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2022, Yet Another Forum.NET
This page was generated in 0.057 seconds.