fGuiDemo.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. unit fGuiDemo;
  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.HUDObjects,
  15. GLS.Objects,
  16. GLS.Cadencer,
  17. GLS.BitmapFont,
  18. GLS.SceneViewer,
  19. GLS.WindowsFont,
  20. GLS.Windows,
  21. GLS.Gui,
  22. GLS.Texture,
  23. GLS.Material,
  24. GLS.Coordinates,
  25. GLS.BaseClasses,
  26. GLS.Utils;
  27. type
  28. TFormGuidemo = class(TForm)
  29. GLScene1: TGLScene;
  30. GLSceneViewer1: TGLSceneViewer;
  31. GLLightSource1: TGLLightSource;
  32. GLCamera1: TGLCamera;
  33. GLCadencer1: TGLCadencer;
  34. Timer1: TTimer;
  35. WindowsBitmapFont1: TGLWindowsBitmapFont;
  36. MainMenu1: TMainMenu;
  37. Font1: TMenuItem;
  38. WindowsFont1: TMenuItem;
  39. FontDialog1: TFontDialog;
  40. GLGuiLayout1: TGLGuiLayout;
  41. GLForm1: TGLForm;
  42. GLMaterialLibrary1: TGLMaterialLibrary;
  43. GLButton1: TGLButton;
  44. GLEdit1: TGLEdit;
  45. GLLabel1: TGLLabel;
  46. miFPS: TMenuItem;
  47. procedure GLCadencer1Progress(Sender: TObject;
  48. const deltaTime, newTime: Double);
  49. procedure Timer1Timer(Sender: TObject);
  50. procedure WindowsFont1Click(Sender: TObject);
  51. procedure GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton;
  52. Shift: TShiftState; X, Y: Integer);
  53. procedure GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState;
  54. X, Y: Integer);
  55. procedure GLSceneViewer1MouseUp(Sender: TObject; Button: TMouseButton;
  56. Shift: TShiftState; X, Y: Integer);
  57. procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  58. procedure FormKeyPress(Sender: TObject; var Key: Char);
  59. procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
  60. procedure GLButton1ButtonClick(Sender: TObject);
  61. private
  62. public
  63. constructor Create(AOwner: TComponent); override;
  64. end;
  65. var
  66. FormGuidemo: TFormGuidemo;
  67. implementation
  68. {$R *.DFM}
  69. constructor TFormGuidemo.Create(AOwner: TComponent);
  70. begin
  71. inherited;
  72. SetGLSceneMediaDir();
  73. GLForm1.Caption := 'Unicode caption...'#$0699#$069A#$963f#$54c0;
  74. WindowsBitmapFont1.EnsureString(GLForm1.Caption);
  75. end;
  76. procedure TFormGuidemo.GLCadencer1Progress(Sender: TObject;
  77. const deltaTime, newTime: Double);
  78. begin
  79. GLForm1.DoChanges;
  80. // make things move a little
  81. GLSceneViewer1.Invalidate;
  82. end;
  83. procedure TFormGuidemo.Timer1Timer(Sender: TObject);
  84. begin
  85. miFPS.Caption := Format('%.1f FPS', [GLSceneViewer1.FramesPerSecond]);
  86. GLSceneViewer1.ResetPerformanceMonitor;
  87. end;
  88. procedure TFormGuidemo.WindowsFont1Click(Sender: TObject);
  89. begin
  90. FontDialog1.Font := WindowsBitmapFont1.Font;
  91. if FontDialog1.Execute then
  92. WindowsBitmapFont1.Font := FontDialog1.Font;
  93. end;
  94. procedure TFormGuidemo.GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton;
  95. Shift: TShiftState; X, Y: Integer);
  96. begin
  97. GLForm1.MouseDown(Sender, TMouseButton(Button), Shift, X, Y);
  98. end;
  99. procedure TFormGuidemo.GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState;
  100. X, Y: Integer);
  101. begin
  102. GLForm1.MouseMove(Sender, Shift, X, Y);
  103. end;
  104. procedure TFormGuidemo.GLSceneViewer1MouseUp(Sender: TObject; Button: TMouseButton;
  105. Shift: TShiftState; X, Y: Integer);
  106. begin
  107. GLForm1.MouseUp(Sender, TMouseButton(Button), Shift, X, Y);
  108. end;
  109. procedure TFormGuidemo.FormKeyDown(Sender: TObject; var Key: Word;
  110. Shift: TShiftState);
  111. begin
  112. GLForm1.KeyDown(Sender, Key, Shift);
  113. end;
  114. procedure TFormGuidemo.FormKeyPress(Sender: TObject; var Key: Char);
  115. begin
  116. GLForm1.KeyPress(Sender, Key);
  117. end;
  118. procedure TFormGuidemo.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
  119. begin
  120. GLForm1.KeyUp(Sender, Key, Shift);
  121. end;
  122. procedure TFormGuidemo.GLButton1ButtonClick(Sender: TObject);
  123. Var
  124. OldCaption: String;
  125. begin
  126. OldCaption := GLForm1.Caption;
  127. GLForm1.Caption := GLEdit1.Caption;
  128. GLEdit1.Caption := OldCaption;
  129. end;
  130. end.