hedgewars/uWorld.pas
changeset 7180 53ffc8853008
parent 7167 0b3b306f129a
child 7194 d8e68cbca7ee
equal deleted inserted replaced
7176:fb4b0c6dfdbd 7180:53ffc8853008
    58     uTextures,
    58     uTextures,
    59     uRender,
    59     uRender,
    60     uCaptions,
    60     uCaptions,
    61     uCursor,
    61     uCursor,
    62     uCommands,
    62     uCommands,
    63     uMobile
    63     uMobile,
       
    64     uVideoRec
    64     ;
    65     ;
    65 
    66 
    66 var cWaveWidth, cWaveHeight: LongInt;
    67 var cWaveWidth, cWaveHeight: LongInt;
    67     AMShiftTargetX, AMShiftTargetY, AMShiftX, AMShiftY, SlotsNum: LongInt;
    68     AMShiftTargetX, AMShiftTargetY, AMShiftX, AMShiftY, SlotsNum: LongInt;
    68     AMAnimStartTime, AMState : LongInt;
    69     AMAnimStartTime, AMState : LongInt;
    78     missionTex: PTexture;
    79     missionTex: PTexture;
    79     missionTimer: LongInt;
    80     missionTimer: LongInt;
    80     stereoDepth: GLfloat;
    81     stereoDepth: GLfloat;
    81     isFirstFrame: boolean;
    82     isFirstFrame: boolean;
    82     AMAnimType: LongInt;
    83     AMAnimType: LongInt;
       
    84     recTexture: PTexture;
    83 
    85 
    84 const cStereo_Sky           = 0.0500;
    86 const cStereo_Sky           = 0.0500;
    85       cStereo_Horizon       = 0.0250;
    87       cStereo_Horizon       = 0.0250;
    86       cStereo_MidDistance   = 0.0175;
    88       cStereo_MidDistance   = 0.0175;
    87       cStereo_Water_distant = 0.0125;
    89       cStereo_Water_distant = 0.0125;
   379     fpsTexture:= nil;
   381     fpsTexture:= nil;
   380     FreeTexture(timeTexture);
   382     FreeTexture(timeTexture);
   381     timeTexture:= nil;
   383     timeTexture:= nil;
   382     FreeTexture(missionTex);
   384     FreeTexture(missionTex);
   383     missionTex:= nil;
   385     missionTex:= nil;
       
   386     FreeTexture(recTexture);
       
   387     recTexture:= nil;
   384 end;
   388 end;
   385 
   389 
   386 function GetAmmoMenuTexture(Ammo: PHHAmmo): PTexture;
   390 function GetAmmoMenuTexture(Ammo: PHHAmmo): PTexture;
   387 const BORDERSIZE = 2;
   391 const BORDERSIZE = 2;
   388 var x, y, i, t, SlotsNumY, SlotsNumX, AMFrame: LongInt;
   392 var x, y, i, t, SlotsNumY, SlotsNumX, AMFrame: LongInt;
   956     // Sky
   960     // Sky
   957     glClear(GL_COLOR_BUFFER_BIT);
   961     glClear(GL_COLOR_BUFFER_BIT);
   958     //glPushMatrix;
   962     //glPushMatrix;
   959     //glScalef(1.0, 1.0, 1.0);
   963     //glScalef(1.0, 1.0, 1.0);
   960 
   964 
   961     if not isPaused then
   965     if (not isPaused) and (GameType <> gmtRecord) then
   962         MoveCamera;
   966         MoveCamera;
   963 
   967 
   964     if cStereoMode = smNone then
   968     if cStereoMode = smNone then
   965         begin
   969         begin
   966         glClear(GL_COLOR_BUFFER_BIT);
   970         glClear(GL_COLOR_BUFFER_BIT);
   987         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer);
   991         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer);
   988         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
   992         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
   989         DrawWorldStereo(0, rmRightEye);
   993         DrawWorldStereo(0, rmRightEye);
   990 
   994 
   991         // detatch drawing from fbs
   995         // detatch drawing from fbs
   992         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
   996         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame);
   993         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
   997         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
   994         SetScale(cDefaultZoomLevel);
   998         SetScale(cDefaultZoomLevel);
   995 
   999 
   996         // draw left frame
  1000         // draw left frame
   997         glBindTexture(GL_TEXTURE_2D, texl);
  1001         glBindTexture(GL_TEXTURE_2D, texl);
  1571         if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then
  1575         if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then
  1572             ScreenFade:= sfNone
  1576             ScreenFade:= sfNone
  1573         end
  1577         end
  1574     end;
  1578     end;
  1575 
  1579 
       
  1580 // rec
       
  1581 if flagPrerecording then
       
  1582     begin
       
  1583     if recTexture = nil then
       
  1584         begin
       
  1585         s:= 'rec';
       
  1586         tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fntBig].Handle, Str2PChar(s), cWhiteColorChannels);
       
  1587         tmpSurface:= doSurfaceConversion(tmpSurface);
       
  1588         FreeTexture(recTexture);
       
  1589         recTexture:= Surface2Tex(tmpSurface, false);
       
  1590         SDL_FreeSurface(tmpSurface)
       
  1591         end;
       
  1592     DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture);
       
  1593 
       
  1594     // draw red circle
       
  1595     glDisable(GL_TEXTURE_2D); 
       
  1596     Tint($FF, $00, $00, Byte(Round(127*(1 + sin(SDL_GetTicks()*0.007)))));
       
  1597     glBegin(GL_POLYGON);
       
  1598     for i:= 0 to 20 do
       
  1599         glVertex2f(-(cScreenWidth shr 1) + 30 + sin(i*2*Pi/20)*10, 35 + cos(i*2*Pi/20)*10);
       
  1600     glEnd();
       
  1601     Tint($FF, $FF, $FF, $FF);
       
  1602     glEnable(GL_TEXTURE_2D);
       
  1603     end;
       
  1604 
  1576 SetScale(zoom);
  1605 SetScale(zoom);
  1577 
  1606 
  1578 // Cursor
  1607 // Cursor
  1579 if isCursorVisible then
  1608 if isCursorVisible then
  1580     begin
  1609     begin
  1750 procedure onFocusStateChanged;
  1779 procedure onFocusStateChanged;
  1751 begin
  1780 begin
  1752 if (not cHasFocus) and (GameState <> gsConfirm) then
  1781 if (not cHasFocus) and (GameState <> gsConfirm) then
  1753     ParseCommand('quit', true);
  1782     ParseCommand('quit', true);
  1754 
  1783 
  1755 if not cHasFocus then DampenAudio()
  1784 // do not change volume during prerecording as it will affect sound in video file
  1756 else UndampenAudio();
  1785 if not flagPrerecording then
       
  1786     begin
       
  1787     if not cHasFocus then DampenAudio()
       
  1788     else UndampenAudio();
       
  1789     end;
  1757 end;
  1790 end;
  1758 
  1791 
  1759 procedure SetUtilityWidgetState(ammoType: TAmmoType);
  1792 procedure SetUtilityWidgetState(ammoType: TAmmoType);
  1760 begin
  1793 begin
  1761 {$IFDEF USE_TOUCH_INTERFACE}
  1794 {$IFDEF USE_TOUCH_INTERFACE}
  1808 
  1841 
  1809 
  1842 
  1810 procedure initModule;
  1843 procedure initModule;
  1811 begin
  1844 begin
  1812     fpsTexture:= nil;
  1845     fpsTexture:= nil;
       
  1846     recTexture:= nil;
  1813     FollowGear:= nil;
  1847     FollowGear:= nil;
  1814     WindBarWidth:= 0;
  1848     WindBarWidth:= 0;
  1815     bShowAmmoMenu:= false;
  1849     bShowAmmoMenu:= false;
  1816     bSelected:= false;
  1850     bSelected:= false;
  1817     bShowFinger:= false;
  1851     bShowFinger:= false;
  1838     FreeTexture(fpsTexture);
  1872     FreeTexture(fpsTexture);
  1839     fpsTexture:= nil;
  1873     fpsTexture:= nil;
  1840     FreeTexture(timeTexture);
  1874     FreeTexture(timeTexture);
  1841     timeTexture:= nil;
  1875     timeTexture:= nil;
  1842     FreeTexture(missionTex);
  1876     FreeTexture(missionTex);
  1843     missionTex:= nil
  1877     missionTex:= nil;
       
  1878     FreeTexture(recTexture);
       
  1879     recTexture:= nil;
  1844 end;
  1880 end;
  1845 
  1881 
  1846 end.
  1882 end.