392 procedure DrawWater(Alpha: byte; OffsetY: LongInt); |
392 procedure DrawWater(Alpha: byte; OffsetY: LongInt); |
393 var VertexBuffer: array [0..3] of TVertex2f; |
393 var VertexBuffer: array [0..3] of TVertex2f; |
394 r: TSDL_Rect; |
394 r: TSDL_Rect; |
395 lw, lh: GLfloat; |
395 lw, lh: GLfloat; |
396 begin |
396 begin |
397 WaterColorArray[0].a := Alpha; |
397 if SuddenDeathDmg then |
398 WaterColorArray[1].a := Alpha; |
398 begin |
399 WaterColorArray[2].a := Alpha; |
399 SDWaterColorArray[0].a := Alpha; |
400 WaterColorArray[3].a := Alpha; |
400 SDWaterColorArray[1].a := Alpha; |
|
401 SDWaterColorArray[2].a := Alpha; |
|
402 SDWaterColorArray[3].a := Alpha |
|
403 end |
|
404 else |
|
405 begin |
|
406 WaterColorArray[0].a := Alpha; |
|
407 WaterColorArray[1].a := Alpha; |
|
408 WaterColorArray[2].a := Alpha; |
|
409 WaterColorArray[3].a := Alpha |
|
410 end; |
401 |
411 |
402 lw:= cScreenWidth / cScaleFactor; |
412 lw:= cScreenWidth / cScaleFactor; |
403 lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16; |
413 lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16; |
404 |
414 |
405 // Water |
415 // Water |
419 VertexBuffer[3].X:= -lw; |
429 VertexBuffer[3].X:= -lw; |
420 VertexBuffer[3].Y:= lh; |
430 VertexBuffer[3].Y:= lh; |
421 |
431 |
422 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
432 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
423 glEnableClientState(GL_COLOR_ARRAY); |
433 glEnableClientState(GL_COLOR_ARRAY); |
424 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); |
434 if SuddenDeathDmg then |
|
435 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @SDWaterColorArray[0]) |
|
436 else |
|
437 glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); |
425 |
438 |
426 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
439 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
427 |
440 |
428 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
441 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
429 |
442 |
435 end; |
448 end; |
436 |
449 |
437 procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte); |
450 procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte); |
438 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
451 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
439 lw, waves, shift: GLfloat; |
452 lw, waves, shift: GLfloat; |
440 begin |
453 sprite: TSprite; |
|
454 begin |
|
455 if SuddenDeathDmg then |
|
456 sprite:= sprSDWater |
|
457 else |
|
458 sprite:= sprWater; |
|
459 |
|
460 cWaveWidth:= SpritesData[sprite].Width; |
|
461 |
441 lw:= cScreenWidth / cScaleFactor; |
462 lw:= cScreenWidth / cScaleFactor; |
442 waves:= lw * 2 / cWaveWidth; |
463 waves:= lw * 2 / cWaveWidth; |
443 |
464 |
444 Tint(LongInt(tnt) * WaterColorArray[2].r div 255 + 255 - tnt, |
465 if SuddenDeathDmg then |
445 LongInt(tnt) * WaterColorArray[2].g div 255 + 255 - tnt, |
466 Tint(LongInt(tnt) * SDWaterColorArray[2].r div 255 + 255 - tnt, |
446 LongInt(tnt) * WaterColorArray[2].b div 255 + 255 - tnt, |
467 LongInt(tnt) * SDWaterColorArray[2].g div 255 + 255 - tnt, |
447 255 |
468 LongInt(tnt) * SDWaterColorArray[2].b div 255 + 255 - tnt, |
448 ); |
469 255 |
449 |
470 ) |
450 glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id); |
471 else |
|
472 Tint(LongInt(tnt) * WaterColorArray[2].r div 255 + 255 - tnt, |
|
473 LongInt(tnt) * WaterColorArray[2].g div 255 + 255 - tnt, |
|
474 LongInt(tnt) * WaterColorArray[2].b div 255 + 255 - tnt, |
|
475 255 |
|
476 ); |
|
477 |
|
478 glBindTexture(GL_TEXTURE_2D, SpritesData[sprite].Texture^.id); |
451 |
479 |
452 VertexBuffer[0].X:= -lw; |
480 VertexBuffer[0].X:= -lw; |
453 VertexBuffer[0].Y:= cWaterLine + WorldDy + dY; |
481 VertexBuffer[0].Y:= cWaterLine + WorldDy + dY; |
454 VertexBuffer[1].X:= lw; |
482 VertexBuffer[1].X:= lw; |
455 VertexBuffer[1].Y:= VertexBuffer[0].Y; |
483 VertexBuffer[1].Y:= VertexBuffer[0].Y; |
456 VertexBuffer[2].X:= lw; |
484 VertexBuffer[2].X:= lw; |
457 VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprWater].Height; |
485 VertexBuffer[2].Y:= VertexBuffer[0].Y + SpritesData[sprite].Height; |
458 VertexBuffer[3].X:= -lw; |
486 VertexBuffer[3].X:= -lw; |
459 VertexBuffer[3].Y:= VertexBuffer[2].Y; |
487 VertexBuffer[3].Y:= VertexBuffer[2].Y; |
460 |
488 |
461 shift:= - lw / cWaveWidth; |
489 shift:= - lw / cWaveWidth; |
462 TextureBuffer[0].X:= shift + (( - WorldDx + LongInt(RealTicks shr 6) * Dir + dX) mod cWaveWidth) / (cWaveWidth - 1); |
490 TextureBuffer[0].X:= shift + (( - WorldDx + LongInt(RealTicks shr 6) * Dir + dX) mod cWaveWidth) / (cWaveWidth - 1); |
463 TextureBuffer[0].Y:= 0; |
491 TextureBuffer[0].Y:= 0; |
464 TextureBuffer[1].X:= TextureBuffer[0].X + waves; |
492 TextureBuffer[1].X:= TextureBuffer[0].X + waves; |
465 TextureBuffer[1].Y:= TextureBuffer[0].Y; |
493 TextureBuffer[1].Y:= TextureBuffer[0].Y; |
466 TextureBuffer[2].X:= TextureBuffer[1].X; |
494 TextureBuffer[2].X:= TextureBuffer[1].X; |
467 TextureBuffer[2].Y:= SpritesData[sprWater].Texture^.ry; |
495 TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry; |
468 TextureBuffer[3].X:= TextureBuffer[0].X; |
496 TextureBuffer[3].X:= TextureBuffer[0].X; |
469 TextureBuffer[3].Y:= TextureBuffer[2].Y; |
497 TextureBuffer[3].Y:= TextureBuffer[2].Y; |
470 |
498 |
471 |
499 |
472 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
500 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |