hedgewars/uWorld.pas
changeset 10869 f23763bbac1b
parent 10818 f642a28cab0c
child 10870 5efea5942475
equal deleted inserted replaced
10868:acb03a9712c3 10869:f23763bbac1b
   855             zoom:= ZoomValue
   855             zoom:= ZoomValue
   856         end
   856         end
   857     else
   857     else
   858         ZoomValue:= zoom;
   858         ZoomValue:= zoom;
   859 
   859 
   860     // Sky
       
   861     glClear(GL_COLOR_BUFFER_BIT);
       
   862     //glPushMatrix;
       
   863     //glScalef(1.0, 1.0, 1.0);
       
   864 
       
   865     if (not isPaused) and (not isAFK) and (GameType <> gmtRecord) then
   860     if (not isPaused) and (not isAFK) and (GameType <> gmtRecord) then
   866         MoveCamera;
   861         MoveCamera;
   867 
   862 
   868     if cStereoMode = smNone then
   863     if cStereoMode = smNone then
   869         begin
   864         begin
   870         glClear(GL_COLOR_BUFFER_BIT);
   865         RenderClear();
   871         DrawWorldStereo(Lag, rmDefault)
   866         DrawWorldStereo(Lag, rmDefault)
   872         end
   867         end
   873 {$IFDEF USE_S3D_RENDERING}
   868 {$IFDEF USE_S3D_RENDERING}
   874     else if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then
   869     else
   875         begin
   870         begin
   876         // create left fb
   871         // draw frame for left eye
   877         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel);
   872         RenderClear(rmLeftEye);
   878         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
       
   879         DrawWorldStereo(Lag, rmLeftEye);
   873         DrawWorldStereo(Lag, rmLeftEye);
   880 
   874 
   881         // create right fb
   875         // draw frame for right eye
   882         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer);
   876         RenderClear(rmRightEye);
   883         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
       
   884         DrawWorldStereo(0, rmRightEye);
   877         DrawWorldStereo(0, rmRightEye);
   885 
   878         end;
   886         // detatch drawing from fbs
   879 {$ENDIF}
   887         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame);
   880 
   888         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
   881 FinishRender();
   889         SetScale(cDefaultZoomLevel);
       
   890 
       
   891         // draw left frame
       
   892         glBindTexture(GL_TEXTURE_2D, texl);
       
   893         glBegin(GL_QUADS);
       
   894             if cStereoMode = smHorizontal then
       
   895                 begin
       
   896                 glTexCoord2f(0.0, 0.0);
       
   897                 glVertex2d(cScreenWidth / -2, cScreenHeight);
       
   898                 glTexCoord2f(1.0, 0.0);
       
   899                 glVertex2d(0, cScreenHeight);
       
   900                 glTexCoord2f(1.0, 1.0);
       
   901                 glVertex2d(0, 0);
       
   902                 glTexCoord2f(0.0, 1.0);
       
   903                 glVertex2d(cScreenWidth / -2, 0);
       
   904                 end
       
   905             else
       
   906                 begin
       
   907                 glTexCoord2f(0.0, 0.0);
       
   908                 glVertex2d(cScreenWidth / -2, cScreenHeight / 2);
       
   909                 glTexCoord2f(1.0, 0.0);
       
   910                 glVertex2d(cScreenWidth / 2, cScreenHeight / 2);
       
   911                 glTexCoord2f(1.0, 1.0);
       
   912                 glVertex2d(cScreenWidth / 2, 0);
       
   913                 glTexCoord2f(0.0, 1.0);
       
   914                 glVertex2d(cScreenWidth / -2, 0);
       
   915                 end;
       
   916         glEnd();
       
   917 
       
   918         // draw right frame
       
   919         glBindTexture(GL_TEXTURE_2D, texr);
       
   920         glBegin(GL_QUADS);
       
   921             if cStereoMode = smHorizontal then
       
   922                 begin
       
   923                 glTexCoord2f(0.0, 0.0);
       
   924                 glVertex2d(0, cScreenHeight);
       
   925                 glTexCoord2f(1.0, 0.0);
       
   926                 glVertex2d(cScreenWidth / 2, cScreenHeight);
       
   927                 glTexCoord2f(1.0, 1.0);
       
   928                 glVertex2d(cScreenWidth / 2, 0);
       
   929                 glTexCoord2f(0.0, 1.0);
       
   930                 glVertex2d(0, 0);
       
   931                 end
       
   932             else
       
   933                 begin
       
   934                 glTexCoord2f(0.0, 0.0);
       
   935                 glVertex2d(cScreenWidth / -2, cScreenHeight);
       
   936                 glTexCoord2f(1.0, 0.0);
       
   937                 glVertex2d(cScreenWidth / 2, cScreenHeight);
       
   938                 glTexCoord2f(1.0, 1.0);
       
   939                 glVertex2d(cScreenWidth / 2, cScreenHeight / 2);
       
   940                 glTexCoord2f(0.0, 1.0);
       
   941                 glVertex2d(cScreenWidth / -2, cScreenHeight / 2);
       
   942                 end;
       
   943         glEnd();
       
   944         SetScale(zoom);
       
   945         end
       
   946     else
       
   947         begin
       
   948         // clear scene
       
   949         glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
       
   950         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
       
   951         // draw left eye in red channel only
       
   952         if cStereoMode = smGreenRed then
       
   953             glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE)
       
   954         else if cStereoMode = smBlueRed then
       
   955             glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE)
       
   956         else if cStereoMode = smCyanRed then
       
   957             glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE)
       
   958         else
       
   959             glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE);
       
   960         DrawWorldStereo(Lag, rmLeftEye);
       
   961         // draw right eye in selected channel(s) only
       
   962         if cStereoMode = smRedGreen then
       
   963             glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE)
       
   964         else if cStereoMode = smRedBlue then
       
   965             glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE)
       
   966         else if cStereoMode = smRedCyan then
       
   967             glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE)
       
   968         else
       
   969             glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE);
       
   970         DrawWorldStereo(Lag, rmRightEye);
       
   971         end
       
   972 {$ENDIF}
       
   973 end;
   882 end;
   974 
   883 
   975 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
   884 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
   976 var tmp: LongInt;
   885 var tmp: LongInt;
   977 begin
   886 begin