uMainForm.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "uMainForm.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLS.BaseClasses"
  9. #pragma link "GLS.Cadencer"
  10. #pragma link "GLS.Coordinates"
  11. #pragma link "GLS.Material"
  12. #pragma link "GLPostEffects"
  13. #pragma link "GLS.Scene"
  14. #pragma link "GLS.SimpleNavigation"
  15. #pragma link "GLS.VectorFileObjects"
  16. #pragma link "GLS.SceneViewer"
  17. #pragma resource "*.dfm"
  18. TMainForm *MainForm;
  19. //---------------------------------------------------------------------------
  20. __fastcall TMainForm::TMainForm(TComponent* Owner)
  21. : TForm(Owner)
  22. {
  23. }
  24. //---------------------------------------------------------------------------
  25. void __fastcall TMainForm::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  26. const double newTime)
  27. {
  28. GLSceneViewer1->Invalidate();
  29. }
  30. //---------------------------------------------------------------------------
  31. void __fastcall TMainForm::FormCreate(TObject *Sender)
  32. {
  33. SetGLSceneMediaDir();
  34. GLActor1->LoadFromFile("waste.md2");
  35. GLActor1->Material->Texture->Image->LoadFromFile("waste.jpg");
  36. GLActor1->Material->Texture->Enabled = True;
  37. /// GLActor1->SwitchToAnimation(GLActor1->Animations[0]);
  38. GLActor1->AnimationMode = aamLoop;
  39. /// GLActor1->ObjectStyle = GLActor1->ObjectStyle + [osDirectDraw];
  40. GLActor1->Reference = aarMorph;
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TMainForm::ComboBox1Change(TObject *Sender)
  44. {
  45. switch (ComboBox1->ItemIndex) {
  46. case 0: GLPostEffect1->Preset = pepNone; break;
  47. case 1: GLPostEffect1->Preset = pepGray; break;
  48. case 2: GLPostEffect1->Preset = pepNegative; break;
  49. case 3: GLPostEffect1->Preset = pepDistort; break;
  50. case 4: GLPostEffect1->Preset = pepNoise; break;
  51. case 5: GLPostEffect1->Preset = pepNightVision; break;
  52. case 6: GLPostEffect1->Preset = pepBlur; break;
  53. case 7: GLPostEffect1->Preset = pepCustom; break;
  54. default:
  55. ;
  56. }
  57. }
  58. //---------------------------------------------------------------------------
  59. void __fastcall TMainForm::GLPostEffect1CustomEffect(TObject *Sender, TGLRenderContextInfo &rci,
  60. TGLPostEffectBuffer &Buffer)
  61. {
  62. int i;
  63. for (i = 0; i <= 7; i++) {
  64. Buffer[i]->r = (int)(Buffer[i + 5]->r * 2);
  65. Buffer[i]->g = Round(Buffer[i]->g * 1.5);
  66. Buffer[i]->b = Round(Buffer[i + 5]->b * 1.5);
  67. }
  68. }
  69. //---------------------------------------------------------------------------