X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/580616706f52835ee5ee48e6ef2ad15b822df971..00c813596e3eefdd028365acf9542355937e5531:/src/mgl/app.cpp diff --git a/src/mgl/app.cpp b/src/mgl/app.cpp index 39d708ed0b..d4903a2af2 100644 --- a/src/mgl/app.cpp +++ b/src/mgl/app.cpp @@ -155,10 +155,9 @@ static wxRootWindow *gs_rootWindow = NULL; // MGL initialization //----------------------------------------------------------------------------- -static bool wxCreateMGL_WM() +static bool wxCreateMGL_WM(const wxDisplayModeInfo& displayMode) { int mode; - int width = 640, height = 480, depth = 16; int refresh = MGL_DEFAULT_REFRESH; #if wxUSE_SYSTEM_OPTIONS @@ -166,11 +165,16 @@ static bool wxCreateMGL_WM() refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh")); #endif - mode = MGL_findMode(width, height, depth); + mode = MGL_findMode(displayMode.GetScreenSize().x, + displayMode.GetScreenSize().y, + displayMode.GetDepth()); if ( mode == -1 ) { - wxLogWarning(_("Mode %ix%i-%i not available, falling back to default mode."), width, height, depth); - mode = 0; // always available + wxLogError(_("Mode %ix%i-%i not available."), + displayMode.GetScreenSize().x, + displayMode.GetScreenSize().y, + displayMode.GetDepth()); + return FALSE; } g_displayDC = new MGLDisplayDC(mode, 1, refresh); if ( !g_displayDC->isValid() ) @@ -183,7 +187,7 @@ static bool wxCreateMGL_WM() g_winMng = MGL_wmCreate(g_displayDC->getDC()); if (!g_winMng) return FALSE; - + return TRUE; } @@ -220,19 +224,34 @@ wxApp::~wxApp() { } -bool wxApp::OnInitGui() +bool wxApp::SetDisplayMode(const wxDisplayModeInfo& mode) { - if ( !wxCreateMGL_WM() ) + if ( !mode.IsOk() ) + { return FALSE; + } + if ( g_displayDC != NULL ) + { + // FIXME_MGL -- we currently don't allow to switch video mode + // more than once. This can hopefully be changed... + wxFAIL_MSG(wxT("Can't change display mode after intialization!")); + return FALSE; + } - // This has to be done *after* wxCreateMGL_WM() because it initializes - // wxUniv's themes - if ( !wxAppBase::OnInitGui() ) + if ( !wxCreateMGL_WM(mode) ) return FALSE; - - // ...and this has to be done after wxUniv themes were initialized gs_rootWindow = new wxRootWindow; + m_displayMode = mode; + + return TRUE; +} + +bool wxApp::OnInitGui() +{ + if ( !wxAppBase::OnInitGui() ) + return FALSE; + #ifdef MGL_DEBUG // That damn MGL redirects stdin and stdout to physical console FILE *file = fopen("stderr", "wt");