OpenWalnut
1.2.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
core
graphicsEngine
offscreen
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
*/
41
class
WGEOffscreenTexturePass
:
public
WGEOffscreenRenderPass
42
{
43
public
:
44
45
/**
46
* Creates a new offscreen rendering instance.
47
*
48
* \param textureWidth the width of all the textures created and used by this render pass. This should be large enough for every reasonable
49
* viewport size.
50
* \param textureHeight the height of all the textures created and used by this render pass. This should be large enough for every reasonable
51
* viewport size.*
52
* \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.
53
*/
54
WGEOffscreenTexturePass
(
size_t
textureWidth,
size_t
textureHeight,
int
num = 0 );
55
56
/**
57
* Creates a new offscreen rendering instance.
58
*
59
* \param textureWidth the width of all the textures created and used by this render pass. This should be large enough for every reasonable
60
* viewport size.
61
* \param textureHeight the height of all the textures created and used by this render pass. This should be large enough for every reasonable
62
* viewport size.*
63
* \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.
64
* \param hud the hud that gets notified about attached and detached textures. Useful for debugging.
65
* \param name the name of this render pass. This is a nice debugging feature in conjunction with WGETextureHud as it gets displayed there.
66
*/
67
WGEOffscreenTexturePass
(
size_t
textureWidth,
size_t
textureHeight, osg::ref_ptr< WGETextureHud > hud, std::string name,
int
num = 0 );
68
69
/**
70
* Destructor.
71
*/
72
virtual
~WGEOffscreenTexturePass
();
73
74
protected
:
75
private
:
76
77
/**
78
* Sets the whole node up. Used to get some code duplication out of the constructors.
79
*/
80
void
setup
();
81
82
/**
83
* The texture matrix for this pass. Used to scale the texture coordinates according to viewport/texture size relation.
84
*/
85
osg::ref_ptr< osg::TexMat >
m_texMat
;
86
87
/**
88
* Callback which aligns and renders the textures.
89
*/
90
class
TextureMatrixUpdateCallback
:
public
osg::NodeCallback
91
{
92
public
:
// NOLINT
93
94
/**
95
* Constructor.
96
*
97
* \param pass the pass to which this callback is applied. Needed for accessing some mebers.
98
*/
99
explicit
TextureMatrixUpdateCallback
(
WGEOffscreenTexturePass
* pass ):
m_pass
( pass )
100
{
101
};
102
103
/**
104
* operator () - called during the update traversal.
105
*
106
* \param node the osg node
107
* \param nv the node visitor
108
*/
109
virtual
void
operator()
( osg::Node* node, osg::NodeVisitor* nv );
110
111
/**
112
* The pass used in conjunction with this callback.
113
*/
114
WGEOffscreenTexturePass
*
m_pass
;
115
};
116
};
117
118
#endif // WGEOFFSCREENTEXTUREPASS_H
119
Generated by
1.8.1