fMemviewerC.cpp 2.5 KB

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