- double a_zx_pilot = a_z_pilot - a_x_pilot;
-
- int x_adjust = int(sqrt(fabs(a_y_pilot) * _jitter)) *
- (a_y_pilot < 0 ? -1 : 1);
- int y_adjust = int(sqrt(fabs(a_zx_pilot) * _jitter)) *
- (a_zx_pilot < 0 ? -1 : 1);
-
- // adjustments in screen coordinates
- x_offset += x_adjust;
- y_offset += y_adjust;
+void
+FGPanel::draw(osg::State& state)
+{
+ // In 3D mode, it's possible that we are being drawn exactly on top
+ // of an existing polygon. Use an offset to prevent z-fighting. In
+ // 2D mode, this is a no-op.
+ static osg::ref_ptr<osg::StateSet> panelStateSet;
+ if (!panelStateSet.valid()) {
+ panelStateSet = new osg::StateSet;
+ panelStateSet->setAttributeAndModes(new osg::PolygonOffset(-1, -POFF_UNITS));
+ panelStateSet->setTextureAttribute(0, new osg::TexEnv);
+
+ // Draw the background
+ panelStateSet->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::ON);
+ panelStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
+ panelStateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
+ panelStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
+ osg::Material* material = new osg::Material;
+ material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
+ material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
+ material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
+ material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
+ material->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
+ panelStateSet->setAttribute(material);
+ panelStateSet->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
+ panelStateSet->setAttributeAndModes(new osg::CullFace(osg::CullFace::BACK));
+ panelStateSet->setAttributeAndModes(new osg::Depth(osg::Depth::LEQUAL));