fTexCombineC.cpp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "fTexCombineC.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "GLS.BaseClasses"
  8. #pragma link "GLS.Coordinates"
  9. #pragma link "GLS.HUDObjects"
  10. #pragma link "GLS.Material"
  11. #pragma link "GLS.Objects"
  12. #pragma link "GLS.Scene"
  13. #pragma link "GLS.SceneViewer"
  14. #pragma link "GLSL.TextureShaders"
  15. #pragma resource "*.dfm"
  16. TFormCombine *FormCombine;
  17. //---------------------------------------------------------------------------
  18. __fastcall TFormCombine::TFormCombine(TComponent* Owner)
  19. : TForm(Owner)
  20. {
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TFormCombine::FormCreate(TObject *Sender)
  24. {
  25. // load the textures
  26. PathToData = GetCurrentAssetPath();
  27. SetCurrentDir(PathToData + "\\texture");
  28. Image1->Picture->LoadFromFile("beigemarble.jpg");
  29. GLMaterialLibrary->Materials->Items[0]->Material->Texture->Image->Assign(Image1->Picture);
  30. Image2->Picture->LoadFromFile("flare1.bmp");
  31. GLMaterialLibrary->Materials->Items[1]->Material->Texture->Image->Assign(Image2->Picture);
  32. Image3->Picture->LoadFromFile("clover.jpg");
  33. GLMaterialLibrary->Materials->Items[2]->Material->Texture->Image->Assign(Image3->Picture);
  34. Image4->Picture->LoadFromFile("concrete.jpg");
  35. GLMaterialLibrary->Materials->Items[3]->Material->Texture->Image->Assign(Image4->Picture);
  36. BUApplyClick(Sender);
  37. Application->HintHidePause = 30000;
  38. }
  39. //---------------------------------------------------------------------------
  40. void __fastcall TFormCombine::BUApplyClick(TObject *Sender)
  41. {
  42. // Apply new combiner code
  43. // Depending on shader and hardware, errors may be triggered during render
  44. GLTexCombineShader->Combiners->Clear();
  45. GLTexCombineShader->Combiners->AddStrings(MECombiner->Lines);
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TFormCombine::SceneViewerPostRender(TObject *Sender)
  49. {
  50. // disable whatever texture units are not supported by the local hardware
  51. int n = SceneViewer->Buffer->LimitOf[limNbTextureUnits];
  52. PATex1->Visible = (n < 2);
  53. CBTex1->Enabled = (n >= 2);
  54. PATex2->Visible = (n < 3);
  55. CBTex2->Enabled = (n >= 3);
  56. PATex3->Visible = (n < 4);
  57. CBTex3->Enabled = (n >= 4);
  58. CBTex1->Checked = (CBTex1->Checked && CBTex1->Enabled);
  59. }
  60. //---------------------------------------------------------------------------
  61. void __fastcall TFormCombine::Shape1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
  62. int X, int Y)
  63. {
  64. // Allow choosing the primary color
  65. ColorDialog->Color = Shape1->Brush->Color; // PAPrimary->Color;
  66. if (ColorDialog->Execute())
  67. {
  68. Shape1->Brush->Color = ColorDialog->Color;
  69. GLMaterialLibrary->Materials->Items[0]->Material->FrontProperties->Diffuse->AsWinColor = ColorDialog->Color;
  70. SceneViewer->Invalidate();
  71. }
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TFormCombine::CBTex0Click(TObject *Sender)
  75. {
  76. TGLLibMaterial* libMat;
  77. libMat = new TGLLibMaterial(GLMaterialLibrary->Materials);
  78. // This event is used for all 4 checkboxes of the 4 texture units
  79. /// libMat = GLMaterialLibrary->Materials->GetLibMaterialByName((Sender as TCheckBox)->Caption);
  80. /// if Assigned(libMat)
  81. /// libMat->Material->Texture->Enabled = CBTex0(Sender)->Checked;
  82. }
  83. //---------------------------------------------------------------------------