-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsceneView.cpp
102 lines (77 loc) · 2.81 KB
/
sceneView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "sceneView.h"
#include <osg/ContextData>
using namespace osg;
using namespace osgUtil;
namespace eqEarth
{
// ----------------------------------------------------------------------------
void SceneView::draw( )
{
if( _camera->getNodeMask( ) == 0 )
return;
osg::State* state = _renderInfo.getState( );
// we in theory should be able to be able to bypass reset, but we'll call it just incase.
//_state->reset();
state->setFrameStamp(_frameStamp.get());
if (_displaySettings.valid())
{
state->setDisplaySettings(_displaySettings.get());
}
state->initializeExtensionProcs();
osg::get<ContextData>(state->getContextID())->newFrame(state->getFrameStamp());
if( !_initCalled )
init( );
// note, to support multi-pipe systems the deletion of OpenGL display list
// and texture objects is deferred until the OpenGL context is the correct
// context for when the object were originally created. Here we know what
// context we are in so can flush the appropriate caches.
if( _requiresFlush )
{
double availableTime = 0.005;
flushDeletedGLObjects( availableTime );
}
// assume the the draw which is about to happen could generate GL objects
// that need flushing in the next frame.
_requiresFlush = _automaticFlush;
RenderLeaf* previous = NULL;
if( 0 == ( _camera->getInheritanceMask() & DRAW_BUFFER ))
{
_renderStage->setDrawBuffer( _camera->getDrawBuffer( ));
_renderStage->setReadBuffer( _camera->getDrawBuffer( ));
}
if( 0 == ( _camera->getInheritanceMask() & READ_BUFFER ))
{
_renderStage->setReadBuffer( _camera->getReadBuffer( ));
}
_localStateSet->setAttribute( getViewport( ));
_localStateSet->setAttribute( _camera->getColorMask( ));
_renderStage->setColorMask( _camera->getColorMask( ));
// bog standard draw.
_renderStage->drawPreRenderStages( _renderInfo, previous );
_renderStage->draw( _renderInfo, previous );
// re apply the defalt OGL state.
state->popAllStateSets( );
state->apply( );
#if 0
if( _camera->getPostDrawCallback( ))
{
(*( _camera->getPostDrawCallback( )))( *_camera );
}
#endif
if ( state->getCheckForGLErrors( ) != State::NEVER_CHECK_GL_ERRORS )
{
if( state->checkGLErrors( "end of SceneView::draw( )" ))
{
// go into debug mode of OGL error in a fine grained way to help
// track down OpenGL errors.
state->setCheckForGLErrors( State::ONCE_PER_ATTRIBUTE );
}
}
// #define REPORT_TEXTURE_MANAGER_STATS
#ifdef REPORT_TEXTURE_MANAGER_STATS
tom->reportStats( );
bom->reportStats( );
#endif
// osg::notify(osg::NOTICE)<<"SceneView draw() DynamicObjectCount"<<getState()->getDynamicObjectCount()<<std::endl;
}
}