Unit1.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "GLBaseClasses"
  8. #pragma link "GLCadencer"
  9. #pragma link "GLCoordinates"
  10. #pragma link "GLCrossPlatform"
  11. #pragma link "GLObjects"
  12. #pragma link "GLScene"
  13. #pragma link "GLWin32Viewer"
  14. #pragma resource "*.dfm"
  15. TForm1 *Form1;
  16. //---------------------------------------------------------------------------
  17. __fastcall TForm1::TForm1(TComponent* Owner)
  18. : TForm(Owner)
  19. {
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TForm1::TrackBarChange(TObject *Sender)
  23. {
  24. int t;
  25. t = TrackBar->Position;
  26. // the "sun" spins slowly
  27. Cube1->TurnAngle = t/4;
  28. // "earth" rotates around the sun and spins
  29. DummyCube1->TurnAngle = -t;
  30. Cube2->TurnAngle = t*2;
  31. // "moon" rotates around earth and spins
  32. DummyCube2->RollAngle = 3*t;
  33. Cube3->TurnAngle = 4*t;
  34. }
  35. //---------------------------------------------------------------------------
  36. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  37. const double newTime)
  38. {
  39. if (CBPlay->Checked && Visible)
  40. // simulate a user action on the trackbar...
  41. TrackBar->Position = ((TrackBar->Position+1) % 360);
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TForm1::FormResize(TObject *Sender)
  45. {
  46. GLSceneViewer1->ResetPerformanceMonitor();
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
  50. {
  51. // We need to stop playing here :
  52. // since the timer is asynchronous, if we don't stop play,
  53. // it may get triggered during the form's destruction
  54. CBPlay->Checked = false;
  55. }
  56. //---------------------------------------------------------------------------