Unit1.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLBaseClasses"
  9. #pragma link "GLBitmapFont"
  10. #pragma link "GLCadencer"
  11. #pragma link "GLCoordinates"
  12. #pragma link "GLCrossPlatform"
  13. #pragma link "GLHUDObjects"
  14. #pragma link "GLScene"
  15. #pragma link "GLTeapot"
  16. #pragma link "GLTimeEventsMgr"
  17. #pragma link "GLWin32Viewer"
  18. #pragma resource "*.dfm"
  19. TForm1 *Form1;
  20. const int FadeOutMax = 100;
  21. const int FadeInMax = 100;
  22. const float OverallTrans = 0.7;
  23. //---------------------------------------------------------------------------
  24. __fastcall TForm1::TForm1(TComponent* Owner)
  25. : TForm(Owner)
  26. {
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::FormCreate(TObject *Sender)
  30. {
  31. SetGLSceneMediaDir();
  32. BitmapFont->Glyphs->LoadFromFile("toonfont.bmp");
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TForm1::GLTimeEventsMGR1Events0Event(TTimeEvent *event)
  36. {
  37. if (FadeOutCount < 0) exit;
  38. HUDText1->ModulateColor->Color = VectorMake(1, 1, 1, (FadeOutCount/FadeOutMax)*OverallTrans);
  39. FadeOutCount--;
  40. }
  41. //---------------------------------------------------------------------------
  42. void __fastcall TForm1::GLTimeEventsMGR1Events1Event(TTimeEvent *event)
  43. {
  44. FadeOutCount = FadeOutMax;
  45. FadeInCount = 0;
  46. OriginalColor = HUDText2->ModulateColor->Color;
  47. HUDText1->ModulateColor->Color = VectorMake(1, 1, 1, (FadeOutCount/FadeOutMax)*OverallTrans);
  48. HUDText2->ModulateColor->Color = VectorMake(1, 1, 1, 0);
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TForm1::GLTimeEventsMGR1Events2Event(TTimeEvent *event)
  52. {
  53. TVector4f NewColor;
  54. if (FadeInCount >= FadeInMax) exit;
  55. NewColor = VectorScale(OriginalColor, FadeInCount/FadeInMax);
  56. HUDText2->ModulateColor->Color = NewColor;
  57. FadeInCount++;
  58. }
  59. //---------------------------------------------------------------------------