GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Filter.hpp
Go to the documentation of this file.
1 /* ************************************************************************************************************* */
2 /* */
3 /* GLIP-LIB */
4 /* OpenGL Image Processing LIBrary */
5 /* */
6 /* Author : R. Kerviche */
7 /* LICENSE : MIT License */
8 /* Website : glip-lib.net */
9 /* */
10 /* File : Filter.hpp */
11 /* Original Date : August 15th 2011 */
12 /* */
13 /* Description : Filter object */
14 /* */
15 /* ************************************************************************************************************* */
16 
24 #ifndef __GLIPLIB_FILTER__
25 #define __GLIPLIB_FILTER__
26 
27  // Includes
28  #include <map>
29  #include "devDebugTools.hpp"
30  #include "Core/LibTools.hpp"
31  #include "Core/Component.hpp"
32  #include "Core/HdlTexture.hpp"
33 
34  namespace Glip
35  {
36  namespace CoreGL
37  {
38  // Prototypes
39  class ShaderSource;
40  class HdlShader;
41  class HdlProgram;
42  class HdlVBO;
43  class HdlFBO;
44  }
45 
46  namespace CorePipeline
47  {
48  // Prototypes
49  class Pipeline;
50  class FilterLayout;
51  class GeometryModel;
52  class GeometryInstance;
53 
54  // Objects
59  class GLIP_API AbstractFilterLayout : virtual public AbstractComponentLayout, virtual public HdlAbstractTextureFormat
60  {
61  private :
62  // Data
64  GeometryModel *geometryModel;
65  bool clearing,
66  blending,
67  depthTesting,
68  isStandardGeometry;
69  GLenum sFactor,
70  dFactor,
71  blendingEquation,
72  depthTestingFunction;
73 
74  // Friends
75  friend class FilterLayout;
76 
77  protected :
78  // Tools
79  AbstractFilterLayout(const std::string& type, const HdlAbstractTextureFormat& f);
80 
81  public :
82  // Tools
84  virtual ~AbstractFilterLayout(void);
85  const ShaderSource* getShaderSource(GLenum shaderType) const;
86  GeometryModel& getGeometryModel(void) const;
87 
88  bool isStandardVertexSource(void) const;
89  bool isStandardGeometryModel(void) const;
90  int getNumUniformVars(void) const;
91  bool isClearingEnabled(void) const;
92  void enableClearing(void);
93  void disableClearing(void);
94  bool isBlendingEnabled(void) const;
95  const GLenum& getSFactor(void) const;
96  const GLenum& getDFactor(void) const;
97  const GLenum& getBlendingEquation(void) const;
98  void enableBlending(const GLenum& _sFactor = GL_ONE, const GLenum& _dFactor = GL_ONE, const GLenum& _blendingEquation = GL_FUNC_ADD);
99  void disableBlending(void);
100  bool isDepthTestingEnabled(void) const;
101  const GLenum& getDepthTestingFunction(void) const;
102  void enableDepthTesting(const GLenum& _depthTestingFunction = GL_LESS);
103  void disableDepthTesting(void);
104  };
105 
110  class GLIP_API FilterLayout : virtual public ComponentLayout, virtual public AbstractFilterLayout
111  {
112  private :
113  void scanPorts(void);
114  public :
115  // Tools
116  FilterLayout(const std::string& type, const HdlAbstractTextureFormat& fout, const ShaderSource& fragmentSource, GeometryModel* geometry = NULL);
117  FilterLayout(const std::string& type, const HdlAbstractTextureFormat& fout, const std::map<GLenum, ShaderSource*>& sources, GeometryModel* geometry = NULL);
118  };
119 
124  class GLIP_API Filter : virtual public Component, virtual public AbstractFilterLayout
125  {
126  private :
127  // Data
129  HdlProgram *prgm;
130  GeometryInstance *geometry;
131  bool firstRun,
132  broken;
133  std::vector<HdlTexture*> arguments;
134 
135  protected :
136  // Tools
137  Filter(const AbstractFilterLayout&, const std::string& name);
138 
139  void setInputForNextRendering(int id, HdlTexture* ptr);
140  void process(HdlFBO& renderer);
141 
142  // Friends
143  friend class Pipeline;
144 
145  public :
146  // Tools
147  virtual ~Filter(void);
148 
149  HdlProgram& program(void);
150  bool wentThroughFirstRun(void) const;
151  bool isBroken(void) const;
152  };
153  }
154  }
155 
156 #endif
Layout of a component template.
Definition: Component.hpp:89
Specific defines for the API structure.
Object handle for OpenGL Shaders Objects (both vertex and fragment shaders).
Definition: HdlShader.hpp:44
Instance of the GeometryModel. Stored on GPU (VBO).
Definition: Geometry.hpp:158
Filter layout (Read Only).
Definition: Filter.hpp:59
OpenGL Texture Handle.
Object handle for OpenGL textures.
Definition: HdlTexture.hpp:138
Definition: Component.hpp:32
Filter layout.
Definition: Filter.hpp:110
Components of pipelines.
static const unsigned int numShaderTypes
Number of different shader types.
Definition: OglInclude.hpp:95
Element of a pipeline.
Definition: Component.hpp:110
Shader source code and infos.
Definition: ShaderSource.hpp:55
Development and debugging tools.
Geometry stored on the host.
Definition: Geometry.hpp:50
Pipeline object.
Definition: Pipeline.hpp:261
Filter object.
Definition: Filter.hpp:124
Object handle for OpenGL Program (A vertex and a fragment program).
Definition: HdlShader.hpp:65
Layout of a component template (Read Only)
Definition: Component.hpp:51
Object handle for OpenGL Frame Buffer Objects.
Definition: HdlFBO.hpp:76
Object handle for OpenGL texture formats (Read Only).
Definition: HdlTexture.hpp:42