fSplinesC.cpp 1.9 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 "fSplinesC.h"
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma link "GLS.Scene"
  15. #pragma link "GLS.SceneViewer"
  16. #pragma link "GLS.Objects"
  17. #pragma link "GLS.BaseClasses"
  18. #pragma link "GLS.Coordinates"
  19. #pragma resource "*.dfm"
  20. TForm1 *Form1;
  21. //---------------------------------------------------------------------------
  22. __fastcall TForm1::TForm1(TComponent * Owner):TForm(Owner)
  23. {
  24. }
  25. //---------------------------------------------------------------------------
  26. void __fastcall TForm1::MoveCenterNodeTo(int x, int y)
  27. {
  28. GLLines1->Nodes->Items[1]->AsAffineVector =
  29. GLSceneViewer1->Buffer->ScreenToWorld(x, y);
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TForm1::GLSceneViewer1MouseDown(TObject * Sender,
  33. TMouseButton Button,
  34. TShiftState Shift, int X, int Y)
  35. {
  36. MoveCenterNodeTo(X, Y);
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall TForm1::GLSceneViewer1MouseMove(TObject * Sender,
  40. TShiftState Shift, int X, int Y)
  41. {
  42. if(Shift.Contains(ssShift))
  43. MoveCenterNodeTo(X, Y);
  44. }
  45. //---------------------------------------------------------------------------