fBmpfontD.pas 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. unit fBmpfontD;
  2. interface
  3. uses
  4. Winapi.Opengl,
  5. System.SysUtils,
  6. System.Classes,
  7. Vcl.Graphics,
  8. Vcl.Controls,
  9. Vcl.Forms,
  10. Vcl.Dialogs,
  11. Vcl.ExtCtrls,
  12. GLS.Scene,
  13. GLS.VectorTypes,
  14. GLS.HUDObjects,
  15. GLS.Objects,
  16. GLS.Cadencer,
  17. GLS.BitmapFont,
  18. GLS.GeomObjects,
  19. GLS.Coordinates,
  20. GLS.BaseClasses,
  21. GLS.Utils,
  22. GLS.SceneViewer;
  23. type
  24. TFormBmpFont = class(TForm)
  25. GLScene1: TGLScene;
  26. GLSceneViewer1: TGLSceneViewer;
  27. BitmapFont1: TGLBitmapFont;
  28. GLLightSource1: TGLLightSource;
  29. GLCamera1: TGLCamera;
  30. HUDText1: TGLHUDText;
  31. GLCadencer1: TGLCadencer;
  32. Timer1: TTimer;
  33. HUDText2: TGLHUDText;
  34. HUDText3: TGLHUDText;
  35. Teapot1: TGLTeapot;
  36. HUDTextFPS: TGLHUDText;
  37. procedure GLCadencer1Progress(Sender: TObject;
  38. const deltaTime, newTime: Double);
  39. procedure Timer1Timer(Sender: TObject);
  40. procedure FormCreate(Sender: TObject);
  41. procedure GLSceneViewer1Click(Sender: TObject);
  42. private
  43. public
  44. end;
  45. var
  46. FormBmpFont: TFormBmpFont;
  47. implementation
  48. {$R *.DFM}
  49. procedure TFormBmpFont.FormCreate(Sender: TObject);
  50. begin
  51. // Load the font bitmap from asset dir
  52. var Path: TFileName := GetCurrentAssetPath();
  53. SetCurrentDir(Path + '\font');
  54. BitmapFont1.Glyphs.LoadFromFile('darkgold_font.bmp');
  55. // sorry, couldn't resist...
  56. {$IFDEF WIN32}
  57. HUDText1.Text := 'Hello WIN 32!'#13#10#13#10 + 'This is me, '#13#10 +
  58. 'the HUD Text.'#13#10#13#10 + 'Bitmap Fonts!';
  59. {$ENDIF}
  60. {$IFDEF WIN64}
  61. HUDText1.Text := 'Hello WIN 64!'#13#10#13#10 + 'This is me, '#13#10 +
  62. 'the HUD Text.'#13#10#13#10 + 'Bitmap Fonts!';
  63. {$ENDIF}
  64. end;
  65. procedure TFormBmpFont.GLCadencer1Progress(Sender: TObject;
  66. const deltaTime, newTime: Double);
  67. begin
  68. // make things move a little
  69. HUDText2.Rotation := HUDText2.Rotation + 15 * deltaTime;
  70. HUDText3.Scale.X := 0.5 * sin(newTime) + 1;
  71. HUDText3.Scale.Y := 0.5 * cos(newTime) + 1;
  72. GLSceneViewer1.Invalidate;
  73. end;
  74. procedure TFormBmpFont.Timer1Timer(Sender: TObject);
  75. begin
  76. FormatSettings.DecimalSeparator := ',';
  77. HUDTextFPS.Text := FloatToStr(-2.01);
  78. HUDTextFPS.Text := Format('%.1f FPS', [GLSceneViewer1.FramesPerSecond]);
  79. GLSceneViewer1.ResetPerformanceMonitor;
  80. end;
  81. procedure TFormBmpFont.GLSceneViewer1Click(Sender: TObject);
  82. begin
  83. Teapot1.Visible := not Teapot1.Visible;
  84. end;
  85. end.