Unit1.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "GLBaseClasses"
  8. #pragma link "GLCadencer"
  9. #pragma link "GLCoordinates"
  10. #pragma link "GLCrossPlatform"
  11. #pragma link "GLMaterial"
  12. #pragma link "GLObjects"
  13. #pragma link "GLScene"
  14. #pragma link "GLWin32Viewer"
  15. #pragma resource "*.dfm"
  16. TForm1 *Form1;
  17. //---------------------------------------------------------------------------
  18. __fastcall TForm1::TForm1(TComponent* Owner)
  19. : TForm(Owner)
  20. {
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TForm1::FormCreate(TObject *Sender)
  24. {
  25. SetGLSceneMediaDir();
  26. // Add GLBlur to scene
  27. B = new TGLBlur(this);
  28. GLCube1->AddChild(B);
  29. B->TargetObject = GLCube1;
  30. B->RenderWidth = 256;
  31. B->RenderHeight = 256;
  32. // Load texture for objects
  33. GLMaterialLibrary1->Materials->Items[0]->Material->Texture->Image->LoadFromFile("marbletiles.jpg");
  34. ComboBox1->ItemIndex = 2;
  35. ComboBox1Change(this);
  36. }
  37. //---------------------------------------------------------------------------
  38. void __fastcall TForm1::ComboBox1Change(TObject *Sender)
  39. {
  40. B->Preset = TGLBlurPreset(ComboBox1->ItemIndex);
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  44. const double newTime)
  45. {
  46. GLCube1->Turn(deltaTime * 10);
  47. GLSphere1->Turn(deltaTime * 50);
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TForm1::ComboBox2Change(TObject *Sender)
  51. {
  52. B->RenderWidth = StrToInt(ComboBox2->Items->Strings[ComboBox2->ItemIndex]);
  53. B->RenderHeight = B->RenderWidth;
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  57. {
  58. LabelFPS->Caption = FloatToStr(Trunc((float)GLSceneViewer1->FramesPerSecond()))+ " FPS";
  59. GLSceneViewer1->ResetPerformanceMonitor();
  60. }
  61. //---------------------------------------------------------------------------
  62. void __fastcall TForm1::GLSceneViewer1MouseMove(TObject *Sender, TShiftState Shift,
  63. int X, int Y)
  64. {
  65. if (Shift.Contains(ssLeft))
  66. GLCamera1->MoveAroundTarget(0.2 * (oldy - Y), 0.2 * (oldx - X));
  67. oldx = X;
  68. oldy = Y;
  69. }
  70. //---------------------------------------------------------------------------