// 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>
{
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; }
#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->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);
}
if (height != lastheight)
fgSetInt("/sim/startup/ysize", lastheight = height);
- guiInitMouse(width, height);
-
// for all views
FGViewMgr *viewmgr = globals->get_viewmgr();
if (viewmgr) {