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