Modified Files:
src/Main/renderer.cxx src/Cockpit/panel.cxx: Move some more into simple scenegraph wrappers. That fixes current problems with invisible panels.
This commit is contained in:
parent
391517f8c7
commit
42528de4ab
2 changed files with 97 additions and 46 deletions
|
@ -370,11 +370,12 @@ FGPanel::draw(osg::State& state)
|
||||||
panelStateSet->setAttribute(material);
|
panelStateSet->setAttribute(material);
|
||||||
panelStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
panelStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||||
panelStateSet->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK));
|
panelStateSet->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK));
|
||||||
if ( _enable_depth_test )
|
panelStateSet->setAttributeAndModes(new osg::Depth(osg::Depth::LEQUAL));
|
||||||
panelStateSet->setAttributeAndModes(new osg::Depth(osg::Depth::ALWAYS));
|
|
||||||
else
|
|
||||||
panelStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
|
|
||||||
}
|
}
|
||||||
|
if ( _enable_depth_test )
|
||||||
|
panelStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
|
||||||
|
else
|
||||||
|
panelStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
|
||||||
state.pushStateSet(panelStateSet.get());
|
state.pushStateSet(panelStateSet.get());
|
||||||
state.apply();
|
state.apply();
|
||||||
|
|
||||||
|
@ -470,15 +471,25 @@ FGPanel::draw(osg::State& state)
|
||||||
// Draw yellow "hotspots" if directed to. This is a panel authoring
|
// Draw yellow "hotspots" if directed to. This is a panel authoring
|
||||||
// feature; not intended to be high performance or to look good.
|
// feature; not intended to be high performance or to look good.
|
||||||
if ( fgGetBool("/sim/panel-hotspots") ) {
|
if ( fgGetBool("/sim/panel-hotspots") ) {
|
||||||
static osg::ref_ptr<osg::StateSet> hotspotStateSet = new osg::StateSet;
|
static osg::ref_ptr<osg::StateSet> hotspotStateSet;
|
||||||
hotspotStateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::OFF);
|
if (!hotspotStateSet.valid()) {
|
||||||
|
hotspotStateSet = new osg::StateSet;
|
||||||
|
hotspotStateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::OFF);
|
||||||
|
hotspotStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||||
|
}
|
||||||
|
|
||||||
state.pushStateSet(hotspotStateSet.get());
|
state.pushStateSet(hotspotStateSet.get());
|
||||||
state.apply();
|
state.apply();
|
||||||
|
|
||||||
|
glPushAttrib(GL_ENABLE_BIT);
|
||||||
|
glDisable(GL_COLOR_MATERIAL);
|
||||||
glColor3f(1, 1, 0);
|
glColor3f(1, 1, 0);
|
||||||
|
|
||||||
for ( unsigned int i = 0; i < _instruments.size(); i++ )
|
for ( unsigned int i = 0; i < _instruments.size(); i++ )
|
||||||
_instruments[i]->drawHotspots(state);
|
_instruments[i]->drawHotspots(state);
|
||||||
|
|
||||||
|
glPopAttrib();
|
||||||
|
|
||||||
state.popStateSet();
|
state.popStateSet();
|
||||||
state.apply();
|
state.apply();
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ public:
|
||||||
setUseDisplayList(false);
|
setUseDisplayList(false);
|
||||||
|
|
||||||
osg::StateSet* stateSet = getOrCreateStateSet();
|
osg::StateSet* stateSet = getOrCreateStateSet();
|
||||||
|
stateSet->setRenderBinDetails(1001, "RenderBin");
|
||||||
// speed optimization?
|
// speed optimization?
|
||||||
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
|
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
|
||||||
// We can do translucent menus, so why not. :-)
|
// We can do translucent menus, so why not. :-)
|
||||||
|
@ -124,7 +125,28 @@ public:
|
||||||
virtual void drawImplementation(osg::State& state) const
|
virtual void drawImplementation(osg::State& state) const
|
||||||
{
|
{
|
||||||
state.pushStateSet(getStateSet());
|
state.pushStateSet(getStateSet());
|
||||||
|
state.apply();
|
||||||
|
|
||||||
|
|
||||||
|
if((fgGetBool("/sim/atc/enabled"))
|
||||||
|
|| (fgGetBool("/sim/ai-traffic/enabled")))
|
||||||
|
globals->get_ATC_display()->update(delta_time_sec, state);
|
||||||
|
|
||||||
|
|
||||||
puDisplay();
|
puDisplay();
|
||||||
|
|
||||||
|
// Fade out the splash screen over the first three seconds.
|
||||||
|
double t = globals->get_sim_time_sec();
|
||||||
|
if (t <= 2.5) {
|
||||||
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
|
glPushClientAttrib(~0u);
|
||||||
|
|
||||||
|
fgSplashUpdate((2.5 - t) / 2.5);
|
||||||
|
|
||||||
|
glPopClientAttrib();
|
||||||
|
glPopAttrib();
|
||||||
|
}
|
||||||
|
|
||||||
state.popStateSet();
|
state.popStateSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +156,56 @@ public:
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class SGHUDAndPanelDrawable : public osg::Drawable {
|
||||||
|
public:
|
||||||
|
SGHUDAndPanelDrawable()
|
||||||
|
{
|
||||||
|
// Dynamic stuff, do not store geometry
|
||||||
|
setUseDisplayList(false);
|
||||||
|
|
||||||
|
osg::StateSet* stateSet = getOrCreateStateSet();
|
||||||
|
stateSet->setRenderBinDetails(1000, "RenderBin");
|
||||||
|
|
||||||
|
// speed optimization?
|
||||||
|
stateSet->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
|
||||||
|
stateSet->setAttribute(new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA));
|
||||||
|
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
|
||||||
|
stateSet->setMode(GL_FOG, osg::StateAttribute::OFF);
|
||||||
|
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
|
||||||
|
}
|
||||||
|
virtual void drawImplementation(osg::State& state) const
|
||||||
|
{
|
||||||
|
state.pushStateSet(getStateSet());
|
||||||
|
state.apply();
|
||||||
|
|
||||||
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
|
glPushClientAttrib(~0u);
|
||||||
|
|
||||||
|
fgCockpitUpdate(&state);
|
||||||
|
|
||||||
|
FGInstrumentMgr *instr = static_cast<FGInstrumentMgr*>(globals->get_subsystem("instrumentation"));
|
||||||
|
HUD *hud = static_cast<HUD*>(instr->get_subsystem("hud"));
|
||||||
|
hud->draw(state);
|
||||||
|
|
||||||
|
// update the panel subsystem
|
||||||
|
if ( globals->get_current_panel() != NULL )
|
||||||
|
globals->get_current_panel()->update(state);
|
||||||
|
// We don't need a state here - can be safely removed when we can pick
|
||||||
|
// correctly
|
||||||
|
fgUpdate3DPanels();
|
||||||
|
|
||||||
|
glPopClientAttrib();
|
||||||
|
glPopAttrib();
|
||||||
|
|
||||||
|
state.popStateSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual osg::Object* cloneType() const { return new SGHUDAndPanelDrawable; }
|
||||||
|
virtual osg::Object* clone(const osg::CopyOp&) const { return new SGHUDAndPanelDrawable; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class FGSunLightUpdateCallback : public osg::StateAttribute::Callback {
|
class FGSunLightUpdateCallback : public osg::StateAttribute::Callback {
|
||||||
public:
|
public:
|
||||||
|
@ -406,6 +478,7 @@ FGRenderer::init( void ) {
|
||||||
mRoot->addChild(guiCamera);
|
mRoot->addChild(guiCamera);
|
||||||
osg::Geode* geode = new osg::Geode;
|
osg::Geode* geode = new osg::Geode;
|
||||||
geode->addDrawable(new SGPuDrawable);
|
geode->addDrawable(new SGPuDrawable);
|
||||||
|
geode->addDrawable(new SGHUDAndPanelDrawable);
|
||||||
guiCamera->addChild(geode);
|
guiCamera->addChild(geode);
|
||||||
|
|
||||||
mSceneCamera->addChild(globals->get_scenery()->get_scene_graph());
|
mSceneCamera->addChild(globals->get_scenery()->get_scene_graph());
|
||||||
|
@ -453,8 +526,14 @@ FGRenderer::update( bool refresh_camera_settings ) {
|
||||||
|
|
||||||
if ( idle_state < 1000 || !scenery_loaded ) {
|
if ( idle_state < 1000 || !scenery_loaded ) {
|
||||||
// still initializing, draw the splash screen
|
// still initializing, draw the splash screen
|
||||||
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
|
glPushClientAttrib(~0u);
|
||||||
|
|
||||||
fgSplashUpdate(1.0);
|
fgSplashUpdate(1.0);
|
||||||
|
|
||||||
|
glPopClientAttrib();
|
||||||
|
glPopAttrib();
|
||||||
|
|
||||||
// Keep resetting sim time while the sim is initializing
|
// Keep resetting sim time while the sim is initializing
|
||||||
globals->set_sim_time_sec( 0.0 );
|
globals->set_sim_time_sec( 0.0 );
|
||||||
return;
|
return;
|
||||||
|
@ -707,45 +786,6 @@ FGRenderer::update( bool refresh_camera_settings ) {
|
||||||
sceneView->update();
|
sceneView->update();
|
||||||
sceneView->cull();
|
sceneView->cull();
|
||||||
sceneView->draw();
|
sceneView->draw();
|
||||||
|
|
||||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
|
||||||
glPushClientAttrib(~0u);
|
|
||||||
|
|
||||||
// display HUD && Panel
|
|
||||||
glDisable( GL_FOG );
|
|
||||||
glDisable( GL_DEPTH_TEST );
|
|
||||||
|
|
||||||
fgCockpitUpdate(sceneView->getState());
|
|
||||||
|
|
||||||
FGInstrumentMgr *instr = static_cast<FGInstrumentMgr*>(globals->get_subsystem("instrumentation"));
|
|
||||||
HUD *hud = static_cast<HUD*>(instr->get_subsystem("hud"));
|
|
||||||
hud->draw(*sceneView->getState());
|
|
||||||
|
|
||||||
// update the panel subsystem
|
|
||||||
if ( globals->get_current_panel() != NULL )
|
|
||||||
globals->get_current_panel()->update(*sceneView->getState());
|
|
||||||
// We don't need a state here - can be safely removed when we can pick
|
|
||||||
// correctly
|
|
||||||
fgUpdate3DPanels();
|
|
||||||
|
|
||||||
if((fgGetBool("/sim/atc/enabled"))
|
|
||||||
|| (fgGetBool("/sim/ai-traffic/enabled")))
|
|
||||||
globals->get_ATC_display()->update(delta_time_sec,
|
|
||||||
*sceneView->getState());
|
|
||||||
|
|
||||||
// We can do translucent menus, so why not. :-)
|
|
||||||
glDisable( GL_TEXTURE_2D ) ;
|
|
||||||
glDisable( GL_CULL_FACE ) ;
|
|
||||||
glEnable( GL_BLEND ) ;
|
|
||||||
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
|
||||||
|
|
||||||
// Fade out the splash screen over the first three seconds.
|
|
||||||
double t = globals->get_sim_time_sec();
|
|
||||||
if (t <= 2.5)
|
|
||||||
fgSplashUpdate((2.5 - t) / 2.5);
|
|
||||||
|
|
||||||
glPopClientAttrib();
|
|
||||||
glPopAttrib();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue