2
0

fGuiDemoD.pas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. unit fGuiDemoD;
  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. GLScene.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. GLForm1.Caption := 'Unicode caption...'#$0699#$069A#$963f#$54c0;
  73. WindowsBitmapFont1.EnsureString(GLForm1.Caption);
  74. end;
  75. procedure TFormGuidemo.GLCadencer1Progress(Sender: TObject;
  76. const deltaTime, newTime: Double);
  77. begin
  78. GLForm1.DoChanges;
  79. // make things move a little
  80. GLSceneViewer1.Invalidate;
  81. end;
  82. procedure TFormGuidemo.Timer1Timer(Sender: TObject);
  83. begin
  84. miFPS.Caption := Format('%.1f FPS', [GLSceneViewer1.FramesPerSecond]);
  85. GLSceneViewer1.ResetPerformanceMonitor;
  86. end;
  87. procedure TFormGuidemo.WindowsFont1Click(Sender: TObject);
  88. begin
  89. FontDialog1.Font := WindowsBitmapFont1.Font;
  90. if FontDialog1.Execute then
  91. WindowsBitmapFont1.Font := FontDialog1.Font;
  92. end;
  93. procedure TFormGuidemo.GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton;
  94. Shift: TShiftState; X, Y: Integer);
  95. begin
  96. GLForm1.MouseDown(Sender, TMouseButton(Button), Shift, X, Y);
  97. end;
  98. procedure TFormGuidemo.GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState;
  99. X, Y: Integer);
  100. begin
  101. GLForm1.MouseMove(Sender, Shift, X, Y);
  102. end;
  103. procedure TFormGuidemo.GLSceneViewer1MouseUp(Sender: TObject; Button: TMouseButton;
  104. Shift: TShiftState; X, Y: Integer);
  105. begin
  106. GLForm1.MouseUp(Sender, TMouseButton(Button), Shift, X, Y);
  107. end;
  108. procedure TFormGuidemo.FormKeyDown(Sender: TObject; var Key: Word;
  109. Shift: TShiftState);
  110. begin
  111. GLForm1.KeyDown(Sender, Key, Shift);
  112. end;
  113. procedure TFormGuidemo.FormKeyPress(Sender: TObject; var Key: Char);
  114. begin
  115. GLForm1.KeyPress(Sender, Key);
  116. end;
  117. procedure TFormGuidemo.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
  118. begin
  119. GLForm1.KeyUp(Sender, Key, Shift);
  120. end;
  121. procedure TFormGuidemo.GLButton1ButtonClick(Sender: TObject);
  122. Var
  123. OldCaption: String;
  124. begin
  125. OldCaption := GLForm1.Caption;
  126. GLForm1.Caption := GLEdit1.Caption;
  127. GLEdit1.Caption := OldCaption;
  128. end;
  129. end.