// 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
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() )
g_winMng = MGL_wmCreate(g_displayDC->getDC());
if (!g_winMng)
return FALSE;
-
+
return TRUE;
}
{
}
-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");