fix view limits in stereo 3d
authorsheepluva
Sun, 23 Nov 2014 03:38:15 +0100
changeset 10532 28651db3f90e
parent 10531 b8e6164a1a18
child 10533 57b4d411f77d
fix view limits in stereo 3d
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uVariables.pas	Sun Nov 23 02:15:57 2014 +0100
+++ b/hedgewars/uVariables.pas	Sun Nov 23 03:38:15 2014 +0100
@@ -2651,6 +2651,7 @@
     UIDisplay:= uiAll;
     LocalMessage:= 0;
 
+    cStereoDepth:= 0;
     cViewLimitsDebug:= false;
     AprilOne := false;
 end;
--- a/hedgewars/uWorld.pas	Sun Nov 23 02:15:57 2014 +0100
+++ b/hedgewars/uWorld.pas	Sun Nov 23 03:38:15 2014 +0100
@@ -978,9 +978,11 @@
 end;
 
 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
+var tmp: LongInt;
 begin
-    rm:= rm; d:= d; // avoid hint
-{$IFDEF USE_S3D_RENDERING}
+{$IFNDEF USE_S3D_RENDERING}
+    rm:= rm; d:= d; tmp:= tmp; // avoid hint
+{$ELSE}
     d:= d / 5;
     if rm = rmDefault then
         exit
@@ -988,16 +990,24 @@
         d:= -d;
     cStereoDepth:= cStereoDepth + d;
     openglTranslProjMatrix(d, 0, 0);
+    tmp:= round(d / cScaleFactor * cScreenWidth);
+    ViewLeftX := ViewLeftX  - tmp;
+    ViewRightX:= ViewRightX - tmp;
 {$ENDIF}
 end;
 
 procedure ResetDepth(rm: TRenderMode);
+var tmp: LongInt;
 begin
-    rm:= rm; // avoid hint
-{$IFDEF USE_S3D_RENDERING}
+{$IFNDEF USE_S3D_RENDERING}
+    rm:= rm; tmp:= tmp; // avoid hint
+{$ELSE}
     if rm = rmDefault then
         exit;
     openglTranslProjMatrix(-cStereoDepth, 0, 0);
+    tmp:= round(cStereoDepth / cScaleFactor * cScreenWidth);
+    ViewLeftX := ViewLeftX  + tmp;
+    ViewRightX:= ViewRightX + tmp;
     cStereoDepth:= 0;
 {$ENDIF}
 end;