Fix problems with ordering and dependencies when initializing OpenGL drawing context
authorTim Goya <tuxdev103@gmail.com>
Wed, 15 Aug 2007 19:39:29 +0000 (19:39 +0000)
committerTim Goya <tuxdev103@gmail.com>
Wed, 15 Aug 2007 19:39:29 +0000 (19:39 +0000)
SVN-Revision: 5139

src/main.cpp

index c3b6805..aa998fd 100644 (file)
@@ -55,7 +55,7 @@
 #include "worldmap/worldmap.hpp"
 #include "binreloc/binreloc.h"
 
-DrawingContext context;
+namespace { DrawingContext *context_pointer; }
 SDL_Surface *screen;
 JoystickKeyboardController* main_controller = 0;
 TinyGetText::DictionaryManager dictionary_manager;
@@ -376,26 +376,6 @@ void init_video()
   }
 #endif
 
-  context.init_renderer();
-  screen = SDL_GetVideoSurface();
-
-  SDL_WM_SetCaption(PACKAGE_NAME " " PACKAGE_VERSION, 0);
-
-  // set icon
-  SDL_Surface* icon = IMG_Load_RW(
-      get_physfs_SDLRWops("images/engine/icons/supertux.xpm"), true);
-  if(icon != 0) {
-    SDL_WM_SetIcon(icon, 0);
-    SDL_FreeSurface(icon);
-  }
-#ifdef DEBUG
-  else {
-    log_warning << "Couldn't find icon 'images/engine/icons/supertux.xpm'" << std::endl;
-  }
-#endif
-
-  SDL_ShowCursor(0);
-
   double aspect_ratio = config->aspect_ratio;
 
   // try to guess aspect ratio of monitor if needed
@@ -416,6 +396,26 @@ void init_video()
     SCREEN_HEIGHT = static_cast<int> (600 * 1/aspect_ratio + 0.5);
   }
 
+  context_pointer->init_renderer();
+  screen = SDL_GetVideoSurface();
+
+  SDL_WM_SetCaption(PACKAGE_NAME " " PACKAGE_VERSION, 0);
+
+  // set icon
+  SDL_Surface* icon = IMG_Load_RW(
+      get_physfs_SDLRWops("images/engine/icons/supertux.xpm"), true);
+  if(icon != 0) {
+    SDL_WM_SetIcon(icon, 0);
+    SDL_FreeSurface(icon);
+  }
+#ifdef DEBUG
+  else {
+    log_warning << "Couldn't find icon 'images/engine/icons/supertux.xpm'" << std::endl;
+  }
+#endif
+
+  SDL_ShowCursor(0);
+
   log_info << (config->use_fullscreen?"fullscreen ":"window ") << SCREEN_WIDTH << "x" << SCREEN_HEIGHT << " Ratio: " << aspect_ratio << "\n";
 }
 
@@ -523,6 +523,8 @@ int main(int argc, char** argv)
     timelog("audio");
     init_audio();
     timelog("video");
+    DrawingContext context;
+    context_pointer = &context;
     init_video();
     Console::instance->init_graphics();
     timelog("scripting");