fArchipelagoC.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. // ---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "fArchipelagoC.h"
  6. // ---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLS.BaseClasses"
  9. #pragma link "GLS.BitmapFont"
  10. #pragma link "GLS.Cadencer"
  11. #pragma link "GLS.Coordinates"
  12. #pragma link "GLS.HeightData"
  13. #pragma link "GLS.HeightTileFileHDS"
  14. #pragma link "GLS.Material"
  15. #pragma link "GLS.Objects"
  16. #pragma link "GLS.Scene"
  17. #pragma link "GLS.SkyDome"
  18. #pragma link "GLS.TerrainRenderer"
  19. #pragma link "GLS.VectorFileObjects"
  20. #pragma link "GLS.SceneViewer"
  21. #pragma link "GLS.WindowsFont"
  22. #pragma link "GLS.HUDObjects"
  23. #pragma link "GLS.File3DS"
  24. #pragma resource "*.dfm"
  25. TForm1 *Form1;
  26. #define cWaterLevel -10000
  27. #define cWaterOpaqueDepth 2000
  28. #define cWaveAmplitude 120
  29. // ---------------------------------------------------------------------------
  30. __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) {
  31. }
  32. // ---------------------------------------------------------------------------
  33. void __fastcall TForm1::FormCreate(TObject *Sender) {
  34. int i, j;
  35. String name;
  36. TGLLibMaterial *libMat;
  37. String DataPath;
  38. DataPath = ExtractFilePath(ParamStr(0));
  39. // DataPath = ExtractFilePath(Application->ExeName);
  40. DataPath += "Data\\";
  41. SetCurrentDir(DataPath);
  42. MaterialLibrary->TexturePaths = DataPath;
  43. GLCustomHDS1->MaxPoolSize = 8 * 1024 * 1024;
  44. GLCustomHDS1->DefaultHeight = cWaterLevel;
  45. // load texmaps
  46. for (i = 0; i <= 3; i++)
  47. for (j = 0; j <= 3; j++) {
  48. name = Format("Tex_%d_%d.bmp", ARRAYOFCONST((i, j)));
  49. if (!FileExists(name)) {
  50. ShowMessage("Texture file " + name + " not found...\r\
  51. Did you run " "splitter->exe"
  52. " as said in the readme->txt?");
  53. Application->Terminate();
  54. Abort();
  55. }
  56. libMat = MaterialLibrary->AddTextureMaterial(name, name, false);
  57. libMat->Material->Texture->TextureMode = tmReplace;
  58. libMat->Material->Texture->TextureWrap = twNone;
  59. // comment out to turn off texture compression
  60. libMat->Material->Texture->Compression = tcStandard;
  61. libMat->Material->Texture->FilteringQuality = tfAnisotropic;
  62. libMat->Texture2Name = "detail";
  63. }
  64. // Initial camera height offset (controled with pageUp/pageDown)
  65. CamHeight = 20;
  66. // Water plane active
  67. WaterPlane = true;
  68. // load the sailboat
  69. /* lost material for sailboat
  70. FFSailBoat->LoadFromFile("sailboat.glsm");
  71. MLSailBoat->LoadFromFile("sailboat.glml");
  72. */
  73. FFSailBoat->LoadFromFile("boat.3DS");
  74. FFSailBoat->Position->SetPoint(-125*TerrainRenderer->Scale->X, 0,
  75. -100*TerrainRenderer->Scale->Z);
  76. FFSailBoat->TurnAngle = -30;
  77. // boost ambient
  78. for (i = 0; i < MLSailBoat->Materials->Count; i++)
  79. MLSailBoat->Materials->Items[i]
  80. ->Material->FrontProperties->Ambient->Color =
  81. MLSailBoat->Materials->Items[i]
  82. ->Material->FrontProperties->Diffuse->Color;
  83. // Move camera starting point near the sailboat
  84. DCCamera->Position = FFSailBoat->Position;
  85. DCCamera->Translate(25, 0, -15);
  86. DCCamera->Turn(200);
  87. // Help text
  88. HTHelp->Text = "Archipelago Demo\r\
  89. * : Increase CLOD precision\r\
  90. / : decrease CLOD precision\r\
  91. W : wireframe on/off\r\
  92. S : sea surface on/off\r\
  93. B : sailboat visible on/off\r\
  94. Num4 & Num6 : steer the sailboat\r\
  95. F1: show this help";
  96. HTHelp->Position->SetPoint(Screen->Width / 2 - 100,
  97. Screen->Height / 2 - 150, 0);
  98. HelpOpacity = 4;
  99. GLSceneViewer->Cursor = crNone;
  100. }
  101. // ---------------------------------------------------------------------------
  102. void TForm1::ResetMousePos(void) {
  103. if (GLSceneViewer->Cursor == crNone)
  104. SetCursorPos(Screen->Width / 2, Screen->Height / 2);
  105. }
  106. // ---------------------------------------------------------------------------
  107. void __fastcall TForm1::GLCadencerProgress(TObject *Sender,
  108. const double deltaTime, const double newTime) {
  109. float Speed, Alpha, f;
  110. float TerrainHeight, SurfaceHeight;
  111. TGLVector Sbp;
  112. POINT NewMousePos;
  113. // Handle keypresses
  114. if (IsKeyDown(VK_SHIFT))
  115. Speed = 100 * deltaTime;
  116. else
  117. Speed = 20 * deltaTime;
  118. if (IsKeyDown(VK_UP))
  119. DCCamera->Position->AddScaledVector(Speed,
  120. GLCamera->AbsoluteVectorToTarget());
  121. if (IsKeyDown(VK_DOWN))
  122. DCCamera->Position->AddScaledVector(-Speed,
  123. GLCamera->AbsoluteVectorToTarget());
  124. if (IsKeyDown(VK_LEFT))
  125. DCCamera->Position->AddScaledVector(-Speed,
  126. GLCamera->AbsoluteRightVectorToTarget());
  127. if (IsKeyDown(VK_RIGHT))
  128. DCCamera->Position->AddScaledVector(Speed,
  129. GLCamera->AbsoluteRightVectorToTarget());
  130. if (IsKeyDown(VK_PRIOR))
  131. CamHeight = CamHeight + Speed;
  132. if (IsKeyDown(VK_NEXT))
  133. CamHeight = CamHeight - Speed;
  134. if (IsKeyDown(VK_ESCAPE))
  135. Close();
  136. if (IsKeyDown(VK_F1))
  137. HelpOpacity = ClampValue(HelpOpacity + deltaTime * 5, 3, 5);
  138. if (IsKeyDown(VK_NUMPAD4))
  139. FFSailBoat->Turn(-deltaTime*3);
  140. if (IsKeyDown(VK_NUMPAD6))
  141. FFSailBoat->Turn(deltaTime*3);
  142. // Mouse movements and actions
  143. if (IsKeyDown(VK_LBUTTON)) {
  144. Alpha = DCCamera->Position->Y;
  145. DCCamera->Position->AddScaledVector(Speed,
  146. GLCamera->AbsoluteVectorToTarget());
  147. CamHeight = CamHeight + DCCamera->Position->Y - Alpha;
  148. }
  149. if (IsKeyDown(VK_RBUTTON)) {
  150. Alpha = DCCamera->Position->Y;
  151. DCCamera->Position->AddScaledVector(-Speed,
  152. GLCamera->AbsoluteVectorToTarget());
  153. CamHeight = CamHeight + DCCamera->Position->Y - Alpha;
  154. }
  155. GetCursorPos(&NewMousePos);
  156. GLCamera->MoveAroundTarget((Screen->Height / 2 - NewMousePos.y)*0.25,
  157. (Screen->Width / 2 - NewMousePos.x)*0.25);
  158. ResetMousePos();
  159. // Don"t drop our target through terrain!
  160. TerrainHeight = TerrainRenderer->InterpolatedHeight
  161. (DCCamera->Position->AsVector);
  162. SurfaceHeight = TerrainRenderer->Scale->Z * cWaterLevel / 128;
  163. if (TerrainHeight < SurfaceHeight)
  164. TerrainHeight = SurfaceHeight;
  165. DCCamera->Position->Y = TerrainHeight + CamHeight;
  166. // Adjust fog distance/color for air/water
  167. if ((GLCamera->AbsolutePosition.Y > SurfaceHeight) || (!WaterPlane)) {
  168. if (!WasAboveWater) {
  169. SkyDome->Visible = true;
  170. GLSceneViewer->Buffer->FogEnvironment->FogColor->Color = clrWhite;
  171. GLSceneViewer->Buffer->FogEnvironment->FogEnd = 1000;
  172. GLSceneViewer->Buffer->FogEnvironment->FogStart = 500;
  173. GLSceneViewer->Buffer->BackgroundColor = clWhite;
  174. GLCamera->DepthOfView = 1000;
  175. WasAboveWater = true;
  176. }
  177. }
  178. else {
  179. if (WasAboveWater) {
  180. SkyDome->Visible = false;
  181. GLSceneViewer->Buffer->FogEnvironment->FogColor->AsWinColor =
  182. clNavy;
  183. GLSceneViewer->Buffer->FogEnvironment->FogEnd = 100;
  184. GLSceneViewer->Buffer->FogEnvironment->FogStart = 0;
  185. GLSceneViewer->Buffer->BackgroundColor = clNavy;
  186. GLCamera->DepthOfView = 100;
  187. WasAboveWater = false;
  188. }
  189. }
  190. // Visibility of Help
  191. if (HelpOpacity > 0) {
  192. HelpOpacity = HelpOpacity - deltaTime;
  193. Alpha = ClampValue(HelpOpacity, 0, 1);
  194. if (Alpha > 0) {
  195. HTHelp->Visible = true;
  196. HTHelp->ModulateColor->Alpha = Alpha;
  197. }
  198. else
  199. HTHelp->Visible = false;
  200. }
  201. // Rock the sailboat
  202. Sbp = TerrainRenderer->AbsoluteToLocal(FFSailBoat->AbsolutePosition);
  203. Alpha = WaterPhase(Sbp.X + TerrainRenderer->TileSize * 0.5,
  204. Sbp.Y + TerrainRenderer->TileSize * 0.5);
  205. FFSailBoat->Position->Y = (cWaterLevel + sin(Alpha) * cWaveAmplitude) *
  206. (TerrainRenderer->Scale->Z / 128) + 10;
  207. f = cWaveAmplitude * 0.01;
  208. FFSailBoat->Up->SetVector(cos(Alpha)*0.02*f, 1,
  209. (sin(Alpha)*0.02 - 0.005)*f);
  210. FFSailBoat->Move(deltaTime*2);
  211. }
  212. // ---------------------------------------------------------------------------
  213. void __fastcall TForm1::Timer1Timer(TObject *Sender) {
  214. HTFPS->Text = Format("%.1f FPS - %d - %d",
  215. ARRAYOFCONST((GLSceneViewer->FramesPerSecond(),
  216. TerrainRenderer->LastTriangleCount, WaterPolyCount)));
  217. GLSceneViewer->ResetPerformanceMonitor();
  218. }
  219. // ---------------------------------------------------------------------------
  220. void __fastcall TForm1::FormKeyPress(TObject *Sender, System::WideChar &Key) {
  221. int i;
  222. TGLPolygonMode pm;
  223. switch (Key) {
  224. case 'w':
  225. case 'W': {
  226. if (MaterialLibrary->Materials->Items[0]->Material->PolygonMode ==
  227. pmLines)
  228. pm = pmFill;
  229. else
  230. pm = pmLines;
  231. for (i = 0; i < MaterialLibrary->Materials->Count; i++)
  232. MaterialLibrary->Materials->Items[i]
  233. ->Material->PolygonMode = pm;
  234. for (i = 0; i < MLSailBoat->Materials->Count; i++)
  235. MLSailBoat->Materials->Items[i]->Material->PolygonMode = pm;
  236. FFSailBoat->StructureChanged();
  237. break;
  238. }
  239. case 's':
  240. case 'S':
  241. WaterPlane = !WaterPlane;
  242. break;
  243. case 'b':
  244. case 'B':
  245. FFSailBoat->Visible = !FFSailBoat->Visible;
  246. break;
  247. case '*':
  248. if (TerrainRenderer->CLODPrecision > 1)
  249. TerrainRenderer->CLODPrecision =
  250. (int)(TerrainRenderer->CLODPrecision * 0.8);
  251. break;
  252. case '/':
  253. if (TerrainRenderer->CLODPrecision < 1000)
  254. TerrainRenderer->CLODPrecision =
  255. (int)(TerrainRenderer->CLODPrecision * 1.2 + 1);
  256. break;
  257. }
  258. Key = 0x0;
  259. }
  260. // ---------------------------------------------------------------------------
  261. void __fastcall TForm1::GLCustomHDS1MarkDirtyEvent(const TRect &area) {
  262. GLHeightTileFileHDS1->MarkDirty(area);
  263. }
  264. // ---------------------------------------------------------------------------
  265. void __fastcall TForm1::GLCustomHDS1StartPreparingData(TGLHeightData *heightData)
  266. {
  267. TGLHeightData *htfHD;
  268. int i, j, n;
  269. TTexPoint offset;
  270. htfHD = GLHeightTileFileHDS1->GetData(heightData->XLeft, heightData->YTop,
  271. heightData->Size, heightData->DataType);
  272. if ((htfHD->DataState == hdsNone))
  273. // or (htfHD->HeightMax<=cWaterLevel-cWaterOpaqueDepth)
  274. heightData->DataState = hdsNone;
  275. else {
  276. i = (heightData->XLeft / 128);
  277. j = (heightData->YTop / 128);
  278. if ((Cardinal(i) < 4) & (Cardinal(j) < 4)) {
  279. heightData->MaterialName =
  280. Format("Tex_%d_%d.bmp", ARRAYOFCONST((i, j)));
  281. heightData->TextureCoordinatesMode = tcmLocal;
  282. n = ((heightData->XLeft / 32) & 3);
  283. offset.S = n * 0.25;
  284. n = ((heightData->YTop / 32) & 3);
  285. offset.T = -n * 0.25;
  286. heightData->TextureCoordinatesOffset = offset;
  287. heightData->TextureCoordinatesScale = TexPointMake(0.25, 0.25);
  288. heightData->DataType = hdtSmallInt;
  289. htfHD->DataType = hdtSmallInt;
  290. heightData->Allocate(hdtSmallInt);
  291. Move(htfHD->SmallIntData, heightData->SmallIntData,
  292. htfHD->DataSize);
  293. heightData->DataState = hdsReady;
  294. heightData->HeightMin = htfHD->HeightMin;
  295. heightData->HeightMax = htfHD->HeightMax;
  296. }
  297. else
  298. heightData->DataState = hdsNone;
  299. }
  300. GLHeightTileFileHDS1->Release(htfHD);
  301. }
  302. // ---------------------------------------------------------------------------
  303. void __fastcall TForm1::GLSceneViewerBeforeRender(TObject *Sender) {
  304. int i, n;
  305. PAProgress->Left = (Width - PAProgress->Width) / 2;
  306. PAProgress->Visible = true;
  307. n = MaterialLibrary->Materials->Count;
  308. ProgressBar->Max = n - 1;
  309. try {
  310. for (i = 0; i < n; i++) {
  311. ProgressBar->Position = i;
  312. MaterialLibrary->Materials->Items[i]->Material->Texture->Handle;
  313. PAProgress->Repaint();
  314. }
  315. }
  316. __finally {
  317. ResetMousePos();
  318. PAProgress->Visible = false;
  319. GLSceneViewer->BeforeRender = NULL;
  320. }
  321. }
  322. // ---------------------------------------------------------------------------
  323. float TForm1::WaterPhase(const float px, const float py) {
  324. return GLCadencer->CurrentTime * 1.0 + px * 0.16 + py * 0.09;
  325. }
  326. // ---------------------------------------------------------------------------
  327. float TForm1::WaterHeight(const float px, const float py) {
  328. float alpha;
  329. alpha = WaterPhase(px + TerrainRenderer->TileSize * 0.5,
  330. py + TerrainRenderer->TileSize * 0.5);
  331. return (cWaterLevel + sin(alpha) * cWaveAmplitude) *
  332. (TerrainRenderer->Scale->Z * (1.0 / 128));
  333. }
  334. // ---------------------------------------------------------------------------
  335. void TForm1::IssuePoint(TGLHeightData *hd, int x, int y, int s2, float t, int rx,
  336. int ry) {
  337. const float r = 0.75;
  338. const float g = 0.75;
  339. const float b = 1.0;
  340. float px, py;
  341. float alpha, colorRatio, ca, sa;
  342. px = x + rx + s2;
  343. py = y + ry + s2;
  344. // if (hd->DataState == hdsNone) {
  345. alpha = 1;
  346. /*
  347. }
  348. else {
  349. alpha = (cWaterLevel - hd->SmallIntHeight(rx, ry)) *
  350. (1 / cWaterOpaqueDepth);
  351. alpha = ClampValue(alpha, 0.5, 1.0);
  352. }
  353. */
  354. SinCos(WaterPhase(px, py), sa, ca);
  355. colorRatio = 1 - alpha * 0.1;
  356. glColor4f(r*colorRatio, g*colorRatio, b, alpha);
  357. glTexCoord2f(px*0.01 + 0.002*sa, py*0.01 + 0.0022*ca - t*0.002);
  358. glVertex3f(px, py, cWaterLevel + cWaveAmplitude*sa);
  359. }
  360. // ---------------------------------------------------------------------------
  361. void __fastcall TForm1::TerrainRendererHeightDataPostRender
  362. (TGLRenderContextInfo &rci, TList *&HeightDatas) {
  363. int i, x, y, s, s2;
  364. float t;
  365. TGLHeightData *hd;
  366. if (WaterPlane) {
  367. t = GLCadencer->CurrentTime;
  368. MaterialLibrary->ApplyMaterial("water", rci);
  369. do {
  370. if (!WasAboveWater)
  371. rci.GLStates->InvertGLFrontFace();
  372. glPushAttrib(GL_ENABLE_BIT);
  373. glDisable(GL_LIGHTING);
  374. glDisable(GL_NORMALIZE);
  375. glStencilFunc(GL_ALWAYS, 1, 255);
  376. glStencilMask(255);
  377. glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
  378. glEnable(GL_STENCIL_TEST);
  379. glNormal3f(0, 0, 1);
  380. for (i = 0; i < HeightDatas->Count; i++) {
  381. hd = (TGLHeightData*)(HeightDatas->List[i]);
  382. if ((hd->DataState == hdsReady) && (hd->HeightMin >
  383. cWaterLevel))
  384. continue;
  385. x = hd->XLeft;
  386. y = hd->YTop;
  387. s = hd->Size - 1;
  388. s2 = s / 2;
  389. glBegin(GL_TRIANGLE_FAN);
  390. IssuePoint(hd, x, y, s2, t, s2, s2);
  391. IssuePoint(hd, x, y, s2, t, 0, 0);
  392. IssuePoint(hd, x, y, s2, t, s2, 0);
  393. IssuePoint(hd, x, y, s2, t, s, 0);
  394. IssuePoint(hd, x, y, s2, t, s, s2);
  395. IssuePoint(hd, x, y, s2, t, s, s);
  396. IssuePoint(hd, x, y, s2, t, s2, s);
  397. IssuePoint(hd, x, y, s2, t, 0, s);
  398. IssuePoint(hd, x, y, s2, t, 0, s2);
  399. IssuePoint(hd, x, y, s2, t, 0, 0);
  400. glEnd();
  401. }
  402. glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
  403. glPopAttrib();
  404. if (!WasAboveWater)
  405. rci.GLStates->InvertGLFrontFace();
  406. WaterPolyCount = HeightDatas->Count * 8;
  407. }
  408. while (MaterialLibrary->UnApplyMaterial(rci));
  409. }
  410. }
  411. // ---------------------------------------------------------------------------
  412. void __fastcall TForm1::DOWakeProgress(TObject *Sender, const double deltaTime,
  413. const double newTime) {
  414. int i;
  415. TGLVector sbp, sbr;
  416. if (WakeVertices == NULL) {
  417. WakeVertices = new TGLAffineVectorList();
  418. WakeStretch = new TGLAffineVectorList();
  419. WakeTime = new TGLSingleList();
  420. }
  421. // enlarge current vertices
  422. i = 0;
  423. while (i < WakeVertices->Count) {
  424. WakeVertices->CombineItem(i, WakeStretch->Items[i >> 1],
  425. -0.45*deltaTime);
  426. WakeVertices->CombineItem(i + 1, WakeStretch->Items[i >> 1],
  427. 0.45*deltaTime);
  428. i += 2;
  429. }
  430. // Progress wake
  431. if (newTime > DOWake->TagFloat) {
  432. if (DOWake->TagFloat == 0) {
  433. DOWake->TagFloat = newTime + 0.2;
  434. }
  435. else {
  436. DOWake->TagFloat = newTime + 1;
  437. sbp = VectorCombine(FFSailBoat->AbsolutePosition,
  438. FFSailBoat->AbsoluteDirection, 1, 3);
  439. sbr = FFSailBoat->AbsoluteRight();
  440. // add new
  441. WakeVertices->Add(VectorCombine(sbp, sbr, 1, -2));
  442. WakeVertices->Add(VectorCombine(sbp, sbr, 1, 2));
  443. WakeStretch->Add(VectorScale(sbr, (0.95 + Random()*0.1)));
  444. WakeTime->Add(newTime*0.1);
  445. if (WakeVertices->Count >= 80) {
  446. WakeVertices->Delete(0);
  447. WakeVertices->Delete(0);
  448. WakeStretch->Delete(0);
  449. WakeTime->Delete(0);
  450. }
  451. }
  452. }
  453. }
  454. // ---------------------------------------------------------------------------
  455. void __fastcall TForm1::DOWakeRender(TObject *Sender, TGLRenderContextInfo &rci) {
  456. int i, n;
  457. Gls::Vectortypes::TVector3f p;
  458. TGLVector sbp;
  459. float c;
  460. if (!(WakeVertices) && (!((FFSailBoat->Visible) || (WaterPlane)))) {
  461. MaterialLibrary->ApplyMaterial("wake", rci);
  462. do {
  463. glPushAttrib(GL_ENABLE_BIT);
  464. glDisable(GL_LIGHTING);
  465. glDisable(GL_FOG);
  466. glEnable(GL_BLEND);
  467. glBlendFunc(GL_ONE, GL_ONE);
  468. glStencilFunc(GL_EQUAL, 1, 255);
  469. glStencilMask(255);
  470. glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
  471. glEnable(GL_STENCIL_TEST);
  472. glDisable(GL_DEPTH_TEST);
  473. if (!WasAboveWater)
  474. rci.GLStates->InvertGLFrontFace();
  475. glBegin(GL_TRIANGLE_STRIP);
  476. n = WakeVertices->Count;
  477. for (i = 0; i < n; i++) {
  478. p = WakeVertices->Items[i ^ 1];
  479. sbp = TerrainRenderer->AbsoluteToLocal(VectorMake(p, 0));
  480. if ((i & 1) == 0) {
  481. c = (i & 0xFFE) * 0.2 / n;
  482. glColor3f(c, c, c);
  483. glTexCoord2f(0, WakeTime->Items[i / 2]);
  484. }
  485. else
  486. glTexCoord2f(1, WakeTime->Items[i / 2]);
  487. glVertex3f(p.X, WaterHeight(sbp.X, sbp.Y), p.Z);
  488. }
  489. glEnd();
  490. if (!WasAboveWater)
  491. rci.GLStates->InvertGLFrontFace();
  492. glPopAttrib();
  493. glDisable(stStencilTest);
  494. }
  495. while (MaterialLibrary->UnApplyMaterial(rci));
  496. }
  497. }
  498. // ---------------------------------------------------------------------------