Unit1.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 "GLObjects"
  15. #pragma link "GLScene"
  16. #pragma link "GLTeapot"
  17. #pragma link "GLWin32Viewer"
  18. #pragma resource "*.dfm"
  19. TForm1 *Form1;
  20. //---------------------------------------------------------------------------
  21. __fastcall TForm1::TForm1(TComponent* Owner)
  22. : TForm(Owner)
  23. {
  24. }
  25. //---------------------------------------------------------------------------
  26. void __fastcall TForm1::FormCreate(TObject *Sender)
  27. {
  28. // Load the font bitmap from media dir
  29. SetGLSceneMediaDir();
  30. BitmapFont1->Glyphs->LoadFromFile("darkgold_font.bmp");
  31. // sorry, couldn't resist...
  32. HUDText1->Text = "Hello World !\r\
  33. This is me, \r\
  34. the HUD Text.\r\
  35. Bitmap Fonts!";
  36. }
  37. //---------------------------------------------------------------------------
  38. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  39. const double newTime)
  40. {
  41. // make things move a little
  42. HUDText2->Rotation = HUDText2->Rotation+15*deltaTime;
  43. HUDText3->Scale->X = 0.5*sin(newTime)+1;
  44. HUDText3->Scale->Y = 0.5*cos(newTime)+1;
  45. GLSceneViewer1->Invalidate();
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  49. {
  50. HUDTextFPS->Text = Format("%.1f FPS",
  51. ARRAYOFCONST ((GLSceneViewer1->FramesPerSecond())));
  52. GLSceneViewer1->ResetPerformanceMonitor();
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TForm1::GLSceneViewer1Click(TObject *Sender)
  56. {
  57. Teapot1->Visible = !Teapot1->Visible;
  58. }
  59. //---------------------------------------------------------------------------