2
0

fWinFont.pas 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. unit fWinFont;
  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. Vcl.Menus,
  13. GLS.Scene,
  14. GLS.VectorTypes,
  15. GLS.HUDObjects,
  16. GLS.Objects,
  17. GLS.Cadencer,
  18. GLS.SceneViewer,
  19. GLS.WindowsFont,
  20. GLS.GeomObjects,
  21. GLS.Coordinates,
  22. GLS.BaseClasses,
  23. GLS.BitmapFont;
  24. type
  25. TFormWinFont = class(TForm)
  26. GLScene1: TGLScene;
  27. GLSceneViewer1: TGLSceneViewer;
  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. WindowsBitmapFont1: TGLWindowsBitmapFont;
  37. MainMenu1: TMainMenu;
  38. MIPickFont: TMenuItem;
  39. FontDialog1: TFontDialog;
  40. MIViewTexture: TMenuItem;
  41. MIFPS: TMenuItem;
  42. procedure GLCadencer1Progress(Sender: TObject;
  43. const deltaTime, newTime: Double);
  44. procedure Timer1Timer(Sender: TObject);
  45. procedure FormCreate(Sender: TObject);
  46. procedure GLSceneViewer1Click(Sender: TObject);
  47. procedure MIPickFontClick(Sender: TObject);
  48. procedure MIViewTextureClick(Sender: TObject);
  49. private
  50. public
  51. end;
  52. var
  53. FormWinFont: TFormWinFont;
  54. implementation
  55. uses
  56. fWinTexture;
  57. {$R *.DFM}
  58. procedure TFormWinFont.FormCreate(Sender: TObject);
  59. begin
  60. // sorry, couldn't resist again...
  61. HUDText1.Text :=
  62. 'Lorem ipsum dolor sit amer, consectetaur adipisicing elit,'#13#10 +
  63. 'sed do eiusmod tempor incididunt ut labore et dolore magna'#13#10 +
  64. 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation'#13#10 +
  65. 'ullamco laboris nisi ut aliquip ex ea commodo consequat.'#13#10 +
  66. 'Duis aute irure dolor in reprehenderit in voluptate velit'#13#10 +
  67. 'esse cillum dolore eu fugiat nulla pariatur. Excepteur sint'#13#10 +
  68. 'occaecat cupidatat non proident, sunt in culpa qui officia'#13#10 +
  69. 'deserunt mollit anim id est laborum.'#13#10 +
  70. 'Woblis ten caracuro Zapothek it Setag!';
  71. // I needed an uppercase 'W' too...
  72. HUDText1.Text := HUDText1.Text + #13#10'Unicode text...' + WideChar($0699) +
  73. WideChar($069A) + WideChar($963F) + WideChar($54C0);
  74. WindowsBitmapFont1.EnsureString(HUDText1.Text);
  75. end;
  76. procedure TFormWinFont.MIPickFontClick(Sender: TObject);
  77. begin
  78. FontDialog1.Font := WindowsBitmapFont1.Font;
  79. if FontDialog1.Execute then
  80. begin
  81. WindowsBitmapFont1.Font := FontDialog1.Font;
  82. HUDText1.ModulateColor.AsWinColor := FontDialog1.Font.Color;
  83. end;
  84. end;
  85. procedure TFormWinFont.MIViewTextureClick(Sender: TObject);
  86. begin
  87. with FormFontTexture.Image1 do
  88. begin
  89. Picture := WindowsBitmapFont1.Glyphs;
  90. FormFontTexture.Width := Picture.Width;
  91. FormFontTexture.Height := Picture.Height;
  92. end;
  93. FormFontTexture.Show;
  94. end;
  95. procedure TFormWinFont.GLCadencer1Progress(Sender: TObject;
  96. const deltaTime, newTime: Double);
  97. begin
  98. // make things move a little
  99. HUDText2.Rotation := HUDText2.Rotation + 15 * deltaTime;
  100. HUDText3.Scale.X := sin(newTime) + 1.5;
  101. HUDText3.Scale.Y := cos(newTime) + 1.5;
  102. GLSceneViewer1.Invalidate;
  103. end;
  104. procedure TFormWinFont.Timer1Timer(Sender: TObject);
  105. begin
  106. MIFPS.Caption := Format('%.1f FPS - %d x %d Font Texture',
  107. [GLSceneViewer1.FramesPerSecond, WindowsBitmapFont1.FontTextureWidth,
  108. WindowsBitmapFont1.FontTextureHeight]);
  109. GLSceneViewer1.ResetPerformanceMonitor;
  110. end;
  111. procedure TFormWinFont.GLSceneViewer1Click(Sender: TObject);
  112. begin
  113. Teapot1.Visible := not Teapot1.Visible;
  114. end;
  115. end.