hedgewars/uWorld.pas
changeset 10275 6c91047f59b6
parent 10265 7e8d4cd76ce7
child 10276 89056c7254ef
equal deleted inserted replaced
10274:07adc8b6288c 10275:6c91047f59b6
   831         VertexBuffer[2].X:= lw;
   831         VertexBuffer[2].X:= lw;
   832         VertexBuffer[2].Y:= lh;
   832         VertexBuffer[2].Y:= lh;
   833         VertexBuffer[3].X:= -lw;
   833         VertexBuffer[3].X:= -lw;
   834         VertexBuffer[3].Y:= lh;
   834         VertexBuffer[3].Y:= lh;
   835 
   835 
   836 {$IFNDEF GL2}
   836         DrawWaterBody(@VertexBuffer[0], Length(VertexBuffer));
   837         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
       
   838         glEnableClientState(GL_COLOR_ARRAY);
       
   839         if SuddenDeathDmg then
       
   840             glColorPointer(4, GL_UNSIGNED_BYTE, 0, @SDWaterColorArray[0])
       
   841         else
       
   842             glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
       
   843 
       
   844         glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
       
   845 
       
   846         glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
       
   847 
       
   848         glDisableClientState(GL_COLOR_ARRAY);
       
   849         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
       
   850 
       
   851 {$ELSE}
       
   852         UpdateModelviewProjection;
       
   853 
       
   854         BeginWater;
       
   855         if SuddenDeathDmg then
       
   856             SetColorPointer(@SDWaterColorArray[0], 4)
       
   857         else
       
   858             SetColorPointer(@WaterColorArray[0], 4);
       
   859 
       
   860         SetVertexPointer(@VertexBuffer[0], 4);
       
   861 
       
   862         glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
       
   863 
       
   864         EndWater;
       
   865 {$ENDIF}
       
   866 
   837 
   867 {$IFNDEF GL2}
   838 {$IFNDEF GL2}
   868         // must not be Tint() as color array seems to stay active and color reset is required
   839         // must not be Tint() as color array seems to stay active and color reset is required
   869         glColor4ub($FF, $FF, $FF, $FF);
   840         glColor4ub($FF, $FF, $FF, $FF);
   870 {$ENDIF}
   841 {$ENDIF}
  1128 {$ENDIF}
  1099 {$ENDIF}
  1129 end;
  1100 end;
  1130 
  1101 
  1131 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
  1102 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
  1132 begin
  1103 begin
  1133 {$IFNDEF USE_S3D_RENDERING}
       
  1134     rm:= rm; d:= d; // avoid hint
  1104     rm:= rm; d:= d; // avoid hint
  1135     exit;
  1105 {$IFDEF USE_S3D_RENDERING}
  1136 {$ELSE}
       
  1137     d:= d / 5;
  1106     d:= d / 5;
  1138     if rm = rmDefault then
  1107     if rm = rmDefault then
  1139         exit
  1108         exit
  1140     else if rm = rmLeftEye then
  1109     else if rm = rmLeftEye then
  1141         d:= -d;
  1110         d:= -d;
  1142     stereoDepth:= stereoDepth + d;
  1111     stereoDepth:= stereoDepth + d;
  1143 
  1112     openglTranslProjMatrix(d, 0, 0);
  1144 {$IFDEF GL2}
       
  1145     hglMatrixMode(MATRIX_PROJECTION);
       
  1146     hglTranslatef(d, 0, 0);
       
  1147     hglMatrixMode(MATRIX_MODELVIEW);
       
  1148 {$ELSE}
       
  1149     glMatrixMode(GL_PROJECTION);
       
  1150     glTranslatef(d, 0, 0);
       
  1151     glMatrixMode(GL_MODELVIEW);
       
  1152 {$ENDIF}
       
  1153 {$ENDIF}
  1113 {$ENDIF}
  1154 end;
  1114 end;
  1155 
  1115 
  1156 procedure ResetDepth(rm: TRenderMode);
  1116 procedure ResetDepth(rm: TRenderMode);
  1157 begin
  1117 begin
  1158 {$IFNDEF USE_S3D_RENDERING}
       
  1159     rm:= rm; // avoid hint
  1118     rm:= rm; // avoid hint
  1160     exit;
  1119 {$IFDEF USE_S3D_RENDERING}
  1161 {$ELSE}
       
  1162     if rm = rmDefault then
  1120     if rm = rmDefault then
  1163         exit;
  1121         exit;
  1164 {$IFDEF GL2}
  1122     openglTranslProjMatrix(-stereoDepth, 0, 0);
  1165     hglMatrixMode(MATRIX_PROJECTION);
       
  1166     hglTranslatef(-stereoDepth, 0, 0);
       
  1167     hglMatrixMode(MATRIX_MODELVIEW);
       
  1168 {$ELSE}
       
  1169     glMatrixMode(GL_PROJECTION);
       
  1170     glTranslatef(-stereoDepth, 0, 0);
       
  1171     glMatrixMode(GL_MODELVIEW);
       
  1172 {$ENDIF}
       
  1173     cStereoDepth:= 0;
  1123     cStereoDepth:= 0;
  1174 {$ENDIF}
  1124 {$ENDIF}
  1175 end;
  1125 end;
  1176 
  1126 
  1177 procedure RenderWorldEdge(Lag: Longword);
  1127 procedure RenderWorldEdge(Lag: Longword);
  1184 (* I think for a bounded world, will fill the left and right areas with black or something. Also will probably want various border effects/animations based on border type.  Prob also, say, trigger a border animation timer on an impact. *)
  1134 (* I think for a bounded world, will fill the left and right areas with black or something. Also will probably want various border effects/animations based on border type.  Prob also, say, trigger a border animation timer on an impact. *)
  1185 
  1135 
  1186     glDisable(GL_TEXTURE_2D);
  1136     glDisable(GL_TEXTURE_2D);
  1187     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  1137     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  1188     if WorldEdge = weWrap then
  1138     if WorldEdge = weWrap then
  1189         glColor4ub($00, $00, $00, $20)
  1139         glColor4ub($00, $00, $00, $40)
  1190     else
  1140     else
  1191         begin
  1141         begin
  1192         glEnableClientState(GL_COLOR_ARRAY);
  1142         glEnableClientState(GL_COLOR_ARRAY);
  1193         glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WorldFade[0]);
  1143         glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WorldFade[0]);
  1194         end;
  1144         end;
  2180     missionTex:= nil;
  2130     missionTex:= nil;
  2181     cOffsetY:= 0;
  2131     cOffsetY:= 0;
  2182     stereoDepth:= 0;
  2132     stereoDepth:= 0;
  2183     AMState:= AMHidden;
  2133     AMState:= AMHidden;
  2184     isFirstFrame:= true;
  2134     isFirstFrame:= true;
  2185     stereoDepth:= stereoDepth; // avoid hint
       
  2186 
  2135 
  2187     FillChar(WorldFade, sizeof(WorldFade), 0);
  2136     FillChar(WorldFade, sizeof(WorldFade), 0);
  2188     WorldFade[0].a:= 255;
  2137     WorldFade[0].a:= 255;
  2189     WorldFade[1].a:= 255;
  2138     WorldFade[1].a:= 255;
  2190     FillChar(WorldEnd, sizeof(WorldEnd), 0);
  2139     FillChar(WorldEnd, sizeof(WorldEnd), 0);