ccGlFilter.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CCFBO #
  5. //# #
  6. //# This program is free software; you can redistribute it and/or modify #
  7. //# it under the terms of the GNU Library General Public License as #
  8. //# published by the Free Software Foundation; version 2 or later of the License. #
  9. //# #
  10. //# This program is distributed in the hope that it will be useful, #
  11. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. //# GNU General Public License for more details. #
  14. //# #
  15. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  16. //# #
  17. //##########################################################################
  18. #include "CCFbo.h"
  19. //Qt
  20. #include <QString>
  21. //! Default GL filter interface
  22. /** A GL filter is a combination of shaders applied to
  23. textures (typically the rendered scene), typically
  24. through intensive use of Frame Buffer Objects.
  25. **/
  26. class CCFBO_LIB_API ccGlFilter
  27. {
  28. public:
  29. //! Default constructor
  30. ccGlFilter(QString description)
  31. : m_isValid(false)
  32. , m_description(description)
  33. {}
  34. //! Default destructor
  35. virtual ~ccGlFilter() {}
  36. //! Returns filter name
  37. inline virtual QString getDescription() const { return m_description; }
  38. //! Cloning mechanism
  39. virtual ccGlFilter* clone() const = 0;
  40. //! Initializes GL filter
  41. /** Must support reinit!
  42. \param width texture/screen width
  43. \param height texture/screen height
  44. \param shadersPath path where shader files are stored
  45. \param error error string (if an error occurred)
  46. \return success
  47. **/
  48. virtual bool init( unsigned width,
  49. unsigned height,
  50. const QString& shadersPath,
  51. QString& error) = 0;
  52. //! Minimal set of 3D viewport parameters that can be used by shaders
  53. struct CCFBO_LIB_API ViewportParameters
  54. {
  55. //! Default constructor
  56. ViewportParameters()
  57. : perspectiveMode(false)
  58. , zNear(0.0)
  59. , zFar(1.0)
  60. , zoomFactor(1.0)
  61. {}
  62. //! Whether perspective mode is enabled or not
  63. bool perspectiveMode;
  64. //! Near clipping plane position
  65. double zNear;
  66. //! Far clipping plane position
  67. double zFar;
  68. //! Rendering zoom factor
  69. float zoomFactor;
  70. };
  71. //! Applies filter to texture (depth + color)
  72. virtual void shade( unsigned texDepth,
  73. unsigned texColor,
  74. ViewportParameters& parameters) = 0;
  75. //! Returns resulting texture
  76. virtual unsigned getTexture() = 0;
  77. protected: //methods
  78. //! Sets whether the filter is valid
  79. inline void setValid(bool state) { m_isValid = state; }
  80. //! Returns whether the filter is valid
  81. inline bool isValid() const { return m_isValid; }
  82. protected:
  83. //! Filter validity
  84. bool m_isValid;
  85. //! Filter description
  86. QString m_description;
  87. };