hedgewars/uWorld.pas
changeset 3376 faee68a28b82
parent 3304 8690a3aa93b5
child 3380 a46a311097af
equal deleted inserted replaced
3375:88bb88294e06 3376:faee68a28b82
   329     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   329     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   330 
   330 
   331     glDisableClientState(GL_VERTEX_ARRAY);
   331     glDisableClientState(GL_VERTEX_ARRAY);
   332     glDisableClientState(GL_COLOR_ARRAY);
   332     glDisableClientState(GL_COLOR_ARRAY);
   333 
   333 
   334     glColor4f(1, 1, 1, 1); // disable coloring
   334     glColor4ub($FF, $FF, $FF, $FF); // disable coloring
   335     glEnable(GL_TEXTURE_2D)
   335     glEnable(GL_TEXTURE_2D)
   336     end
   336     end
   337 end;
   337 end;
   338 
   338 
   339 procedure DrawWaves(Dir, dX, dY: LongInt; Tint: GLfloat);
   339 procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte);
   340 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
   340 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
   341     lw, waves, shift: GLfloat;
   341     lw, waves, shift: GLfloat;
   342 begin
   342 begin
   343 lw:= cScreenWidth / cScaleFactor;
   343 lw:= cScreenWidth / cScaleFactor;
   344 waves:= lw * 2 / cWaveWidth;
   344 waves:= lw * 2 / cWaveWidth;
   345 
   345 
   346 glColor4f(
   346 Tint(
   347       (Tint * WaterColorArray[2].r / 255) + (1-Tint)
   347       (tnt * WaterColorArray[2].r div 255) + (255-tnt)
   348     , (Tint * WaterColorArray[2].g / 255) + (1-Tint)
   348     , (tnt * WaterColorArray[2].g div 255) + (255-tnt)
   349     , (Tint * WaterColorArray[2].b / 255) + (1-Tint)
   349     , (tnt * WaterColorArray[2].b div 255) + (255-tnt)
   350     , 1
   350     , 255
   351 );
   351 );
   352 
   352 
   353 glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id);
   353 glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id);
   354 
   354 
   355 VertexBuffer[0].X:= -lw;
   355 VertexBuffer[0].X:= -lw;
   378 glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]);
   378 glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]);
   379 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   379 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   380 
   380 
   381 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
   381 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
   382 glDisableClientState(GL_VERTEX_ARRAY);
   382 glDisableClientState(GL_VERTEX_ARRAY);
   383 glColor4f(1, 1, 1, 1);
   383 Tint($FFFFFFFF);
   384 
       
   385 
   384 
   386 {for i:= -1 to cWaterSprCount do
   385 {for i:= -1 to cWaterSprCount do
   387     DrawSprite(sprWater,
   386     DrawSprite(sprWater,
   388         i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2),
   387         i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2),
   389         cWaterLine + WorldDy + dY,
   388         cWaterLine + WorldDy + dY,
   451     if ZoomValue < zoom then zoom:= ZoomValue
   450     if ZoomValue < zoom then zoom:= ZoomValue
   452     end;
   451     end;
   453 
   452 
   454 // Sky
   453 // Sky
   455 glClear(GL_COLOR_BUFFER_BIT);
   454 glClear(GL_COLOR_BUFFER_BIT);
   456 glEnable(GL_BLEND);
       
   457 glEnable(GL_TEXTURE_2D);
       
   458 //glPushMatrix;
   455 //glPushMatrix;
   459 //glScalef(1.0, 1.0, 1.0);
   456 //glScalef(1.0, 1.0, 1.0);
   460 
   457 
   461 if not isPaused then MoveCamera;
   458 if not isPaused then MoveCamera;
   462 
   459 
   476 
   473 
   477     DrawVisualGears(0);
   474     DrawVisualGears(0);
   478     
   475     
   479     // Waves
   476     // Waves
   480     DrawWater(255, SkyOffset); 
   477     DrawWater(255, SkyOffset); 
   481     DrawWaves( 1,  0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 0.25);
   478     DrawWaves( 1,  0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64);
   482     DrawWaves( -1,  25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 0.19);
   479     DrawWaves( -1,  25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48);
   483     DrawWaves( 1,  75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 0.14);
   480     DrawWaves( 1,  75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32);
   484     DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 0.09);
   481     DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24);
   485     end
   482     end
   486 else
   483 else
   487     DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
   484     DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
   488 
   485 
   489 DrawLand(WorldDx, WorldDy);
   486 DrawLand(WorldDx, WorldDy);
   519 DrawVisualGears(2);
   516 DrawVisualGears(2);
   520 
   517 
   521 DrawWater(cWaterOpacity, 0);
   518 DrawWater(cWaterOpacity, 0);
   522 
   519 
   523 // Waves
   520 // Waves
   524 DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 0.05);
   521 DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12);
   525 
   522 
   526 if not cReducedQuality then
   523 if not cReducedQuality then
   527     begin
   524     begin
   528     //DrawWater(cWaterOpacity, - offsetY div 40);
   525     //DrawWater(cWaterOpacity, - offsetY div 40);
   529     DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 0.03);
   526     DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8);
   530     DrawWater(cWaterOpacity, - offsetY div 20);
   527     DrawWater(cWaterOpacity, - offsetY div 20);
   531     DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 0.01);
   528     DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2);
   532     DrawWater(cWaterOpacity, - offsetY div 10);
   529     DrawWater(cWaterOpacity, - offsetY div 10);
   533     DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0);
   530     DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0);
   534     end
   531     end
   535 else
   532 else
   536     DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
   533     DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
   653    with TeamsArray[t]^ do
   650    with TeamsArray[t]^ do
   654       begin
   651       begin
   655       highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
   652       highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
   656       
   653       
   657       if highlight then
   654       if highlight then
   658          glColor4f(((Clan^.Color shr 16) and $ff) / $ff, ((Clan^.Color shr 8) and $ff) / $ff, (Clan^.Color and $ff) / $ff, 1);
   655          Tint(Clan^.Color);
   659 
   656 
   660       // draw name
   657       // draw name
   661       DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY, NameTagTex);
   658       DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY, NameTagTex);
   662       
   659       
   663       // draw flag
   660       // draw flag
   676       DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY, @r, HealthTex);
   673       DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY, @r, HealthTex);
   677       // if highlighted, draw flag and other contents again to keep their colors
   674       // if highlighted, draw flag and other contents again to keep their colors
   678       // this approach should be faster than drawing all borders one by one tinted or not
   675       // this approach should be faster than drawing all borders one by one tinted or not
   679       if highlight then
   676       if highlight then
   680          begin
   677          begin
   681          glColor4f(1, 1, 1, 1);
   678          Tint($FFFFFFFF);
   682 
   679 
   683          // draw name
   680          // draw name
   684          r.x:= 2;
   681          r.x:= 2;
   685          r.y:= 2;
   682          r.y:= 2;
   686          r.w:= NameTagTex^.w - 4;
   683          r.w:= NameTagTex^.w - 4;
   811    end;
   808    end;
   812 
   809 
   813 if GameState = gsConfirm then
   810 if GameState = gsConfirm then
   814     DrawCentered(0, (cScreenHeight shr 1), ConfirmTexture);
   811     DrawCentered(0, (cScreenHeight shr 1), ConfirmTexture);
   815 
   812 
   816 glDisable(GL_TEXTURE_2D);
       
   817 
       
   818 if ScreenFade <> sfNone then
   813 if ScreenFade <> sfNone then
   819     begin
   814     begin
   820     if not isFirstFrame then
   815     if not isFirstFrame then
   821         case ScreenFade of
   816         case ScreenFade of
   822             sfToBlack, sfToWhite:     if ScreenFadeValue + Lag * ScreenFadeSpeed < sfMax then
   817             sfToBlack, sfToWhite:     if ScreenFadeValue + Lag * ScreenFadeSpeed < sfMax then
   829                                           ScreenFadeValue:= 0;
   824                                           ScreenFadeValue:= 0;
   830             end;
   825             end;
   831     if ScreenFade <> sfNone then
   826     if ScreenFade <> sfNone then
   832         begin
   827         begin
   833         case ScreenFade of
   828         case ScreenFade of
   834             sfToBlack, sfFromBlack: glColor4f(0, 0, 0, ScreenFadeValue / 1000);
   829             sfToBlack, sfFromBlack: Tint(0, 0, 0, ScreenFadeValue * 255 div 1000);
   835             sfToWhite, sfFromWhite: glColor4f(1, 1, 1, ScreenFadeValue / 1000);
   830             sfToWhite, sfFromWhite: Tint($FF, $FF, $FF, ScreenFadeValue * 255 div 1000);
   836             end;
   831             end;
   837         
   832         
   838         glDisable(GL_TEXTURE_2D);
       
   839         VertexBuffer[0].X:= -cScreenWidth;
   833         VertexBuffer[0].X:= -cScreenWidth;
   840         VertexBuffer[0].Y:= cScreenHeight;
   834         VertexBuffer[0].Y:= cScreenHeight;
   841         VertexBuffer[1].X:= -cScreenWidth;
   835         VertexBuffer[1].X:= -cScreenWidth;
   842         VertexBuffer[1].Y:= 0;
   836         VertexBuffer[1].Y:= 0;
   843         VertexBuffer[2].X:= cScreenWidth;
   837         VertexBuffer[2].X:= cScreenWidth;
   844         VertexBuffer[2].Y:= 0;
   838         VertexBuffer[2].Y:= 0;
   845         VertexBuffer[3].X:= cScreenWidth;
   839         VertexBuffer[3].X:= cScreenWidth;
   846         VertexBuffer[3].Y:= cScreenHeight;
   840         VertexBuffer[3].Y:= cScreenHeight;
   847          
   841          
       
   842         glDisable(GL_TEXTURE_2D);
   848         glEnableClientState(GL_VERTEX_ARRAY);
   843         glEnableClientState(GL_VERTEX_ARRAY);
   849         glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   844         glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   850         glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   845         glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   851         glDisableClientState(GL_VERTEX_ARRAY);
   846         glDisableClientState(GL_VERTEX_ARRAY);
   852          
   847         glEnable(GL_TEXTURE_2D);
   853         glColor4f(1, 1, 1, 1);
   848         Tint($FFFFFFFF);
   854         if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone
   849         if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone
   855         end
   850         end
   856     end;
   851     end;
   857 
   852 
   858 SetScale(zoom);
   853 SetScale(zoom);
   859 glEnable(GL_TEXTURE_2D);
       
   860 
   854 
   861 // Cursor
   855 // Cursor
   862 if isCursorVisible then
   856 if isCursorVisible then
   863    begin
   857    begin
   864    if not bShowAmmoMenu then
   858    if not bShowAmmoMenu then
   872              DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
   866              DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
   873          end;
   867          end;
   874      DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   868      DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   875      end
   869      end
   876    end;
   870    end;
   877 
       
   878 glDisable(GL_TEXTURE_2D);
       
   879 glDisable(GL_BLEND);
       
   880 isFirstFrame:= false
   871 isFirstFrame:= false
   881 end;
   872 end;
   882 
   873 
   883 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
   874 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
   884 begin
   875 begin