fMultiTexturesC.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "fMultiTexturesC.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLS.BaseClasses"
  9. #pragma link "GLS.BitmapFont"
  10. #pragma link "GLS.Cadencer"
  11. #pragma link "GLS.Coordinates"
  12. #pragma link "GLSL.CustomShader"
  13. #pragma link "GLS.FBORenderer"
  14. #pragma link "GLS.GeomObjects"
  15. #pragma link "GLS.HUDObjects"
  16. #pragma link "GLS.Material"
  17. #pragma link "GLS.Objects"
  18. #pragma link "GLS.Scene"
  19. #pragma link "GLS.SimpleNavigation"
  20. #pragma link "GLSL.Shader"
  21. #pragma link "GLS.SceneViewer"
  22. #pragma link "GLS.WindowsFont"
  23. #pragma link "GLS.MultiSampleImage"
  24. #pragma resource "*.dfm"
  25. TForm1 *Form1;
  26. //---------------------------------------------------------------------------
  27. __fastcall TForm1::TForm1(TComponent* Owner)
  28. : TForm(Owner)
  29. {
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TForm1::FormCreate(TObject *Sender)
  33. {
  34. // Width = Screen->Width;
  35. // Height = Screen->Height;
  36. MainMaterialLibrary->TextureByName("MultisampledColor")->ImageClassName = "TGLMultisampleImage";
  37. ((TGLMultisampleImage *)(MainMaterialLibrary->TextureByName("MultisampledColor")->Image))->SamplesCount = 16;
  38. MainMaterialLibrary->TextureByName("Depth")->ImageClassName = "TGLMultisampleImage";
  39. ((TGLMultisampleImage *)(MainMaterialLibrary->TextureByName("Depth")->Image))->SamplesCount = 16;
  40. GLSLShader1->Enabled = true;
  41. GLHUDText1->Text = "F1/F2 - Multisampling and F3/F4 - Wireframe mode";
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TForm1::MainCadencerProgress(TObject *Sender, const double deltaTime,
  45. const double newTime)
  46. {
  47. if (IsKeyDown(VK_F2))
  48. {
  49. FBOContainer->Visible = false;
  50. GLScreenQuad->Visible = false;
  51. SceneObjects->Visible = true;
  52. }
  53. if (IsKeyDown(VK_F1))
  54. {
  55. FBOContainer->Visible = true;
  56. GLScreenQuad->Visible = true;
  57. SceneObjects->Visible = false;
  58. }
  59. if (IsKeyDown(VK_F3))
  60. {
  61. GLTorus1->Material->PolygonMode = pmLines;
  62. GLTorus2->Material->PolygonMode = pmLines;
  63. GLCone1->Material->PolygonMode = pmLines;
  64. }
  65. if (IsKeyDown(VK_F4))
  66. {
  67. GLTorus1->Material->PolygonMode = pmFill;
  68. GLTorus2->Material->PolygonMode = pmFill;
  69. GLCone1->Material->PolygonMode = pmFill;
  70. }
  71. MainViewer->Invalidate();
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TForm1::FormResize(TObject *Sender)
  75. {
  76. MultisampleFBO->Width = MainViewer->Width;
  77. MultisampleFBO->Height = MainViewer->Height;
  78. GLScreenQuad->Width = MainViewer->Width;
  79. GLScreenQuad->Height = MainViewer->Height;
  80. GLScreenQuad->Position->SetPoint(
  81. MainViewer->Width / 2,
  82. MainViewer->Height / 2, 0);
  83. }
  84. //---------------------------------------------------------------------------
  85. void __fastcall TForm1::GLSLShader1Apply(TGLCustomGLSLShader *Shader)
  86. {
  87. Shader->Param["TexUnit0"]->AsTexture[0] =
  88. MainMaterialLibrary->TextureByName("MultisampledColor");
  89. Shader->Param["ViewerSize"]->AsVector2f =
  90. Vector2fMake(MainViewer->Width, MainViewer->Height);
  91. }
  92. //---------------------------------------------------------------------------
  93. void __fastcall TForm1::MainViewerBeforeRender(TObject *Sender)
  94. {
  95. /*
  96. if (GL_EXT_framebuffer_multisample)
  97. {
  98. ShowMessage("Sorry, your hardware do not support Multisampling");
  99. Close();
  100. }
  101. */
  102. }
  103. //---------------------------------------------------------------------------