OpenWalnut  1.5.0dev
WGEOffscreenTexturePass.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGEOFFSCREENTEXTUREPASS_H
26 #define WGEOFFSCREENTEXTUREPASS_H
27 
28 #include <string>
29 
30 #include <osg/Geode>
31 #include <osg/TexMat>
32 
33 #include "WGEOffscreenRenderPass.h"
34 
35 class WGETextureHud;
36 
37 /**
38  * This class encapsulates an OSG Camera and a corresponding framebuffer object. It is a specialized variant of \ref WGEOffscreenRenderPass,
39  * optimized for processing textures. Therefore, it creates an correctly sized quad and can process each pixel in the fragment shader.
40  */
42 {
43 public:
44  /**
45  * Creates a new offscreen rendering instance.
46  *
47  * \param textureWidth the width of all the textures created and used by this render pass. This should be large enough for every reasonable
48  * viewport size.
49  * \param textureHeight the height of all the textures created and used by this render pass. This should be large enough for every reasonable
50  * viewport size.*
51  * \param num the order number. This camera gets rendered at the num'th place in the pre render queue of the subgraph it is attached to.
52  */
53  WGEOffscreenTexturePass( size_t textureWidth, size_t textureHeight, int num = 0 );
54 
55  /**
56  * Creates a new offscreen rendering instance.
57  *
58  * \param textureWidth the width of all the textures created and used by this render pass. This should be large enough for every reasonable
59  * viewport size.
60  * \param textureHeight the height of all the textures created and used by this render pass. This should be large enough for every reasonable
61  * viewport size.*
62  * \param num the order number. This camera gets rendered at the num'th place in the pre render queue of the subgraph it is attached to.
63  * \param hud the hud that gets notified about attached and detached textures. Useful for debugging.
64  * \param name the name of this render pass. This is a nice debugging feature in conjunction with WGETextureHud as it gets displayed there.
65  */
66  WGEOffscreenTexturePass( size_t textureWidth, size_t textureHeight, osg::ref_ptr< WGETextureHud > hud, std::string name, int num = 0 );
67 
68  /**
69  * Destructor.
70  */
71  virtual ~WGEOffscreenTexturePass();
72 
73 protected:
74 private:
75  /**
76  * Sets the whole node up. Used to get some code duplication out of the constructors.
77  */
78  void setup();
79 
80  /**
81  * The texture matrix for this pass. Used to scale the texture coordinates according to viewport/texture size relation.
82  */
83  osg::ref_ptr< osg::TexMat > m_texMat;
84 
85  /**
86  * Callback which aligns and renders the textures.
87  */
88  class TextureMatrixUpdateCallback : public osg::NodeCallback
89  {
90  public: // NOLINT
91  /**
92  * Constructor.
93  *
94  * \param pass the pass to which this callback is applied. Needed for accessing some mebers.
95  */
97  {
98  };
99 
100  /**
101  * operator () - called during the update traversal.
102  *
103  * \param node the osg node
104  * \param nv the node visitor
105  */
106  virtual void operator()( osg::Node* node, osg::NodeVisitor* nv );
107 
108  /**
109  * The pass used in conjunction with this callback.
110  */
112  };
113 };
114 
115 #endif // WGEOFFSCREENTEXTUREPASS_H
116 
This class encapsulates an OSG Camera and a corresponding framebuffer object.
Callback which aligns and renders the textures.
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
operator () - called during the update traversal.
TextureMatrixUpdateCallback(WGEOffscreenTexturePass *pass)
Constructor.
WGEOffscreenTexturePass * m_pass
The pass used in conjunction with this callback.
This class encapsulates an OSG Camera and a corresponding framebuffer object.
osg::ref_ptr< osg::TexMat > m_texMat
The texture matrix for this pass.
virtual ~WGEOffscreenTexturePass()
Destructor.
void setup()
Sets the whole node up.
WGEOffscreenTexturePass(size_t textureWidth, size_t textureHeight, int num=0)
Creates a new offscreen rendering instance.
This class implements a HUD showing several textures on screen.
Definition: WGETextureHud.h:47