~ubuntu-branches/ubuntu/vivid/openwalnut/vivid-proposed

« back to all changes in this revision

Viewing changes to src/core/graphicsEngine/offscreen/WGEOffscreenRenderNode.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2014-03-19 17:46:12 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140319174612-e4mgtr1avbq3f7ph
Tags: 1.4.0~rc1+hg3a3147463ee2-1
* Major functionality and stability improvements.
* Several bug fixes
* Changed ttf-liberation dependency to fonts-liberation (Closes: #722405)
* OpenWalnut now works properly with OpenSceneGraph 3.2 (Closes: #718381)
* See http://www.openwalnut.org/versions/2

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <osg/Geode>
28
28
 
29
29
#include "../../common/WAssert.h"
 
30
#include "../WGEUtils.h"
30
31
 
31
32
#include "WGEOffscreenRenderNode.h"
32
33
 
37
38
 
38
39
bool checkTextureSize( size_t size )
39
40
{
40
 
    return !( ( size > 4096 ) || ( size < 8 ) || !isPowerOfTwo( size ) );
 
41
    return !( ( size > 8192 ) || ( size < 8 ) );
41
42
}
42
43
 
43
 
WGEOffscreenRenderNode::WGEOffscreenRenderNode( osg::ref_ptr< osg::Camera > reference, size_t width, size_t height, bool noHud ):
 
44
WGEOffscreenRenderNode::WGEOffscreenRenderNode( osg::ref_ptr< WGECamera > reference, size_t width, size_t height, bool noHud ):
44
45
    WGEGroupNode(),
45
46
    m_referenceCamera( reference ),
46
47
    m_hud(),
47
48
    m_textureWidth( width ),
48
49
    m_textureHeight( height ),
49
 
    m_nextPassNum( 0 )
 
50
    m_nextPassNum( 0 ),
 
51
    m_forceViewportTextureSize( false )
50
52
{
51
53
    WAssert( checkTextureSize( width ) && checkTextureSize( height ), "Invalid offscreen texture size. Must be power of two and in [8,4096]." );
52
54
 
70
72
    // create a plain render pass and add some geometry
71
73
    osg::ref_ptr< WGEOffscreenRenderPass > pass = addRenderPass< WGEOffscreenRenderPass >( name );
72
74
    pass->addChild( node );
 
75
 
 
76
    // add proxy to ensure proper clipping/culling even when the node changes its size in the shader. The programmer of the node has to take
 
77
    // care, that the getBounds methods of the node returns the right size (use a ComputeBoundingSpereCallback or overwrite computeBounds in
 
78
    // your node)
 
79
    //
 
80
    // It is important to add this proxy into the goup as the passes disable near/far recalculation. They inherit the near/far planes from the
 
81
    // camera of this group node. To ensure that OSG sets it properly, we use these proxies.
 
82
    insert( wge::generateDynamicCullProxy( node ) );
 
83
 
73
84
    return pass;
74
85
}
75
86
 
81
92
    osg::ref_ptr< WGEOffscreenRenderPass > pass = addRenderPass< WGEOffscreenRenderPass >( name );
82
93
    pass->addChild( node );
83
94
    shader->apply( pass );
 
95
 
 
96
    // add proxy to ensure proper clipping/culling even when the node changes its size in the shader. The programmer of the node has to take
 
97
    // care, that the getBounds methods of the node returns the right size (use a ComputeBoundingSpereCallback or overwrite computeBounds in
 
98
    // your node)
 
99
    //
 
100
    // It is important to add this proxy into the goup as the passes disable near/far recalculation. They inherit the near/far planes from the
 
101
    // camera of this group node. To ensure that OSG sets it properly, we use these proxies.    insert( wge::generateDynamicCullProxy( node ) );
 
102
 
84
103
    return pass;
85
104
}
86
105
 
115
134
    return m_hud;
116
135
}
117
136
 
 
137
size_t WGEOffscreenRenderNode::getTextureWidth() const
 
138
{
 
139
    return m_textureWidth;
 
140
}
 
141
 
 
142
size_t WGEOffscreenRenderNode::getTextureHeight() const
 
143
{
 
144
    return m_textureHeight;
 
145
}
 
146
 
 
147
void WGEOffscreenRenderNode::setLinkViewportToTextureSize( bool vp )
 
148
{
 
149
    m_forceViewportTextureSize = vp;
 
150
}
 
151
 
 
152
bool WGEOffscreenRenderNode::getLinkViewportToTextureSize() const
 
153
{
 
154
    return m_forceViewportTextureSize;
 
155
}
 
156