28 #include <osg/ShapeDrawable>
32 #include <osgGA/FlightManipulator>
33 #include <osgGA/DriveManipulator>
34 #include <osgGA/UFOManipulator>
35 #include <osgGA/KeySwitchMatrixManipulator>
36 #include <osgGA/StateSetManipulator>
37 #include <osgGA/AnimationPathManipulator>
38 #include <osgGA/TerrainManipulator>
39 #include <osgViewer/ViewerEventHandlers>
40 #include <osgViewer/View>
42 #include <osgDB/ReadFile>
44 #include "exceptions/WGEInitFailed.h"
45 #include "WGE2DManipulator.h"
46 #include "WGEGroupNode.h"
47 #include "WGENoOpManipulator.h"
48 #include "WGEZoomTrackballManipulator.h"
49 #include "WPickHandler.h"
50 #include "../common/WConditionOneShot.h"
52 #include "../common/WThreadedRunner.h"
54 #include "WGEViewer.h"
63 m_inAnimationMode( false )
67 #ifdef WGEMODE_MULTITHREADED
68 m_View = osg::ref_ptr<osgViewer::View>(
new osgViewer::View );
71 m_View = osg::ref_ptr<osgViewer::Viewer>(
new osgViewer::Viewer );
74 m_View->setCamera(
new WGECamera( width, height, projectionMode ) );
79 #ifdef WGEMODE_MULTITHREADED
80 m_View->getCamera()->setGraphicsContext( m_GraphicsContext.get() );
85 switch( projectionMode )
87 case( WGECamera::ORTHOGRAPHIC ):
90 if( name != std::string(
"Main View" ) )
92 case( WGECamera::PERSPECTIVE ):
96 m_View->setLightingMode( osg::View::HEADLIGHT );
99 case( WGECamera::TWO_D ):
102 case( WGECamera::TWO_D_UNIT ):
107 throw WGEInitFailed( std::string(
"Unknown projection mode" ) );
111 m_View->addEventHandler(
new osgViewer::StatsHandler );
115 throw WGEInitFailed( std::string(
"Initialization of WGEViewer failed" ) );
125 #ifdef WGEMODE_SINGLETHREADED
126 osg::ref_ptr<osgViewer::Viewer>
128 osg::ref_ptr<osgViewer::View>
139 m_View->setCameraManipulator( manipulator );
145 return m_View->getCameraManipulator();
150 m_View->setCamera( camera );
156 return m_View->getCamera();
161 m_View->setSceneData( node );
172 m_View->getCamera()->setClearColor( bgColor );
177 #ifdef WGEMODE_SINGLETHREADED
184 m_View->getEventQueue()->windowResize( 0, 0, width, height );
189 m_View->getCamera()->setViewport( 0, 0, width, height );
248 const GLubyte* vendor = glGetString( GL_VENDOR );
249 m_vendor =
reinterpret_cast< const char*
>( vendor );
252 m_camera->setInitialDrawCallback( NULL );
280 m_View->setCameraManipulator( anim );