Developer Documentation

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 #pragma once
43
44 #include <ACG/GL/GLState.hh>
45 #include <OpenFlipper/common/GlobalDefines.hh>
46 #include <QAction>
47
54 struct DLLEXPORT PostProcessorInput
55 {
56 PostProcessorInput(GLuint _colTex = 0,
57 GLuint _depthTex = 0,
58 int _width = 0,
59 int _height = 0);
60
61 // scene colors
62 GLuint colorTex_;
63
64 // non-linear depth values directly from the depth buffer
65 GLuint depthTex_;
66
67 int width, height;
68
69 // multisampling count
70 int sampleCount_;
71
72 // format of color tex
73 GLuint texfmt_;
74
75 // view and projection matrix
76 ACG::GLMatrixf view_;
77 ACG::GLMatrixf proj_;
78 float depthRange_[2];
79
80
81 // bind color texture to a given texture-slot (0, 1, 2, ..)
82 void bindColorTex(int _texSlot = 0) const;
83
84 // bind non-linear depth texture to a given texture-slot (0, 1, 2, ..)
85 void bindDepthTex(int _texSlot = 0) const;
86 };
87
88
89 struct DLLEXPORT PostProcessorOutput
90 {
91 PostProcessorOutput(GLuint _fbo = 0,
92 GLuint _drawBuffer = 0,
93 int _width = 0,
94 int _height = 0,
95 const GLint* _viewport = 0);
96
97 // opengl fbo id
98 GLuint fbo_;
99
100 // draw target of fbo: GL_BACK, GL_FRONT, GL_COLOR_ATTACHMENT0..
101 GLuint drawBuffer_;
102
103 // target viewport
104 GLint viewport_[4];
105
106 int width, height;
107
108
109 // bind fbo, drawbuffer and viewport
110 void bind() const;
111 };
112
113
114 // in/out format descriptor
115 struct PostProcessorFormatDesc
116 {
117 explicit PostProcessorFormatDesc(bool _multisampled = false) : supportMultisampling_(_multisampled),outputFormat_(PostProcessorFormat_DONTCARE)
118 {}
119
120
121 enum Format
122 {
123 PostProcessorFormat_DONTCARE, // the postprocessor works for any format type (default)
124 PostProcessorFormat_FLOAT, // expect format in fp32 or fp16 format, used by tonemapper for example
125 // PostProcessorFormat_UNORM, // expect format in normalized ubyte4 format
126 };
127
128 // expected format of each input
129 std::vector<Format> inputFormats_;
130
131 // post-processor supports multisampled input
132 bool supportMultisampling_;
133
134 // output format
135 Format outputFormat_;
136 };
137
138
147 class PostProcessorInterface {
148
149 public:
150
152 virtual ~PostProcessorInterface() {};
153
154 public slots:
155
159 virtual void postProcess(ACG::GLState* _glState, const std::vector<const PostProcessorInput*>& _input, const PostProcessorOutput& _output) = 0;
160
165 virtual QString postProcessorName() = 0;
166
167
174 virtual bool isStereoProcessor() {return false;}
175
176
177 /* \brief Provide in/out format info
178 *
179 * The postprocessor might require non-standard in/out formats,
180 * which can be described by initializing a descriptor with the in/out formats.
181 * This is entirely optional, is is assumed that the postprocessor does not care about the formats per default.
182 *
183 */
184 virtual void getFormatDesc(PostProcessorFormatDesc* _desc) {}
185
186
195 virtual QAction* optionsAction() { return 0; };
196
197 private slots:
198
230 virtual QString checkOpenGL() = 0;
231 };
232
282 Q_DECLARE_INTERFACE(PostProcessorInterface,"OpenFlipper.PostProcessorInterface/1.0")
283
PostProcessorInterface::optionsAction
virtual QAction * optionsAction()
Return options menu.
Definition: PostProcessorInterface.hh:195
ACG::GLState
Definition: GLState.hh:213
DLLEXPORT
#define DLLEXPORT
Definition: GlobalDefines.hh:95
PostProcessorInput
Definition: PostProcessorInterface.hh:54
ACG::GLMatrixT< float >
PostProcessorInterface
Interface to add global image post processor functions from within plugins.
Definition: PostProcessorInterface.hh:147
OpenMesh::Kernel_OSG::bind
bool bind(osg::GeometryPtr &_geo, Mesh &_mesh)
Definition: bindT.hh:101
PostProcessorOutput
Definition: PostProcessorInterface.hh:89
PostProcessorInterface::isStereoProcessor
virtual bool isStereoProcessor()
does post processor resolve stereo buffer
Definition: PostProcessorInterface.hh:174
PostProcessorFormatDesc
Definition: PostProcessorInterface.hh:115
GlobalDefines.hh
PostProcessorInterface::~PostProcessorInterface
virtual ~PostProcessorInterface()
Destructor.
Definition: PostProcessorInterface.hh:152