fBlurC.cpp 2.5 KB

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