]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel.cxx
make --enable-osgviewer the default
[flightgear.git] / src / Cockpit / panel.cxx
index 90ee33b1d15659e1eec96db5a03a36d0ee497eae..5be11a20e142f61c2b05c2f34324b2c0db84fb72 100644 (file)
@@ -31,7 +31,7 @@
 #  include <config.h>
 #endif
 
-#ifdef HAVE_WINDOWS_H          
+#ifdef HAVE_WINDOWS_H
 #  include <windows.h>
 #endif
 
@@ -98,18 +98,18 @@ get_aspect_adjust (int xsize, int ysize)
 bool
 fgPanelVisible ()
 {
-     if (globals->get_current_panel() == 0)
+     const FGPanel* current = globals->get_current_panel();
+     if (current == 0)
        return false;
-     if (globals->get_current_panel()->getVisibility() == 0)
+     if (current->getVisibility() == 0)
        return false;
      if (globals->get_viewmgr()->get_current() != 0)
        return false;
-     if (globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS != 0)
+     if (current->getAutohide() && globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS != 0)
        return false;
      return true;
 }
 
-
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGTextureManager.
@@ -118,7 +118,7 @@ fgPanelVisible ()
 map<string,osg::ref_ptr<osg::Texture2D> > FGTextureManager::_textureMap;
 
 osg::Texture2D*
-FGTextureManager::createTexture (const string &relativePath)
+FGTextureManager::createTexture (const string &relativePath, bool staticTexture)
 {
   osg::Texture2D* texture = _textureMap[relativePath].get();
   if (texture == 0) {
@@ -127,7 +127,7 @@ FGTextureManager::createTexture (const string &relativePath)
     SGPath tpath(globals->get_fg_root());
     tpath.append(relativePath);
 
-    texture = SGLoadTexture2D(tpath);
+    texture = SGLoadTexture2D(staticTexture, tpath);
 
     _textureMap[relativePath] = texture;
     if (!_textureMap[relativePath].valid()) 
@@ -139,7 +139,11 @@ FGTextureManager::createTexture (const string &relativePath)
 }
 
 
-
+void FGTextureManager::addTexture(const string &relativePath,
+                                  osg::Texture2D* texture)
+{
+    _textureMap[relativePath] = texture;
+}
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGCropped Texture.
@@ -378,6 +382,8 @@ FGPanel::draw(osg::State& state)
     panelStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
   state.pushStateSet(panelStateSet.get());
   state.apply();
+  state.setActiveTextureUnit(0);
+  state.setClientActiveTextureUnit(0);
 
   FGLight *l = (FGLight *)(globals->get_subsystem("lighting"));
   sgCopyVec4( panel_color, l->scene_diffuse().data());
@@ -390,6 +396,9 @@ FGPanel::draw(osg::State& state)
   if (_bg != 0) {
     state.pushStateSet(_bg.get());
     state.apply();
+    state.setActiveTextureUnit(0);
+    state.setClientActiveTextureUnit(0);
+
     glBegin(GL_POLYGON);
     glTexCoord2f(0.0, 0.0); glVertex2f(WIN_X, WIN_Y);
     glTexCoord2f(1.0, 0.0); glVertex2f(WIN_X + _width, WIN_Y);
@@ -398,11 +407,17 @@ FGPanel::draw(osg::State& state)
     glEnd();
     state.popStateSet();
     state.apply();
+    state.setActiveTextureUnit(0);
+    state.setClientActiveTextureUnit(0);
+
   } else {
     for (int i = 0; i < 4; i ++) {
       // top row of textures...(1,3,5,7)
       state.pushStateSet(_mbg[i*2].get());
       state.apply();
+      state.setActiveTextureUnit(0);
+      state.setClientActiveTextureUnit(0);
+
       glBegin(GL_POLYGON);
       glTexCoord2f(0.0, 0.0); glVertex2f(WIN_X + (_width/4) * i, WIN_Y + (_height/2));
       glTexCoord2f(1.0, 0.0); glVertex2f(WIN_X + (_width/4) * (i+1), WIN_Y + (_height/2));
@@ -411,9 +426,15 @@ FGPanel::draw(osg::State& state)
       glEnd();
       state.popStateSet();
       state.apply();
+      state.setActiveTextureUnit(0);
+      state.setClientActiveTextureUnit(0);
+
       // bottom row of textures...(2,4,6,8)
       state.pushStateSet(_mbg[i*2+1].get());
       state.apply();
+      state.setActiveTextureUnit(0);
+      state.setClientActiveTextureUnit(0);
+
       glBegin(GL_POLYGON);
       glTexCoord2f(0.0, 0.0); glVertex2f(WIN_X + (_width/4) * i, WIN_Y);
       glTexCoord2f(1.0, 0.0); glVertex2f(WIN_X + (_width/4) * (i+1), WIN_Y);
@@ -422,6 +443,9 @@ FGPanel::draw(osg::State& state)
       glEnd();
       state.popStateSet();
       state.apply();
+      state.setActiveTextureUnit(0);
+      state.setClientActiveTextureUnit(0);
+
     }
   }
 
@@ -467,6 +491,9 @@ FGPanel::draw(osg::State& state)
 
   state.popStateSet();
   state.apply();
+  state.setActiveTextureUnit(0);
+  state.setClientActiveTextureUnit(0);
+
 
   // Draw yellow "hotspots" if directed to.  This is a panel authoring
   // feature; not intended to be high performance or to look good.
@@ -480,6 +507,9 @@ FGPanel::draw(osg::State& state)
 
     state.pushStateSet(hotspotStateSet.get());
     state.apply();
+    state.setActiveTextureUnit(0);
+    state.setClientActiveTextureUnit(0);
+
 
     glPushAttrib(GL_ENABLE_BIT);
     glDisable(GL_COLOR_MATERIAL);
@@ -492,6 +522,9 @@ FGPanel::draw(osg::State& state)
 
     state.popStateSet();
     state.apply();
+    state.setActiveTextureUnit(0);
+    state.setClientActiveTextureUnit(0);
+
   }
 }
 
@@ -661,7 +694,7 @@ FGPanelAction::~FGPanelAction ()
 }
 
 void
-FGPanelAction::addBinding (FGBinding * binding, int updown)
+FGPanelAction::addBinding (SGBinding * binding, int updown)
 {
   _bindings[updown].push_back(binding);
 }
@@ -1019,6 +1052,9 @@ FGTexturedLayer::draw (osg::State& state)
     transform();
     state.pushStateSet(_texture.getTexture());
     state.apply();
+    state.setActiveTextureUnit(0);
+    state.setClientActiveTextureUnit(0);
+
     glBegin(GL_POLYGON);
 
     if (_emissive) {
@@ -1036,6 +1072,9 @@ FGTexturedLayer::draw (osg::State& state)
     glEnd();
     state.popStateSet();
     state.apply();
+    state.setActiveTextureUnit(0);
+    state.setClientActiveTextureUnit(0);
+
   }
 }