Unit1.cpp 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 "GLWin32Viewer"
  17. #pragma link "GLWindowsFont"
  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. // sorry, couldn't resist again...
  29. HUDText1->Text = "Lorem ipsum dolor sit amer, consectetaur adipisicing elit,\r\
  30. sed do eiusmod tempor incididunt ut labore et dolore magna\r\
  31. aliqua. Ut enim ad minim veniam, quis nostrud exercitation\r\
  32. ullamco laboris nisi ut aliquip ex ea commodo consequat.\r\
  33. Duis aute irure dolor in reprehenderit in voluptate velit\r\
  34. esse cillum dolore eu fugiat nulla pariatur. Excepteur sint\r\
  35. occaecat cupidatat non proident, sunt in culpa qui officia\r\
  36. deserunt mollit anim id est laborum.\r\
  37. Woblis ten caracuro Zapothek it Setag!"; // I needed an uppercase 'W' too...
  38. HUDText1->Text = HUDText1->Text + "Unicode text..." +
  39. WideChar(0x0699)+WideChar(0x069A)+WideChar(0x963f)+WideChar(0x54c0);
  40. WindowsBitmapFont1->EnsureString(HUDText1->Text);
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TForm1::MIPickFontClick(TObject *Sender)
  44. {
  45. FontDialog1->Font = WindowsBitmapFont1->Font;
  46. if (FontDialog1->Execute())
  47. {
  48. WindowsBitmapFont1->Font = FontDialog1->Font;
  49. HUDText1->ModulateColor->AsWinColor = FontDialog1->Font->Color;
  50. }
  51. }
  52. //---------------------------------------------------------------------------
  53. void __fastcall TForm1::MIViewTextureClick(TObject *Sender)
  54. {
  55. {
  56. Form2->Image1->Picture = WindowsBitmapFont1->Glyphs;
  57. Form2->Width = Form2->Image1->Picture->Width;
  58. Form2->Height = Form2->Image1->Picture->Height;
  59. }
  60. Form2->Show();
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  64. const double newTime)
  65. {
  66. // make things move a little
  67. HUDText2->Rotation = HUDText2->Rotation+15*deltaTime;
  68. HUDText3->Scale->X = sin(newTime)+1.5;
  69. HUDText3->Scale->Y = cos(newTime)+1.5;
  70. GLSceneViewer1->Invalidate();
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  74. {
  75. MIFPS->Caption = Format("%.1f FPS - %d x %d Font Texture",
  76. ARRAYOFCONST ((GLSceneViewer1->FramesPerSecond(),
  77. WindowsBitmapFont1->FontTextureWidth(),
  78. WindowsBitmapFont1->FontTextureHeight())));
  79. GLSceneViewer1->ResetPerformanceMonitor();
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TForm1::GLSceneViewer1Click(TObject *Sender)
  83. {
  84. Teapot1->Visible = !Teapot1->Visible;
  85. }
  86. //---------------------------------------------------------------------------