detectCurrentScreenMode()

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
pianoman
Halfling
Posts: 47
Joined: Sun Feb 08, 2009 10:52 pm

detectCurrentScreenMode()

Post by pianoman »

A method (in RenderSystem:: maybe ?) for detecting the current system screen resolution/depth. This way, for example, you could start your Ogre application in full screen mode using the user's current mode (the mode of their "desktop").

To help a bit, here is some code from my old 2D game library for doing it under Windows with a Win32 GDI call :D :

Code: Select all

	DEVMODE dm;
	dm.dmSize = sizeof(dm);
	dm.dmDriverExtra = 0;
	EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm);
	return SCREEN_MODE(dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency);
I haven't looked into it for Linux or MacOS, but I would imagine it wouldn't be much more complex than the above.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: detectCurrentScreenMode()

Post by Klaim »

You already have all those informations in the RenderWindow class .
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

Re: detectCurrentScreenMode()

Post by madmarx »

Hi Klaim, I think there is a misunderstanding there. It looks like pianoman is asking for the screen abilities before even 1 rendersystem was created. Not the renderwindow abilities.
This is quite 'system' oriented. Pianoman, if you want to know what are the available display settings of the graphic card, you might have a look at rendersystem->getCapabilities(), even if that does not answer your request.

>>>you could start your Ogre application in full screen mode using the user's current mode (the mode of their "desktop").
I am not sure this is always possible, because you need a directx/opengl surface to draw. And the rendering might be bigger than the available surface (what if you have 3 screens?). This is just my thought. I am not 100% sure of that.
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
User avatar
pianoman
Halfling
Posts: 47
Joined: Sun Feb 08, 2009 10:52 pm

Re: detectCurrentScreenMode()

Post by pianoman »

Hi, Klaim: madmarx is right, we're looking for the user's current screen resolution before any render window is created, so that we can create a full-screen render surface in the same resolution.

Hi, Madmarx: yes, getting the possible screen modes is one way of doing it, but it's nice also to be able to automatically use a resolution that the user prefers, in the sense that it is the resolution that they have their desktop set to. Concerning multiple monitors, I believe the code I gave gives the resolution for the primary display monitor. I used to use dual-monitoring, but can't remember 100% sure if i tested the code with dual-monitors, so that is indeed something one would need to verify with the above code. However, it is certainly "possible" to use the primary display device, and default to the resolution at which that device was already set to. It is useful to the developer when you don't want the user to have to wade through a dialog before diving into your game. And, if you don't want to guess which resolution to choose from a list of available; besides, the resolutions at which a device can run may include resolutions that the actual monitor being used doesn't support (particularly CRTs i think). (Hence the "Keep current settings? 20 seconds left..." dialog when you change your resolution in Windows OS, in case the user can't see anything after the change).

Thus I still think this is a useful feature :) Thanks for the discussion.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Re: detectCurrentScreenMode()

Post by Vectrex »

I think this is a good idea. No need to set it automatically to fullscreen though. Simply show the ogre dialog with the current desktop res highlighted in the resolution options. 99% of the time the user wouldn't have to change it.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: detectCurrentScreenMode()

Post by Klaim »

Hi, Klaim: madmarx is right, we're looking for the user's current screen resolution before any render window is created, so that we can create a full-screen render surface in the same resolution.
Oh, ok didn't understood that. ^^;
User avatar
bishopnator
Goblin
Posts: 223
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 5

Re: detectCurrentScreenMode()

Post by bishopnator »

Hi, I used following code for determining desktop resolution (in Windows):

Code: Select all

	//////////////////////////////////////////////////////////////////////////
	// turn-on fullscreen mode
	CRect rect;

	// Next function copies the dimensions of 
	// the bounding rectangle of the desktop
	// note: don't use CWnd::GetDesktopWindow()->GetWindowRect(&rect)
	//       due to multimonitor systems
	HMONITOR hMonitor = MonitorFromWindow(AfxGetMainWnd()->m_hWnd, MONITOR_DEFAULTTONEAREST);
	MONITORINFO lpmi;
	lpmi.cbSize = sizeof(lpmi);
	if(GetMonitorInfo(hMonitor, &lpmi))
	{
		rect.left = lpmi.rcMonitor.left;
		rect.top = lpmi.rcMonitor.top;
		rect.right = lpmi.rcMonitor.right;
		rect.bottom = lpmi.rcMonitor.bottom;
	}

	// note: rect.Width() and rect.Height() contains desktop resolution
	// etc.
It is piece of code using MFC, but it is really easy to remove MFC calls from this code (use RECT instead of CRect and use your own HWND handle instead of AfxGetMainWnd()->m_hWnd). For example you can use ogre initialization dialog's HWND for determining resolution of monitor where dialog is located in multimonitor systems.
Post Reply