Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PostProcessorInterface.hh
Go to the documentation of this file.
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 #ifndef POSTPROCESSORINTERFACE_HH
52 #define POSTPROCESSORINTERFACE_HH
53 
54 #include <ACG/GL/GLState.hh>
56 #include <QAction>
57 
65 {
66  PostProcessorInput(GLuint _colTex = 0,
67  GLuint _depthTex = 0,
68  int _width = 0,
69  int _height = 0);
70 
71  // scene colors
72  GLuint colorTex_;
73 
74  // non-linear depth values directly from the depth buffer
75  GLuint depthTex_;
76 
77  int width, height;
78 
79  // multisampling count
80  int sampleCount_;
81 
82  // format of color tex
83  GLuint texfmt_;
84 
85  // view and projection matrix
86  ACG::GLMatrixf view_;
87  ACG::GLMatrixf proj_;
88  float depthRange_[2];
89 
90 
91  // bind color texture to a given texture-slot (0, 1, 2, ..)
92  void bindColorTex(int _texSlot = 0) const;
93 
94  // bind non-linear depth texture to a given texture-slot (0, 1, 2, ..)
95  void bindDepthTex(int _texSlot = 0) const;
96 };
97 
98 
100 {
101  PostProcessorOutput(GLuint _fbo = 0,
102  GLuint _drawBuffer = 0,
103  int _width = 0,
104  int _height = 0,
105  const GLint* _viewport = 0);
106 
107  // opengl fbo id
108  GLuint fbo_;
109 
110  // draw target of fbo: GL_BACK, GL_FRONT, GL_COLOR_ATTACHMENT0..
111  GLuint drawBuffer_;
112 
113  // target viewport
114  GLint viewport_[4];
115 
116  int width, height;
117 
118 
119  // bind fbo, drawbuffer and viewport
120  void bind() const;
121 };
122 
123 
124 // in/out format descriptor
126 {
127  PostProcessorFormatDesc(bool _multisampled = false) : supportMultisampling_(_multisampled),outputFormat_(PostProcessorFormat_DONTCARE)
128  {}
129 
130 
131  enum Format
132  {
133  PostProcessorFormat_DONTCARE, // the postprocessor works for any format type (default)
134  PostProcessorFormat_FLOAT, // expect format in fp32 or fp16 format, used by tonemapper for example
135 // PostProcessorFormat_UNORM, // expect format in normalized ubyte4 format
136  };
137 
138  // expected format of each input
139  std::vector<Format> inputFormats_;
140 
141  // post-processor supports multisampled input
142  bool supportMultisampling_;
143 
144  // output format
145  Format outputFormat_;
146 };
147 
148 
158 
159  public:
160 
163 
164  public slots:
165 
169  virtual void postProcess(ACG::GLState* _glState, const std::vector<const PostProcessorInput*>& _input, const PostProcessorOutput& _output) = 0;
170 
175  virtual QString postProcessorName() = 0;
176 
177 
184  virtual bool isStereoProcessor() {return false;}
185 
186 
187  /* \brief Provide in/out format info
188  *
189  * The postprocessor might require non-standard in/out formats,
190  * which can be described by initializing a descriptor with the in/out formats.
191  * This is entirely optional, is is assumed that the postprocessor does not care about the formats per default.
192  *
193  */
194  virtual void getFormatDesc(PostProcessorFormatDesc* _desc) {}
195 
196 
205  virtual QAction* optionsAction() { return 0; };
206 
207  private slots:
208 
240  virtual QString checkOpenGL() = 0;
241 };
242 
292 Q_DECLARE_INTERFACE(PostProcessorInterface,"OpenFlipper.PostProcessorInterface/1.0")
293 
294 #endif // RPCINTERFACE_HH
virtual QAction * optionsAction()
Return options menu.
virtual void postProcess(ACG::GLState *_glState, const std::vector< const PostProcessorInput * > &_input, const PostProcessorOutput &_output)=0
post processor function
virtual QString postProcessorName()=0
announce name for the postProcessor function
virtual bool isStereoProcessor()
does post processor resolve stereo buffer
#define DLLEXPORT
Interface to add global image post processor functions from within plugins.
virtual QString checkOpenGL()=0
Check OpenGL capabilities.
bool bind(osg::GeometryPtr &_geo, Mesh &_mesh)
Definition: bindT.hh:106
virtual ~PostProcessorInterface()
Destructor.