Unit1.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.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.GeomObjects"
  11. #pragma link "GLS.Material"
  12. #pragma link "GLS.Objects"
  13. #pragma link "GLS.Scene"
  14. #pragma link "GLS.ShadowPlane"
  15. #pragma link "GLS.SceneViewer"
  16. #pragma resource "*.dfm"
  17. TForm1 *Form1;
  18. //---------------------------------------------------------------------------
  19. __fastcall TForm1::TForm1(TComponent* Owner)
  20. : TForm(Owner)
  21. {
  22. }
  23. //---------------------------------------------------------------------------
  24. void __fastcall TForm1::FormCreate(TObject *Sender)
  25. {
  26. SetGLSceneMediaDir();
  27. GLMaterialLibrary->Materials->Items[0]->Material->Texture->Image->LoadFromFile("BeigeMarble.jpg");
  28. }
  29. //---------------------------------------------------------------------------
  30. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  31. const double newTime)
  32. {
  33. DCLight->PitchAngle = Sin(newTime)*60;
  34. DCShadowing->TurnAngle = newTime*10;
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TForm1::CBShadowsClick(TObject *Sender)
  38. {
  39. if (CBShadows->Checked)
  40. GLShadowPlane1->ShadowedLight = GLLightSource1;
  41. else
  42. GLShadowPlane1->ShadowedLight = NULL;
  43. GLShadowPlane2->ShadowedLight = GLShadowPlane1->ShadowedLight;
  44. GLShadowPlane3->ShadowedLight = GLShadowPlane1->ShadowedLight;
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::CBStencilClick(TObject *Sender)
  48. {
  49. if (CBStencil->Checked)
  50. GLShadowPlane1->ShadowOptions = GLShadowPlane1->ShadowOptions << spoUseStencil, spoScissor;
  51. else
  52. GLShadowPlane1->ShadowOptions = GLShadowPlane1->ShadowOptions << spoScissor;
  53. GLShadowPlane2->ShadowOptions = GLShadowPlane1->ShadowOptions;
  54. GLShadowPlane3->ShadowOptions = GLShadowPlane1->ShadowOptions;
  55. }
  56. //---------------------------------------------------------------------------
  57. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  58. {
  59. Caption = "Shadow Plane - " + Format("%.1f FPS",
  60. ARRAYOFCONST ((GLSceneViewer1->FramesPerSecond())));
  61. GLSceneViewer1->ResetPerformanceMonitor();
  62. }
  63. //---------------------------------------------------------------------------