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