postEffectVis.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _POSTEFFECTVIS_H_
  23. #define _POSTEFFECTVIS_H_
  24. #ifndef _TSINGLETON_H_
  25. #include "core/util/tSingleton.h"
  26. #endif
  27. #ifndef _POST_EFFECT_H_
  28. #include "postFx/postEffect.h"
  29. #endif
  30. class GuiWindowCtrl;
  31. class GuiBitmapCtrl;
  32. class GuiControl;
  33. class PostEffectVis
  34. {
  35. // Protected constructor.
  36. // Use PFXVIS define to access singleton.
  37. PostEffectVis();
  38. friend class ManagedSingleton<PostEffectVis>;
  39. public:
  40. ~PostEffectVis();
  41. /// Open visualization windows for all input and target textures.
  42. void open( PostEffect *pfx );
  43. /// Close all visualization windows.
  44. void clear();
  45. /// Hide or show all visualization windows.
  46. void setVisible( bool visible );
  47. /// Callback from PostEffectManager at the start of a frame.
  48. void onStartOfFrame();
  49. /// Callback from PostEffect to update visualization.
  50. void onPFXProcessed( PostEffect *pfx );
  51. /// Callback when a visualization window is closed.
  52. void onWindowClosed( GuiWindowCtrl *ctrl );
  53. protected:
  54. /// Get or create the content control, the parent of all visualization windows.
  55. GuiControl* _getContentControl();
  56. protected:
  57. enum TexIndex
  58. {
  59. Target = 0,
  60. Input1,
  61. Input2,
  62. Input3,
  63. Input4,
  64. TexCount
  65. };
  66. /// Structure representing a single 'opened' PostEffect
  67. /// including GuiControls for displaying any input/target textures.
  68. struct VisWindow
  69. {
  70. PostEffect *pfx;
  71. GuiWindowCtrl *window[TexCount];
  72. GuiBitmapCtrl *bmp[TexCount];
  73. };
  74. void _setDefaultCaption( VisWindow &vis, U32 texIndex );
  75. typedef Vector< VisWindow > VisVector;
  76. VisVector mWindows;
  77. GuiControl *mContent;
  78. public:
  79. // For ManagedSingleton.
  80. static const char* getSingletonName() { return "PostEffectVis"; }
  81. };
  82. class PfxVis
  83. {
  84. DECLARE_STATIC_CLASS(PfxVis)
  85. };
  86. /// Returns the PostEffectVis singleton.
  87. #define PFXVIS ManagedSingleton<PostEffectVis>::instance()
  88. #endif // _POSTEFFECTVIS_H_