fFullScreenC.cpp 2.6 KB

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