hedgewars/uStore.pas
changeset 10266 a90a55ec5b98
parent 10262 435c82ab9058
child 10275 6c91047f59b6
--- a/hedgewars/uStore.pas	Tue Jun 10 08:19:59 2014 +0200
+++ b/hedgewars/uStore.pas	Tue Jun 10 08:47:03 2014 +0200
@@ -72,6 +72,8 @@
 procedure BeginWater;
 procedure EndWater;
 
+procedure updateViewLimits();
+
 implementation
 uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils,
      uCommands, uPhysFSLayer, uDebug
@@ -1175,6 +1177,19 @@
 end;
 *)
 
+
+procedure updateViewLimits();
+var tmp: real;
+begin
+    // cScaleFactor is 2.0 on "no zoom"
+    tmp:= cScreenWidth / cScaleFactor;
+    ViewRightX:= round(tmp); // ceil could make more sense
+    ViewLeftX:= round(-tmp); // floor could make more sense
+    tmp:= cScreenHeight / cScaleFactor;
+    ViewBottomY:= round(tmp) + cScreenHeight div 2; // ceil could make more sense
+    ViewTopY:= round(-tmp) + cScreenHeight div 2; // floor could make more sense
+end;
+
 procedure SetScale(f: GLfloat);
 begin
 // leave immediately if scale factor did not change
@@ -1203,6 +1218,7 @@
         end;
 
     cScaleFactor:= f;
+    updateViewLimits();
 
 {$IFDEF GL2}
     UpdateModelviewProjection;
@@ -1690,6 +1706,7 @@
     RegisterVariable('fullscr', @chFullScr, true);
 
     cScaleFactor:= 2.0;
+    updateViewLimits();
     Step:= 0;
     ProgrTex:= nil;
     SupportNPOTT:= false;