Remove indirection on viewer draw/resize code-paths.
This commit is contained in:
parent
7dd8f00c42
commit
227b3e469c
7 changed files with 5 additions and 54 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "CameraGroup.hxx"
|
||||
#include "FGEventHandler.hxx"
|
||||
#include "WindowSystemAdapter.hxx"
|
||||
#include "renderer.hxx"
|
||||
|
||||
#if !defined(X_DISPLAY_MISSING)
|
||||
#define X_DOUBLE_SCROLL_BUG 1
|
||||
|
@ -29,8 +30,6 @@ const int printStatsKey = 2;
|
|||
|
||||
FGEventHandler::FGEventHandler() :
|
||||
idleHandler(0),
|
||||
drawHandler(0),
|
||||
windowResizeHandler(0),
|
||||
keyHandler(0),
|
||||
mouseClickHandler(0),
|
||||
mouseMotionHandler(0),
|
||||
|
@ -233,8 +232,8 @@ bool FGEventHandler::handle(const osgGA::GUIEventAdapter& ea,
|
|||
return true;
|
||||
case osgGA::GUIEventAdapter::RESIZE:
|
||||
CameraGroup::getDefault()->resized();
|
||||
if (resizable && windowResizeHandler)
|
||||
(*windowResizeHandler)(ea.getWindowWidth(), ea.getWindowHeight());
|
||||
if (resizable)
|
||||
globals->get_renderer()->resize(ea.getWindowWidth(), ea.getWindowHeight());
|
||||
return true;
|
||||
case osgGA::GUIEventAdapter::CLOSE_WINDOW:
|
||||
case osgGA::GUIEventAdapter::QUIT_APPLICATION:
|
||||
|
|
|
@ -34,26 +34,6 @@ public:
|
|||
return idleHandler;
|
||||
}
|
||||
|
||||
void setDrawHandler(fgDrawHandler drawHandler)
|
||||
{
|
||||
this->drawHandler = drawHandler;
|
||||
}
|
||||
|
||||
fgDrawHandler getDrawHandler() const
|
||||
{
|
||||
return drawHandler;
|
||||
}
|
||||
|
||||
void setWindowResizeHandler(fgWindowResizeHandler windowResizeHandler)
|
||||
{
|
||||
this->windowResizeHandler = windowResizeHandler;
|
||||
}
|
||||
|
||||
fgWindowResizeHandler getWindowResizeHandler() const
|
||||
{
|
||||
return windowResizeHandler;
|
||||
}
|
||||
|
||||
void setKeyHandler(fgKeyHandler keyHandler)
|
||||
{
|
||||
this->keyHandler = keyHandler;
|
||||
|
@ -103,8 +83,6 @@ public:
|
|||
protected:
|
||||
osg::ref_ptr<osg::Node> _node;
|
||||
fgIdleHandler idleHandler;
|
||||
fgDrawHandler drawHandler;
|
||||
fgWindowResizeHandler windowResizeHandler;
|
||||
fgKeyHandler keyHandler;
|
||||
fgMouseClickHandler mouseClickHandler;
|
||||
fgMouseMotionHandler mouseMotionHandler;
|
||||
|
|
|
@ -39,16 +39,6 @@ void fgRegisterIdleHandler(fgIdleHandler func)
|
|||
globals->get_renderer()->getEventHandler()->setIdleHandler(func);
|
||||
}
|
||||
|
||||
void fgRegisterDrawHandler(fgDrawHandler func)
|
||||
{
|
||||
globals->get_renderer()->getEventHandler()->setDrawHandler(func);
|
||||
}
|
||||
|
||||
void fgRegisterWindowResizeHandler(fgWindowResizeHandler func)
|
||||
{
|
||||
globals->get_renderer()->getEventHandler()->setWindowResizeHandler(func);
|
||||
}
|
||||
|
||||
void fgRegisterKeyHandler(fgKeyHandler func)
|
||||
{
|
||||
globals->get_renderer()->getEventHandler()->setKeyHandler(func);
|
||||
|
|
|
@ -279,11 +279,9 @@ int fgOSMainLoop()
|
|||
viewer->realize();
|
||||
while (!viewer->done()) {
|
||||
fgIdleHandler idleFunc = manipulator->getIdleHandler();
|
||||
fgDrawHandler drawFunc = manipulator->getDrawHandler();
|
||||
if (idleFunc)
|
||||
(*idleFunc)();
|
||||
if (drawFunc)
|
||||
(*drawFunc)();
|
||||
globals->get_renderer()->update(true);
|
||||
viewer->frame();
|
||||
}
|
||||
|
||||
|
|
|
@ -551,11 +551,6 @@ static void fgIdleFunction ( void ) {
|
|||
}
|
||||
}
|
||||
|
||||
static void fgWinResizeFunction(int width, int height)
|
||||
{
|
||||
globals->get_renderer()->resize(width, height);
|
||||
}
|
||||
|
||||
static void upper_case_property(const char *name)
|
||||
{
|
||||
using namespace simgear;
|
||||
|
@ -646,9 +641,7 @@ int fgMainInit( int argc, char **argv ) {
|
|||
fgOSInit(&argc, argv);
|
||||
_bootstrap_OSInit++;
|
||||
|
||||
fgRegisterWindowResizeHandler( &fgWinResizeFunction );
|
||||
fgRegisterIdleHandler( &fgIdleFunction );
|
||||
fgRegisterDrawHandler( &FGRenderer::update );
|
||||
|
||||
// Initialize sockets (WinSock needs this)
|
||||
simgear::Socket::initSockets();
|
||||
|
|
|
@ -595,12 +595,6 @@ FGRenderer::setupView( void )
|
|||
stateSet->setAttributeAndModes(new osg::Program, osg::StateAttribute::ON);
|
||||
}
|
||||
|
||||
void
|
||||
FGRenderer::update()
|
||||
{
|
||||
globals->get_renderer()->update(true);
|
||||
}
|
||||
|
||||
// Update all Visuals (redraws anything graphics related)
|
||||
void
|
||||
FGRenderer::update( bool refresh_camera_settings ) {
|
||||
|
|
|
@ -55,7 +55,6 @@ public:
|
|||
// touch window or camera settings. This is useful for the tiled
|
||||
// renderer which needs to set the view frustum itself.
|
||||
void update( bool refresh_camera_settings);
|
||||
static void update();
|
||||
|
||||
/** Just pick into the scene and return the pick callbacks on the way ...
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue