diff engine/core/controller/engine.cpp @ 642:6e2151325017

* Added the ability to query the current running screen mode * Added a method to detect the closest supported screen mode (not complete yet). If no matching screen modes are detected an exception is thrown. * Small change to the way the screen is initialized. The screen mode now MUST be in the supported screen mode list before the screen will initialize.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 08 Oct 2010 21:22:02 +0000
parents 855ad500f991
children edf6dcfe8cd4
line wrap: on
line diff
--- a/engine/core/controller/engine.cpp	Thu Oct 07 19:39:58 2010 +0000
+++ b/engine/core/controller/engine.cpp	Fri Oct 08 21:22:02 2010 +0000
@@ -125,10 +125,14 @@
 		return m_settings;
 	}
 
-	DeviceCaps& Engine::getDeviceCaps() {
+	const DeviceCaps& Engine::getDeviceCaps() const {
 		return m_devcaps;
 	}
 
+	const ScreenMode& Engine::getCurrentScreenMode() const{
+		return m_screenMode;
+	}
+
 	void Engine::preInit() {
 		m_logmanager = LogManager::instance();
 
@@ -200,12 +204,18 @@
 		FL_LOG(_log, "Querying device capabilities");
 		m_devcaps.fillDeviceCaps();
 
+		uint32_t bpp = m_settings.getBitsPerPixel();
+
+		m_screenMode = m_devcaps.getNearestScreenMode(
+			m_settings.getScreenWidth(),
+			m_settings.getScreenHeight(),
+			(bpp ? bpp : 32) , //if it's 0 we use 32 bit as a default
+			rbackend,
+			m_settings.isFullScreen());
+
 		FL_LOG(_log, "Creating main screen");
 		m_renderbackend->createMainScreen(
-			m_settings.getScreenWidth(),
-			m_settings.getScreenHeight(),
-			static_cast<unsigned char>(m_settings.getBitsPerPixel()),
-			m_settings.isFullScreen(),
+			m_screenMode,
 			m_settings.getWindowTitle(),
 			m_settings.getWindowIcon());
 		FL_LOG(_log, "Main screen created");