2
0

Unit1.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //---------------------------------------------------------------------------
  2. #pragma hdrstop
  3. #include <vcl.h>
  4. #include <tchar.h>
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma classgroup "Vcl.Controls.TControl"
  9. #pragma link "GLBaseClasses"
  10. #pragma link "GLCoordinates"
  11. #pragma link "GLCrossPlatform"
  12. #pragma link "GLFullScreenViewer"
  13. #pragma link "GLObjects"
  14. #pragma link "GLScene"
  15. #pragma link "GLTeapot"
  16. #pragma resource "*.dfm"
  17. TDataModule1 *DataModule1;
  18. //---------------------------------------------------------------------------
  19. __fastcall TDataModule1::TDataModule1(TComponent* Owner)
  20. : TDataModule(Owner)
  21. {
  22. }
  23. //---------------------------------------------------------------------------
  24. void __fastcall TDataModule1::DataModuleCreate(TObject *Sender)
  25. {
  26. // Adjusts Zoom to size (might have been modified in the IDE, by you, user!)
  27. GLCamera1->SceneScale = GLFullScreenViewer1->Width/160;
  28. // Start fullscreen mode, no cursor
  29. GLFullScreenViewer1->Cursor = crNone;
  30. GLFullScreenViewer1->Active = true;
  31. while (GLFullScreenViewer1->Active)
  32. {
  33. // Message queue is not operational, but there may still be some messages
  34. Application->ProcessMessages();
  35. // Relinquish some of that CPU time
  36. Sleep(1);
  37. // Slowly rotate the teapot and the blue light
  38. Teapot1->TurnAngle = 4*Frac(24*(Now()))*3600;
  39. DCBlueLight->RollAngle = 32*Frac(24*(Now()))*3600;
  40. }
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TDataModule1::GLFullScreenViewer1PostRender(TObject *Sender)
  44. {
  45. TGLCanvas *glc;
  46. int x, y;
  47. glc = new TGLCanvas(GLFullScreenViewer1->Width, GLFullScreenViewer1->Height);
  48. // with glc do begin
  49. x = Mouse->CursorPos.X;
  50. y = Mouse->CursorPos.Y;
  51. glc->PenColor = clYellow;
  52. // Alpha-transparency antialiasing:
  53. // we render the ellipse twice, the first pass with a very transparent
  54. // wide pen, and a second time with a thinner pen.
  55. glc->PenAlpha = 0.4;
  56. glc->PenWidth = 3;
  57. glc->Ellipse(x, y, 16, 16);
  58. glc->PenAlpha = 0.75;
  59. glc->PenWidth = 2;
  60. glc->Ellipse(x, y, 16, 16);
  61. // Complete the reticle
  62. glc->PenAlpha = 0.3;
  63. glc->PenWidth = 2;
  64. glc->Line(x-32, y, x+32, y);
  65. glc->Line(x, y-32, x, y+32);
  66. glc->Free();
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TDataModule1::GLFullScreenViewer1KeyPress(TObject *Sender, System::WideChar &Key)
  70. {
  71. // ESC leaves fullscreen mode
  72. if (Key = '\27') {
  73. GLFullScreenViewer1->Active = false;
  74. Key = '\0';
  75. }
  76. }
  77. //---------------------------------------------------------------------------