Browse Source

preserve window size when switching example (#1229)

I think this is more convenient on desktop, but is a must have on mobile where app is running in fullscreen and window size is set to screen size.
attilaz 8 years ago
parent
commit
80a1006ac7
1 changed files with 7 additions and 2 deletions
  1. 7 2
      examples/common/entry/entry.cpp

+ 7 - 2
examples/common/entry/entry.cpp

@@ -24,6 +24,8 @@ namespace entry
 {
 {
 	static uint32_t s_debug = BGFX_DEBUG_NONE;
 	static uint32_t s_debug = BGFX_DEBUG_NONE;
 	static uint32_t s_reset = BGFX_RESET_NONE;
 	static uint32_t s_reset = BGFX_RESET_NONE;
+	static uint32_t s_width = ENTRY_DEFAULT_WIDTH;
+	static uint32_t s_height = ENTRY_DEFAULT_HEIGHT;
 	static bool s_exit = false;
 	static bool s_exit = false;
 
 
 	static bx::FileReaderI* s_fileReader = NULL;
 	static bx::FileReaderI* s_fileReader = NULL;
@@ -494,11 +496,11 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 
 
 	int runApp(AppI* _app, int _argc, const char* const* _argv)
 	int runApp(AppI* _app, int _argc, const char* const* _argv)
 	{
 	{
-		_app->init(_argc, _argv, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT);
+		_app->init(_argc, _argv, s_width, s_height);
 		bgfx::frame();
 		bgfx::frame();
 
 
 		WindowHandle defaultWindow = { 0 };
 		WindowHandle defaultWindow = { 0 };
-		setWindowSize(defaultWindow, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT);
+		setWindowSize(defaultWindow, s_width, s_height);
 
 
 #if BX_PLATFORM_EMSCRIPTEN
 #if BX_PLATFORM_EMSCRIPTEN
 		s_app = _app;
 		s_app = _app;
@@ -747,6 +749,9 @@ restart:
 		}
 		}
 
 
 		_debug = s_debug;
 		_debug = s_debug;
+		
+		s_width = _width;
+		s_height = _height;
 
 
 		return s_exit;
 		return s_exit;
 	}
 	}