Unit1.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*: This is a quick demo for the TGLLines object and spline functionality.
  2. TGLLines can handle normal lines and cubic splines, each node can have a
  3. different color, and the line can be color-interpolated.
  4. Note that the camera in this sample is in <i>orthogonal</i> mode, this makes
  5. for a quick and easy way to work in 2D with OpenGL (try switching the camera
  6. to perpective mode if you don't see the point).
  7. */
  8. //---------------------------------------------------------------------------
  9. #include <vcl.h>
  10. #pragma hdrstop
  11. #include "Unit1.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "GLScene"
  15. #pragma link "GLSceneViewer"
  16. #pragma link "GLObjects"
  17. #pragma link "GLBaseClasses"
  18. #pragma link "GLCoordinates"
  19. #pragma link "GLCrossPlatform"
  20. #pragma resource "*.dfm"
  21. TForm1 *Form1;
  22. //---------------------------------------------------------------------------
  23. __fastcall TForm1::TForm1(TComponent * Owner):TForm(Owner)
  24. {
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TForm1::MoveCenterNodeTo(int x, int y)
  28. {
  29. GLLines1->Nodes->Items[1]->AsAffineVector =
  30. GLSceneViewer1->Buffer->ScreenToWorld(x, y);
  31. }
  32. //---------------------------------------------------------------------------
  33. void __fastcall TForm1::GLSceneViewer1MouseDown(TObject * Sender,
  34. TMouseButton Button,
  35. TShiftState Shift, int X, int Y)
  36. {
  37. MoveCenterNodeTo(X, Y);
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TForm1::GLSceneViewer1MouseMove(TObject * Sender,
  41. TShiftState Shift, int X, int Y)
  42. {
  43. if(Shift.Contains(ssShift))
  44. MoveCenterNodeTo(X, Y);
  45. }
  46. //---------------------------------------------------------------------------