Unit1.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "GLObjects"
  12. #pragma link "GLScene"
  13. #pragma link "GLWin32Viewer"
  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. textureFramerateRatio = 1;
  25. n = 0;
  26. }
  27. //---------------------------------------------------------------------------
  28. void __fastcall TForm1::RB1to1Click(TObject *Sender)
  29. {
  30. textureFramerateRatio = RB1to1->Tag;
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TForm1::CheckBox1Click(TObject *Sender)
  34. {
  35. if (CheckBox1->Checked)
  36. GLSceneViewer1->VSync = vsmSync;
  37. else
  38. GLSceneViewer1->VSync = vsmNoSync;
  39. }
  40. //---------------------------------------------------------------------------
  41. void __fastcall TForm1::GLSceneViewer1AfterRender(TObject *Sender)
  42. {
  43. if (!GLSceneViewer1->Buffer->RenderingContext->GL->W_ARB_pbuffer)
  44. {
  45. ShowMessage("WGL_ARB_pbuffer not supported...\r\n\
  46. Get newer graphics hardware or try updating your drivers!");
  47. GLSceneViewer1->AfterRender = NULL;
  48. exit;
  49. }
  50. n++;
  51. try {
  52. if (n >= textureFramerateRatio)
  53. {
  54. // render to the viewer
  55. GLMemoryViewer1->Render();
  56. // copy result to the textures
  57. GLMemoryViewer1->CopyToTexture(Cube1->Material->Texture);
  58. n = 0;
  59. }
  60. } catch (...) {
  61. // pbuffer not supported... catchall for exotic ICDs...
  62. GLSceneViewer1->AfterRender = NULL;
  63. exit; //raise;
  64. }
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  68. {
  69. LabelFPS->Caption = Format("%.1f FPS", ARRAYOFCONST((GLSceneViewer1->FramesPerSecond())));
  70. GLSceneViewer1->ResetPerformanceMonitor();
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  74. const double newTime)
  75. {
  76. DummyCube1->TurnAngle = newTime * 60;
  77. }
  78. //---------------------------------------------------------------------------