// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-// $Id$
-
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <simgear/compiler.h>
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
#include <osg/ref_ptr>
#include <osg/AlphaFunc>
#include <osg/BlendFunc>
#include <simgear/screen/extensions.hxx>
#include <simgear/scene/material/matlib.hxx>
#include <simgear/scene/model/animation.hxx>
-#include <simgear/scene/model/model.hxx>
-#include <simgear/scene/model/modellib.hxx>
#include <simgear/scene/model/placement.hxx>
#include <simgear/scene/util/SGUpdateVisitor.hxx>
#include <simgear/scene/util/RenderConstants.hxx>
#include <simgear/environment/visual_enviro.hxx>
-#include <Scenery/tileentry.hxx>
#include <Time/light.hxx>
#include <Time/light.hxx>
#include <Aircraft/aircraft.hxx>
{
if (!fgOSIsMainContext(state.getGraphicsContext()))
return;
-
- state.pushStateSet(getStateSet());
- state.apply();
state.setActiveTextureUnit(0);
state.setClientActiveTextureUnit(0);
+
state.disableAllVertexArrays();
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPopClientAttrib();
glPopAttrib();
-
- state.popStateSet();
- state.dirtyAllModes();
- state.dirtyAllAttributes();
- state.dirtyAllVertexArrays();
}
virtual osg::Object* cloneType() const { return new SGPuDrawable; }
{ drawImplementation(*renderInfo.getState()); }
void drawImplementation(osg::State& state) const
{
-// std::cout << state.getGraphicsContext() << std::endl;
if (!fgOSIsMainContext(state.getGraphicsContext()))
return;
-
- state.pushStateSet(getStateSet());
- state.apply();
state.setActiveTextureUnit(0);
state.setClientActiveTextureUnit(0);
state.disableAllVertexArrays();
glPopClientAttrib();
glPopAttrib();
- state.popStateSet();
- state.dirtyAllModes();
- state.dirtyAllAttributes();
- state.dirtyAllVertexArrays();
}
virtual osg::Object* cloneType() const { return new SGHUDAndPanelDrawable; }
// Sky structures
SGSky *thesky;
-// Precipitations
-FGPrecipitationMgr *fgPrecipitationMgr;
-
static osg::ref_ptr<osg::FrameStamp> mFrameStamp = new osg::FrameStamp;
static osg::ref_ptr<SGUpdateVisitor> mUpdateVisitor= new SGUpdateVisitor;
#endif
}
+namespace
+{
+// Create a slave camera that will be used to render a fixed GUI-like
+// element.
+osg::Camera*
+makeSlaveCamera(osg::Camera::RenderOrder renderOrder, int orderNum)
+{
+ using namespace osg;
+ Camera* camera = new osg::Camera;
+ GraphicsContext *gc = fgOSGetMainContext();
+
+ camera->setRenderOrder(renderOrder, orderNum);
+ camera->setClearMask(0);
+ camera->setInheritanceMask(CullSettings::ALL_VARIABLES
+ & ~(CullSettings::COMPUTE_NEAR_FAR_MODE
+ | CullSettings::CULLING_MODE));
+ camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
+ camera->setCullingMode(osg::CullSettings::NO_CULLING);
+ camera->setGraphicsContext(gc);
+ // Establish an initial viewport. This may be altered,
+ // particularly when drawing a 2d panel.
+ const GraphicsContext::Traits *traits = gc->getTraits();
+ camera->setViewport(new Viewport(0, 0, traits->width, traits->height));
+ camera->setProjectionResizePolicy(Camera::FIXED);
+ camera->setReferenceFrame(Transform::ABSOLUTE_RF);
+ camera->setAllowEventFocus(false);
+ globals->get_renderer()->getViewer()->addSlave(camera, false);
+ return camera;
+}
+
+}
+
void
-FGRenderer::init( void ) {
- // The viewer can call this before the graphics context is current
- // in the main thread; indeed, in a multithreaded setup it might
- // never be current in the main thread.
- fgMakeCurrent();
+FGRenderer::init( void )
+{
osgViewer::Viewer* viewer = globals->get_renderer()->getViewer();
osg::initNotifyLevel();
stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
-
- // Add Precipitation object
- sceneGroup->addChild( fgPrecipitationMgr->getObject() );
-
-
// need to update the light on every frame
osg::LightSource* lightSource = new osg::LightSource;
lightSource->setUpdateCallback(new FGLightSourceUpdateCallback);
stateSet->setUpdateCallback(new FGFogEnableUpdateCallback);
// plug in the GUI
- osg::Camera* guiCamera = new osg::Camera;
- guiCamera->setRenderOrder(osg::Camera::POST_RENDER, 100);
- guiCamera->setClearMask(0);
- GLbitfield inheritanceMask = osg::CullSettings::ALL_VARIABLES;
- inheritanceMask &= ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE;
- inheritanceMask &= ~osg::CullSettings::CULLING_MODE;
- guiCamera->setInheritanceMask(inheritanceMask);
- guiCamera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
- guiCamera->setCullingMode(osg::CullSettings::NO_CULLING);
+ osg::Camera* guiCamera = makeSlaveCamera(osg::Camera::POST_RENDER, 100);
+ guiCamera->setName("GUI");
osg::Geode* geode = new osg::Geode;
geode->addDrawable(new SGPuDrawable);
geode->addDrawable(new SGHUDAndPanelDrawable);
mRealRoot->addChild(viewPartition.get());
mRealRoot->addChild(FGCreateRedoutNode());
- mRealRoot->addChild(guiCamera);
}
// fgGetDouble("/velocities/airspeed-kt", 0.0)
// * cos( fgGetDouble("/orientation/pitch-deg", 0.0)
// * SGD_DEGREES_TO_RADIANS);
- // TODO:find the real view speed, not the AC one
-// sgEnviro.drawPrecipitation(
-// fgGetDouble("/environment/metar/rain-norm", 0.0),
-// fgGetDouble("/environment/metar/snow-norm", 0.0),
-// fgGetDouble("/environment/metar/hail-norm", 0.0),
-// current__view->getPitch_deg() + current__view->getPitchOffset_deg(),
-// current__view->getRoll_deg() + current__view->getRollOffset_deg(),
-// - current__view->getHeadingOffset_deg(),
-// current_view_origin_airspeed_horiz_kt
-// );
-
- // Update precipitation informations...
- fgPrecipitationMgr->update();
-
// OSGFIXME
// if( is_internal )
if (height != lastheight)
fgSetInt("/sim/startup/ysize", lastheight = height);
- guiInitMouse(width, height);
-
// for all views
FGViewMgr *viewmgr = globals->get_viewmgr();
if (viewmgr) {