1
0
Fork 0

Remove indirection on viewer draw/resize code-paths.

This commit is contained in:
James Turner 2011-09-18 15:05:05 +01:00
parent 7dd8f00c42
commit 227b3e469c
7 changed files with 5 additions and 54 deletions

View file

@ -12,6 +12,7 @@
#include "CameraGroup.hxx" #include "CameraGroup.hxx"
#include "FGEventHandler.hxx" #include "FGEventHandler.hxx"
#include "WindowSystemAdapter.hxx" #include "WindowSystemAdapter.hxx"
#include "renderer.hxx"
#if !defined(X_DISPLAY_MISSING) #if !defined(X_DISPLAY_MISSING)
#define X_DOUBLE_SCROLL_BUG 1 #define X_DOUBLE_SCROLL_BUG 1
@ -29,8 +30,6 @@ const int printStatsKey = 2;
FGEventHandler::FGEventHandler() : FGEventHandler::FGEventHandler() :
idleHandler(0), idleHandler(0),
drawHandler(0),
windowResizeHandler(0),
keyHandler(0), keyHandler(0),
mouseClickHandler(0), mouseClickHandler(0),
mouseMotionHandler(0), mouseMotionHandler(0),
@ -233,8 +232,8 @@ bool FGEventHandler::handle(const osgGA::GUIEventAdapter& ea,
return true; return true;
case osgGA::GUIEventAdapter::RESIZE: case osgGA::GUIEventAdapter::RESIZE:
CameraGroup::getDefault()->resized(); CameraGroup::getDefault()->resized();
if (resizable && windowResizeHandler) if (resizable)
(*windowResizeHandler)(ea.getWindowWidth(), ea.getWindowHeight()); globals->get_renderer()->resize(ea.getWindowWidth(), ea.getWindowHeight());
return true; return true;
case osgGA::GUIEventAdapter::CLOSE_WINDOW: case osgGA::GUIEventAdapter::CLOSE_WINDOW:
case osgGA::GUIEventAdapter::QUIT_APPLICATION: case osgGA::GUIEventAdapter::QUIT_APPLICATION:

View file

@ -34,26 +34,6 @@ public:
return idleHandler; 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) void setKeyHandler(fgKeyHandler keyHandler)
{ {
this->keyHandler = keyHandler; this->keyHandler = keyHandler;
@ -103,8 +83,6 @@ public:
protected: protected:
osg::ref_ptr<osg::Node> _node; osg::ref_ptr<osg::Node> _node;
fgIdleHandler idleHandler; fgIdleHandler idleHandler;
fgDrawHandler drawHandler;
fgWindowResizeHandler windowResizeHandler;
fgKeyHandler keyHandler; fgKeyHandler keyHandler;
fgMouseClickHandler mouseClickHandler; fgMouseClickHandler mouseClickHandler;
fgMouseMotionHandler mouseMotionHandler; fgMouseMotionHandler mouseMotionHandler;

View file

@ -39,16 +39,6 @@ void fgRegisterIdleHandler(fgIdleHandler func)
globals->get_renderer()->getEventHandler()->setIdleHandler(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) void fgRegisterKeyHandler(fgKeyHandler func)
{ {
globals->get_renderer()->getEventHandler()->setKeyHandler(func); globals->get_renderer()->getEventHandler()->setKeyHandler(func);

View file

@ -279,11 +279,9 @@ int fgOSMainLoop()
viewer->realize(); viewer->realize();
while (!viewer->done()) { while (!viewer->done()) {
fgIdleHandler idleFunc = manipulator->getIdleHandler(); fgIdleHandler idleFunc = manipulator->getIdleHandler();
fgDrawHandler drawFunc = manipulator->getDrawHandler();
if (idleFunc) if (idleFunc)
(*idleFunc)(); (*idleFunc)();
if (drawFunc) globals->get_renderer()->update(true);
(*drawFunc)();
viewer->frame(); viewer->frame();
} }

View file

@ -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) static void upper_case_property(const char *name)
{ {
using namespace simgear; using namespace simgear;
@ -646,9 +641,7 @@ int fgMainInit( int argc, char **argv ) {
fgOSInit(&argc, argv); fgOSInit(&argc, argv);
_bootstrap_OSInit++; _bootstrap_OSInit++;
fgRegisterWindowResizeHandler( &fgWinResizeFunction );
fgRegisterIdleHandler( &fgIdleFunction ); fgRegisterIdleHandler( &fgIdleFunction );
fgRegisterDrawHandler( &FGRenderer::update );
// Initialize sockets (WinSock needs this) // Initialize sockets (WinSock needs this)
simgear::Socket::initSockets(); simgear::Socket::initSockets();

View file

@ -595,12 +595,6 @@ FGRenderer::setupView( void )
stateSet->setAttributeAndModes(new osg::Program, osg::StateAttribute::ON); stateSet->setAttributeAndModes(new osg::Program, osg::StateAttribute::ON);
} }
void
FGRenderer::update()
{
globals->get_renderer()->update(true);
}
// Update all Visuals (redraws anything graphics related) // Update all Visuals (redraws anything graphics related)
void void
FGRenderer::update( bool refresh_camera_settings ) { FGRenderer::update( bool refresh_camera_settings ) {

View file

@ -55,8 +55,7 @@ public:
// touch window or camera settings. This is useful for the tiled // touch window or camera settings. This is useful for the tiled
// renderer which needs to set the view frustum itself. // renderer which needs to set the view frustum itself.
void update( bool refresh_camera_settings); void update( bool refresh_camera_settings);
static void update();
/** Just pick into the scene and return the pick callbacks on the way ... /** Just pick into the scene and return the pick callbacks on the way ...
*/ */
bool pick( std::vector<SGSceneryPick>& pickList, bool pick( std::vector<SGSceneryPick>& pickList,