[Supertux-Commit] r5480 - in trunk/supertux/src: . video

grumbel at millhouse.dreamhost.com grumbel at millhouse.dreamhost.com
Wed May 14 23:33:38 PDT 2008


Author: grumbel
Date: 2008-05-14 23:33:38 -0700 (Wed, 14 May 2008)
New Revision: 5480

Modified:
   trunk/supertux/src/options_menu.cpp
   trunk/supertux/src/video/gl_renderer.cpp
Log:
Switched magnification to percentage, added black-border as alternative to scale

Modified: trunk/supertux/src/options_menu.cpp
===================================================================
--- trunk/supertux/src/options_menu.cpp	2008-05-15 04:00:03 UTC (rev 5479)
+++ trunk/supertux/src/options_menu.cpp	2008-05-15 06:33:38 UTC (rev 5480)
@@ -129,15 +129,18 @@
   fullscreen_res->set_help(_("Change the Resolution to be used in Fullscreen Mode, you have to toggle fullscreen mode to let this change take effect"));
 
   MenuItem* maginfication = add_string_select(MNID_MAGINFICATION, _("Maginfication"));
-  maginfication->set_help(_("Change the magnification, to small values will result in a black border around the screen"));
+  maginfication->set_help(_("Change the magnification of the game area"));
 
-  maginfication->list.push_back("0.5");
-  maginfication->list.push_back("0.625");
-  maginfication->list.push_back("0.8");
-  maginfication->list.push_back("1.0");
-  maginfication->list.push_back("1.25");
-  maginfication->list.push_back("1.6");
-  maginfication->list.push_back("2.0");
+  // These values go from screen:640/projection:1600 to screen:1600/projection:640
+  maginfication->list.push_back("40%");
+  maginfication->list.push_back("50%");
+  maginfication->list.push_back("62.5%");
+  maginfication->list.push_back("80%");
+  maginfication->list.push_back("100%");
+  maginfication->list.push_back("125%");
+  maginfication->list.push_back("160%");
+  maginfication->list.push_back("200%");
+  maginfication->list.push_back("250%");
 
   SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
 
@@ -235,6 +238,7 @@
     case MNID_MAGINFICATION:
       if(sscanf(item->list[item->selected].c_str(), "%f", &config->magnification) == 1)
         {
+          config->magnification /= 100.0f;
           Renderer::instance()->apply_config();
           Menu::recalc_pos();
         }

Modified: trunk/supertux/src/video/gl_renderer.cpp
===================================================================
--- trunk/supertux/src/video/gl_renderer.cpp	2008-05-15 04:00:03 UTC (rev 5479)
+++ trunk/supertux/src/video/gl_renderer.cpp	2008-05-15 06:33:38 UTC (rev 5480)
@@ -560,30 +560,60 @@
       SCREEN_HEIGHT = h  * (target_aspect / desktop_aspect);
     }
 
-  SCREEN_WIDTH  *= config->magnification;  
-  SCREEN_HEIGHT *= config->magnification;  
+  SCREEN_WIDTH  /= config->magnification;  
+  SCREEN_HEIGHT /= config->magnification;  
 
-  int max_width  = 1600;
+  int max_width  = 1600; // FIXME: Maybe 1920 is ok too
   int max_height = 1200;
-  
-  // A little wonky
-  if (SCREEN_WIDTH > max_width)
+
+  if (0)
     {
-      float scale = float(max_width)/SCREEN_WIDTH;
-      SCREEN_WIDTH  *= scale;
-      SCREEN_HEIGHT *= scale;
+      // This scales SCREEN_WIDTH/SCREEN_HEIGHT so that they never excede
+      // max_width/max_height
+      if (SCREEN_WIDTH > max_width || SCREEN_HEIGHT > max_height)
+        {
+          float scale1 = float(max_width)/SCREEN_WIDTH;
+          float scale2 = float(max_height)/SCREEN_HEIGHT;
+          float scale = scale1 < scale2 ? scale1 : scale2;
+          SCREEN_WIDTH  *= scale;
+          SCREEN_HEIGHT *= scale;
+        }
+
+      glViewport(0, 0, w, h);
     }
-  else if (SCREEN_HEIGHT > max_height)
+  else
     {
-      float scale = float(max_height)/SCREEN_HEIGHT;
-      SCREEN_WIDTH  *= scale;
-      SCREEN_HEIGHT *= scale;
+      // This works by adding black borders around the screen to limit
+      // SCREEN_WIDTH/SCREEN_HEIGHT to max_width/max_height
+      int nw = w;
+      int nh = h;
+
+      if (SCREEN_WIDTH > max_width)
+        {
+          nw *= float(max_width)/SCREEN_WIDTH;
+          SCREEN_WIDTH = max_width;
+        }
+
+      if (SCREEN_HEIGHT > max_height)
+        {
+          nh *= float(max_height)/SCREEN_HEIGHT;
+          SCREEN_HEIGHT = max_height;
+        }
+
+      glClear(GL_COLOR_BUFFER_BIT);
+
+      std::cout << (w-nw)/2 << " "
+                << (h-nh)/2 << " "
+                << nw << "x" << nh << std::endl;
+      glViewport(std::max(0, (w-nw)/2), 
+                 std::max(0, (h-nh)/2), 
+                 std::min(nw, w),
+                 std::min(nh, h));
     }
-  
-  std::cout << " -> " << SCREEN_WIDTH << "x" << SCREEN_HEIGHT << std::endl;
 
-  glViewport(0, 0, w, h);
+  std::cout << "  -> " << SCREEN_WIDTH << "x" << SCREEN_HEIGHT << std::endl;
 
+
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);    




More information about the Supertux-Commit mailing list