diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index d0d76763..cd59c1f7 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -140,15 +140,6 @@ BEGIN_EVENT_TABLE(MainToolBar, wxToolBar) END_EVENT_TABLE() void MainWindow::init(string fname) { -#if wxCHECK_VERSION(2, 9, 3) - //glCanvas->setCurrentGLContext(); - //printf("setcurrent #1\n"); -#elif wxCHECK_VERSION(2, 9, 1) - -#else - if(glCanvas) glCanvas->SetCurrent(); - //printf("setcurrent #2\n"); -#endif //menus menuBar = new wxMenuBar(); @@ -458,6 +449,17 @@ void MainWindow::init(string fname) { //setDirty(false); //setExtension(); + initGlCanvas(); + #if wxCHECK_VERSION(2, 9, 3) + //glCanvas->setCurrentGLContext(); + //printf("setcurrent #1\n"); + #elif wxCHECK_VERSION(2, 9, 1) + + #else + if(glCanvas) glCanvas->SetCurrent(); + //printf("setcurrent #2\n"); + #endif + if(startupSettingsInited == false) { startupSettingsInited = true; setupStartupSettings(); @@ -482,12 +484,20 @@ void MainWindow::onClose(wxCloseEvent &event) { this->Destroy(); } +void MainWindow::initGlCanvas(){ + if(glCanvas == NULL) { + int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; + glCanvas = new GlCanvas(this, this->panel, args); + + boxsizer->Add(glCanvas, 1, wxEXPAND); + } +} + void MainWindow::setupStartupSettings() { //gl canvas if(glCanvas == NULL) { - int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; - glCanvas = new GlCanvas(this, this->panel, args); + initGlCanvas(); boxsizer->Add(glCanvas, 1, wxEXPAND); diff --git a/source/glest_map_editor/main.h b/source/glest_map_editor/main.h index 33447b3e..61e14c92 100644 --- a/source/glest_map_editor/main.h +++ b/source/glest_map_editor/main.h @@ -287,6 +287,7 @@ private: void setDirty(bool val=true); void setExtension(); void setupStartupSettings(); + void initGlCanvas(); }; // =====================================================